[nagiosplug] check_snmp: add timeout handler befor running ...
"Nagios Plugin Development" <[email protected]> Thu, 12 Sep 2013 21:40:14 +0000
| Newsgroups | gmane.network.nagios.plugins.cvs |
|---|---|
| Message-ID | <[email protected]> |
Module: nagiosplug
Branch: master
Commit: 4933146e00ccecc83144cb567520b963670028c3
Author: Sven Nierlein <[email protected]>
Committer: Sven Nierlein <[email protected]>
Date: Thu Sep 12 18:26:01 2013 +0200
URL: http://nagiosplug.git.sf.net/git/gitweb.cgi?p=nagiosplug/nagiosplug;a=commit;h=4933146
check_snmp: add timeout handler befor running snmpget
---
plugins/check_snmp.c | 10 ++++++++++
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";
const char *email = "[email protected]";
#include "common.h"
+#include "runcmd.h"
#include "utils.h"
#include "utils_cmd.h"
@@ -330,9 +331,18 @@ main (int argc, char **argv)
if (verbose)
printf ("%s\n", cl_hidden_auth);
+ /* Set signal handling and alarm */
+ if (signal (SIGALRM, runcmd_timeout_alarm_handler) == SIG_ERR) {
+ usage4 (_("Cannot catch SIGALRM"));
+ }
+ alarm(timeout_interval * retries + 5);
+
/* Run the command */
return_code = cmd_run_array (command_line, &chld_out, &chld_err, 0);
+ /* disable alarm again */
+ alarm(0);
+
/* Due to net-snmp sometimes showing stderr messages with poorly formed MIBs,
only return state unknown if return code is non zero or there is no stdout.
Do this way so that if there is stderr, will get added to output, which helps problem diagnosis
------------------------------------------------------------------------------
How ServiceNow helps IT people transform IT departments:
1. Consolidate legacy IT systems to a single system of record for IT
2. Standardize and globalize service processes across IT
3. Implement zero-touch automation to replace manual, redundant tasks
http://pubads.g.doubleclick.net/gampad/clk?id=51271111&iu=/4140/ostg.clktrk