ソースを参照

Merge branch 'issue613' of https://github.com/m-erhardt/nagios-plugins into m-erhardt-issue613

Sebastian Wolf 2 年 前
コミット
41492ad7a5
1 ファイル変更11 行追加0 行削除
  1. 11 0
      plugins/check_ping.c

+ 11 - 0
plugins/check_ping.c

@@ -38,6 +38,7 @@ const char *email = "devel@nagios-plugins.org";
 #include "utils.h"
 
 #define WARN_DUPLICATES "DUPLICATES FOUND! "
+#define WARN_ICMP_CHECKSUM "BAD CHECKSUM! "
 #define UNKNOWN_TRIP_TIME -1.0	/* -1 seconds */
 
 enum {
@@ -468,6 +469,7 @@ run_ping (const char *cmd, const char *addr)
 		if((sscanf(buf,"%*d packets transmitted, %*d packets received, +%*d errors, %d%% packet loss%n",&pl,&match) && match) ||
 			 (sscanf(buf,"%*d packets transmitted, %*d packets received, +%*d duplicates, %d%% packet loss%n",&pl,&match) && match) ||
 			 (sscanf(buf,"%*d packets transmitted, %*d received, +%*d duplicates, %d%% packet loss%n",&pl,&match) && match) ||
+			 (sscanf(buf,"%*d packets transmitted, %*d received, +%*d corrupted, %d%% packet loss, time%n",&pl,&match) && match) ||
 			 (sscanf(buf,"%*d packets transmitted, %*d packets received, %d%% packet loss%n",&pl,&match) && match) ||
 			 (sscanf(buf,"%*d packets transmitted, %*d packets received, %d%% loss, time%n",&pl,&match) && match) ||
 			 (sscanf(buf,"%*d packets transmitted, %*d received, %d%% loss, time%n",&pl,&match) && match) ||
@@ -567,6 +569,15 @@ error_scan (char buf[MAX_INPUT_BUFFER], const char *addr)
 		return (STATE_WARNING);
 	}
 
+	if (strstr (buf, "(BAD CHECKSUM!)")) {
+		if (warn_text == NULL)
+			warn_text = strdup (_(WARN_ICMP_CHECKSUM));
+		else if (! strstr (warn_text, _(WARN_ICMP_CHECKSUM)) &&
+		         xasprintf (&warn_text, "%s %s", warn_text, _(WARN_ICMP_CHECKSUM)) == -1)
+			die (STATE_UNKNOWN, _("Unable to realloc warn_text\n"));
+		return (STATE_WARNING);
+	}
+
 	return (STATE_OK);
 }