我正在尝试使用社区磁盘检查插件让磁盘在磁盘充满时发送电子邮件。即使执行的命令返回状态0,Sensu也会触发处理程序。
这是check_disk.json文件
{
"checks": {
"check_disk_usage": {
"command": "/etc/sensu/plugins/check-disk.rb -c 42 -w 43",
"handlers": ["debug", "email"],
"subscribers": [ "disk_check" ],
"interval": 30,
"notification": "Disk Check failed",
"occurrences": 5
}
}
}
这里我手动运行命令,注意成功和状态为零:
/etc/sensu/plugins/check-disk.rb -c 42 -w 43
CheckDisk OK: All disk usage under 43% and inode usage under 85%
[root@ip-10-9-66-239 conf.d]# echo $?
0
这是我的sensu-client.log中的相关输出
{"timestamp":"2015-06-17T20:03:43.079971+0000","level":"info","message":"publishing check result","payload":{"client":"portal","check":{"name":"check_disk_usage","issued":1434571422,"command":"/etc/sensu/plugins/check-disk.rb -c 42 -w 43","handlers":["debug","email"],"subscribers":["disk_check"],"interval":30,"notification":"Disk Check failed", "occurrences":5,"executed":1434571422,"duration":0.104,"output":"CheckDisk OK: All disk usage under 43% and inode usage under 85%\n","status":0}}}
任何见解为什么sensu称之为失败,并且非常感谢通知。
答案 0 :(得分:1)
docs中陈述的内容,您可以指定处理程序将触发的严重性。
{
"handlers": {
"statsd": {
"type": "udp",
"severities": [
"warning",
"critical",
"unknown"
],
"socket": {
"port": 8125,
"host": "statsd.service.consul"
}
}
}
}
这不起作用,然后在上面发布你的处理程序配置。