How to Monitor a systemd Service: 7 Options Compared
A service that crashes at 3 a.m. and stays down is bad. One that crashes and nobody notices for a week is worse.
There are plenty of ways to catch it, from a five-line script to a full metrics stack. Here's what each one really takes, what it catches, and where it falls short.
| Option | What it watches | Alerts | Setup | Best for |
|---|---|---|---|---|
| Shell script + cron | Failed units, on your schedule | Whatever you script | Minutes | One box, no budget |
| Monit | Processes, or a program check per unit | Email via your SMTP | An hour | A few hand-picked services |
| Prometheus | Unit states as metrics | Alertmanager rules | Hours to days | Teams already on Prometheus |
| Zabbix | Discovered services and sockets | Zabbix actions | Hours to days | Fleets already on Zabbix |
| Netdata | Unit states plus resource use | Netdata alerts | Under an hour | Live charts with alerts |
| OnFailure= hook | Each unit that fails | Whatever you script | About ten minutes | Fast alerts, DIY |
| FailNote | Every service, plus silent servers | Email, Slack, Discord, Teams, webhook | One command | Alerts with the cause, no stack |
First, decide what "down" means
Most tools check one of two things. Some ask whether a unit is in the failed state. Others ask whether it is
active, which also flags units you stopped on purpose.
Oneshot jobs and timers add a twist. A backup that ran and exited is inactive, not broken. Pick a tool that tells those
apart, or you'll learn to ignore its alerts.
1. A shell script on cron
The cheapest check asks systemd for failed units every few minutes and mails anything it finds. You still have to work out why each one broke, which our systemd failure analyzer does from the status output.
#!/bin/sh
failed="$(systemctl list-units --failed --no-legend --plain)"
[ -n "$failed" ] && printf '%s\n' "$failed" | mail -s "$(hostname): failed units" [email protected] Good: free, and you can read every line. Not so good: it mails you every run until you fix the unit, it needs working mail on the server, and a hung server never runs it.
2. Monit
Monit watches processes, files and programs, and can restart things for you. It has no systemd check type, so the usual trick is a program check per unit:
check program nginx-unit with path "/usr/bin/systemctl is-active --quiet nginx"
if status != 0 then alert Good: small, mature and light on resources. Not so good: you list each service by hand, and alerts
need a set mailserver line pointing at an SMTP server you run or pay for.
3. Prometheus with node_exporter
node_exporter can export unit states, but its systemd collector is off by
default. Start it with --collector.systemd, then alert on failed units in Prometheus:
- alert: SystemdUnitFailed
expr: node_systemd_unit_state{state="failed"} == 1
for: 1m
labels:
severity: warning Good: great if Prometheus, Alertmanager and Grafana already run your world. Not so good: that's three services to install and keep healthy just to hear that one unit died, and the alert has no cause in it.
4. Zabbix
Zabbix has an official systemd template that works through Zabbix agent 2 and its systemd plugin. It discovers service and socket units and raises a "Service is not running" trigger.
Good: solid for large fleets with a Zabbix server already in place. Not so good: standing up a Zabbix server, database and frontend is a project of its own, and "not running" also fires for units you stopped on purpose.
5. Netdata
Netdata's systemd units collector tracks each unit's state and includes a failed-state alert. You also get live charts of CPU, memory and disk per service.
Good: fast to install, with a lot of detail. Not so good: it's a full monitoring agent with its own footprint, and the alert tells you a unit failed, not why.
6. An OnFailure= hook
systemd can run another unit the moment a unit fails, using OnFailure=. A top-level drop-in adds it to every service. Our step-by-step guide to a systemd alert on failure covers it in about ten minutes.
Good: instant, built in, and free. Not so good: you still need a way to send the alert, which is where mail gets tricky. Our guide to failure emails without a mail server covers that part. A dead server can't run the hook either.
7. FailNote
FailNote is our agent, built for exactly this one job. It installs with one command, hooks every service through
OnFailure=, and backs that up with a check-in every minute.
- It explains the failure. Alerts name the likely cause and the next command to run.
- No alert storms. A crash loop sends one alert, then one recovery note.
- Silent servers count. If a server stops checking in for five minutes, you get told.
- No stack to run. Alerts go out from our servers by email, Slack, Discord, Microsoft Teams or webhook.
Not so good: it only watches systemd services. It doesn't chart CPU or disk, and it isn't a replacement for a full metrics stack if you need one. It's free for one server, and Pro covers up to 10 for a monthly fee.
Which one fits you
- Already running Prometheus, Zabbix or Netdata? Turn on its systemd support and add the failed-state alert.
- One hobby server? A script or an OnFailure= hook is enough, as long as mail works.
- A handful of servers and no time for a stack? That's the gap FailNote was built for.
Whatever you pick, check your scheduled jobs too. A backup timer can stop running without anything failing, which our guide to alerts for failed timers explains.
Start FailNote free
Enter your email. We'll send a sign-in link, and your dashboard has the install command.
Already have an account? Sign in. See our privacy policy and terms.