Monitor the execution of your jobs, scripts, and scheduled tasks in real-time
Heartbeat monitoring, also known as dead man's switch or liveness ping, represents a fundamental approach to monitoring critical processes. Unlike traditional HTTP monitoring that actively checks if a server responds, heartbeat takes an inverse approach: it passively waits for a regular signal from your applications and only alerts when that signal is absent.
This technique is particularly powerful for detecting silent failures—situations where a process stops working without generating any visible error. A cron job that no longer starts, a backup script that crashes before writing its logs, a worker that silently dies: all these situations go unnoticed with classic monitoring but are immediately detected by heartbeat.
MoniTao provides a complete and easy-to-integrate heartbeat monitoring solution. By adding a single line of code to your existing scripts, you benefit from 24/7 surveillance with instant alerts via email, SMS, or webhook as soon as a job misses its expected check-in.
Heartbeat monitoring is based on a simple but highly effective principle: your application periodically sends a liveness signal, and the absence of this signal triggers an alert. This approach has several distinctive characteristics.
Heartbeat is the ideal solution for monitoring any process that runs on a recurring, automated basis, where absence of execution is as critical as an explicit error.
MoniTao heartbeat integration follows a simple four-step process, designed to minimize implementation effort while maximizing monitoring coverage.
Here are concrete examples of MoniTao heartbeat integration in different contexts. The goal is to add the ping only on success.
# Bash - At the end of a cron script
#!/bin/bash
set -e # Stop on error
# Your business logic here
./backup.sh
rsync -av /data/ /backup/
# Ping MoniTao only on success
curl -fsS "https://monitao.com/ping/YOUR_TOKEN" > /dev/null
# PHP - In a processing script
try {
// Your business logic
$result = processData();
// Ping MoniTao on success
file_get_contents("https://monitao.com/ping/YOUR_TOKEN");
} catch (Exception $e) {
// No ping = automatic alert
log_error($e);
}
The crucial point is that the ping should only be sent on success. If your script fails before the ping, the absence of signal will automatically trigger the alert. This is the fundamental principle of the dead man's switch.
Heartbeat offers unique advantages that classic monitoring cannot provide, especially for monitoring batch processes and scheduled tasks.
HTTP monitoring actively and periodically checks if your server responds to a request. Heartbeat works in reverse: your application sends a liveness signal, and the absence of this signal triggers the alert. HTTP is ideal for websites, heartbeat for batch processes.
Simply add an HTTP call to the MoniTao ping URL at the end of your script. In bash: curl -fsS "URL" > /dev/null. In PHP: file_get_contents("URL"). In Python: requests.get("URL"). The key is that this ping should be the last instruction executed after success.
That's exactly the purpose of heartbeat. If your script fails before reaching the ping line, no signal is sent. MoniTao waits for the ping, notes its absence after the configured delay, and triggers the alert. That's the dead man's switch principle.
Yes, MoniTao offers start and complete endpoints. Call /start at the beginning of your job and /complete at the end. MoniTao automatically calculates the duration and can alert if a job exceeds a configured maximum duration.
Configure an appropriate grace period. If your cron is supposed to run every hour, set an interval of 1h and a grace of 10-15 minutes. This way, a minor delay won't trigger an alert, but a real failure will be detected.
Absolutely. Heartbeat is particularly useful in containerized environments where pods can be evicted, restarted, or dynamically scaled. Add the ping to your Kubernetes CronJobs or to scripts executed by containers.
Heartbeat monitoring is an essential complement to traditional monitoring. While HTTP monitoring and classic alert systems excel at detecting errors that occur, only heartbeat can detect actions that should have occurred but didn't. For any critical process that runs on a recurring basis—crons, backups, imports, synchronizations—heartbeat represents the last line of defense against silent failures.
MoniTao makes heartbeat implementation trivial: create a job in a few clicks, add one line of code to your scripts, and sleep easy knowing you'll be alerted if something doesn't run. Start protecting your critical processes with MoniTao heartbeat monitoring now.
Start free, no credit card required.