Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Creating a Sensu Check

Creating a Sensu Check

Lightning talk delivered at DevOpsMtl #2 - Monitoring and Graphing. November 4th.

Mathieu Martin

November 05, 2013
Tweet

Other Decks in Technology

Transcript

  1. Outputs one line Exit code Output 0 CheckRAM OK: 45%

    free RAM left 1 CheckRAM WARNING: 9% free RAM left 2 CheckRAM CRITICAL: 4% free RAM left 3 CheckRAM UNKNOWN: invalid percentage
  2. dummy example #!/bin/bash! # Check the state! rand=$RANDOM! # Make

    a decision! if [ $rand -gt 22000 ]; then! # Report the decision! echo "Ok: random number generated was high enough ($rand)"! exit 0! else! …! fi!
  3. Command args mixlib-cli gem lets you declare: ! - short

    and long argument names (-v or --version) - description for CLI help - required arguments - argument types (default string, supports integer, boolean) - a proc to run on the argument (commonly used to call .to_f) ! Documentation ! https://github.com/opscode/mixlib-cli
  4. Ruby SDK recap • Inherit from Sensu::Plugin::Check::CLI! • Declare arguments

    with option! • def run()! • Access options with options[]! • Set exit status and message with ok(msg), warning(msg), critical(msg) or unknown(msg). Ends the execution immediately.! • Optional: use message(msg) instead, then ok(), warning(), etc.
  5. Metric checks Almost the same! • Exit status can be

    used too • Outputs multiple lines in Graphite format ! lolcathost.disk_usage.lolcats.used 9000000 1383246228! lolcathost.disk_usage.lolcats.avail 9000 1383246228! lolcathost.disk_usage.lolcats.used_percentage 99 1383246228! lolcathost.disk_usage.root.used 42 1383246229! …
  6. Ruby SDK for metrics • Inherit from Sensu::Plugin::Metric::CLI::Graphite instead •

    Output stats with output(name, value, timestamp)! • End with ok() (or other)
  7. Metrics convention • Always give option to override --scheme Can

    be used as an api key to authenticate (e.g. hostedgraphite.com) deadbeef4242.lolcathost.disk_usage.lolcats.used 9000000 1383246228
  8. Resources • Examples for this talk: https://github.com/webmat/sensu-check-lightning-talk • Sensu website:

    http://sensuapp.org/ • Community plugins: https://github.com/sensu/sensu-community-plugins • option documentation: https://github.com/opscode/mixlib-cli ! • I can be reached at @webmat or rocksolidops.com