Explorar o código

check_snmp now only prints perfdata for non numeric values (Joerg Linge #1867716)

git-svn-id: https://nagiosplug.svn.sourceforge.net/svnroot/nagiosplug/nagiosplug/trunk@2021 f882894a-f735-0410-b71e-b25c423dba1c
Matthias Eble %!s(int64=17) %!d(string=hai) anos
pai
achega
be144b6720
Modificáronse 2 ficheiros con 12 adicións e 7 borrados
  1. 1 0
      NEWS
  2. 11 7
      plugins/check_snmp.c

+ 1 - 0
NEWS

@@ -7,6 +7,7 @@ This file documents the major additions and syntax changes between releases.
 	Fix Debian bug #479013: check_dig's -l is mandatory now (sf.net #1986306)
 	check_dig now returns CRITICAL instead of WARNING when no answer section is found
 	check_procs now captures stderr in external command and adds to plugin output
+	check_snmp now only prints perfdata for non numeric values (#1867716)
 
 1.4.12 27th May 2008
 	Added ./check_nt -v INSTANCES to count number of instances (Alessandro Ren)

+ 11 - 7
plugins/check_snmp.c

@@ -228,14 +228,14 @@ main (int argc, char **argv)
 
 	strncat(perfstr, "| ", sizeof(perfstr)-strlen(perfstr)-1);
 	while (ptr) {
-		char *foo;
+		char *foo, *ptr2;
 		unsigned int copylen;
 
 		foo = strstr (ptr, delimiter);
 		copylen = foo-ptr;
 		if (copylen > sizeof(perfstr)-strlen(perfstr)-1)
 			copylen = sizeof(perfstr)-strlen(perfstr)-1;
-		strncat(perfstr, ptr, copylen);
+		ptr2 = ptr;
 		ptr = foo; 
 
 		if (ptr == NULL)
@@ -368,11 +368,15 @@ main (int argc, char **argv)
 
 		i++;
 
-		strncat(perfstr, "=", sizeof(perfstr)-strlen(perfstr)-1);
-		strncat(perfstr, show, sizeof(perfstr)-strlen(perfstr)-1);
-		if (type)
-			strncat(perfstr, type, sizeof(perfstr)-strlen(perfstr)-1);
-		strncat(perfstr, " ", sizeof(perfstr)-strlen(perfstr)-1);
+		if (is_numeric(show)) {
+			strncat(perfstr, ptr2, copylen);
+			strncat(perfstr, "=", sizeof(perfstr)-strlen(perfstr)-1);
+			strncat(perfstr, show, sizeof(perfstr)-strlen(perfstr)-1);
+
+			if (type)
+				strncat(perfstr, type, sizeof(perfstr)-strlen(perfstr)-1);
+			strncat(perfstr, " ", sizeof(perfstr)-strlen(perfstr)-1);
+		}
 
 	}	/* end while (ptr) */