我试图从monit得到一个警报,如果它重新启动服务失败5次,但我得到一个语法错误
/etc/monit/monit.d/engine.conf:5: Error: syntax error 'alert'
任何想法有什么问题呢?
的/ etc / monit的/ monitrc:
set daemon 120 set mailserver localhost set eventqueue basedir /var/monit # set the base directory where events will be stored slots 100 # optionaly limit the queue size set httpd port 2812 allow localhost set logfile syslog set alert root@localhost include /etc/monit/monit.d/*
/etc/monit/monit.d/engine.conf(monit.d中唯一的文件):
check process engine with pidfile /var/run/engine.pid group engine start program = "/etc/init.d/engine start" stop program = "/etc/init.d/engine stop" if 5 restarts within 5 cycles then alert
版:
# monit -V This is monit version 4.10.1
它似乎支持这个在monit 5.1中添加
从更改日志http://mmonit.com/monit/dist/CHANGES.txt :
Version 5.1 NEW FEATURES AND FUNCTIONS: It is now possible to define any action for the restart timeout rule. Multiple restart timeout rules can also be defined. Example: if 3 restarts within 5 cycles then exec "/foo/bar" if 8 restarts within 10 cycles then unmonitor
我试图使用与您完全相同的语法(出于完全相同的原因),发现它在一台服务器上工作,而另一台工作。 当我比较版本时,我发现一个是5.2.5,另一个是4.10.1
所以答案似乎是升级到至less5.1
我觉得看起来很好。 你有没有尝试重新input该行,以排除任何隐藏的字符搞乱了行?
你在这个configuration之前是否已经定义了一个set alert <email_address>
?
好的,发现错误。 alert
不是有效的事件,您需要指定将生成警报的事件。 没有一个特定的事件,monit不知道该对你说什么。
手册页中的事件列表:
这是您可以在邮件filter中使用的事件列表:uid,gid,size,nonexist,data,icmp,instance,invalid,exec,changed,timeout,resource,checksum,match,timestamp,connection,permission
在你的情况下,我build议执行。 消息的完整列表是:
Event: | Failure state: | Recovery state: --------------------------------------------------------------- CHANGED | "Changed" | "Changed back" CHECKSUM | "Checksum failed" | "Checksum passed" CONNECTION| "Connection failed" | "Connection passed" DATA | "Data access error" | "Data access succeeded" EXEC | "Execution failed" | "Execution succeeded" GID | "GID failed" | "GID passed" ICMP | "ICMP failed" | "ICMP passed" INSTANCE | "Monit instance changed"| "Monit instance changed not" INVALID | "Invalid type" | "Type passed" MATCH | "Regex match" | "No regex match" NONEXIST | "Does not exist" | "Exists" PERMISSION| "Permission failed" | "Permission passed" RESOURCE | "Resource limit matched"| "Resource limit passed" SIZE | "Size failed" | "Size passed" TIMEOUT | "Timeout" | "Timeout recovery" TIMESTAMP | "Timestamp failed" | "Timestamp passed" UID | "UID failed" | "UID passed"
祝你好运,
JoãoMiguel Neves
在monit 5.4-2中,我注意到有一些奇怪的alert和unmonitor参数:如果在alertconfiguration行中使用unmonitor参数,它会产生一个语法错误:
alert [email protected] on { uid, gid, unmonitor } with the mail-format { subject: Alarm! }
重新启动监视时,您会看到:
Error: syntax error 'unmonitor'
我解决了这个问题,删除参数unmonitor:
alert [email protected] on { uid, gid } with the mail-format { subject: Alarm! }
我看不到语法改变…奇怪…不是吗?