sensu triggering handler when command returns status 0

709 views Asked by At

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

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.

1

There are 1 answers

0
Matty On

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.