Monit is not limited to Monitor Linux system performance, also doing auto repair action for dead services
SSH on systemd
check process sshd with pidfile /var/run/sshd.pid start program = "systemctl start sshd.service" stop program = "systemctl stop sshd.service" if failed port 22 protocol ssh then restart
After making the changes on Monit configuration file, verify the syntax once to confirm there is no error on configuration. Finally restart the Monit service.
[Start Monit service on SysVinit] $ sudo service monit start [Start Monit service on systemd] $ sudo systemctl restart monit.service
5) Test Monit
I’m going to test Monit whether automatically kiking up the down service or not by stoping ssh on server.
[Stop apache service on SysVinit] $ sudo service sshd stop [Stop apache service on systemd] $ sudo systemctl stop sshd.service
Verify the log once. Yes, ssh is down.
$ tail -f /var/log/monit.log
Wait two minutes and refresh the Monit web interface. Yes, ssh is up now and check all the logs and CLI too.