sensu/sensu-plugin — pull request #40 by piavlo (2013-06-17 16:48:56+00:00)
Title: Feature - hybird checks support

This add support for json and graphite hybird checks by allowing to write explicit hybird checks where both check message and metrics are embedded in output as json fields.

Here is example hybird check using the graphite hybird class
https://github.com/piavlo/sensu-community-plugins/compare/hybird;cpu
as well you can see there two extension mutators to be used in server to handle the hybird checks

config example using **prune_hybird_check_metrics** mutator - which remove metrics data from event,so that handlers could use the human readable message output

{
"handlers": {
"logevent": {
"type": "pipe",
"mutator": "prune_hybird_check_metrics",
"severities": [ "warning","critical" ],
"handle_flapping": true,
"command": "/etc/sensu/handlers/logevent.rb"
}
},
"logevent": {
"eventdir": "/var/log/sensu/events",
"keep": 10
}
}

config example using **hybird_check_metrics** mutator - basicly works like only_check_output mutator but handles both metric events and hybird events

{
"handlers": {
"graphite": {
"type": "amqp",
"exchange": {
"type": "topic",
"name": "metrics",
"durable": "true"
},
"mutator": "hybird_check_metrics"
}
}
}

As well there is a sensu server PR which add hybird checks support, so that one can explicitly define hybird check type like this

{
"checks": {
"check_cpu": {
"command": "/etc/sensu/plugins/hybird-cpu.rb -w :::params.cpu.warning|70::: -c :::params.cpu.critical|90::: --sleep 30",
"interval": 60,
"occurrences": 3,
"subscribers": [ "common" ],
"handlers": [ "default" ],
"type": "hybird"
}
}
}

Then the above 2 extension mutators are able to differentiate if they got "type": "hybird" or not and act appropriately.

As well this is also required so that sensu server pushes only the human readable part of hybird event to redis, and then tools like dashboards using the sensu api will show only the human readable description.