summaryrefslogtreecommitdiffstats
path: root/web/attachments/428489-check_ping-seconds-perfdata.diff
blob: 78b01f645f136bc1b24327a49d770ace213233f5 (plain)
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
diff -u -p -b check_ping.c.v0 check_ping.c
--- check_ping.c.v0	2011-11-15 13:00:48.823063478 +0100
+++ check_ping.c	2011-11-15 13:28:40.819060887 +0100
@@ -54,6 +54,7 @@ void print_usage (void);
 void print_help (void);
 
 int display_html = FALSE;
+int perfdata_seconds = FALSE;
 int wpl = UNKNOWN_PACKET_LOSS;
 int cpl = UNKNOWN_PACKET_LOSS;
 float wrta = UNKNOWN_TRIP_TIME;
@@ -163,6 +164,12 @@ main (int argc, char **argv)
 			printf ("</A>");
 
 		/* Print performance data */
+		if (perfdata_seconds)
+			printf("|%s", fperfdata ("rta", (double) (rta/1000), "s",
+		                           wrta>0?TRUE:FALSE, wrta/1000,
+		                           crta>0?TRUE:FALSE, crta/1000,
+		                           TRUE, 0, FALSE, 0));
+		else
 		printf("|%s", fperfdata ("rta", (double) rta, "ms",
 		                          wrta>0?TRUE:FALSE, wrta,
 		                          crta>0?TRUE:FALSE, crta,
@@ -200,6 +207,7 @@ process_arguments (int argc, char **argv
 		{"link", no_argument, 0, 'L'},
 		{"use-ipv4", no_argument, 0, '4'},
 		{"use-ipv6", no_argument, 0, '6'},
+		{"seconds", no_argument, 0, 's'},
 		{0, 0, 0, 0}
 	};
 
@@ -214,7 +222,7 @@ process_arguments (int argc, char **argv
 	}
 
 	while (1) {
-		c = getopt_long (argc, argv, "VvhnL46t:c:w:H:p:", longopts, &option);
+		c = getopt_long (argc, argv, "VvhnL46st:c:w:H:p:", longopts, &option);
 
 		if (c == -1 || c == EOF)
 			break;
@@ -283,6 +291,9 @@ process_arguments (int argc, char **argv
 		case 'w':
 			get_threshold (optarg, &wrta, &wpl);
 			break;
+		case 's':
+			perfdata_seconds = TRUE;
+			break;
 		}
 	}
 
@@ -578,6 +589,8 @@ print_help (void)
   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", "-s, --seconds");
+  printf ("    %s\n", _("output performance data in seconds rather than milliseconds"));
 
 	printf (UT_TIMEOUT, DEFAULT_SOCKET_TIMEOUT);
 
@@ -600,5 +613,5 @@ print_usage (void)
 {
   printf ("%s\n", _("Usage:"));
 	printf ("%s -H <host_address> -w <wrta>,<wpl>%% -c <crta>,<cpl>%%\n", progname);
-  printf (" [-p packets] [-t timeout] [-4|-6]\n");
+  printf (" [-p packets] [-t timeout] [-4|-6] [-s]\n");
 }