Jelajahi Sumber

check_snmp units label option outputs the label in the incorrect location

Fix for issue https://github.com/nagios-plugins/nagios-plugins/issues/180
John C. Frickson 9 tahun lalu
induk
melakukan
655f55c486
2 mengubah file dengan 6 tambahan dan 5 penghapusan
  1. 1 0
      NEWS
  2. 5 5
      plugins/check_snmp.c

+ 1 - 0
NEWS

@@ -10,6 +10,7 @@ This file documents the major additions and syntax changes between releases.
 	check_http: SSL Certificate check returns 12:00:00AM <local timezone>
 	check_http: -u is misleading. Changed help text
 	check_file_age: does not handle filenames with space
+	check_snmp: units label option outputs the label in the incorrect location
 
 
 2.1.3 2016-09-12

+ 5 - 5
plugins/check_snmp.c

@@ -594,6 +594,11 @@ main (int argc, char **argv)
 			len = sizeof(perfstr)-strlen(perfstr)-1;
 			strncat(perfstr, show, len>ptr-show ? ptr-show : len);
 
+			if (nunits > (size_t)0 && (size_t)i < nunits && unitv[i] != NULL) {
+				xasprintf (&temp_string, "%s", unitv[i]);
+				strncat(perfstr, temp_string, sizeof(perfstr)-strlen(perfstr)-1);
+				}
+
 			if (warning_thresholds) {
 				strncat(perfstr, ";", sizeof(perfstr)-strlen(perfstr)-1);
 				strncat(perfstr, warning_thresholds, sizeof(perfstr)-strlen(perfstr)-1);
@@ -607,11 +612,6 @@ main (int argc, char **argv)
 
 			if (type)
 				strncat(perfstr, type, sizeof(perfstr)-strlen(perfstr)-1);
-			if (nunits > (size_t)0 && (size_t)i < nunits && unitv[i] != NULL) {
-				xasprintf (&temp_string, "%s", unitv[i]);
-				strncat(perfstr, temp_string, sizeof(perfstr)-strlen(perfstr)-1);
-				}
-
 
 			if (thlds[i]->warning || thlds[i]->critical) {
 				strncat(perfstr, ";", sizeof(perfstr)-strlen(perfstr)-1);