0

I want to monitor SSH with Monit but I got an error. This setup works with my old Ubuntu 18.04 server but it doesn't work on my new Ubuntu 20.04 server :

ubuntu@ov-xxxx ~ $ cd /var
ubuntu@ov-xxxx /var $ ls
backups  cache  crash  lib  local  lock  log  mail  opt  run  snap  spool  tmp  www
ubuntu@ov-xxxx /var $ cd run
ubuntu@ov-xxxx /var/run $ ls
agetty.reload  crond.reboot     initctl     monit.pid       netns           sendsigs.omit.d    sshd.pid    user
atd.pid        cryptsetup       initramfs   motd.d          network         shm                sudo        utmp
blkid          dbus             irqbalance  motd.dynamic    NetworkManager  snapd              systemd     uuidd
cloud-init     dmeventd-client  lock        mount           nginx.pid       snapd-snap.socket  tmpfiles.d  xtables.lock
console-setup  dmeventd-server  log         multipathd.pid  php             snapd.socket       udev
crond.pid      fail2ban         lvm         mysqld          screen          sshd               ufw.lock
ubuntu@ov-xxxx /var/run $ sudo systemctl start monit
ubuntu@ov-xxxx /var/run $ sudo systemctl reload monit
ubuntu@ov-xxxx /var/run $ sudo monit -t
/etc/monit/conf.d/lemp-services:3: Program does not exist: '/etc/init.d/sshd'
/etc/monit/conf.d/lemp-services:4: Program does not exist: '/etc/init.d/sshd'
Control file syntax OK
ubuntu@ov-xxxx /var/run $ 

$ sudo nano /etc/monit/conf.d/lemp-services

check process sshd with pidfile /var/run/sshd.pid
   group login
   start program = "/etc/init.d/sshd start"
   stop program = "/etc/init.d/sshd stop"

check process fail2ban with pidfile /var/run/fail2ban/fail2ban.pid
   start program = "/etc/init.d/fail2ban start"
   stop program = "/etc/init.d/fail2ban stop"

check process nginx with pidfile /var/run/nginx.pid
   group www-data
   start program = "/etc/init.d/nginx start"
   stop program = "/etc/init.d/nginx stop"

check process mysql with pidfile /var/run/mysqld/mysqld.pid
   start program = "/etc/init.d/mysql start"
   stop program = "/etc/init.d/mysql stop"

check process php-fpm with pidfile /var/run/php/php7.4-fpm.pid
   start program = "/etc/init.d/php7.4-fpm start"
   stop program = "/etc/init.d/php7.4-fpm stop"

check process postfix with pidfile /var/spool/postfix/pid/master.pid
   start program = "/etc/init.d/postfix start"
   stop program = "/etc/init.d/postfix stop"

check file drupal with path /home/ubuntu/www-example-com/web/sites/default/settings.php
mathieu
  • 1
  • 2
  • There is no such file, exactly as the error message says. What is your configuration? – Michael Hampton Aug 17 '20 at 03:33
  • @MichaelHampton I just updated my question – mathieu Aug 17 '20 at 03:44
  • Ubuntu doesn't use the ancient SysV-style init scripts for many services anymore. These are managed by systemd, and this monit configuration is completely redundant, as systemd will restart the service if it fails. – Michael Hampton Aug 17 '20 at 03:45
  • @MichaelHampton Ok but monit is able to send notifications in case of problem and displays the status of the services. – mathieu Aug 17 '20 at 03:57
  • Sure, but systemd can literally do _anything_ you can think of. Consider https://serverfault.com/q/876233/126632 – Michael Hampton Aug 17 '20 at 04:07
  • @MichaelHampton So monit is no longer useful ? – mathieu Aug 17 '20 at 04:15
  • It depends on what you're doing. If you're just restarting failed services, or doing other common stuff that systemd already handles, then that is redundant. If you have something complex then it could possibly still be useful. – Michael Hampton Aug 17 '20 at 04:26
  • @MichaelHampton I just want to display the service status and permissions of certain file in a web interface. – mathieu Aug 17 '20 at 04:28
  • That's a good point. systemd doesn't include a web interface. But have you tried [cockpit](https://cockpit-project.org/running)? – Michael Hampton Aug 17 '20 at 04:31
  • @MichaelHampton Thank you but this program is too heavy and gives access to functionality from the web which may pose security problems – mathieu Aug 17 '20 at 05:44
  • Haha, that's funny. You have the same security problems with ssh so you shouldn't run that either. – Michael Hampton Aug 17 '20 at 08:41
  • @MichaelHampton I will use my simply to display the status of the services and files. However I have a problem to access https://serverfault.com/questions/1030398/unable-to-access-monit-connection-refused-despite-the-open-port – mathieu Aug 17 '20 at 09:24

0 Answers0