About

grep is a good tool that is common enough to be found in most docker containers that can be used to perform various types of generic health checks.

Requirements

  • grep

Checking for Open Port

The following command will check whether port 5613 is open. Note that the following can only guarantee that a numeric port is open from the perspective of the TCP/IP stack, yet it does not perform any "HTTP request" such as the one performed using curl or wget. In that sense, this a weaker test that should only be used if some program-specific stronger test cannot be used that would also additionally attest to the proper functionality of the program.

grep -qi ":"`printf '%04x' 5613` /proc/*/net/tcp || exit 1

Checking for Running Command

Due to recent kernels, processes, process numbers and their corresponding command line can be fished out of /proc, such that the following command, for example:

grep -qa elasticsearch /proc/[0-9]/cmdline || exit 1

will check whether there is a process running whose command line parameters contain the string elasticsearch.

This is also a very weak test and can only guarantee that whatever string is being searched for is also the name of a process or is contained within the command-line parameters but without being able to say much else.


fuss/docker/health_checks/grep.txt ยท Last modified: 2024/11/06 01:01 by office

Access website using Tor Access website using i2p Wizardry and Steamworks PGP Key


For the contact, copyright, license, warranty and privacy terms for the usage of this website please see the contact, license, privacy, copyright.