Browse Source

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)

Thomas Guyot-Sionnest 17 years ago
parent
commit
e2aec83e61
2 changed files with 6 additions and 6 deletions
  1. 5 5
      plugins/check_snmp.c
  2. 1 1
      plugins/t/check_snmp.t

+ 5 - 5
plugins/check_snmp.c

@@ -106,7 +106,7 @@ char *authproto = NULL;
 char *privproto = NULL;
 char *privproto = NULL;
 char *authpasswd = NULL;
 char *authpasswd = NULL;
 char *privpasswd = NULL;
 char *privpasswd = NULL;
-char **oids = NULL; 
+char **oids = NULL;
 char *label;
 char *label;
 char *units;
 char *units;
 char *port;
 char *port;
@@ -186,7 +186,7 @@ main (int argc, char **argv)
 		snmpcmd = strdup (PATH_TO_SNMPGETNEXT);
 		snmpcmd = strdup (PATH_TO_SNMPGETNEXT);
 	}else{
 	}else{
 		snmpcmd = strdup (PATH_TO_SNMPGET);
 		snmpcmd = strdup (PATH_TO_SNMPGET);
-	} 
+	}
 	
 	
         /* 9 arguments to pass before authpriv options + 1 for host and numoids. Add one for terminating NULL */
         /* 9 arguments to pass before authpriv options + 1 for host and numoids. Add one for terminating NULL */
 	command_line = calloc (9 + numauthpriv + 1 + numoids + 1, sizeof (char *));
 	command_line = calloc (9 + numauthpriv + 1 + numoids + 1, sizeof (char *));
@@ -224,10 +224,10 @@ main (int argc, char **argv)
 	/* Run the command */
 	/* Run the command */
 	return_code = cmd_run_array (command_line, &chld_out, &chld_err, 0);
 	return_code = cmd_run_array (command_line, &chld_out, &chld_err, 0);
 
 
-	/* Due to net-snmp sometimes showing stderr messages with poorly formed MIBs, 
+	/* 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.
 	   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
 	   Do this way so that if there is stderr, will get added to output, which helps problem diagnosis
-	/*
+	*/
 	if (return_code != 0)
 	if (return_code != 0)
 		external_error=1;
 		external_error=1;
 	if (chld_out.lines == 0)
 	if (chld_out.lines == 0)
@@ -252,7 +252,7 @@ main (int argc, char **argv)
 
 
 	for (i = 0; i < chld_out.lines; i++) {
 	for (i = 0; i < chld_out.lines; i++) {
 		ptr = chld_out.line[i];
 		ptr = chld_out.line[i];
-		oidname = strpcpy (oidname, ptr, delimiter); 
+		oidname = strpcpy (oidname, ptr, delimiter);
 		response = strstr (ptr, delimiter);
 		response = strstr (ptr, delimiter);
 
 
 		/* We strip out the datatype indicator for PHBs */
 		/* We strip out the datatype indicator for PHBs */

+ 1 - 1
plugins/t/check_snmp.t

@@ -94,7 +94,7 @@ SKIP: {
 		skip "no non invalid host defined", 2 if ( ! $hostname_invalid );
 		skip "no non invalid host defined", 2 if ( ! $hostname_invalid );
 		$res = NPTest->testCmd( "./check_snmp -H $hostname_invalid   -C $snmp_community -o system.sysUpTime.0 -w 1: -c 1:");
 		$res = NPTest->testCmd( "./check_snmp -H $hostname_invalid   -C $snmp_community -o system.sysUpTime.0 -w 1: -c 1:");
 		cmp_ok( $res->return_code, '==', 3, "Exit UNKNOWN with non responsive host" ); 
 		cmp_ok( $res->return_code, '==', 3, "Exit UNKNOWN with non responsive host" ); 
-		like($res->output, '/External command error: .*nosuchhost/', "String matches invalid host");
+		like($res->output, '/External command error: .*(nosuchhost|Name or service not known)/', "String matches invalid host");
 	}
 	}
 
 
 }
 }