aboutsummaryrefslogtreecommitdiff
path: root/plugins/utils.c
diff options
context:
space:
mode:
authorGravatar Thomas Guyot-Sionnest <dermoth@users.sourceforge.net> 2007-11-23 04:18:16 +0000
committerGravatar Thomas Guyot-Sionnest <dermoth@users.sourceforge.net> 2007-11-23 04:18:16 +0000
commitcaca7a50fdaaf447c7c5b9fd28a26b51f1ca1f2d (patch)
treea53506326cff2e0a2063f3cf7fc8fde3e3f62565 /plugins/utils.c
parent1bb5e1e2ff07aaa9dc986807e25cf7243647f72f (diff)
downloadmonitoring-plugins-caca7a50fdaaf447c7c5b9fd28a26b51f1ca1f2d.tar.gz
Add a max_state_alt function that put UNKNOWN and DEPENDENT ahead of OK.
git-svn-id: https://nagiosplug.svn.sourceforge.net/svnroot/nagiosplug/nagiosplug/trunk@1829 f882894a-f735-0410-b71e-b25c423dba1c
Diffstat (limited to 'plugins/utils.c')
-rw-r--r--plugins/utils.c27
1 files changed, 27 insertions, 0 deletions
diff --git a/plugins/utils.c b/plugins/utils.c
index 0e79fbdb..88b44114 100644
--- a/plugins/utils.c
+++ b/plugins/utils.c
@@ -53,6 +53,33 @@ max_state (int a, int b)
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);