// free agents / heartbeat-watchdog

💓 Heartbeat watchdog (dead man's switch)

“Warn me on Discord when my nightly backup, cron job or n8n workflow silently stops running.”

Free, no sign-up. MIT licence. Python standard library only, so there's nothing to pip install.

What it does

A self-hosted dead man's switch. Your jobs check in when they finish (touch a file, call a ping URL, or just succeed in n8n), and the watchdog alerts Discord or email once when a check-in is late and once when it's back. It catches what error alerts can't: a job that never ran because it was deactivated, the server rebooted, or cron stopped. It also catches runs that succeed but produce nothing: a backup file that is fresh but empty, or a job that checks in with ?count=0. It also does simple uptime checks on URLs.

What you need

5-minute setup

Python

  1. Install Python 3.9+ and unzip the download.
  2. Try it with no accounts: python3 heartbeat_watchdog.py --dry-run
  3. Copy .env.example to .env and fill it in.
  4. Run: set -a; . ./.env; set +a; python3 heartbeat_watchdog.py (Windows steps in the README).

n8n (no code)

  1. Workflows, then Import from file, then heartbeat-watchdog.n8n.json.
  2. Follow the yellow “Read me” note (credentials or webhook).
  3. Test workflow, then switch it to Active.

Run it on a schedule

Every 10 minutes (and, for ping heartbeats, keep `python3 heartbeat_watchdog.py serve` running as a service) with cron:

*/10 * * * * cd /path/to/heartbeat-watchdog && set -a && . ./.env && set +a && python3 heartbeat_watchdog.py >> run.log 2>&1

On Windows use Task Scheduler. With n8n, the Schedule node does it for you.

Settings

VariableWhat it does
CHECKS_FILEYour heartbeats, default checks.json (copy checks.example.json): file, ping, n8n or url, each with a max_age like 15m, 2h, 26h. Optional: min_size for files ("1MB"; the target can be a pattern like /backups/*.sql.gz, newest file counts) and min_count for pings (jobs call /ping/name?count=12, or /ping/name/fail for a failed run)
DISCORD_WEBHOOK_URLWhere alerts go
EMAIL_TO / SMTP_HOST / SMTP_PORT / SMTP_USER / SMTP_PASSWORDOptional: alerts by email
N8N_URL / N8N_API_KEYOptional: for n8n heartbeats, e.g. http://localhost:5678
PORT / PING_TOKENserve mode: ping receiver port (default 8765) and an optional secret ?token=

What we tested

Honest limits

Related guides

Want one built for your task?

Describe it in one sentence. We build it, test it and email it to you, usually within 24h. Free while we're in beta.

We'll only email you about your agent and TaskToAgent.