在/etc/monit.d/下vim
vim mongotcp
# 匹配進程名
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
進程
配置結束it