← All guides

Guide · NAS

Monitor TrueNAS (SCALE / CORE) with a dead man's switch

TrueNAS alerts you when a pool degrades or a task errors out. It stays silent when a Cron Job, Replication, or Cloud Sync task simply stops firing, gets disabled or deleted, or the box itself goes dark. One check-in per run closes that gap.

1. Create a check

Create a check in Mortemain matching your task's schedule plus a grace window, then copy its ping URL.

2. Add a Cron Job that pings on every run

On SCALE: System Settings → Advanced → Cron Jobs. On CORE: Tasks → Cron Jobs. Add a job on the same schedule as the task you want to watch, with a command that pings on completion:

 Command field
curl -fsS -m 10 --retry 3 https://ping.mortemain.com/your-check-uuid

Tick Hide Standard Output and Hide Standard Error so TrueNAS doesn't mail you on every silent success. This proves the box and cron are alive, it doesn't yet prove the backup itself succeeded.

3. Gate on the task's real result (recommended)

For a Replication or Cloud Sync task, trigger it from the cron job with midclt and wait for the actual outcome instead of trusting its own schedule. Switch the task's built-in schedule to manual so it only ever runs from this script:

 /mnt/tank/scripts/truenas-ping.sh
#!/bin/sh
# Trigger a Replication task, wait for it, then check in.
URL="https://ping.mortemain.com/your-check-uuid"
TASK_ID=1   # Data Protection → Replication Tasks, id shown on the task's row

curl -fsS -m 10 "$URL/start"

if midclt call -job replication.run "$TASK_ID" >/tmp/repl-last.log 2>&1; then
    curl -fsS -m 10 "$URL"
else
    curl -fsS -m 10 "$URL/fail"
fi

Save the script on a data pool dataset, not under /root on SCALE, so it survives boot-environment updates. Point the cron job's command at sh /mnt/tank/scripts/truenas-ping.sh. Swap replication.run for cloudsync.sync to gate a Cloud Sync task the same way.

Prefer to keep the task on its own schedule? Cloud Sync tasks expose Pre-Script and Post-Script fields under Advanced Options: point Pre-Script at a call to $URL/start and Post-Script at $URL.

4. Test it

Run the cron job once, the check flips to up. Disable the job (or unplug the box) and confirm the alert lands once the grace window passes: exactly the failure mode TrueNAS's own alerting can't see.