diff options
author | Thomas Guyot-Sionnest <dermoth@aei.ca> | 2009-03-16 05:37:00 (GMT) |
---|---|---|
committer | Thomas Guyot-Sionnest <dermoth@aei.ca> | 2009-03-16 05:37:00 (GMT) |
commit | e2aec83e61487916d32ac98bd4c3171cd6899efd (patch) | |
tree | 9409571979ff96ec1678b63fedd565ef9377cac8 | |
parent | 12c17fe8a25ada493a87ed3d5a5885e3414052ac (diff) | |
download | monitoring-plugins-e2aec83e61487916d32ac98bd4c3171cd6899efd.tar.gz |
check_snmp fixes:
- Fix broken compilation caused by typo in command ending
- Remove extra whitespaces at EOL
- Fix invalid host test on Ubuntu Hardy (and possibly others)
-rw-r--r-- | plugins/check_snmp.c | 10 | ||||
-rw-r--r-- | plugins/t/check_snmp.t | 2 |
2 files changed, 6 insertions, 6 deletions
diff --git a/plugins/check_snmp.c b/plugins/check_snmp.c index 03c2a17..3dc52df 100644 --- a/plugins/check_snmp.c +++ b/plugins/check_snmp.c | |||
@@ -106,7 +106,7 @@ char *authproto = NULL; | |||
106 | char *privproto = NULL; | 106 | char *privproto = NULL; |
107 | char *authpasswd = NULL; | 107 | char *authpasswd = NULL; |
108 | char *privpasswd = NULL; | 108 | char *privpasswd = NULL; |
109 | char **oids = NULL; | 109 | char **oids = NULL; |
110 | char *label; | 110 | char *label; |
111 | char *units; | 111 | char *units; |
112 | char *port; | 112 | char *port; |
@@ -186,7 +186,7 @@ main (int argc, char **argv) | |||
186 | snmpcmd = strdup (PATH_TO_SNMPGETNEXT); | 186 | snmpcmd = strdup (PATH_TO_SNMPGETNEXT); |
187 | }else{ | 187 | }else{ |
188 | snmpcmd = strdup (PATH_TO_SNMPGET); | 188 | snmpcmd = strdup (PATH_TO_SNMPGET); |
189 | } | 189 | } |
190 | 190 | ||
191 | /* 9 arguments to pass before authpriv options + 1 for host and numoids. Add one for terminating NULL */ | 191 | /* 9 arguments to pass before authpriv options + 1 for host and numoids. Add one for terminating NULL */ |
192 | command_line = calloc (9 + numauthpriv + 1 + numoids + 1, sizeof (char *)); | 192 | command_line = calloc (9 + numauthpriv + 1 + numoids + 1, sizeof (char *)); |
@@ -224,10 +224,10 @@ main (int argc, char **argv) | |||
224 | /* Run the command */ | 224 | /* Run the command */ |
225 | return_code = cmd_run_array (command_line, &chld_out, &chld_err, 0); | 225 | return_code = cmd_run_array (command_line, &chld_out, &chld_err, 0); |
226 | 226 | ||
227 | /* Due to net-snmp sometimes showing stderr messages with poorly formed MIBs, | 227 | /* Due to net-snmp sometimes showing stderr messages with poorly formed MIBs, |
228 | only return state unknown if return code is non zero or there is no stdout. | 228 | only return state unknown if return code is non zero or there is no stdout. |
229 | Do this way so that if there is stderr, will get added to output, which helps problem diagnosis | 229 | Do this way so that if there is stderr, will get added to output, which helps problem diagnosis |
230 | /* | 230 | */ |
231 | if (return_code != 0) | 231 | if (return_code != 0) |
232 | external_error=1; | 232 | external_error=1; |
233 | if (chld_out.lines == 0) | 233 | if (chld_out.lines == 0) |
@@ -252,7 +252,7 @@ main (int argc, char **argv) | |||
252 | 252 | ||
253 | for (i = 0; i < chld_out.lines; i++) { | 253 | for (i = 0; i < chld_out.lines; i++) { |
254 | ptr = chld_out.line[i]; | 254 | ptr = chld_out.line[i]; |
255 | oidname = strpcpy (oidname, ptr, delimiter); | 255 | oidname = strpcpy (oidname, ptr, delimiter); |
256 | response = strstr (ptr, delimiter); | 256 | response = strstr (ptr, delimiter); |
257 | 257 | ||
258 | /* We strip out the datatype indicator for PHBs */ | 258 | /* We strip out the datatype indicator for PHBs */ |
diff --git a/plugins/t/check_snmp.t b/plugins/t/check_snmp.t index 4820aac..c2c965d 100644 --- a/plugins/t/check_snmp.t +++ b/plugins/t/check_snmp.t | |||
@@ -94,7 +94,7 @@ SKIP: { | |||
94 | skip "no non invalid host defined", 2 if ( ! $hostname_invalid ); | 94 | skip "no non invalid host defined", 2 if ( ! $hostname_invalid ); |
95 | $res = NPTest->testCmd( "./check_snmp -H $hostname_invalid -C $snmp_community -o system.sysUpTime.0 -w 1: -c 1:"); | 95 | $res = NPTest->testCmd( "./check_snmp -H $hostname_invalid -C $snmp_community -o system.sysUpTime.0 -w 1: -c 1:"); |
96 | cmp_ok( $res->return_code, '==', 3, "Exit UNKNOWN with non responsive host" ); | 96 | cmp_ok( $res->return_code, '==', 3, "Exit UNKNOWN with non responsive host" ); |
97 | like($res->output, '/External command error: .*nosuchhost/', "String matches invalid host"); | 97 | like($res->output, '/External command error: .*(nosuchhost|Name or service not known)/', "String matches invalid host"); |
98 | } | 98 | } |
99 | 99 | ||
100 | } | 100 | } |