Monitoring
python
Intermediate
New
Cron Job Heartbeat Monitor
Send a heartbeat ping after each cron job run — alert if a heartbeat is missed.
python
import httpx, os, functools, time
HEARTBEAT_URL = os.environ["HEARTBEAT_URL"] # e.g. https://updown.io/api/checks/TOKEN/metrics
def with_heartbeat(fn):
@functools.wraps(fn)
def wrapper(*args, **kwargs):
start = time.time()
try:
result = fn(*args, **kwargs)
httpx.get(HEARTBEAT_URL, timeout=5)
return result
except Exception as e:
httpx.get(HEARTBEAT_URL + "/fail", timeout=5)
raise
return wrapper
@with_heartbeat
def nightly_export():
print("Running export...")
Prerequisites
- httpx
- Healthchecks.io or similar
Pro Tips
- → Use healthchecks.io free tier for up to 20 monitors.
Commercial Licensing
Acquire a production access token or template license for enterprise deployment.
Module Info
- Language
- python
- Level
- Intermediate
- Read time
- 3 min
- Published
- Sep 2026
- License
- Commercial License
Newsletter
New modules every week, directly to your inbox.
Similar Modules
Disk IO Monitor
Monitor per-device disk read/write throughput in real time using iostat.
bash
·
Beginner
Datadog Custom Metric Reporter
Report custom business metrics to Datadog from a Python script via DogStatsD.
python
·
Advanced
AlertManager PagerDuty Config
Route critical Prometheus alerts to PagerDuty with deduplication and silencing.
yaml
·
Intermediate