summaryrefslogtreecommitdiffstats
path: root/plugins/utils.c
diff options
context:
space:
mode:
authorSven Nierlein <sven@nierlein.de>2019-02-15 09:36:28 (GMT)
committerSven Nierlein <sven@nierlein.de>2019-02-15 09:36:28 (GMT)
commit7cafb0e84550035fe671662c293122be975065ca (patch)
tree5d80a8e80854edc41a72da668a89485505d7e5dc /plugins/utils.c
parent2962148d8bac3a65f1fb5e1a948e3f0a86a42a1a (diff)
downloadmonitoring-plugins-7cafb0e84550035fe671662c293122be975065ca.tar.gz
check_by_ssh: fix child process leak on timeoutsrefs/pull/1583/head
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 <sven@nierlein.de>
Diffstat (limited to 'plugins/utils.c')
-rw-r--r--plugins/utils.c31
1 files changed, 0 insertions, 31 deletions
diff --git a/plugins/utils.c b/plugins/utils.c
index 231af92..ee62013 100644
--- a/plugins/utils.c
+++ b/plugins/utils.c
@@ -36,9 +36,6 @@ extern const char *progname;
36#define STRLEN 64 36#define STRLEN 64
37#define TXTBLK 128 37#define TXTBLK 128
38 38
39unsigned int timeout_state = STATE_CRITICAL;
40unsigned int timeout_interval = DEFAULT_SOCKET_TIMEOUT;
41
42time_t start_time, end_time; 39time_t start_time, end_time;
43 40
44/* ************************************************************************** 41/* **************************************************************************
@@ -148,33 +145,6 @@ print_revision (const char *command_name, const char *revision)
148 command_name, revision, PACKAGE, VERSION); 145 command_name, revision, PACKAGE, VERSION);
149} 146}
150 147
151const char *
152state_text (int result)
153{
154 switch (result) {
155 case STATE_OK:
156 return "OK";
157 case STATE_WARNING:
158 return "WARNING";
159 case STATE_CRITICAL:
160 return "CRITICAL";
161 case STATE_DEPENDENT:
162 return "DEPENDENT";
163 default:
164 return "UNKNOWN";
165 }
166}
167
168void
169timeout_alarm_handler (int signo)
170{
171 if (signo == SIGALRM) {
172 printf (_("%s - Plugin timed out after %d seconds\n"),
173 state_text(timeout_state), timeout_interval);
174 exit (timeout_state);
175 }
176}
177
178int 148int
179is_numeric (char *number) 149is_numeric (char *number)
180{ 150{
@@ -708,4 +678,3 @@ char *sperfdata_int (const char *label,
708 678
709 return data; 679 return data;
710} 680}
711