Simple Nagios Probes in Ruby

I needed to write a custom nagios probe a few weeks ago. I googled for existing solutions in Ruby, but surprisingly
found none. A nagios probe can really be written in any language, it just has to return a single line of output and
an exit code of 0 (OK), 1 (WARNING), 2 (CRITICAL), or 3 (UNKNOWN). I chose Ruby because of the syntactical simplicity,
as well as the ease of bundling it as a gem using Gemcutter.

You can view the source here.

Installation

gem install nagios-probe

Usage

Simply create a subclass of Nagios::Probe and define the following methods:

  • check_crit
  • check_warn
  • check_ok (optional – it is defined in the base class to always return true)
  • crit_message
  • warn_message
  • ok_message

Example

To use your probe you must wrap it in a begin/rescue block to catch any exceptions and accurately report the status
to Nagios.

No comments yet.

Leave a Reply