Sensu Plugin
Build Status Gem Version Dependency Status pullreminders
This is a framework for writing your own Sensu plugins and handlers. It's not required to write a plugin (most Nagios plugins will work without modification); it just makes it easier.
Examples of plugins written with and without it can be found in the sensu-plugins organization.
Checks and Metrics
To implement your own check, subclass Sensu::Plugin::Check::CLI, like this:
require 'sensu-plugin/check/cli'
class MyCheck < Sensu::Plugin::Check::CLI
check_name 'my_awesome_check' # defaults to class name
option :foo, :short => '-f' # Mixlib::CLI is included
def run
ok "All is well"
end
end
This will output the string "my_awesome_check OK: All is well" (like a Nagios plugin), and exit with a code of 0. The available exit methods, which will immediately end the process, are:
ok
warning
critical
unknown
You can also call message first to set the message, then call an exit method without any arguments (for example, if you want to choose between WARNING and CRITICAL based on a threshold, but use the same message in both cases).
For a metric, you can subclass one of the following:
Sensu::Plugin::Metric::CLI::JSON
Sensu::Plugin::Metric::CLI::Graphite
Sensu::Plugin::Metric::CLI::Statsd
Sensu::Plugin::Metric::CLI::Dogstatsd
Sensu::Plugin::Metric::CLI::Influxdb
Sensu::Plugin::Metric::CLI::Generic
Instead of outputting a Nagios-style line of text, these classes will output differently formated messages depending on the class you chose.