简体   繁体   中英

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 is triggering the handler even when the command that it executes returns a status of 0.

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 } } }

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

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 }}}

Any insights why sensu calls this a failure and does the notification would be greatly appreciated.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM