[Nagiosplug-checkins] CVS: nagiosplug/plugins check_ping.c,1.18,1.19
Karl DeBisschop
kdebisschop at users.sourceforge.net
Thu Aug 7 02:53:02 CEST 2003
Update of /cvsroot/nagiosplug/nagiosplug/plugins
In directory sc8-pr-cvs1:/tmp/cvs-serv4030
Modified Files:
check_ping.c
Log Message:
markup for translation
Index: check_ping.c
===================================================================
RCS file: /cvsroot/nagiosplug/nagiosplug/plugins/check_ping.c,v
retrieving revision 1.18
retrieving revision 1.19
diff -C2 -r1.18 -r1.19
*** check_ping.c 30 Jun 2003 18:52:38 -0000 1.18
--- check_ping.c 7 Aug 2003 09:51:58 -0000 1.19
***************
*** 1,53 ****
! /*****************************************************************************
! *
! * CHECK_PING.C
! *
! * Program: Ping plugin for Nagios
! * License: GPL
! * Copyright (c) 1999 Ethan Galstad (nagios at nagios.org)
! *
! * $Id$
! *
! *****************************************************************************/
! const char *progname = "check_ping";
! #define REVISION "$Revision$"
! #define COPYRIGHT "1999-2001"
! #define AUTHOR "Ethan Galstad/Karl DeBisschop"
! #define EMAIL "kdebisschop at users.sourceforge.net"
! #define SUMMARY "Use ping to check connection statistics for a remote host.\n"
!
! #define OPTIONS "\
! -H <host_address> -w <wrta>,<wpl>%% -c <crta>,<cpl>%%\n\
! [-p packets] [-t timeout] [-L] [-4|-6]\n"
! #define LONGOPTIONS "\
! -H, --hostname=HOST\n\
! host to ping\n\
! -4, --use-ipv4\n\
! Use IPv4 ICMP PING\n\
! -6, --use-ipv6\n\
! Use IPv6 ICMP PING\n\
! -w, --warning=THRESHOLD\n\
! warning threshold pair\n\
! -c, --critical=THRESHOLD\n\
! critical threshold pair\n\
! -p, --packets=INTEGER\n\
! number of ICMP ECHO packets to send (Default: %d)\n\
! -t, --timeout=INTEGER\n\
! optional specified timeout in second (Default: %d)\n\
! -L, --link\n\
! show HTML in the plugin output (obsoleted by urlize)\n\
! THRESHOLD is <rta>,<pl>%% where <rta> is the round trip average travel\n\
! time (ms) which triggers a WARNING or CRITICAL state, and <pl> is the\n\
! percentage of packet loss to trigger an alarm state.\n"
! #define DESCRIPTION "\
! This plugin uses the ping command to probe the specified host for packet loss\n\
! (percentage) and round trip average (milliseconds). It can produce HTML output\n\
! linking to a traceroute CGI contributed by Ian Cass. The CGI can be found in\n\
! the contrib area of the downloads section at http://www.nagios.org\n\n"
- #include "config.h"
#include "common.h"
#include "netutils.h"
--- 1,25 ----
! /******************************************************************************
! This program is free software; you can redistribute it and/or modify
! it under the terms of the GNU General Public License as published by
! the Free Software Foundation; either version 2 of the License, or
! (at your option) any later version.
!
! This program is distributed in the hope that it will be useful,
! but WITHOUT ANY WARRANTY; without even the implied warranty of
! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
! GNU General Public License for more details.
!
! You should have received a copy of the GNU General Public License
! along with this program; if not, write to the Free Software
! Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
! ******************************************************************************/
! const char *progname = "check_ping";
! const char *revision = "$Revision$";
! const char *copyright = "2000-2003";
! const char *email = "nagiosplug-devel at lists.sourceforge.net";
#include "common.h"
#include "netutils.h"
***************
*** 95,104 ****
if (process_arguments (argc, argv) == ERROR)
! usage ("Could not parse arguments");
exit;
/* Set signal handling and alarm */
if (signal (SIGALRM, popen_timeout_alarm_handler) == SIG_ERR) {
! printf ("Cannot catch SIGALRM");
return STATE_UNKNOWN;
}
--- 67,76 ----
if (process_arguments (argc, argv) == ERROR)
! usage (_("Could not parse arguments"));
exit;
/* Set signal handling and alarm */
if (signal (SIGALRM, popen_timeout_alarm_handler) == SIG_ERR) {
! printf (_("Cannot catch SIGALRM"));
return STATE_UNKNOWN;
}
***************
*** 139,143 ****
printf ("%s\n", command_line);
terminate (STATE_UNKNOWN,
! "Error: Could not interpret output from ping command\n");
}
--- 111,115 ----
printf ("%s\n", command_line);
terminate (STATE_UNKNOWN,
! _("Error: Could not interpret output from ping command\n"));
}
***************
*** 155,162 ****
printf ("<A HREF='%s/traceroute.cgi?%s'>", CGIURL, addresses[i]);
if (pl == 100)
! printf ("PING %s - %sPacket loss = %d%%", state_text (this_result), warn_text,
pl);
else
! printf ("PING %s - %sPacket loss = %d%%, RTA = %2.2f ms",
state_text (this_result), warn_text, pl, rta);
if (display_html == TRUE)
--- 127,134 ----
printf ("<A HREF='%s/traceroute.cgi?%s'>", CGIURL, addresses[i]);
if (pl == 100)
! printf (_("PING %s - %sPacket loss = %d%%"), state_text (this_result), warn_text,
pl);
else
! printf (_("PING %s - %sPacket loss = %d%%, RTA = %2.2f ms"),
state_text (this_result), warn_text, pl, rta);
if (display_html == TRUE)
***************
*** 211,220 ****
switch (c) {
case '?': /* usage */
! usage3 ("Unknown argument", optopt);
case 'h': /* help */
print_help ();
exit (STATE_OK);
case 'V': /* version */
! print_revision (progname, REVISION);
exit (STATE_OK);
case 't': /* timeout period */
--- 183,192 ----
switch (c) {
case '?': /* usage */
! usage3 (_("Unknown argument"), optopt);
case 'h': /* help */
print_help ();
exit (STATE_OK);
case 'V': /* version */
! print_revision (progname, revision);
exit (STATE_OK);
case 't': /* timeout period */
***************
*** 231,235 ****
address_family = AF_INET6;
#else
! usage ("IPv6 support not available\n");
#endif
break;
--- 203,207 ----
address_family = AF_INET6;
#else
! usage (_("IPv6 support not available\n"));
#endif
break;
***************
*** 242,249 ****
addresses = realloc (addresses, max_addr);
if (addresses == NULL)
! terminate (STATE_UNKNOWN, "Could not realloc() addresses\n");
}
addresses[n_addresses-1] = ptr;
! if (ptr = index (ptr, ',')) {
strcpy (ptr, "");
ptr += sizeof(char);
--- 214,221 ----
addresses = realloc (addresses, max_addr);
if (addresses == NULL)
! terminate (STATE_UNKNOWN, _("Could not realloc() addresses\n"));
}
addresses[n_addresses-1] = ptr;
! if ((ptr = index (ptr, ','))) {
strcpy (ptr, "");
ptr += sizeof(char);
***************
*** 257,261 ****
max_packets = atoi (optarg);
else
! usage2 ("<max_packets> (%s) must be a non-negative number\n", optarg);
break;
case 'n': /* no HTML */
--- 229,233 ----
max_packets = atoi (optarg);
else
! usage2 (_("<max_packets> (%s) must be a non-negative number\n"), optarg);
break;
case 'n': /* no HTML */
***************
*** 280,284 ****
if (addresses[0] == NULL) {
if (is_host (argv[c]) == FALSE) {
! printf ("Invalid host name/address: %s\n\n", argv[c]);
return ERROR;
} else {
--- 252,256 ----
if (addresses[0] == NULL) {
if (is_host (argv[c]) == FALSE) {
! printf (_("Invalid host name/address: %s\n\n"), argv[c]);
return ERROR;
} else {
***************
*** 291,295 ****
if (wpl == UNKNOWN_PACKET_LOSS) {
if (is_intpercent (argv[c]) == FALSE) {
! printf ("<wpl> (%s) must be an integer percentage\n", argv[c]);
return ERROR;
} else {
--- 263,267 ----
if (wpl == UNKNOWN_PACKET_LOSS) {
if (is_intpercent (argv[c]) == FALSE) {
! printf (_("<wpl> (%s) must be an integer percentage\n"), argv[c]);
return ERROR;
} else {
***************
*** 302,306 ****
if (cpl == UNKNOWN_PACKET_LOSS) {
if (is_intpercent (argv[c]) == FALSE) {
! printf ("<cpl> (%s) must be an integer percentage\n", argv[c]);
return ERROR;
} else {
--- 274,278 ----
if (cpl == UNKNOWN_PACKET_LOSS) {
if (is_intpercent (argv[c]) == FALSE) {
! printf (_("<cpl> (%s) must be an integer percentage\n"), argv[c]);
return ERROR;
} else {
***************
*** 313,317 ****
if (wrta == UNKNOWN_TRIP_TIME) {
if (is_negative (argv[c])) {
! printf ("<wrta> (%s) must be a non-negative number\n", argv[c]);
return ERROR;
} else {
--- 285,289 ----
if (wrta == UNKNOWN_TRIP_TIME) {
if (is_negative (argv[c])) {
! printf (_("<wrta> (%s) must be a non-negative number\n"), argv[c]);
return ERROR;
} else {
***************
*** 324,328 ****
if (crta == UNKNOWN_TRIP_TIME) {
if (is_negative (argv[c])) {
! printf ("<crta> (%s) must be a non-negative number\n", argv[c]);
return ERROR;
} else {
--- 296,300 ----
if (crta == UNKNOWN_TRIP_TIME) {
if (is_negative (argv[c])) {
! printf (_("<crta> (%s) must be a non-negative number\n"), argv[c]);
return ERROR;
} else {
***************
*** 337,341 ****
max_packets = atoi (argv[c++]);
} else {
! printf ("<max_packets> (%s) must be a non-negative number\n", argv[c]);
return ERROR;
}
--- 309,313 ----
max_packets = atoi (argv[c++]);
} else {
! printf (_("<max_packets> (%s) must be a non-negative number\n"), argv[c]);
return ERROR;
}
***************
*** 354,359 ****
else if (strstr (arg, "%") && sscanf (arg, "%d%%", tpl) == 1)
return OK;
! else
! usage2 ("%s: Warning threshold must be integer or percentage!\n\n", arg);
}
--- 326,332 ----
else if (strstr (arg, "%") && sscanf (arg, "%d%%", tpl) == 1)
return OK;
!
! usage2 (_("%s: Warning threshold must be integer or percentage!\n\n"), arg);
! return STATE_UNKNOWN;
}
***************
*** 365,389 ****
if (wrta == UNKNOWN_TRIP_TIME) {
! printf ("<wrta> was not set\n");
return ERROR;
}
else if (crta == UNKNOWN_TRIP_TIME) {
! printf ("<crta> was not set\n");
return ERROR;
}
else if (wpl == UNKNOWN_PACKET_LOSS) {
! printf ("<wpl> was not set\n");
return ERROR;
}
else if (cpl == UNKNOWN_PACKET_LOSS) {
! printf ("<cpl> was not set\n");
return ERROR;
}
else if (wrta > crta) {
! printf ("<wrta> (%f) cannot be larger than <crta> (%f)\n", wrta, crta);
return ERROR;
}
else if (wpl > cpl) {
! printf ("<wpl> (%d) cannot be larger than <cpl> (%d)\n", wpl, cpl);
return ERROR;
}
--- 338,362 ----
if (wrta == UNKNOWN_TRIP_TIME) {
! printf (_("<wrta> was not set\n"));
return ERROR;
}
else if (crta == UNKNOWN_TRIP_TIME) {
! printf (_("<crta> was not set\n"));
return ERROR;
}
else if (wpl == UNKNOWN_PACKET_LOSS) {
! printf (_("<wpl> was not set\n"));
return ERROR;
}
else if (cpl == UNKNOWN_PACKET_LOSS) {
! printf (_("<cpl> was not set\n"));
return ERROR;
}
else if (wrta > crta) {
! printf (_("<wrta> (%f) cannot be larger than <crta> (%f)\n"), wrta, crta);
return ERROR;
}
else if (wpl > cpl) {
! printf (_("<wpl> (%d) cannot be larger than <cpl> (%d)\n"), wpl, cpl);
return ERROR;
}
***************
*** 398,402 ****
for (i=0; i<n_addresses; i++) {
if (is_host(addresses[i]) == FALSE)
! usage2 ("Invalid host name/address", addresses[i]);
}
--- 371,375 ----
for (i=0; i<n_addresses; i++) {
if (is_host(addresses[i]) == FALSE)
! usage2 (_("Invalid host name/address"), addresses[i]);
}
***************
*** 408,430 ****
run_ping (char *command_line, char *server_address)
{
! char input_buffer[MAX_INPUT_BUFFER];
int result = STATE_UNKNOWN;
warn_text = malloc (1);
if (warn_text == NULL)
! terminate (STATE_UNKNOWN, "unable to malloc warn_text");
warn_text[0] = 0;
if ((child_process = spopen (command_line)) == NULL) {
! printf ("Cannot open pipe: ");
terminate (STATE_UNKNOWN, command_line);
}
child_stderr = fdopen (child_stderr_array[fileno (child_process)], "r");
if (child_stderr == NULL)
! printf ("Cannot open stderr for %s\n", command_line);
! while (fgets (input_buffer, MAX_INPUT_BUFFER - 1, child_process)) {
! if (strstr (input_buffer, "(DUP!)")) {
/* cannot use the max function since STATE_UNKNOWN is max
result = max (result, STATE_WARNING); */
--- 381,403 ----
run_ping (char *command_line, char *server_address)
{
! char buf[MAX_INPUT_BUFFER];
int result = STATE_UNKNOWN;
warn_text = malloc (1);
if (warn_text == NULL)
! terminate (STATE_UNKNOWN, _("unable to malloc warn_text"));
warn_text[0] = 0;
if ((child_process = spopen (command_line)) == NULL) {
! printf (_("Cannot open pipe: "));
terminate (STATE_UNKNOWN, command_line);
}
child_stderr = fdopen (child_stderr_array[fileno (child_process)], "r");
if (child_stderr == NULL)
! printf (_("Cannot open stderr for %s\n"), command_line);
! while (fgets (buf, MAX_INPUT_BUFFER - 1, child_process)) {
! if (strstr (buf, _("(DUP!)"))) {
/* cannot use the max function since STATE_UNKNOWN is max
result = max (result, STATE_WARNING); */
***************
*** 435,478 ****
warn_text = realloc (warn_text, strlen (WARN_DUPLICATES) + 1);
if (warn_text == NULL)
! terminate (STATE_UNKNOWN, "unable to realloc warn_text");
strcpy (warn_text, WARN_DUPLICATES);
}
/* get the percent loss statistics */
! if (sscanf
! (input_buffer, "%*d packets transmitted, %*d packets received, +%*d errors, %d%% packet loss",
! &pl) == 1
! || sscanf
! (input_buffer, "%*d packets transmitted, %*d packets received, %d%% packet loss",
! &pl) == 1
! || sscanf
! (input_buffer, "%*d packets transmitted, %*d packets received, %d%% loss, time", &pl) == 1
! || sscanf
! (input_buffer, "%*d packets transmitted, %*d received, %d%% loss, time", &pl) == 1
! /* Suse 8.0 as reported by Richard * Brodie */
! )
continue;
/* get the round trip average */
else
! if (sscanf (input_buffer, "round-trip min/avg/max = %*f/%f/%*f", &rta)
! == 1
! || sscanf (input_buffer,
! "round-trip min/avg/max/mdev = %*f/%f/%*f/%*f",
! &rta) == 1
! || sscanf (input_buffer,
! "round-trip min/avg/max/sdev = %*f/%f/%*f/%*f",
! &rta) == 1
! || sscanf (input_buffer,
! "round-trip min/avg/max/stddev = %*f/%f/%*f/%*f",
! &rta) == 1
! || sscanf (input_buffer,
! "round-trip min/avg/max/std-dev = %*f/%f/%*f/%*f",
! &rta) == 1
! || sscanf (input_buffer, "round-trip (ms) min/avg/max = %*f/%f/%*f",
! &rta) == 1
! || sscanf (input_buffer, "rtt min/avg/max/mdev = %*f/%f/%*f/%*f ms",
! &rta) == 1
! )
continue;
}
--- 408,431 ----
warn_text = realloc (warn_text, strlen (WARN_DUPLICATES) + 1);
if (warn_text == NULL)
! terminate (STATE_UNKNOWN, _("unable to realloc warn_text"));
strcpy (warn_text, WARN_DUPLICATES);
}
/* get the percent loss statistics */
! if(sscanf(buf,"%*d packets transmitted, %*d packets received, +%*d errors, %d%% packet loss",&pl)==1 ||
! sscanf(buf,"%*d packets transmitted, %*d packets received, %d%% packet loss",&pl)==1 ||
! sscanf(buf,"%*d packets transmitted, %*d packets received, %d%% loss, time",&pl)==1 ||
! sscanf(buf,"%*d packets transmitted, %*d received, %d%% loss, time", &pl)==1)
continue;
/* get the round trip average */
else
! if(sscanf(buf,"round-trip min/avg/max = %*f/%f/%*f",&rta)==1 ||
! sscanf(buf,"round-trip min/avg/max/mdev = %*f/%f/%*f/%*f",&rta)==1 ||
! sscanf(buf,"round-trip min/avg/max/sdev = %*f/%f/%*f/%*f",&rta)==1 ||
! sscanf(buf,"round-trip min/avg/max/stddev = %*f/%f/%*f/%*f",&rta)==1 ||
! sscanf(buf,"round-trip min/avg/max/std-dev = %*f/%f/%*f/%*f",&rta)==1 ||
! sscanf(buf,"round-trip (ms) min/avg/max = %*f/%f/%*f",&rta)==1 ||
! sscanf(buf,"rtt min/avg/max/mdev = %*f/%f/%*f/%*f ms",&rta)==1)
continue;
}
***************
*** 484,513 ****
/* check stderr */
! while (fgets (input_buffer, MAX_INPUT_BUFFER - 1, child_stderr)) {
! if (strstr
! (input_buffer,
! "Warning: no SO_TIMESTAMP support, falling back to SIOCGSTAMP"))
continue;
! if (strstr (input_buffer, "Network is unreachable"))
! terminate (STATE_CRITICAL, "PING CRITICAL - Network unreachable (%s)",
! server_address);
! else if (strstr (input_buffer, "Destination Host Unreachable"))
! terminate (STATE_CRITICAL, "PING CRITICAL - Host Unreachable (%s)",
! server_address);
! else if (strstr (input_buffer, "unknown host" ) )
! terminate (STATE_CRITICAL, "PING CRITICAL - Host not found (%s)",
! server_address);
warn_text =
! realloc (warn_text, strlen (warn_text) + strlen (input_buffer) + 2);
if (warn_text == NULL)
! terminate (STATE_UNKNOWN, "unable to realloc warn_text");
if (strlen (warn_text) == 0)
! strcpy (warn_text, input_buffer);
else
! sprintf (warn_text, "%s %s", warn_text, input_buffer);
! if (strstr (input_buffer, "DUPLICATES FOUND")) {
if( !(result == STATE_CRITICAL) ){
result = STATE_WARNING;
--- 437,467 ----
/* check stderr */
! while (fgets (buf, MAX_INPUT_BUFFER - 1, child_stderr)) {
! if (strstr(buf,"Warning: no SO_TIMESTAMP support, falling back to SIOCGSTAMP"))
continue;
! if (strstr (buf, "Network is unreachable"))
! terminate (STATE_CRITICAL,
! _("PING CRITICAL - Network unreachable (%s)"),
! server_address);
! else if (strstr (buf, "Destination Host Unreachable"))
! terminate (STATE_CRITICAL,
! _("PING CRITICAL - Host Unreachable (%s)"),
! server_address);
! else if (strstr (buf, "unknown host" ))
! terminate (STATE_CRITICAL,
! _("PING CRITICAL - Host not found (%s)"),
! server_address);
warn_text =
! realloc (warn_text, strlen (warn_text) + strlen (buf) + 2);
if (warn_text == NULL)
! terminate (STATE_UNKNOWN, _("unable to realloc warn_text"));
if (strlen (warn_text) == 0)
! strcpy (warn_text, buf);
else
! sprintf (warn_text, "%s %s", warn_text, buf);
! if (strstr (buf, "DUPLICATES FOUND")) {
if( !(result == STATE_CRITICAL) ){
result = STATE_WARNING;
***************
*** 531,538 ****
print_usage (void)
{
! printf ("Usage:\n" " %s %s\n"
! " %s (-h | --help) for detailed help\n"
! " %s (-V | --version) for version information\n",
! progname, OPTIONS, progname, progname);
}
--- 485,492 ----
print_usage (void)
{
! printf (\
! "Usage: %s -H <host_address> -w <wrta>,<wpl>%% -c <crta>,<cpl>%%\n\
! [-p packets] [-t timeout] [-L] [-4|-6]\n", progname);
! printf (_(UT_HLP_VRS), progname, progname);
}
***************
*** 540,551 ****
print_help (void)
{
! print_revision (progname, REVISION);
! printf
! ("Copyright (c) %s %s <%s>\n\n%s\n",
! COPYRIGHT, AUTHOR, EMAIL, SUMMARY);
print_usage ();
! printf
! ("\nOptions:\n" LONGOPTIONS "\n" DESCRIPTION "\n",
! DEFAULT_MAX_PACKETS, DEFAULT_SOCKET_TIMEOUT);
! support ();
}
--- 494,536 ----
print_help (void)
{
! print_revision (progname, revision);
!
! printf (_("Copyright (c) 1999 Ethan Galstad <nagios at nagios.org>"));
! printf (_(COPYRIGHT), copyright, email);
!
! printf (_("Use ping to check connection statistics for a remote host.\n\n"));
!
print_usage ();
!
! printf (_(UT_HELP_VRSN));
!
! printf (_(UT_IPv46));
!
! printf (_("\
! -H, --hostname=HOST\n\
! host to ping\n\
! -w, --warning=THRESHOLD\n\
! warning threshold pair\n\
! -c, --critical=THRESHOLD\n\
! critical threshold pair\n\
! -p, --packets=INTEGER\n\
! number of ICMP ECHO packets to send (Default: %d)\n\
! -L, --link\n\
! show HTML in the plugin output (obsoleted by urlize)\n"),
! DEFAULT_MAX_PACKETS);
!
! printf (_(UT_TIMEOUT), DEFAULT_SOCKET_TIMEOUT);
!
! printf (_("\
! THRESHOLD is <rta>,<pl>%% where <rta> is the round trip average travel\n\
! time (ms) which triggers a WARNING or CRITICAL state, and <pl> is the\n\
! percentage of packet loss to trigger an alarm state.\n\n"));
!
! printf (_("\
! This plugin uses the ping command to probe the specified host for packet loss\n\
! (percentage) and round trip average (milliseconds). It can produce HTML output\n\
! linking to a traceroute CGI contributed by Ian Cass. The CGI can be found in\n\
! the contrib area of the downloads section at http://www.nagios.org\n\n"));
!
! printf (_(UT_SUPPORT));
}
More information about the Commits
mailing list