check_ping.c 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630
  1. /*****************************************************************************
  2. *
  3. * Nagios check_ping plugin
  4. *
  5. * License: GPL
  6. * Copyright (c) 2000-2014 Nagios Plugins Development Team
  7. *
  8. * Description:
  9. *
  10. * This file contains the check_ping plugin
  11. *
  12. * Use the ping program to check connection statistics for a remote host.
  13. *
  14. *
  15. * This program is free software: you can redistribute it and/or modify
  16. * it under the terms of the GNU General Public License as published by
  17. * the Free Software Foundation, either version 3 of the License, or
  18. * (at your option) any later version.
  19. *
  20. * This program is distributed in the hope that it will be useful,
  21. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  22. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  23. * GNU General Public License for more details.
  24. *
  25. * You should have received a copy of the GNU General Public License
  26. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  27. *
  28. *
  29. *****************************************************************************/
  30. const char *progname = "check_ping";
  31. const char *copyright = "2000-2014";
  32. const char *email = "devel@nagios-plugins.org";
  33. #include "common.h"
  34. #include "netutils.h"
  35. #include "popen.h"
  36. #include "utils.h"
  37. #define WARN_DUPLICATES "DUPLICATES FOUND! "
  38. #define UNKNOWN_TRIP_TIME -1.0 /* -1 seconds */
  39. enum {
  40. UNKNOWN_PACKET_LOSS = 200, /* 200% */
  41. DEFAULT_MAX_PACKETS = 5 /* default no. of ICMP ECHO packets */
  42. };
  43. int process_arguments (int, char **);
  44. int get_threshold (char *, float *, int *);
  45. int validate_arguments (void);
  46. int run_ping (const char *cmd, const char *addr);
  47. int error_scan (char buf[MAX_INPUT_BUFFER], const char *addr);
  48. void print_usage (void);
  49. void print_help (void);
  50. int display_html = FALSE;
  51. int show_resolution = FALSE;
  52. int wpl = UNKNOWN_PACKET_LOSS;
  53. int cpl = UNKNOWN_PACKET_LOSS;
  54. float wrta = UNKNOWN_TRIP_TIME;
  55. float crta = UNKNOWN_TRIP_TIME;
  56. char **addresses = NULL;
  57. int n_addresses = 0;
  58. int max_addr = 1;
  59. int max_packets = -1;
  60. int verbose = 0;
  61. float rta = UNKNOWN_TRIP_TIME;
  62. int pl = UNKNOWN_PACKET_LOSS;
  63. char ping_name[256];
  64. char ping_ip_addr[64];
  65. char *warn_text;
  66. int
  67. main (int argc, char **argv)
  68. {
  69. char *cmd = NULL;
  70. char *rawcmd = NULL;
  71. int result = STATE_UNKNOWN;
  72. int this_result = STATE_UNKNOWN;
  73. int i;
  74. setlocale (LC_ALL, "");
  75. setlocale (LC_NUMERIC, "C");
  76. bindtextdomain (PACKAGE, LOCALEDIR);
  77. textdomain (PACKAGE);
  78. addresses = malloc (sizeof(char*) * max_addr);
  79. addresses[0] = NULL;
  80. /* Parse extra opts if any */
  81. argv=np_extra_opts (&argc, argv, progname);
  82. if (process_arguments (argc, argv) == ERROR)
  83. usage4 (_("Could not parse arguments"));
  84. /* Set signal handling and alarm */
  85. if (signal (SIGALRM, popen_timeout_alarm_handler) == SIG_ERR) {
  86. usage4 (_("Cannot catch SIGALRM"));
  87. }
  88. /* If ./configure finds ping has timeout values, set plugin alarm slightly
  89. * higher so that we can use response from command line ping */
  90. #if defined(PING_PACKETS_FIRST) && defined(PING_HAS_TIMEOUT)
  91. alarm (timeout_interval + 1);
  92. #else
  93. alarm (timeout_interval);
  94. #endif
  95. for (i = 0 ; i < n_addresses ; i++) {
  96. #ifdef PING6_COMMAND
  97. if (address_family != AF_INET && is_inet6_addr(addresses[i]))
  98. rawcmd = strdup(PING6_COMMAND);
  99. else
  100. rawcmd = strdup(PING_COMMAND);
  101. #else
  102. rawcmd = strdup(PING_COMMAND);
  103. #endif
  104. /* does the host address of number of packets argument come first? */
  105. #ifdef PING_PACKETS_FIRST
  106. # ifdef PING_HAS_TIMEOUT
  107. xasprintf (&cmd, rawcmd, timeout_interval, max_packets, addresses[i]);
  108. # else
  109. xasprintf (&cmd, rawcmd, max_packets, addresses[i]);
  110. # endif
  111. #else
  112. xasprintf (&cmd, rawcmd, addresses[i], max_packets);
  113. #endif
  114. if (verbose >= 2)
  115. printf ("CMD: %s\n", cmd);
  116. /* run the command */
  117. this_result = run_ping (cmd, addresses[i]);
  118. if (pl == UNKNOWN_PACKET_LOSS || rta < 0.0) {
  119. die (STATE_UNKNOWN,
  120. _("CRITICAL - Could not interpret output from ping command\n"));
  121. }
  122. if (pl >= cpl || rta >= crta || rta < 0)
  123. this_result = STATE_CRITICAL;
  124. else if (pl >= wpl || rta >= wrta)
  125. this_result = STATE_WARNING;
  126. else if (pl >= 0 && rta >= 0)
  127. this_result = max_state (STATE_OK, this_result);
  128. if (n_addresses > 1 && this_result != STATE_UNKNOWN)
  129. die (STATE_OK, "%s is alive\n", addresses[i]);
  130. if (display_html == TRUE)
  131. printf ("<A HREF='%s/traceroute.cgi?%s'>", CGIURL, addresses[i]);
  132. if (pl == 100)
  133. printf (_("PING %s - %sPacket loss = %d%%"), state_text (this_result), warn_text,
  134. pl);
  135. else
  136. printf (_("PING %s - %sPacket loss = %d%%, RTA = %2.2f ms"),
  137. state_text (this_result), warn_text, pl, rta);
  138. if (show_resolution) {
  139. if (strcmp(ping_name, ping_ip_addr) == 0)
  140. printf(" - %s", ping_name);
  141. else
  142. printf(" - %s (%s)", ping_name, ping_ip_addr);
  143. }
  144. if (display_html == TRUE)
  145. printf ("</A>");
  146. /* Print performance data */
  147. printf("|%s", fperfdata ("rta", (double) rta, "ms",
  148. wrta>0?TRUE:FALSE, wrta,
  149. crta>0?TRUE:FALSE, crta,
  150. TRUE, 0, FALSE, 0));
  151. printf(" %s\n", perfdata ("pl", (long) pl, "%",
  152. wpl>0?TRUE:FALSE, wpl,
  153. cpl>0?TRUE:FALSE, cpl,
  154. TRUE, 0, FALSE, 0));
  155. if (verbose >= 2)
  156. printf ("%f:%d%% %f:%d%%\n", wrta, wpl, crta, cpl);
  157. result = max_state (result, this_result);
  158. free (rawcmd);
  159. free (cmd);
  160. }
  161. return result;
  162. }
  163. /* process command-line arguments */
  164. int
  165. process_arguments (int argc, char **argv)
  166. {
  167. int c = 1;
  168. char *ptr;
  169. int option = 0;
  170. static struct option longopts[] = {
  171. STD_LONG_OPTS,
  172. {"packets", required_argument, 0, 'p'},
  173. {"show-resolution", no_argument, 0, 's'},
  174. {"nohtml", no_argument, 0, 'n'},
  175. {"link", no_argument, 0, 'L'},
  176. {"use-ipv4", no_argument, 0, '4'},
  177. {"use-ipv6", no_argument, 0, '6'},
  178. {0, 0, 0, 0}
  179. };
  180. if (argc < 2)
  181. return ERROR;
  182. for (c = 1; c < argc; c++) {
  183. if (strcmp ("-to", argv[c]) == 0)
  184. strcpy (argv[c], "-t");
  185. if (strcmp ("-nohtml", argv[c]) == 0)
  186. strcpy (argv[c], "-n");
  187. }
  188. while (1) {
  189. c = getopt_long (argc, argv, "VvhsnL46t:c:w:H:p:", longopts, &option);
  190. if (c == -1 || c == EOF)
  191. break;
  192. switch (c) {
  193. case '?': /* usage */
  194. usage5 ();
  195. case 'h': /* help */
  196. print_help ();
  197. exit (STATE_OK);
  198. break;
  199. case 'V': /* version */
  200. print_revision (progname, NP_VERSION);
  201. exit (STATE_OK);
  202. break;
  203. case 't': /* timeout period */
  204. timeout_interval = parse_timeout_string(optarg);
  205. break;
  206. case 'v': /* verbose mode */
  207. verbose++;
  208. break;
  209. case '4': /* IPv4 only */
  210. address_family = AF_INET;
  211. break;
  212. case '6': /* IPv6 only */
  213. #ifdef USE_IPV6
  214. address_family = AF_INET6;
  215. #else
  216. usage (_("IPv6 support not available\n"));
  217. #endif
  218. break;
  219. case 'H': /* hostname */
  220. ptr=optarg;
  221. while (1) {
  222. n_addresses++;
  223. if (n_addresses > max_addr) {
  224. max_addr *= 2;
  225. addresses = realloc (addresses, sizeof(char*) * max_addr);
  226. if (addresses == NULL)
  227. die (STATE_UNKNOWN, _("Could not realloc() addresses\n"));
  228. }
  229. addresses[n_addresses-1] = ptr;
  230. if ((ptr = index (ptr, ','))) {
  231. strcpy (ptr, "");
  232. ptr += sizeof(char);
  233. } else {
  234. break;
  235. }
  236. }
  237. break;
  238. case 'p': /* number of packets to send */
  239. if (is_intnonneg (optarg))
  240. max_packets = atoi (optarg);
  241. else
  242. usage2 (_("<max_packets> (%s) must be a non-negative number\n"), optarg);
  243. break;
  244. case 's':
  245. show_resolution = TRUE;
  246. break;
  247. case 'n': /* no HTML */
  248. display_html = FALSE;
  249. break;
  250. case 'L': /* show HTML */
  251. display_html = TRUE;
  252. break;
  253. case 'c':
  254. get_threshold (optarg, &crta, &cpl);
  255. break;
  256. case 'w':
  257. get_threshold (optarg, &wrta, &wpl);
  258. break;
  259. }
  260. }
  261. c = optind;
  262. if (c == argc)
  263. return validate_arguments ();
  264. if (addresses[0] == NULL) {
  265. if (is_host (argv[c]) == FALSE) {
  266. usage2 (_("Invalid hostname/address"), argv[c]);
  267. } else {
  268. addresses[0] = argv[c++];
  269. n_addresses++;
  270. if (c == argc)
  271. return validate_arguments ();
  272. }
  273. }
  274. if (wpl == UNKNOWN_PACKET_LOSS) {
  275. if (is_intpercent (argv[c]) == FALSE) {
  276. printf (_("<wpl> (%s) must be an integer percentage\n"), argv[c]);
  277. return ERROR;
  278. } else {
  279. wpl = atoi (argv[c++]);
  280. if (c == argc)
  281. return validate_arguments ();
  282. }
  283. }
  284. if (cpl == UNKNOWN_PACKET_LOSS) {
  285. if (is_intpercent (argv[c]) == FALSE) {
  286. printf (_("<cpl> (%s) must be an integer percentage\n"), argv[c]);
  287. return ERROR;
  288. } else {
  289. cpl = atoi (argv[c++]);
  290. if (c == argc)
  291. return validate_arguments ();
  292. }
  293. }
  294. if (wrta < 0.0) {
  295. if (is_negative (argv[c])) {
  296. printf (_("<wrta> (%s) must be a non-negative number\n"), argv[c]);
  297. return ERROR;
  298. } else {
  299. wrta = atof (argv[c++]);
  300. if (c == argc)
  301. return validate_arguments ();
  302. }
  303. }
  304. if (crta < 0.0) {
  305. if (is_negative (argv[c])) {
  306. printf (_("<crta> (%s) must be a non-negative number\n"), argv[c]);
  307. return ERROR;
  308. } else {
  309. crta = atof (argv[c++]);
  310. if (c == argc)
  311. return validate_arguments ();
  312. }
  313. }
  314. if (max_packets == -1) {
  315. if (is_intnonneg (argv[c])) {
  316. max_packets = atoi (argv[c++]);
  317. } else {
  318. printf (_("<max_packets> (%s) must be a non-negative number\n"), argv[c]);
  319. return ERROR;
  320. }
  321. }
  322. return validate_arguments ();
  323. }
  324. int
  325. get_threshold (char *arg, float *trta, int *tpl)
  326. {
  327. if (is_intnonneg (arg) && sscanf (arg, "%f", trta) == 1)
  328. return OK;
  329. else if (strpbrk (arg, ",:") && strstr (arg, "%") && sscanf (arg, "%f%*[:,]%d%%", trta, tpl) == 2)
  330. return OK;
  331. else if (strstr (arg, "%") && sscanf (arg, "%d%%", tpl) == 1)
  332. return OK;
  333. usage2 (_("%s: Warning threshold must be integer or percentage!\n\n"), arg);
  334. return STATE_UNKNOWN;
  335. }
  336. int
  337. validate_arguments ()
  338. {
  339. float max_seconds;
  340. int i;
  341. if (wrta < 0.0) {
  342. printf (_("<wrta> was not set\n"));
  343. return ERROR;
  344. }
  345. else if (crta < 0.0) {
  346. printf (_("<crta> was not set\n"));
  347. return ERROR;
  348. }
  349. else if (wpl == UNKNOWN_PACKET_LOSS) {
  350. printf (_("<wpl> was not set\n"));
  351. return ERROR;
  352. }
  353. else if (cpl == UNKNOWN_PACKET_LOSS) {
  354. printf (_("<cpl> was not set\n"));
  355. return ERROR;
  356. }
  357. else if (wrta > crta) {
  358. printf (_("<wrta> (%f) cannot be larger than <crta> (%f)\n"), wrta, crta);
  359. return ERROR;
  360. }
  361. else if (wpl > cpl) {
  362. printf (_("<wpl> (%d) cannot be larger than <cpl> (%d)\n"), wpl, cpl);
  363. return ERROR;
  364. }
  365. if (max_packets == -1)
  366. max_packets = DEFAULT_MAX_PACKETS;
  367. max_seconds = crta / 1000.0 * max_packets + max_packets;
  368. if (max_seconds > timeout_interval)
  369. timeout_interval = (int)max_seconds;
  370. for (i=0; i<n_addresses; i++) {
  371. if (is_host(addresses[i]) == FALSE)
  372. usage2 (_("Invalid hostname/address"), addresses[i]);
  373. }
  374. if (n_addresses == 0) {
  375. usage (_("You must specify a server address or host name"));
  376. }
  377. return OK;
  378. }
  379. int
  380. run_ping (const char *cmd, const char *addr)
  381. {
  382. char buf[MAX_INPUT_BUFFER];
  383. int result = STATE_UNKNOWN;
  384. int match;
  385. if ((child_process = spopen (cmd)) == NULL)
  386. die (STATE_UNKNOWN, _("Could not open pipe: %s\n"), cmd);
  387. child_stderr = fdopen (child_stderr_array[fileno (child_process)], "r");
  388. if (child_stderr == NULL)
  389. printf (_("Cannot open stderr for %s\n"), cmd);
  390. while (fgets (buf, MAX_INPUT_BUFFER - 1, child_process)) {
  391. if (verbose >= 3)
  392. printf("Output: %s", buf);
  393. result = max_state (result, error_scan (buf, addr));
  394. if(sscanf(buf, "PING %255s (%63[^)]", &ping_name, &ping_ip_addr))
  395. continue;
  396. /* get the percent loss statistics */
  397. match = 0;
  398. if((sscanf(buf,"%*d packets transmitted, %*d packets received, +%*d errors, %d%% packet loss%n",&pl,&match) && match) ||
  399. (sscanf(buf,"%*d packets transmitted, %*d packets received, +%*d duplicates, %d%% packet loss%n",&pl,&match) && match) ||
  400. (sscanf(buf,"%*d packets transmitted, %*d received, +%*d duplicates, %d%% packet loss%n",&pl,&match) && match) ||
  401. (sscanf(buf,"%*d packets transmitted, %*d packets received, %d%% packet loss%n",&pl,&match) && match) ||
  402. (sscanf(buf,"%*d packets transmitted, %*d packets received, %d%% loss, time%n",&pl,&match) && match) ||
  403. (sscanf(buf,"%*d packets transmitted, %*d received, %d%% loss, time%n",&pl,&match) && match) ||
  404. (sscanf(buf,"%*d packets transmitted, %*d received, %d%% packet loss, time%n",&pl,&match) && match) ||
  405. (sscanf(buf,"%*d packets transmitted, %*d received, +%*d errors, %d%% packet loss%n",&pl,&match) && match) ||
  406. (sscanf(buf,"%*d packets transmitted %*d received, +%*d errors, %d%% packet loss%n",&pl,&match) && match) ||
  407. (sscanf(buf,"%*[^(](%d%% %*[^)])%n",&pl,&match) && match)
  408. )
  409. continue;
  410. /* get the round trip average */
  411. else
  412. if((sscanf(buf,"round-trip min/avg/max = %*f/%f/%*f%n",&rta,&match) && match) ||
  413. (sscanf(buf,"round-trip min/avg/max/mdev = %*f/%f/%*f/%*f%n",&rta,&match) && match) ||
  414. (sscanf(buf,"round-trip min/avg/max/sdev = %*f/%f/%*f/%*f%n",&rta,&match) && match) ||
  415. (sscanf(buf,"round-trip min/avg/max/stddev = %*f/%f/%*f/%*f%n",&rta,&match) && match) ||
  416. (sscanf(buf,"round-trip min/avg/max/std-dev = %*f/%f/%*f/%*f%n",&rta,&match) && match) ||
  417. (sscanf(buf,"round-trip (ms) min/avg/max = %*f/%f/%*f%n",&rta,&match) && match) ||
  418. (sscanf(buf,"round-trip (ms) min/avg/max/stddev = %*f/%f/%*f/%*f%n",&rta,&match) && match) ||
  419. (sscanf(buf,"rtt min/avg/max/mdev = %*f/%f/%*f/%*f ms%n",&rta,&match) && match) ||
  420. (sscanf(buf, "%*[^=] = %*fms, %*[^=] = %*fms, %*[^=] = %fms%n", &rta, &match) && match)
  421. )
  422. continue;
  423. }
  424. /* this is needed because there is no rta if all packets are lost */
  425. if (pl == 100)
  426. rta = crta;
  427. /* check stderr, setting at least WARNING if there is output here */
  428. /* Add warning into warn_text */
  429. while (fgets (buf, MAX_INPUT_BUFFER - 1, child_stderr)) {
  430. if (
  431. ! strstr(buf,"WARNING - no SO_TIMESTAMP support, falling back to SIOCGSTAMP")
  432. && ! strstr(buf,"Warning: time of day goes back")
  433. ) {
  434. if (verbose >= 3) {
  435. printf("Got stderr: %s", buf);
  436. }
  437. if ((result=error_scan(buf, addr)) == STATE_OK) {
  438. result = STATE_WARNING;
  439. if (warn_text == NULL) {
  440. warn_text = strdup(_("System call sent warnings to stderr "));
  441. } else {
  442. xasprintf(&warn_text, "%s %s", warn_text, _("System call sent warnings to stderr "));
  443. }
  444. }
  445. }
  446. }
  447. (void) fclose (child_stderr);
  448. spclose (child_process);
  449. if (warn_text == NULL)
  450. warn_text = strdup("");
  451. return result;
  452. }
  453. int
  454. error_scan (char buf[MAX_INPUT_BUFFER], const char *addr)
  455. {
  456. if (strstr (buf, "Network is unreachable") ||
  457. strstr (buf, "Destination Net Unreachable")
  458. )
  459. die (STATE_CRITICAL, _("CRITICAL - Network Unreachable (%s)\n"), addr);
  460. else if (strstr (buf, "Destination Host Unreachable"))
  461. die (STATE_CRITICAL, _("CRITICAL - Host Unreachable (%s)\n"), addr);
  462. else if (strstr (buf, "Destination Port Unreachable"))
  463. die (STATE_CRITICAL, _("CRITICAL - Bogus ICMP: Port Unreachable (%s)\n"), addr);
  464. else if (strstr (buf, "Destination Protocol Unreachable"))
  465. die (STATE_CRITICAL, _("CRITICAL - Bogus ICMP: Protocol Unreachable (%s)\n"), addr);
  466. else if (strstr (buf, "Destination Net Prohibited"))
  467. die (STATE_CRITICAL, _("CRITICAL - Network Prohibited (%s)\n"), addr);
  468. else if (strstr (buf, "Destination Host Prohibited"))
  469. die (STATE_CRITICAL, _("CRITICAL - Host Prohibited (%s)\n"), addr);
  470. else if (strstr (buf, "Packet filtered"))
  471. die (STATE_CRITICAL, _("CRITICAL - Packet Filtered (%s)\n"), addr);
  472. else if (strstr (buf, "unknown host" ))
  473. die (STATE_CRITICAL, _("CRITICAL - Host not found (%s)\n"), addr);
  474. else if (strstr (buf, "Time to live exceeded"))
  475. die (STATE_CRITICAL, _("CRITICAL - Time to live exceeded (%s)\n"), addr);
  476. else if (strstr (buf, "Destination unreachable: "))
  477. die (STATE_CRITICAL, _("CRITICAL - Destination Unreachable (%s)\n"), addr);
  478. if (strstr (buf, "(DUP!)") || strstr (buf, "DUPLICATES FOUND")) {
  479. if (warn_text == NULL)
  480. warn_text = strdup (_(WARN_DUPLICATES));
  481. else if (! strstr (warn_text, _(WARN_DUPLICATES)) &&
  482. xasprintf (&warn_text, "%s %s", warn_text, _(WARN_DUPLICATES)) == -1)
  483. die (STATE_UNKNOWN, _("Unable to realloc warn_text\n"));
  484. return (STATE_WARNING);
  485. }
  486. return (STATE_OK);
  487. }
  488. void
  489. print_help (void)
  490. {
  491. print_revision (progname, NP_VERSION);
  492. printf ("Copyright (c) 1999 Ethan Galstad <nagios@nagios.org>\n");
  493. printf (COPYRIGHT, copyright, email);
  494. printf (_("Use ping to check connection statistics for a remote host."));
  495. printf ("\n\n");
  496. print_usage ();
  497. printf (UT_HELP_VRSN);
  498. printf (UT_EXTRA_OPTS);
  499. printf (UT_IPv46);
  500. printf (" %s\n", "-H, --hostname=HOST");
  501. printf (" %s\n", _("host to ping"));
  502. printf (" %s\n", "-w, --warning=THRESHOLD");
  503. printf (" %s\n", _("warning threshold pair"));
  504. printf (" %s\n", "-c, --critical=THRESHOLD");
  505. printf (" %s\n", _("critical threshold pair"));
  506. printf (" %s\n", "-p, --packets=INTEGER");
  507. printf (" %s ", _("number of ICMP ECHO packets to send"));
  508. printf (_("(Default: %d)\n"), DEFAULT_MAX_PACKETS);
  509. printf (" %s\n", "-s, --show-resolution");
  510. printf (" %s\n", _("show name resolution in the plugin output (DNS & IP)"));
  511. printf (" %s\n", "-L, --link");
  512. printf (" %s\n", _("show HTML in the plugin output (obsoleted by urlize)"));
  513. printf (UT_CONN_TIMEOUT, DEFAULT_SOCKET_TIMEOUT);
  514. printf ("\n");
  515. printf ("%s\n", _("THRESHOLD is <rta>,<pl>% where <rta> is the round trip average travel"));
  516. printf ("%s\n", _("time (ms) which triggers a WARNING or CRITICAL state, and <pl> is the"));
  517. printf ("%s\n", _("percentage of packet loss to trigger an alarm state."));
  518. printf ("\n");
  519. printf ("%s\n", _("This plugin uses the ping command to probe the specified host for packet loss"));
  520. printf ("%s\n", _("(percentage) and round trip average (milliseconds). It can produce HTML output"));
  521. printf ("%s\n", _("linking to a traceroute CGI contributed by Ian Cass. The CGI can be found in"));
  522. printf ("%s\n", _("the contrib area of the downloads section at http://www.nagios.org/"));
  523. printf (UT_SUPPORT);
  524. }
  525. void
  526. print_usage (void)
  527. {
  528. printf ("%s\n", _("Usage:"));
  529. printf ("%s -H <host_address> -w <wrta>,<wpl>%% -c <crta>,<cpl>%%\n", progname);
  530. printf (" [-p packets] [-t timeout] [-4|-6]\n");
  531. }