summaryrefslogtreecommitdiffstats
path: root/lib/utils_base.c
diff options
context:
space:
mode:
Diffstat (limited to 'lib/utils_base.c')
-rw-r--r--lib/utils_base.c30
1 files changed, 26 insertions, 4 deletions
diff --git a/lib/utils_base.c b/lib/utils_base.c
index 3822bcf..fd7058d 100644
--- a/lib/utils_base.c
+++ b/lib/utils_base.c
@@ -37,6 +37,9 @@
37 37
38monitoring_plugin *this_monitoring_plugin=NULL; 38monitoring_plugin *this_monitoring_plugin=NULL;
39 39
40unsigned int timeout_state = STATE_CRITICAL;
41unsigned int timeout_interval = DEFAULT_SOCKET_TIMEOUT;
42
40int _np_state_read_file(FILE *); 43int _np_state_read_file(FILE *);
41 44
42void np_init( char *plugin_name, int argc, char **argv ) { 45void np_init( char *plugin_name, int argc, char **argv ) {
@@ -87,10 +90,13 @@ void _get_monitoring_plugin( monitoring_plugin **pointer ){
87void 90void
88die (int result, const char *fmt, ...) 91die (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 }
@@ -356,6 +362,22 @@ char *np_extract_value(const char *varlist, const char *name, char sep) {
356 return value; 362 return value;
357} 363}
358 364
365const char *
366state_text (int result)
367{
368 switch (result) {
369 case STATE_OK:
370 return "OK";
371 case STATE_WARNING:
372 return "WARNING";
373 case STATE_CRITICAL:
374 return "CRITICAL";
375 case STATE_DEPENDENT:
376 return "DEPENDENT";
377 default:
378 return "UNKNOWN";
379 }
380}
359 381
360/* 382/*
361 * Read a string representing a state (ok, warning... or numeric: 0, 1) and 383 * Read a string representing a state (ok, warning... or numeric: 0, 1) and