Nagios::Plugin - Object oriented helper routines for your Nagios plugin
use Nagios::Plugin qw(%ERRORS); $p = Nagios::Plugin->new( shortname => "PAGESIZE" ); $threshold = $p->set_thresholds( warning => "10:25", critical => "25:" ); # ... collect current metric into $value if ($trouble_getting_metric) { $p->die( return_code => $ERRORS{UNKNOWN}, message => "Could not retrieve page"); # Output: PAGESIZE UNKNOWN Could not retrieve page # Return code: 3 } $p->add_perfdata( label => "size", value => $value, uom => "kB", threshold => $threshold, ); $p->add_perfdata( label => "time", ... ); $p->die( return_code => $threshold->get_status($value), message => "page size at http://... was ${value}kB" ); # Output: PAGESIZE OK: page size at http://... was 36kB | size=36kB;10:25;25: time=... # Return code: 0
This is the place for common routines when writing Nagios plugins. The idea is to make it as easy as possible for developers to conform to the plugin guidelines (http://nagiosplug.sourceforge.net/developer-guidelines.html).
To facilitate object oriented classes, there are multiple perl modules, each reflecting a type of data (ie, thresholds, ranges, performance). However, a plugin developer does not need to know about the different types - a "use Nagios::Plugin" should be sufficient.
There is a Nagios::Plugin::Export. This holds all internals variables. You can specify these variables when use'ing Nagios::Plugin
use Nagios::Plugin qw(%ERRORS) print $ERRORS{WARNING} # prints 1
Only methods listed in the documentation for each module is public.
These modules are experimental and so the interfaces may change up until Nagios::Plugin hits version 1.0, but every attempt will be made to make backwards compatible.
Imports the %ERRORS hash. This is currently the only symbol that can be imported.
Initializes a new Nagios::Plugin object. Can specify the shortname here.
Sets the thresholds, based on the range specification at http://nagiosplug.sourceforge.net/developer-guidelines.html#THRESHOLDFORMAT. Returns a Nagios::Plugin::Threshold object, which can be used to input a value to see which threshold is crossed.
Adds to an array a Nagios::Plugin::Performance object with the specified values.
This needs to be done separately to allow multiple perfdata output.
Exits the plugin and prints to STDOUT a Nagios plugin compatible output. Exits with the specified return code. Also prints performance data if any have been added in.
http://nagiosplug.sourceforge.net
Ton Voon, <ton.voon@altinity.com>
Copyright (C) 2006 by Nagios Plugin Development Team
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.8.4 or, at your option, any later version of Perl 5 you may have available.
6 POD Errors
The following errors were encountered while parsing the POD:
You forgot a '=back' before '=head1'
'=item' outside of any '=over'
To install Nagios::__::Plugin, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Nagios::__::Plugin
CPAN shell
perl -MCPAN -e shell install Nagios::__::Plugin
For more information on module installation, please visit the detailed CPAN module installation guide.