summaryrefslogtreecommitdiffstats
path: root/lib/utils_base.c
diff options
context:
space:
mode:
authorRincewindsHat <12514511+RincewindsHat@users.noreply.github.com>2021-12-02 14:11:21 (GMT)
committerGitHub <noreply@github.com>2021-12-02 14:11:21 (GMT)
commitdf1e9e975f69c8f7965bab91684870fe509739c6 (patch)
tree526b0c77c524b2219d5a48fd78b8302f055a4a5b /lib/utils_base.c
parent6246b8f1830e8a375bc656deafd28aab715b4fd9 (diff)
parent1a3a715702a5b6709fed2a1eb53ec644c9968057 (diff)
downloadmonitoring-plugins-df1e9e975f69c8f7965bab91684870fe509739c6.tar.gz
Merge branch 'master' into mailq-add-config-dir
Diffstat (limited to 'lib/utils_base.c')
-rw-r--r--lib/utils_base.c32
1 files changed, 27 insertions, 5 deletions
diff --git a/lib/utils_base.c b/lib/utils_base.c
index 3822bcf..08fa215 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 }
@@ -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
366const char *
367state_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