diff options
author | Sven Nierlein <sven@nierlein.de> | 2014-01-20 00:54:34 +0100 |
---|---|---|
committer | Sven Nierlein <sven@nierlein.de> | 2014-01-20 00:54:34 +0100 |
commit | b418181dfe80dd75169b6e8a619ac1932155dea2 (patch) | |
tree | cad9c0ae0eae8e800cfff60555ead06ad33c6856 /t/check_stuff.pl | |
parent | 1cd8d1c52cbd47121f344c4074aec84653f412ce (diff) | |
download | monitoring-plugin-perl-b418181dfe80dd75169b6e8a619ac1932155dea2.tar.gz |
renamed module into Monitoring::Plugin
since the complete monitoring team has been renamed, we
also rename this module.
Signed-off-by: Sven Nierlein <sven@nierlein.de>
Diffstat (limited to 't/check_stuff.pl')
-rwxr-xr-x | t/check_stuff.pl | 45 |
1 files changed, 20 insertions, 25 deletions
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 @@ | |||
2 | 2 | ||
3 | ### check_stuff.pl | 3 | ### check_stuff.pl |
4 | 4 | ||
5 | # an example Nagios plugin using the Nagios::Plugin modules. | 5 | # an example Monitoring plugin using the Monitoring::Plugin modules. |
6 | 6 | ||
7 | # Originally by Nathan Vonnahme, n8v at users dot sourceforge | 7 | # Originally by Nathan Vonnahme, n8v at users dot sourceforge |
8 | # dot net, July 19 2006 | 8 | # dot net, July 19 2006 |
9 | 9 | ||
10 | # Please modify to your heart's content and use as the basis for all | 10 | # Please modify to your heart's content and use as the basis for all |
11 | # the really cool Nagios monitoring scripts you're going to create. | 11 | # the really cool monitoring scripts you're going to create. |
12 | # You rock. | 12 | # You rock. |
13 | 13 | ||
14 | ############################################################################## | 14 | ############################################################################## |
15 | # prologue | 15 | # prologue |
16 | use strict; | 16 | use strict; |
17 | use warnings; | 17 | use warnings; |
18 | 18 | ||
19 | use Nagios::Plugin ; | 19 | use Monitoring::Plugin; |
20 | 20 | ||
21 | use vars qw($VERSION $PROGNAME $verbose $warn $critical $timeout $result); | 21 | use vars qw($VERSION $PROGNAME $verbose $warn $critical $timeout $result); |
22 | $VERSION = '1.0'; | 22 | $VERSION = '1.0'; |
@@ -28,18 +28,18 @@ $PROGNAME = basename($0); | |||
28 | 28 | ||
29 | ############################################################################## | 29 | ############################################################################## |
30 | # define and get the command line options. | 30 | # define and get the command line options. |
31 | # see the command line option guidelines at | 31 | # see the command line option guidelines at |
32 | # http://nagiosplug.sourceforge.net/developer-guidelines.html#PLUGOPTIONS | 32 | # https://www.monitoring-plugins.org/doc/guidelines.html#PLUGOPTIONS |
33 | 33 | ||
34 | 34 | ||
35 | # Instantiate Nagios::Plugin object (the 'usage' parameter is mandatory) | 35 | # Instantiate Monitoring::Plugin object (the 'usage' parameter is mandatory) |
36 | my $p = Nagios::Plugin->new( | 36 | my $p = Monitoring::Plugin->new( |
37 | usage => "Usage: %s [ -v|--verbose ] [-H <host>] [-t <timeout>] | 37 | usage => "Usage: %s [ -v|--verbose ] [-H <host>] [-t <timeout>] |
38 | [ -c|--critical=<critical threshold> ] | 38 | [ -c|--critical=<critical threshold> ] |
39 | [ -w|--warning=<warning threshold> ] | 39 | [ -w|--warning=<warning threshold> ] |
40 | [ -r|--result = <INTEGER> ]", | 40 | [ -r|--result = <INTEGER> ]", |
41 | version => $VERSION, | 41 | version => $VERSION, |
42 | 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.', | 42 | 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.', |
43 | 43 | ||
44 | extra => " | 44 | extra => " |
45 | 45 | ||
@@ -47,11 +47,7 @@ THRESHOLDs for -w and -c are specified 'min:max' or 'min:' or ':max' | |||
47 | (or 'max'). If specified '\@min:max', a warning status will be generated | 47 | (or 'max'). If specified '\@min:max', a warning status will be generated |
48 | if the count *is* inside the specified range. | 48 | if the count *is* inside the specified range. |
49 | 49 | ||
50 | See more threshold examples at http | 50 | See more threshold examples at https://www.monitoring-plugins.org/doc/guidelines.html#THRESHOLDFORMAT |
51 | : // nagiosplug | ||
52 | . sourceforge | ||
53 | . net / developer-guidelines | ||
54 | . html #THRESHOLDFORMAT | ||
55 | 51 | ||
56 | Examples: | 52 | Examples: |
57 | 53 | ||
@@ -75,7 +71,7 @@ See more threshold examples at http | |||
75 | $p->add_arg( | 71 | $p->add_arg( |
76 | spec => 'warning|w=s', | 72 | spec => 'warning|w=s', |
77 | 73 | ||
78 | help => | 74 | help => |
79 | qq{-w, --warning=INTEGER:INTEGER | 75 | qq{-w, --warning=INTEGER:INTEGER |
80 | Minimum and maximum number of allowable result, outside of which a | 76 | Minimum and maximum number of allowable result, outside of which a |
81 | warning will be generated. If omitted, no warning is generated.}, | 77 | warning will be generated. If omitted, no warning is generated.}, |
@@ -86,7 +82,7 @@ qq{-w, --warning=INTEGER:INTEGER | |||
86 | 82 | ||
87 | $p->add_arg( | 83 | $p->add_arg( |
88 | spec => 'critical|c=s', | 84 | spec => 'critical|c=s', |
89 | help => | 85 | help => |
90 | qq{-c, --critical=INTEGER:INTEGER | 86 | qq{-c, --critical=INTEGER:INTEGER |
91 | Minimum and maximum number of the generated result, outside of | 87 | Minimum and maximum number of the generated result, outside of |
92 | which a critical will be generated. }, | 88 | which a critical will be generated. }, |
@@ -94,7 +90,7 @@ qq{-c, --critical=INTEGER:INTEGER | |||
94 | 90 | ||
95 | $p->add_arg( | 91 | $p->add_arg( |
96 | spec => 'result|r=f', | 92 | spec => 'result|r=f', |
97 | help => | 93 | help => |
98 | qq{-r, --result=INTEGER | 94 | qq{-r, --result=INTEGER |
99 | Specify the result on the command line rather than generating a | 95 | Specify the result on the command line rather than generating a |
100 | random number. For testing.}, | 96 | random number. For testing.}, |
@@ -106,11 +102,11 @@ $p->getopts; | |||
106 | 102 | ||
107 | # perform sanity checking on command line options | 103 | # perform sanity checking on command line options |
108 | if ( (defined $p->opts->result) && ($p->opts->result < 0 || $p->opts->result > 20) ) { | 104 | if ( (defined $p->opts->result) && ($p->opts->result < 0 || $p->opts->result > 20) ) { |
109 | $p->nagios_die( " invalid number supplied for the -r option " ); | 105 | $p->plugin_die( " invalid number supplied for the -r option " ); |
110 | } | 106 | } |
111 | 107 | ||
112 | unless ( defined $p->opts->warning || defined $p->opts->critical ) { | 108 | unless ( defined $p->opts->warning || defined $p->opts->critical ) { |
113 | $p->nagios_die( " you didn't supply a threshold argument " ); | 109 | $p->plugin_die( " you didn't supply a threshold argument " ); |
114 | } | 110 | } |
115 | 111 | ||
116 | 112 | ||
@@ -135,8 +131,7 @@ else { | |||
135 | ############################################################################## | 131 | ############################################################################## |
136 | # check the result against the defined warning and critical thresholds, | 132 | # check the result against the defined warning and critical thresholds, |
137 | # output the result and exit | 133 | # output the result and exit |
138 | $p->nagios_exit( | 134 | $p->plugin_exit( |
139 | return_code => $p->check_threshold($result), | 135 | return_code => $p->check_threshold($result), |
140 | message => " sample result was $result" | 136 | message => " sample result was $result" |
141 | ); | 137 | ); |
142 | |||