summaryrefslogtreecommitdiffstats
path: root/plugins/utils.c
diff options
context:
space:
mode:
authorThomas Guyot-Sionnest <dermoth@users.sourceforge.net>2007-11-23 04:18:16 (GMT)
committerThomas Guyot-Sionnest <dermoth@users.sourceforge.net>2007-11-23 04:18:16 (GMT)
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 0e79fbd..88b4411 100644
--- a/plugins/utils.c
+++ b/plugins/utils.c
@@ -53,6 +53,33 @@ max_state (int a, int b)
53 return max (a, b); 53 return max (a, b);
54} 54}
55 55
56/* **************************************************************************
57 * max_state_alt(STATE_x, STATE_y)
58 * compares STATE_x to STATE_y and returns result based on the following
59 * STATE_OK < STATE_DEPENDENT < STATE_UNKNOWN < STATE_WARNING < STATE_CRITICAL
60 *
61 * The main difference between max_state_alt and max_state it that it doesn't
62 * allow setting a default to UNKNOWN. It will instead prioritixe any valid
63 * non-OK state.
64 ****************************************************************************/
65
66int
67max_state_alt (int a, int b)
68{
69 if (a == STATE_CRITICAL || b == STATE_CRITICAL)
70 return STATE_CRITICAL;
71 else if (a == STATE_WARNING || b == STATE_WARNING)
72 return STATE_WARNING;
73 else if (a == STATE_UNKNOWN || b == STATE_UNKNOWN)
74 return STATE_UNKNOWN;
75 else if (a == STATE_DEPENDENT || b == STATE_DEPENDENT)
76 return STATE_DEPENDENT;
77 else if (a == STATE_OK || b == STATE_OK)
78 return STATE_OK;
79 else
80 return max (a, b);
81}
82
56void usage (const char *msg) 83void usage (const char *msg)
57{ 84{
58 printf ("%s\n", msg); 85 printf ("%s\n", msg);