Uptimecat

Command line access

There is no official Uptimecat command line tool yet. The API works well with curl, so you can script most tasks today.

What to expect

A dedicated CLI is not available and has no release date. What is available is the HTTP API described on the API page. It covers listing monitors, pushing heartbeats, reading badges and reading public status data. Creating monitors from the command line is not possible yet.

The examples below need curl and, for JSON, jq. Store the API key in an environment variable. Do not paste it into scripts that you commit.

Set the key and list monitors

export UPTIMECAT_API_KEY='paste-your-key'
curl -fsS -H "Authorization: Bearer $UPTIMECAT_API_KEY" https://dashboard.uptimecat.co/api/monitors | jq .

Show the server version

curl -fsS -H "Authorization: Bearer $UPTIMECAT_API_KEY" https://dashboard.uptimecat.co/api/info | jq .

Wrap a cron job with a heartbeat

#!/bin/sh
# usage: heartbeat.sh PUSH_TOKEN command [args...]
token=$1; shift
base=https://dashboard.uptimecat.co/api/push
start=$(date +%s)
if "$@"; then
  ms=$((($(date +%s) - start) * 1000))
  curl -fsS -m 10 "$base/$token?status=up&msg=OK&ping=$ms" >/dev/null
else
  curl -fsS -m 10 "$base/$token?status=down&msg=job%20failed" >/dev/null
  exit 1
fi

Use it in cron

0 3 * * * /usr/local/bin/heartbeat.sh YOUR_PUSH_TOKEN /usr/local/bin/backup.sh

Check a public badge

curl -fsS https://dashboard.uptimecat.co/api/badge/1/status

Good habits

  • Use -f so curl returns an error on HTTP failures, and -m to set a timeout.
  • Put the interval of the push monitor a little above the job schedule.
  • Keep keys in a secret store or the environment, never in git.
  • Rotate a key by creating a new one, switching scripts, then deleting the old one.

Ideas for small scripts

  • A morning check that prints monitors from /api/monitors and exits non-zero when something is down, for use in a terminal prompt or a chat bot.
  • A deploy script that sends a push heartbeat after a successful release, so a missing deploy shows up.
  • A wrapper for backups that reports the job duration as the ping value.
  • A Prometheus scrape plus a dashboard, if you already run Grafana.

Frequently asked questions

Will an official CLI come?

It may. Follow the roadmap.

Can I create monitors with curl?

Not through a documented endpoint. Use the dashboard.

Does heartbeat.sh work on macOS and Linux?

Yes, it uses only POSIX shell, date and curl.

Related

Open the dashboard

Sign in with your Google account to add a monitor and pick an alert channel. Access is currently limited to Moruk accounts; open sign-up is not available yet.

Sign in