System Health Check

I have a service on Redhat 7.1 that I use start, stop, restart and the status of systemctl to manage. Once the status of systemctl returned active, but the application "behind" the service responded to an http code other than 200.

I know that I can use Monit or Nagios to check this and restart systemctl, but I would like to know if something exists by default when using systemd, so I do not need to install other tools.

My preferred solution was to restart my service if the HTTP return code is different from 200 completely automatically without using other tools except the system itself - (and possibly with the option to notify the Hipchat room or send an email ...)

I tried to search for a topic - with no luck. Please, help: -)

+4
source share
1 answer

Short answer

systemd has its own method for verifying health (based on sockets), but not HTTP-based. You can write a gasket that checks the status using the HTTP protocol and redirects it to its own mechanism.


Long answer

The right thing in the world of systemd is to use a socket mechanism sd_notifyto inform the init system when your application is fully accessible. Use Type=notifyfor your service to enable this feature.

, sd_notify(), NOTIFY_SOCKET, , READY=1 , 200.

, HTTP , - , NotifyAccess ( ).


, , sd_notify :

WATCHDOG_USEC=..., , , WATCHDOG=1, ; , .

+5

Source: https://habr.com/ru/post/1655707/


All Articles