[英]sensu triggering handler when command returns status 0
I'm trying to get sensu to send an email when disks get full, using a community disk checking plugin. 我正在尝试使用社区磁盘检查插件让sensu在磁盘已满时发送电子邮件。 Sensu is triggering the handler even when the command that it executes returns a status of 0.
即使执行的命令返回状态0,Sensu仍会触发处理程序。
Here is the check_disk.json file { "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 } } }
这是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 } } }
Here I run the command manually, notice success and status of zero: /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
在这里,我手动运行命令,注意成功和状态为零:
/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
/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
Here is the relevant output in my 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-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 }}}
Any insights why sensu calls this a failure and does the notification would be greatly appreciated. sensu为什么称其为失败并进行通知的任何见解将不胜感激。
A stated in the docs you can specify the severity that the handler will fire on. 您可以在文档中声明您可以指定处理程序触发的严重性。
{
"handlers": {
"statsd": {
"type": "udp",
"severities": [
"warning",
"critical",
"unknown"
],
"socket": {
"port": 8125,
"host": "statsd.service.consul"
}
}
}
}
Is this does not work then post your handler config above as well. 这是行不通的,然后在上面发布您的处理程序配置。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.