summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--plugins/utils.c27
-rw-r--r--plugins/utils.h1
2 files changed, 28 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);
diff --git a/plugins/utils.h b/plugins/utils.h
index f15a7b1..bb99ee1 100644
--- a/plugins/utils.h
+++ b/plugins/utils.h
@@ -76,6 +76,7 @@ char *strpcpy (char *, const char *, const char *);
76char *strpcat (char *, const char *, const char *); 76char *strpcat (char *, const char *, const char *);
77 77
78int max_state (int a, int b); 78int max_state (int a, int b);
79int max_state_alt (int a, int b);
79 80
80void usage (const char *) __attribute__((noreturn)); 81void usage (const char *) __attribute__((noreturn));
81void usage2(const char *, const char *) __attribute__((noreturn)); 82void usage2(const char *, const char *) __attribute__((noreturn));