2
I have Systemd service that is supposed to be running all the time. I would like to get alerted by email in case the service has stopped? What is the best way to do it in linux?
2
I have Systemd service that is supposed to be running all the time. I would like to get alerted by email in case the service has stopped? What is the best way to do it in linux?
1
You can use the ExecStopPost
setting in your service configuration, as documented in systemd.service to send an email whenever the service stops. If you don't want to receive an email when the service exits cleanly, you can use the SERVICE_RESULT
environment variable (documented in systemd.exec) in the script sending the email.
0
You can have a short bash script that checks the status of the service and pushes a notification if it is not running. For pushing notifications you can use Pushover which is pretty easy to integrate with a bash script after generating security keys.
Your bash script can be added to the crontab
for periodic execution say every 5 minutes(basically whatever period you want).
We use Naemon to monitor our systems. It’s easy to configure it to send an email if a service is down. – Colin 't Hart – 2018-09-21T21:39:54.803