diff options
Diffstat (limited to 'lib/utils_base.c')
-rw-r--r-- | lib/utils_base.c | 32 |
1 files changed, 27 insertions, 5 deletions
diff --git a/lib/utils_base.c b/lib/utils_base.c index 3822bcf1..08fa215c 100644 --- a/lib/utils_base.c +++ b/lib/utils_base.c | |||
@@ -37,6 +37,9 @@ | |||
37 | 37 | ||
38 | monitoring_plugin *this_monitoring_plugin=NULL; | 38 | monitoring_plugin *this_monitoring_plugin=NULL; |
39 | 39 | ||
40 | unsigned int timeout_state = STATE_CRITICAL; | ||
41 | unsigned int timeout_interval = DEFAULT_SOCKET_TIMEOUT; | ||
42 | |||
40 | int _np_state_read_file(FILE *); | 43 | int _np_state_read_file(FILE *); |
41 | 44 | ||
42 | void np_init( char *plugin_name, int argc, char **argv ) { | 45 | void np_init( char *plugin_name, int argc, char **argv ) { |
@@ -87,10 +90,13 @@ void _get_monitoring_plugin( monitoring_plugin **pointer ){ | |||
87 | void | 90 | void |
88 | die (int result, const char *fmt, ...) | 91 | die (int result, const char *fmt, ...) |
89 | { | 92 | { |
90 | va_list ap; | 93 | if(fmt!=NULL) { |
91 | va_start (ap, fmt); | 94 | va_list ap; |
92 | vprintf (fmt, ap); | 95 | va_start (ap, fmt); |
93 | va_end (ap); | 96 | vprintf (fmt, ap); |
97 | va_end (ap); | ||
98 | } | ||
99 | |||
94 | if(this_monitoring_plugin!=NULL) { | 100 | if(this_monitoring_plugin!=NULL) { |
95 | np_cleanup(); | 101 | np_cleanup(); |
96 | } | 102 | } |
@@ -122,6 +128,7 @@ range | |||
122 | temp_range->end = 0; | 128 | temp_range->end = 0; |
123 | temp_range->end_infinity = TRUE; | 129 | temp_range->end_infinity = TRUE; |
124 | temp_range->alert_on = OUTSIDE; | 130 | temp_range->alert_on = OUTSIDE; |
131 | temp_range->text = strdup(str); | ||
125 | 132 | ||
126 | if (str[0] == '@') { | 133 | if (str[0] == '@') { |
127 | temp_range->alert_on = INSIDE; | 134 | temp_range->alert_on = INSIDE; |
@@ -356,6 +363,22 @@ char *np_extract_value(const char *varlist, const char *name, char sep) { | |||
356 | return value; | 363 | return value; |
357 | } | 364 | } |
358 | 365 | ||
366 | const char * | ||
367 | state_text (int result) | ||
368 | { | ||
369 | switch (result) { | ||
370 | case STATE_OK: | ||
371 | return "OK"; | ||
372 | case STATE_WARNING: | ||
373 | return "WARNING"; | ||
374 | case STATE_CRITICAL: | ||
375 | return "CRITICAL"; | ||
376 | case STATE_DEPENDENT: | ||
377 | return "DEPENDENT"; | ||
378 | default: | ||
379 | return "UNKNOWN"; | ||
380 | } | ||
381 | } | ||
359 | 382 | ||
360 | /* | 383 | /* |
361 | * Read a string representing a state (ok, warning... or numeric: 0, 1) and | 384 | * Read a string representing a state (ok, warning... or numeric: 0, 1) and |
@@ -684,4 +707,3 @@ void np_state_write_string(time_t data_time, char *data_string) { | |||
684 | 707 | ||
685 | np_free(temp_file); | 708 | np_free(temp_file); |
686 | } | 709 | } |
687 | |||