diff options
Diffstat (limited to 'plugins/utils.c')
-rw-r--r-- | plugins/utils.c | 27 |
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) | |||
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 | |||
66 | int | ||
67 | max_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 | |||
56 | void usage (const char *msg) | 83 | void usage (const char *msg) |
57 | { | 84 | { |
58 | printf ("%s\n", msg); | 85 | printf ("%s\n", msg); |