From 7cafb0e84550035fe671662c293122be975065ca Mon Sep 17 00:00:00 2001 From: Sven Nierlein Date: Fri, 15 Feb 2019 10:36:28 +0100 Subject: check_by_ssh: fix child process leak on timeouts When check_by_ssh runs into a timeout it simply exits keeping all child processes running. Simply adopting the kill loop from runcmd_timeout_alarm_handler() fixes this. Signed-off-by: Sven Nierlein --- lib/utils_base.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'lib/utils_base.c') diff --git a/lib/utils_base.c b/lib/utils_base.c index 19a531f5..fd7058da 100644 --- a/lib/utils_base.c +++ b/lib/utils_base.c @@ -37,6 +37,9 @@ monitoring_plugin *this_monitoring_plugin=NULL; +unsigned int timeout_state = STATE_CRITICAL; +unsigned int timeout_interval = DEFAULT_SOCKET_TIMEOUT; + int _np_state_read_file(FILE *); void np_init( char *plugin_name, int argc, char **argv ) { @@ -359,6 +362,22 @@ char *np_extract_value(const char *varlist, const char *name, char sep) { return value; } +const char * +state_text (int result) +{ + switch (result) { + case STATE_OK: + return "OK"; + case STATE_WARNING: + return "WARNING"; + case STATE_CRITICAL: + return "CRITICAL"; + case STATE_DEPENDENT: + return "DEPENDENT"; + default: + return "UNKNOWN"; + } +} /* * Read a string representing a state (ok, warning... or numeric: 0, 1) and -- cgit v1.2.3