我想用 Monit 监控 SSH,但出现错误。此设置适用于我的旧 Ubuntu 18.04 服务器,但不适用于我的新 Ubuntu 20.04 服务器:
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