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

Navigate to Web Interface and check the newly added services.
install-monit-on-linux-2

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

Check on Monit Web Interface. Yes, ssh is down.
install-monit-on-linux-3

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.

Vinoth Kumar

Vinoth Kumar has 3.5+ years of experience in Linux server administration & RHEL certified professional. He is currently working as a Senior L2 Linux Server administrator.

You may also like...