You can easily add Status monitoring to a shell script. All you have to do is make a HTTP request at an appropriate place in the script. curl and wget are two common command line HTTP clients you can use.
# Sends a HTTP GET request with curl:
curl -m 10 --retry 5 https://chk.sh/your-uuid-here
# Silent version (no stdout/stderr output unless curl hits an error):
curl -fsS -m 10 --retry 5 -o /dev/null https://chk.sh/your-uuid-here
Here's what each curl parameter does:
You can append /fail
or /{exit-status}
to any ping URL and use the resulting URL
to actively signal a failure. The exit status should be a 0-255 integer.
Status will interpret exit status 0 as success, and all non-zero values as failures.
The following example runs /usr/bin/certbot renew
, and uses the $?
variable to
look up its exit status:
#!/bin/sh
# Payload here:
/usr/bin/certbot renew
# Ping Status
curl -m 10 --retry 5 https://chk.sh/your-uuid-here/$?
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, Status will accept and store first 10KB of the request body.
In the below example, certbot's output is captured and submitted via HTTP POST:
#!/bin/sh
m=$(/usr/bin/certbot renew 2>&1)
curl -fsS -m 10 --retry 5 --data-raw "$m" https://chk.sh/your-uuid-here
This example uses Status 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 Status the first time they run.
#!/bin/bash
API_KEY=your-api-key-here
# 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 https://www.status.ms/api/v1/checks/ -H "X-Api-Key: $API_KEY" -d "$PAYLOAD" | jq -r .ping_url`
# Finally, send a ping:
curl -m 10 --retry 5 $URL