summaryrefslogtreecommitdiffstats
path: root/plugins/check_snmp.c
diff options
context:
space:
mode:
authorSven Nierlein <Sven.Nierlein@consol.de>2013-09-12 16:26:01 (GMT)
committerSven Nierlein <sven@consol.de>2013-09-12 21:39:32 (GMT)
commit4933146e00ccecc83144cb567520b963670028c3 (patch)
treef50a2b2ee89f3dcbcaeaf61a4f7e641606bae158 /plugins/check_snmp.c
parentc0926c2b1eddf25600c2dc1c7aff922eec98957d (diff)
downloadmonitoring-plugins-4933146e00ccecc83144cb567520b963670028c3.tar.gz
check_snmp: add timeout handler befor running snmpget
Diffstat (limited to 'plugins/check_snmp.c')
-rw-r--r--plugins/check_snmp.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/plugins/check_snmp.c b/plugins/check_snmp.c
index 0bc810d..52ad31e 100644
--- a/plugins/check_snmp.c
+++ b/plugins/check_snmp.c
@@ -33,6 +33,7 @@ const char *copyright = "1999-2007";
33const char *email = "nagiosplug-devel@lists.sourceforge.net"; 33const char *email = "nagiosplug-devel@lists.sourceforge.net";
34 34
35#include "common.h" 35#include "common.h"
36#include "runcmd.h"
36#include "utils.h" 37#include "utils.h"
37#include "utils_cmd.h" 38#include "utils_cmd.h"
38 39
@@ -330,9 +331,18 @@ main (int argc, char **argv)
330 if (verbose) 331 if (verbose)
331 printf ("%s\n", cl_hidden_auth); 332 printf ("%s\n", cl_hidden_auth);
332 333
334 /* Set signal handling and alarm */
335 if (signal (SIGALRM, runcmd_timeout_alarm_handler) == SIG_ERR) {
336 usage4 (_("Cannot catch SIGALRM"));
337 }
338 alarm(timeout_interval * retries + 5);
339
333 /* Run the command */ 340 /* Run the command */
334 return_code = cmd_run_array (command_line, &chld_out, &chld_err, 0); 341 return_code = cmd_run_array (command_line, &chld_out, &chld_err, 0);
335 342
343 /* disable alarm again */
344 alarm(0);
345
336 /* Due to net-snmp sometimes showing stderr messages with poorly formed MIBs, 346 /* Due to net-snmp sometimes showing stderr messages with poorly formed MIBs,
337 only return state unknown if return code is non zero or there is no stdout. 347 only return state unknown if return code is non zero or there is no stdout.
338 Do this way so that if there is stderr, will get added to output, which helps problem diagnosis 348 Do this way so that if there is stderr, will get added to output, which helps problem diagnosis