1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
|
Index: Projects/Nagiosplug/trunk/plugins/check_ping.c
===================================================================
--- Projects/Nagiosplug/trunk/plugins/check_ping.c (revision 1932)
+++ Projects/Nagiosplug/trunk/plugins/check_ping.c (working copy)
@@ -67,6 +67,7 @@
int max_addr = 1;
int max_packets = -1;
int verbose = 0;
+int warn_on_duplicate = 1;
float rta = UNKNOWN_TRIP_TIME;
int pl = UNKNOWN_PACKET_LOSS;
@@ -192,6 +193,7 @@
{"link", no_argument, 0, 'L'},
{"use-ipv4", no_argument, 0, '4'},
{"use-ipv6", no_argument, 0, '6'},
+ {"ignore-duplicates", no_argument, 0, "d"},
{0, 0, 0, 0}
};
@@ -206,7 +208,7 @@
}
while (1) {
- c = getopt_long (argc, argv, "VvhnL46t:c:w:H:p:", longopts, &option);
+ c = getopt_long (argc, argv, "VvhnL46t:c:d:w:H:p:", longopts, &option);
if (c == -1 || c == EOF)
break;
@@ -275,6 +277,9 @@
case 'w':
get_threshold (optarg, &wrta, &wpl);
break;
+ case 'd':
+ warn_on_duplicate = 0;
+ break;
}
}
@@ -527,12 +532,14 @@
die (STATE_CRITICAL, _("CRITICAL - Time to live exceeded (%s)"), addr);
if (strstr (buf, "(DUP!)") || strstr (buf, "DUPLICATES FOUND")) {
- if (warn_text == NULL)
- warn_text = strdup (_(WARN_DUPLICATES));
- else if (! strstr (warn_text, _(WARN_DUPLICATES)) &&
- asprintf (&warn_text, "%s %s", warn_text, _(WARN_DUPLICATES)) == -1)
- die (STATE_UNKNOWN, _("Unable to realloc warn_text"));
- return (STATE_WARNING);
+ if (warn_on_duplicate) {
+ if (warn_text == NULL)
+ warn_text = strdup (_(WARN_DUPLICATES));
+ else if (! strstr (warn_text, _(WARN_DUPLICATES)) &&
+ asprintf (&warn_text, "%s %s", warn_text, _(WARN_DUPLICATES)) == -1)
+ die (STATE_UNKNOWN, _("Unable to realloc warn_text"));
+ return (STATE_WARNING);
+ }
}
return (STATE_OK);
@@ -559,31 +566,33 @@
printf (_(UT_IPv46));
printf (" %s\n", "-H, --hostname=HOST");
- printf (" %s\n", _("host to ping"));
- printf (" %s\n", "-w, --warning=THRESHOLD");
- printf (" %s\n", _("warning threshold pair"));
- printf (" %s\n", "-c, --critical=THRESHOLD");
- printf (" %s\n", _("critical threshold pair"));
- printf (" %s\n", "-p, --packets=INTEGER");
- printf (" %s ", _("number of ICMP ECHO packets to send"));
- printf (_("(Default: %d)\n"), DEFAULT_MAX_PACKETS);
- printf (" %s\n", "-L, --link");
- printf (" %s\n", _("show HTML in the plugin output (obsoleted by urlize)"));
+ printf (" %s\n", _("host to ping"));
+ printf (" %s\n", "-w, --warning=THRESHOLD");
+ printf (" %s\n", _("warning threshold pair"));
+ printf (" %s\n", "-c, --critical=THRESHOLD");
+ printf (" %s\n", _("critical threshold pair"));
+ printf (" %s\n", "-p, --packets=INTEGER");
+ printf (" %s ", _("number of ICMP ECHO packets to send"));
+ printf (_("(Default: %d)\n"), DEFAULT_MAX_PACKETS);
+ printf (" %s\n", "-L, --link");
+ printf (" %s\n", _("show HTML in the plugin output (obsoleted by urlize)"));
+ printf (" %s\n", "-d, --ignore-duplicates");
+ printf (" %s\n", _("don't warn on duplicate responses"));
printf (_(UT_TIMEOUT), DEFAULT_SOCKET_TIMEOUT);
printf ("%s\n", _("THRESHOLD is <rta>,<pl>% where <rta> is the round trip average travel"));
- printf ("%s\n", _("time (ms) which triggers a WARNING or CRITICAL state, and <pl> is the"));
- printf ("%s\n", _("percentage of packet loss to trigger an alarm state."));
+ printf ("%s\n", _("time (ms) which triggers a WARNING or CRITICAL state, and <pl> is the"));
+ printf ("%s\n", _("percentage of packet loss to trigger an alarm state."));
- printf ("\n\n");
+ printf ("\n\n");
printf ("%s\n", _("This plugin uses the ping command to probe the specified host for packet loss"));
- printf ("%s\n", _("(percentage) and round trip average (milliseconds). It can produce HTML output"));
- printf ("%s\n", _("linking to a traceroute CGI contributed by Ian Cass. The CGI can be found in"));
- printf ("%s\n", _("the contrib area of the downloads section at http://www.nagios.org/"));
+ printf ("%s\n", _("(percentage) and round trip average (milliseconds). It can produce HTML output"));
+ printf ("%s\n", _("linking to a traceroute CGI contributed by Ian Cass. The CGI can be found in"));
+ printf ("%s\n", _("the contrib area of the downloads section at http://www.nagios.org/"));
- printf ("\n\n");
+ printf ("\n\n");
printf (_(UT_SUPPORT));
}
|