[Nagiosplug-checkins] SF.net SVN: nagiosplug: [1829] nagiosplug/trunk/plugins

dermoth at users.sourceforge.net dermoth at users.sourceforge.net
Fri Nov 23 05:18:16 CET 2007


Revision: 1829
          http://nagiosplug.svn.sourceforge.net/nagiosplug/?rev=1829&view=rev
Author:   dermoth
Date:     2007-11-22 20:18:16 -0800 (Thu, 22 Nov 2007)

Log Message:
-----------
Add a max_state_alt function that put UNKNOWN and DEPENDENT ahead of OK.

Modified Paths:
--------------
    nagiosplug/trunk/plugins/utils.c
    nagiosplug/trunk/plugins/utils.h

Modified: nagiosplug/trunk/plugins/utils.c
===================================================================
--- nagiosplug/trunk/plugins/utils.c	2007-11-17 06:36:24 UTC (rev 1828)
+++ nagiosplug/trunk/plugins/utils.c	2007-11-23 04:18:16 UTC (rev 1829)
@@ -53,6 +53,33 @@
 		return max (a, b);
 }
 
+/* **************************************************************************
+ * max_state_alt(STATE_x, STATE_y)
+ * compares STATE_x to  STATE_y and returns result based on the following
+ * STATE_OK < STATE_DEPENDENT < STATE_UNKNOWN < STATE_WARNING < STATE_CRITICAL
+ *
+ * The main difference between max_state_alt and max_state it that it doesn't
+ * allow setting a default to UNKNOWN. It will instead prioritixe any valid
+ * non-OK state.
+ ****************************************************************************/
+
+int
+max_state_alt (int a, int b)
+{
+	if (a == STATE_CRITICAL || b == STATE_CRITICAL)
+		return STATE_CRITICAL;
+	else if (a == STATE_WARNING || b == STATE_WARNING)
+		return STATE_WARNING;
+	else if (a == STATE_UNKNOWN || b == STATE_UNKNOWN)
+		return STATE_UNKNOWN;
+	else if (a == STATE_DEPENDENT || b == STATE_DEPENDENT)
+		return STATE_DEPENDENT;
+	else if (a == STATE_OK || b == STATE_OK)
+		return STATE_OK;
+	else
+		return max (a, b);
+}
+
 void usage (const char *msg)
 {
 	printf ("%s\n", msg);

Modified: nagiosplug/trunk/plugins/utils.h
===================================================================
--- nagiosplug/trunk/plugins/utils.h	2007-11-17 06:36:24 UTC (rev 1828)
+++ nagiosplug/trunk/plugins/utils.h	2007-11-23 04:18:16 UTC (rev 1829)
@@ -76,6 +76,7 @@
 char *strpcat (char *, const char *, const char *);
 
 int max_state (int a, int b);
+int max_state_alt (int a, int b);
 
 void usage (const char *) __attribute__((noreturn));
 void usage2(const char *, const char *) __attribute__((noreturn));


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.




More information about the Commits mailing list