From b418181dfe80dd75169b6e8a619ac1932155dea2 Mon Sep 17 00:00:00 2001 From: Sven Nierlein Date: Mon, 20 Jan 2014 00:54:34 +0100 Subject: renamed module into Monitoring::Plugin since the complete monitoring team has been renamed, we also rename this module. Signed-off-by: Sven Nierlein --- t/check_stuff.pl | 45 ++++++++++++++++++++------------------------- 1 file changed, 20 insertions(+), 25 deletions(-) (limited to 't/check_stuff.pl') diff --git a/t/check_stuff.pl b/t/check_stuff.pl index 112a18a..4fc125c 100755 --- a/t/check_stuff.pl +++ b/t/check_stuff.pl @@ -2,21 +2,21 @@ ### check_stuff.pl -# an example Nagios plugin using the Nagios::Plugin modules. +# an example Monitoring plugin using the Monitoring::Plugin modules. # Originally by Nathan Vonnahme, n8v at users dot sourceforge # dot net, July 19 2006 # Please modify to your heart's content and use as the basis for all -# the really cool Nagios monitoring scripts you're going to create. -# You rock. +# the really cool monitoring scripts you're going to create. +# You rock. ############################################################################## # prologue use strict; use warnings; -use Nagios::Plugin ; +use Monitoring::Plugin; use vars qw($VERSION $PROGNAME $verbose $warn $critical $timeout $result); $VERSION = '1.0'; @@ -28,18 +28,18 @@ $PROGNAME = basename($0); ############################################################################## # define and get the command line options. -# see the command line option guidelines at -# http://nagiosplug.sourceforge.net/developer-guidelines.html#PLUGOPTIONS +# see the command line option guidelines at +# https://www.monitoring-plugins.org/doc/guidelines.html#PLUGOPTIONS -# Instantiate Nagios::Plugin object (the 'usage' parameter is mandatory) -my $p = Nagios::Plugin->new( +# Instantiate Monitoring::Plugin object (the 'usage' parameter is mandatory) +my $p = Monitoring::Plugin->new( usage => "Usage: %s [ -v|--verbose ] [-H ] [-t ] - [ -c|--critical= ] - [ -w|--warning= ] + [ -c|--critical= ] + [ -w|--warning= ] [ -r|--result = ]", version => $VERSION, - blurb => 'This plugin is an example of a Nagios plugin written in Perl using the Nagios::Plugin modules. It will generate a random integer between 1 and 20 (though you can specify the number with the -n option for testing), and will output OK, WARNING or CRITICAL if the resulting number is outside the specified thresholds.', + blurb => 'This plugin is an example of a monitoring plugin written in Perl using the Monitoring::Plugin modules. It will generate a random integer between 1 and 20 (though you can specify the number with the -n option for testing), and will output OK, WARNING or CRITICAL if the resulting number is outside the specified thresholds.', extra => " @@ -47,11 +47,7 @@ THRESHOLDs for -w and -c are specified 'min:max' or 'min:' or ':max' (or 'max'). If specified '\@min:max', a warning status will be generated if the count *is* inside the specified range. -See more threshold examples at http - : // nagiosplug - . sourceforge - . net / developer-guidelines - . html #THRESHOLDFORMAT +See more threshold examples at https://www.monitoring-plugins.org/doc/guidelines.html#THRESHOLDFORMAT Examples: @@ -75,7 +71,7 @@ See more threshold examples at http $p->add_arg( spec => 'warning|w=s', - help => + help => qq{-w, --warning=INTEGER:INTEGER Minimum and maximum number of allowable result, outside of which a warning will be generated. If omitted, no warning is generated.}, @@ -86,7 +82,7 @@ qq{-w, --warning=INTEGER:INTEGER $p->add_arg( spec => 'critical|c=s', - help => + help => qq{-c, --critical=INTEGER:INTEGER Minimum and maximum number of the generated result, outside of which a critical will be generated. }, @@ -94,7 +90,7 @@ qq{-c, --critical=INTEGER:INTEGER $p->add_arg( spec => 'result|r=f', - help => + help => qq{-r, --result=INTEGER Specify the result on the command line rather than generating a random number. For testing.}, @@ -106,11 +102,11 @@ $p->getopts; # perform sanity checking on command line options if ( (defined $p->opts->result) && ($p->opts->result < 0 || $p->opts->result > 20) ) { - $p->nagios_die( " invalid number supplied for the -r option " ); + $p->plugin_die( " invalid number supplied for the -r option " ); } unless ( defined $p->opts->warning || defined $p->opts->critical ) { - $p->nagios_die( " you didn't supply a threshold argument " ); + $p->plugin_die( " you didn't supply a threshold argument " ); } @@ -135,8 +131,7 @@ else { ############################################################################## # check the result against the defined warning and critical thresholds, # output the result and exit -$p->nagios_exit( - return_code => $p->check_threshold($result), - message => " sample result was $result" +$p->plugin_exit( + return_code => $p->check_threshold($result), + message => " sample result was $result" ); - -- cgit v1.2.3-74-g34f1