Shell Scripts

You can easily add monitoring to a shell script. All you have to do is make a HTTP request at the end of the script. curl and wget are two common command line HTTP clients you can use.

# Sending a HTTP GET request with curl:
curl --retry 3

# Silent version (no stdout/stderr output unless curl hits an error):
curl -fsS --retry 3

# Sending a HTTP GET request with wget:
wget -O /dev/null

Signalling Failure from Shell Scripts

You can append /fail to any ping URL and use the resulting URL to actively signal a failure. The below example:

  • runs /usr/bin/certbot renew
  • if the certbot command is successful (exit code 0), send HTTP GET to
  • otherwise, send HTTP GET to

# Payload here:
/usr/bin/certbot renew
# Ping
curl --retry 3 "$([ $? -ne 0 ] && echo -n /fail)"

Logging Command Output

When pinging with HTTP POST, you can put extra diagnostic information in request body. If the request body looks like a valid UTF-8 string, will accept and store first 10KB of the request body.

In the below example, certbot's output is captured and submitted via HTTP POST:


m=$(/usr/bin/certbot renew 2>&1)
curl -fsS --retry 3 --data-raw "$m"

Auto-provisioning New Checks

This example uses Management API to create a check "on the fly" (if it does not already exist) and to retrieve its ping URL. Using this technique, you can write services that automatically register with the first time they run.



# Check's parameters. This example uses system's hostname for check's name.
PAYLOAD='{"name": "'`hostname`'", "timeout": 60, "grace": 60, "unique": ["name"]}'

# Create the check if it does not exist.
# Grab the ping_url from JSON response using the jq utility:
URL=`curl -s  -H "X-Api-Key: $API_KEY" -d "$PAYLOAD"  | jq -r .ping_url`

# Finally, send a ping:
curl --retry 3 $URL