Code

re-add a call to setlocale(LC_ALL, "") in check_ping.c
[nagiosplug.git] / plugins / check_ping.c
index 4778fcf90bfe3a73c6af68e6ad6d04230b1ef4ea..fc720144dd0b419a7b97368282b407306452e637 100644 (file)
@@ -72,6 +72,7 @@ main (int argc, char **argv)
        int i;
 
        setlocale (LC_ALL, "");
+       setlocale (LC_NUMERIC, "C");
        bindtextdomain (PACKAGE, LOCALEDIR);
        textdomain (PACKAGE);
 
@@ -194,9 +195,7 @@ process_arguments (int argc, char **argv)
 
                switch (c) {
                case '?':       /* usage */
-                       printf (_("%s: Unknown argument: %s\n\n"), progname, optarg);
-                       print_usage ();
-                       exit (STATE_UNKNOWN);
+                       usage2 (_("Unknown argument"), optarg);
                case 'h':       /* help */
                        print_help ();
                        exit (STATE_OK);
@@ -405,7 +404,7 @@ run_ping (const char *cmd, const char *addr)
        int result = STATE_UNKNOWN;
 
        if ((child_process = spopen (cmd)) == NULL)
-               die (STATE_UNKNOWN, _("Cannot open pipe: %s"), cmd);
+               die (STATE_UNKNOWN, _("Could not open pipe: %s\n"), cmd);
 
        child_stderr = fdopen (child_stderr_array[fileno (child_process)], "r");
        if (child_stderr == NULL)
@@ -417,11 +416,15 @@ run_ping (const char *cmd, const char *addr)
 
                /* 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 duplicates, %d%% packet loss", &pl) == 1 ||
+                        sscanf(buf,"%*d packets transmitted, %*d received, +%*d duplicates, %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 ||
                         sscanf(buf,"%*d packets transmitted, %*d received, %d%% packet loss, time", &pl)==1 ||
-                  sscanf(buf,"%*d packets transmitted, %*d received, +%*d errors, %d%% packet loss", &pl) == 1)
+                        sscanf(buf,"%*d packets transmitted, %*d received, +%*d errors, %d%% packet loss", &pl) == 1 ||
+                        sscanf(buf,"%*d packets transmitted %*d received, +%*d errors, %d%% packet loss", &pl) == 1
+                        )
                        continue;
 
                /* get the round trip average */
@@ -432,6 +435,7 @@ run_ping (const char *cmd, const char *addr)
                                 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,"round-trip (ms) min/avg/max/stddev = %*f/%f/%*f/%*f",&rta)==1 ||
                                 sscanf(buf,"rtt min/avg/max/mdev = %*f/%f/%*f/%*f ms",&rta)==1)
                        continue;
        }
@@ -469,6 +473,8 @@ error_scan (char buf[MAX_INPUT_BUFFER], const char *addr)
                die (STATE_CRITICAL, _("CRITICAL - Host Unreachable (%s)"), addr);
        else if (strstr (buf, "unknown host" ))
                die (STATE_CRITICAL, _("CRITICAL - Host not found (%s)"), addr);
+       else if (strstr (buf, "Time to live exceeded"))
+               die (STATE_CRITICAL, _("CRITICAL - Time to live exceeded (%s)"), addr);
 
        if (strstr (buf, "(DUP!)") || strstr (buf, "DUPLICATES FOUND")) {
                if (warn_text == NULL)