summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/Nagios/Plugin/Functions.pm22
1 files changed, 19 insertions, 3 deletions
diff --git a/lib/Nagios/Plugin/Functions.pm b/lib/Nagios/Plugin/Functions.pm
index 9983456..43f371c 100644
--- a/lib/Nagios/Plugin/Functions.pm
+++ b/lib/Nagios/Plugin/Functions.pm
@@ -18,11 +18,11 @@ our @STATUS_CODES = qw(OK WARNING CRITICAL UNKNOWN DEPENDENT);
18require Exporter; 18require Exporter;
19our @ISA = qw(Exporter); 19our @ISA = qw(Exporter);
20our @EXPORT = (@STATUS_CODES, qw(nagios_exit nagios_die check_messages)); 20our @EXPORT = (@STATUS_CODES, qw(nagios_exit nagios_die check_messages));
21our @EXPORT_OK = qw(%ERRORS %STATUS_TEXT @STATUS_CODES get_shortname); 21our @EXPORT_OK = qw(%ERRORS %STATUS_TEXT @STATUS_CODES get_shortname max_state);
22our %EXPORT_TAGS = ( 22our %EXPORT_TAGS = (
23 all => [ @EXPORT, @EXPORT_OK ], 23 all => [ @EXPORT, @EXPORT_OK ],
24 codes => [ @STATUS_CODES ], 24 codes => [ @STATUS_CODES ],
25 functions => [ qw(nagios_exit nagios_die check_messages) ], 25 functions => [ qw(nagios_exit nagios_die check_messages max_state) ],
26); 26);
27 27
28use constant OK => 0; 28use constant OK => 0;
@@ -56,6 +56,15 @@ sub get_shortname {
56 return $shortname; 56 return $shortname;
57} 57}
58 58
59sub max_state {
60 return CRITICAL if grep { $_ == CRITICAL } @_;
61 return WARNING if grep { $_ == WARNING } @_;
62 return OK if grep { $_ == OK } @_;
63 return UNKNOWN if grep { $_ == UNKNOWN } @_;
64 return DEPENDENT if grep { $_ == DEPENDENT } @_;
65 return UNKNOWN;
66}
67
59# nagios_exit( $code, $message ) 68# nagios_exit( $code, $message )
60sub nagios_exit { 69sub nagios_exit {
61 my ($code, $message, $arg) = @_; 70 my ($code, $message, $arg) = @_;
@@ -197,7 +206,7 @@ __END__
197=head1 NAME 206=head1 NAME
198 207
199Nagios::Plugin::Functions - functions to simplify the creation of 208Nagios::Plugin::Functions - functions to simplify the creation of
200Nagios plugins. 209Nagios plugins
201 210
202=head1 SYNOPSIS 211=head1 SYNOPSIS
203 212
@@ -259,6 +268,7 @@ The following variables and functions are exported only on request:
259 %ERRORS 268 %ERRORS
260 %STATUS_TEXT 269 %STATUS_TEXT
261 get_shortname 270 get_shortname
271 max_state
262 272
263 273
264=head2 FUNCTIONS 274=head2 FUNCTIONS
@@ -349,6 +359,12 @@ imported.
349 359
350=back 360=back
351 361
362=item max_state(@a)
363
364Returns the worst state in the array. Order is: CRITICAL, WARNING, OK, UNKNOWN,
365DEPENDENT
366
367=back
352 368
353=head1 SEE ALSO 369=head1 SEE ALSO
354 370