Revision: 2162
http://nagiosplug.svn.sourceforge.net/nagiosplug/?rev=2162&view=rev
Author: dermoth
Date: 2009-03-14 02:38:13 +0000 (Sat, 14 Mar 2009)
Log Message:
-----------
Ignore stderr messages unless return code is non-zero or there is no output
From: Ton Voon <[email protected]>
Modified Paths:
--------------
nagiosplug/trunk/plugins/check_snmp.c
Modified: nagiosplug/trunk/plugins/check_snmp.c
===================================================================
--- nagiosplug/trunk/plugins/check_snmp.c 2009-03-14 01:19:50 UTC (rev 2161)
+++ nagiosplug/trunk/plugins/check_snmp.c 2009-03-14 02:38:13 UTC (rev 2162)
@@ -143,6 +143,8 @@
int i = 0;
int iresult = STATE_UNKNOWN;
int result = STATE_UNKNOWN;
+ int return_code = 0;
+ int external_error = 0;
char **command_line = NULL;
char *cl_hidden_auth = NULL;
char *oidname = NULL;
@@ -220,22 +222,28 @@
printf ("%s\n", cl_hidden_auth);
/* Run the command */
- result = cmd_run_array (command_line, &chld_out, &chld_err, 0);
+ return_code = cmd_run_array (command_line, &chld_out, &chld_err, 0);
- if (chld_err.lines > 0) {
- printf (_("External command error: %s\n"), chld_err.line[0]);
- for (i = 1; i < chld_err.lines; i++) {
- printf ("%s\n", chld_err.line[i]);
+ /* 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
+ /*
+ if (return_code != 0)
+ external_error=1;
+ if (chld_out.lines == 0)
+ external_error=1;
+ if (external_error) {
+ if (chld_err.lines > 0) {
+ printf (_("External command error: %s\n"), chld_err.line[0]);
+ for (i = 1; i < chld_err.lines; i++) {
+ printf ("%s\n", chld_err.line[i]);
+ }
+ } else {
+ printf(_("External command error with no output (return code: %d)\n"), return_code);
}
exit (STATE_UNKNOWN);
}
- /* Return UNKNOWN or worse if no output is returned */
- if (chld_out.lines == 0)
- die (max_state_alt (result, STATE_UNKNOWN), _("%s problem - No data received from host\nCMD: %s\n"),
- label,
- cl_hidden_auth);
-
if (verbose) {
for (i = 0; i < chld_out.lines; i++) {
printf ("%s\n", chld_out.line[i]);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
------------------------------------------------------------------------------
Apps built with the Adobe(R) Flex(R) framework and Flex Builder(TM) are
powering Web 2.0 with engaging, cross-platform capabilities. Quickly and
easily build your RIAs with Flex Builder, the Eclipse(TM)based development
software that enables intelligent coding and step-through debugging.
Download the free 60 day trial. http://p.sf.net/sfu/www-adobe-com
lmpx.com only provides a reader for public news (NNTP) servers. It is not
affiliated with the servers or forums shown here and is not responsible for
the content of articles, which is written by their respective authors.