Monitoring SystemD services with Healthchecks.io
SystemD services, particularly those triggered by systemd timers, can be monitored using Healthchecks.io. This system allows for the creation of a simple setup that can be integrated with other tooling, such as Vorta/borg for machine backups. Healthchecks.io provides a hosted instance, and users can trigger pings when a systemd service status changes.
This is achieved through OnSuccess/OnFailure hooks and custom services. These services run a curl command to ping the Healthchecks.io instance, passing the ping UUID as an argument. The setup is simple and can be integrated with other tools. In the future, there may be an opportunity to migrate to a single healthcheck service and attach logs.
The updated SystemD template service file provided allows for the use of the same template file while supporting the start and logging options of Healthchecks.io. Important dependencies include :failure, :success, and :start, which ensure the $MONITOR_* environmental variables are passed through to the service. These variables include $MONITOR_SERVICE_RESULT, $MONITOR_EXIT_CODE, $MONITOR_EXIT_STATUS, $MONITOR_INVOCATION_ID, and $MONITOR_UNIT, which provide valuable information about the service's execution.
Written by urgent.news from Lobsters's reporting — not their text. Machine-written — may contain errors; check the original before relying on it.