Linux下如何通过monit工具监控某个进程并在进程死亡的时候发送邮件通知
check process example matching "python /home/user/sdc/rembg/example.py"
start program = "/home/user/sdc/rembg/example.sh start"
stop program = "/home/user/sdc/rembg/example.sh stop"
if does not exist for 2 cycles then restart
if 1 restarts within 2 cycles then alert
2、打开monit的配置文件:sudo vim /etc/monit/monitrc
3、配置要用到的发送邮件的服务器:
set mailserver smtp.163.com # primary mailserver
port 465
username "your_name@163.com"
password "your_password"
using ssl
with timeout 120 seconds
4、配置邮件格式:
set mail-format {
from: Monit <monit@$HOST>
subject: monit alert -- $EVENT $SERVICE
message: $EVENT Service $SERVICE
Date: $DATE
Action: $ACTION
Host: $HOST
Description: $DESCRIPTION
Your faithful employee,
Monit
}
5、配置发件人:
set mail-format { from: your_name@163.com }
6、配置收件人:
set alert recipient@qq.com not on { instance, action }
#、另外如果想开启web页面管理monit用如下配置:
set httpd port 2812 and
use address 192.168.8.4 # only accept connection from localhost (drop if you use M/Monit)
allow * # allow localhost to connect to the server and
allow admin:monit # require user 'admin' with password 'monit'
浙公网安备 33010602011771号