Send alert if system service goes down centos

0

I'd like to monitor a system service on a set of hosts that are all running centos. The status can easily be obtained from systemctl, but does anyone know of a way to send an email if the service dies (i.e. the state of the service is not "running")?

I'd like to avoid sending hundreds of emails if the service is down for hours at a time, which could mean avoiding short term cron jobs. I'd like maybe 1 email if the service goes down, possible as many as 1 an hour, but even that feels like a lot.

I've heard Nagios, Zabbix or Kapacitor might fit the bill here, but I'm not sure which would be best for solving this type of problem. Any advice would be very helpful.

user3270760

Posted 2017-06-19T13:44:02.543

Reputation: 121

1

This looks like a relevant answer: https://serverfault.com/questions/694818/get-notification-when-systemd-monitored-service-enters-failed-state

– Eric Renouf – 2017-06-19T13:48:17.357

Answers

0

Nagios sends an email to an email address when a ping doesn't return back. You can configure a bunch of options;

check_period 24x7
check_interval 5
retry_interval 1
max_check_attempts 10
notification_period 24x7
notification_interval 30
notification_options d,u,r   

Notably, you can see an option for "notification interval" which is the option for the time period between email alerts.
Recently I've noticed they've added an Acknowledgement system, where if a system goes down, you can "acknowledge" it and it won't send any more notifications.

Shiffle McDoobles

Posted 2017-06-19T13:44:02.543

Reputation: 220

You can also set notification_interval to 0 so that it will only send one notification for the problem – Roddie – 2019-08-16T10:03:46.150