diff options
| author | Lorenz Kästle <12514511+RincewindsHat@users.noreply.github.com> | 2025-02-21 14:33:24 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-02-21 14:33:24 +0100 |
| commit | 75658bd04d84d037dbcc9fafd9f7860555ac4836 (patch) | |
| tree | 6b50ee39401c68a27757abac785c931bd82ae02d /plugins/utils.c | |
| parent | b38dec3e9b45efa6a6631acc38ada853e69fc547 (diff) | |
| parent | 7c8c9d9b3e7bb6c29d82788d05d74e3f18f01aa5 (diff) | |
| download | monitoring-plugins-75658bd0.tar.gz | |
Merge pull request #2064 from RincewindsHat/feature/new_output_infra
Feature/new output infra
Diffstat (limited to 'plugins/utils.c')
| -rw-r--r-- | plugins/utils.c | 48 |
1 files changed, 0 insertions, 48 deletions
diff --git a/plugins/utils.c b/plugins/utils.c index 6d366e3d..09649429 100644 --- a/plugins/utils.c +++ b/plugins/utils.c | |||
| @@ -42,54 +42,6 @@ extern const char *progname; | |||
| 42 | 42 | ||
| 43 | time_t start_time, end_time; | 43 | time_t start_time, end_time; |
| 44 | 44 | ||
| 45 | /* ************************************************************************** | ||
| 46 | * max_state(STATE_x, STATE_y) | ||
| 47 | * compares STATE_x to STATE_y and returns result based on the following | ||
| 48 | * STATE_UNKNOWN < STATE_OK < STATE_WARNING < STATE_CRITICAL | ||
| 49 | * | ||
| 50 | * Note that numerically the above does not hold | ||
| 51 | ****************************************************************************/ | ||
| 52 | |||
| 53 | int max_state(int a, int b) { | ||
| 54 | if (a == STATE_CRITICAL || b == STATE_CRITICAL) | ||
| 55 | return STATE_CRITICAL; | ||
| 56 | else if (a == STATE_WARNING || b == STATE_WARNING) | ||
| 57 | return STATE_WARNING; | ||
| 58 | else if (a == STATE_OK || b == STATE_OK) | ||
| 59 | return STATE_OK; | ||
| 60 | else if (a == STATE_UNKNOWN || b == STATE_UNKNOWN) | ||
| 61 | return STATE_UNKNOWN; | ||
| 62 | else if (a == STATE_DEPENDENT || b == STATE_DEPENDENT) | ||
| 63 | return STATE_DEPENDENT; | ||
| 64 | else | ||
| 65 | return max(a, b); | ||
| 66 | } | ||
| 67 | |||
| 68 | /* ************************************************************************** | ||
| 69 | * max_state_alt(STATE_x, STATE_y) | ||
| 70 | * compares STATE_x to STATE_y and returns result based on the following | ||
| 71 | * STATE_OK < STATE_DEPENDENT < STATE_UNKNOWN < STATE_WARNING < STATE_CRITICAL | ||
| 72 | * | ||
| 73 | * The main difference between max_state_alt and max_state it that it doesn't | ||
| 74 | * allow setting a default to UNKNOWN. It will instead prioritixe any valid | ||
| 75 | * non-OK state. | ||
| 76 | ****************************************************************************/ | ||
| 77 | |||
| 78 | int max_state_alt(int a, int b) { | ||
| 79 | if (a == STATE_CRITICAL || b == STATE_CRITICAL) | ||
| 80 | return STATE_CRITICAL; | ||
| 81 | else if (a == STATE_WARNING || b == STATE_WARNING) | ||
| 82 | return STATE_WARNING; | ||
| 83 | else if (a == STATE_UNKNOWN || b == STATE_UNKNOWN) | ||
| 84 | return STATE_UNKNOWN; | ||
| 85 | else if (a == STATE_DEPENDENT || b == STATE_DEPENDENT) | ||
| 86 | return STATE_DEPENDENT; | ||
| 87 | else if (a == STATE_OK || b == STATE_OK) | ||
| 88 | return STATE_OK; | ||
| 89 | else | ||
| 90 | return max(a, b); | ||
| 91 | } | ||
| 92 | |||
| 93 | void usage(const char *msg) { | 45 | void usage(const char *msg) { |
| 94 | printf("%s\n", msg); | 46 | printf("%s\n", msg); |
| 95 | print_usage(); | 47 | print_usage(); |
