Browse Source

plugins/check_snmp: Show snmp error when we fail to parse its output

Dying without a hint of what went wrong is just plain annoying. With
this patch we at least get a hint.

While at it, we fix the string offset so the output we're interested
in doesn't keep the equal sign that snmpget prints.

Signed-off-by: Andreas Ericsson <ae@op5.se>
Andreas Ericsson 13 năm trước cách đây
mục cha
commit
c537d71a3a
1 tập tin đã thay đổi với 2 bổ sung2 xóa
  1. 2 2
      plugins/check_snmp.c

+ 2 - 2
plugins/check_snmp.c

@@ -419,7 +419,7 @@ main (int argc, char **argv)
 			show = strstr (response, "Timeticks: ");
 			show = strstr (response, "Timeticks: ");
 		}
 		}
 		else
 		else
-			show = response;
+			show = response + 3;
 
 
 		iresult = STATE_DEPENDENT;
 		iresult = STATE_DEPENDENT;
 
 
@@ -428,7 +428,7 @@ main (int argc, char **argv)
 		if (thlds[i]->warning || thlds[i]->critical || calculate_rate) {
 		if (thlds[i]->warning || thlds[i]->critical || calculate_rate) {
 			ptr = strpbrk (show, "0123456789");
 			ptr = strpbrk (show, "0123456789");
 			if (ptr == NULL)
 			if (ptr == NULL)
-				die (STATE_UNKNOWN,_("No valid data returned"));
+				die (STATE_UNKNOWN,_("No valid data returned (%s)\n"), show);
 			response_value[i] = strtod (ptr, NULL);
 			response_value[i] = strtod (ptr, NULL);
 
 
 			if(calculate_rate) {
 			if(calculate_rate) {