monit 任務 monit.d/

check process nginx with pidfile /run/nginx.pid
start program = "/usr/bin/sudo service nginx start" with timeout 30 seconds
restart program = "/usr/bin/sudo service nginx restart"
if failed port 80  type tcp then alert
if failed port 80  type tcp then restartnginx

 

或者tcp

# 匹配進程名
check process mongo MATCHING mongo
# 配置服務啓動和重啓命令
start program = "/usr/bin/sudo service mongod start"
restart program = "/usr/bin/sudo service mongod restart"
# 若是端口27017沒法訪問則認爲服務失敗,發報警郵件並重啓服務
if failed port 27017  type tcp then alert
if failed port 27017  type tcp then restartrest

# 若是在三個週期內重啓了3次,則再也不監控
# if 3 restarts within 3 cycles then unmonitor進程

相關文章
相關標籤/搜索