通过外部脚本进行的munin警报失败

时间:2015-03-05 03:59:20

标签: alert munin

我通过外部脚本坚持使用munin警报。我按照这里的指南(http://guide.munin-monitoring.org/en/latest/tutorial/alert.html#alerts-to-or-through-external-scripts),但结果出错了。

contact.test.command >/etc/munin/scripts/sendsms.py /etc/munin/scripts/sendsms.py

munin-limits日志显示:

  

[警告]发现">"在命令开始时。这应该不再是   必要的,并将在执行前从命令中删除。

     

[警告]无法关闭管道以进行接触测试:管道损坏

而且sentms.py从stdin没有收到任何东西,这很奇怪。

警报信息在哪里?编写命令的正确方法是什么?

3 个答案:

答案 0 :(得分:1)

我正在运行基于我服务器上的python脚本的警报。要设置它,请将它放入/etc/munin/munin.conf中我的情况如下:

contact.test.command | /path/to/my_python_script.py

python脚本本身可以由munin执行。在脚本中,我从Stdin读取了

中指定的文本
contact.test.text some text and ${var:label} 

使用http://munin-monitoring.org/wiki/MuninAlertVariables

中指定的一些Munin变量

答案 1 :(得分:0)

您忘记为脚本添加[pipe]。

可以使用这样的静态消息:

contact.test.command | /path/to/my_python_script.py "something gone wrong!!!"

或者使用munin提供的[vars]:

contact.test.command | /path/to/my_python_script.py "${var:group} ${var:host} ${var:graph_category} '${var:graph_title}'"

答案 2 :(得分:0)

最好是以这种方式对其进行调试:

su - munin --shell=/bin/bash
/usr/share/munin/munin-limits