[Nagiosplug-checkins] Nagios-Plugin/lib/Nagios/Plugin Functions.pm, 1.8, 1.9

Ton Voon tonvoon at users.sourceforge.net
Wed Feb 7 18:35:39 CET 2007


Update of /cvsroot/nagiosplug/Nagios-Plugin/lib/Nagios/Plugin
In directory sc8-pr-cvs7.sourceforge.net:/tmp/cvs-serv3464/lib/Nagios/Plugin

Modified Files:
	Functions.pm 
Log Message:
Added max_state function


Index: Functions.pm
===================================================================
RCS file: /cvsroot/nagiosplug/Nagios-Plugin/lib/Nagios/Plugin/Functions.pm,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -d -r1.8 -r1.9
--- Functions.pm	11 Nov 2006 05:18:45 -0000	1.8
+++ Functions.pm	7 Feb 2007 17:35:34 -0000	1.9
@@ -18,11 +18,11 @@
 require Exporter;
 our @ISA = qw(Exporter);
 our @EXPORT = (@STATUS_CODES, qw(nagios_exit nagios_die check_messages));
-our @EXPORT_OK = qw(%ERRORS %STATUS_TEXT @STATUS_CODES get_shortname);
+our @EXPORT_OK = qw(%ERRORS %STATUS_TEXT @STATUS_CODES get_shortname max_state);
 our %EXPORT_TAGS = (
     all => [ @EXPORT, @EXPORT_OK ],
     codes => [ @STATUS_CODES ],
-    functions => [ qw(nagios_exit nagios_die check_messages) ],
+    functions => [ qw(nagios_exit nagios_die check_messages max_state) ],
 );
 
 use constant OK         => 0;
@@ -56,6 +56,15 @@
     return $shortname;
 }
 
+sub max_state {
+	return CRITICAL if grep { $_ == CRITICAL } @_;
+	return WARNING if grep { $_ == WARNING } @_;
+	return OK if grep { $_ == OK } @_;
+	return UNKNOWN if grep { $_ == UNKNOWN } @_;
+	return DEPENDENT if grep { $_ == DEPENDENT } @_;
+	return UNKNOWN;
+}
+
 # nagios_exit( $code, $message )
 sub nagios_exit {
     my ($code, $message, $arg) = @_;
@@ -197,7 +206,7 @@
 =head1 NAME
 
 Nagios::Plugin::Functions - functions to simplify the creation of 
-Nagios plugins.
+Nagios plugins
 
 =head1 SYNOPSIS
 
@@ -259,6 +268,7 @@
     %ERRORS
     %STATUS_TEXT
     get_shortname
+    max_state
 
 
 =head2 FUNCTIONS
@@ -349,6 +359,12 @@
 
 =back
 
+=item max_state(@a)
+
+Returns the worst state in the array. Order is: CRITICAL, WARNING, OK, UNKNOWN,
+DEPENDENT
+
+=back
 
 =head1 SEE ALSO
 





More information about the Commits mailing list