diff options
| author | Thomas Guyot-Sionnest <dermoth@aei.ca> | 2014-01-29 03:20:23 -0500 |
|---|---|---|
| committer | Thomas Guyot-Sionnest <dermoth@aei.ca> | 2014-01-29 03:20:23 -0500 |
| commit | 8fc9e5ac4b3a699f8d6b78471829692f0c92d5fa (patch) | |
| tree | 4d630aa158d65602307723e9c7c6d41eca82b94d /lib/utils_base.c | |
| parent | 55f97c2021bf920b62148ea31fdf56d95572d944 (diff) | |
| download | monitoring-plugins-8fc9e5ac4b3a699f8d6b78471829692f0c92d5fa.tar.gz | |
Move negate' translate_state() to utils_base.h mp_translate_state()
Also use strcasecmp imported from gnulib for simplicity
Diffstat (limited to 'lib/utils_base.c')
| -rw-r--r-- | lib/utils_base.c | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/lib/utils_base.c b/lib/utils_base.c index f5f75067..04c4b4f9 100644 --- a/lib/utils_base.c +++ b/lib/utils_base.c | |||
| @@ -369,6 +369,23 @@ char *np_extract_value(const char *varlist, const char *name, char sep) { | |||
| 369 | return value; | 369 | return value; |
| 370 | } | 370 | } |
| 371 | 371 | ||
| 372 | |||
| 373 | /* | ||
| 374 | * Read a string representing a state (ok, warning... or numeric: 0, 1) and | ||
| 375 | * return the corresponding STATE_ value or ERROR) | ||
| 376 | */ | ||
| 377 | int mp_translate_state (char *state_text) { | ||
| 378 | if (!strcasecmp(state_text,"OK") || !strcmp(state_text,"0")) | ||
| 379 | return STATE_OK; | ||
| 380 | if (!strcasecmp(state_text,"WARNING") || !strcmp(state_text,"1")) | ||
| 381 | return STATE_WARNING; | ||
| 382 | if (!strcasecmp(state_text,"CRITICAL") || !strcmp(state_text,"2")) | ||
| 383 | return STATE_CRITICAL; | ||
| 384 | if (!strcasecmp(state_text,"UNKNOWN") || !strcmp(state_text,"3")) | ||
| 385 | return STATE_UNKNOWN; | ||
| 386 | return ERROR; | ||
| 387 | } | ||
| 388 | |||
| 372 | /* | 389 | /* |
| 373 | * Returns a string to use as a keyname, based on an md5 hash of argv, thus | 390 | * Returns a string to use as a keyname, based on an md5 hash of argv, thus |
| 374 | * hopefully a unique key per service/plugin invocation. Use the extra-opts | 391 | * hopefully a unique key per service/plugin invocation. Use the extra-opts |
