4
0

check_ping.c 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631
  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. printf ("%s\n", cmd);
  120. die (STATE_UNKNOWN,
  121. _("CRITICAL - Could not interpret output from ping command\n"));
  122. }
  123. if (pl >= cpl || rta >= crta || rta < 0)
  124. this_result = STATE_CRITICAL;
  125. else if (pl >= wpl || rta >= wrta)
  126. this_result = STATE_WARNING;
  127. else if (pl >= 0 && rta >= 0)
  128. this_result = max_state (STATE_OK, this_result);
  129. if (n_addresses > 1 && this_result != STATE_UNKNOWN)
  130. die (STATE_OK, "%s is alive\n", addresses[i]);
  131. if (display_html == TRUE)
  132. printf ("<A HREF='%s/traceroute.cgi?%s'>", CGIURL, addresses[i]);
  133. if (pl == 100)
  134. printf (_("PING %s - %sPacket loss = %d%%"), state_text (this_result), warn_text,
  135. pl);
  136. else
  137. printf (_("PING %s - %sPacket loss = %d%%, RTA = %2.2f ms"),
  138. state_text (this_result), warn_text, pl, rta);
  139. if (show_resolution) {
  140. if (strcmp(ping_name, ping_ip_addr) == 0)
  141. printf(" - %s", ping_name);
  142. else
  143. printf(" - %s (%s)", ping_name, ping_ip_addr);
  144. }
  145. if (display_html == TRUE)
  146. printf ("</A>");
  147. /* Print performance data */
  148. printf("|%s", fperfdata ("rta", (double) rta, "ms",
  149. wrta>0?TRUE:FALSE, wrta,
  150. crta>0?TRUE:FALSE, crta,
  151. TRUE, 0, FALSE, 0));
  152. printf(" %s\n", perfdata ("pl", (long) pl, "%",
  153. wpl>0?TRUE:FALSE, wpl,
  154. cpl>0?TRUE:FALSE, cpl,
  155. TRUE, 0, FALSE, 0));
  156. if (verbose >= 2)
  157. printf ("%f:%d%% %f:%d%%\n", wrta, wpl, crta, cpl);
  158. result = max_state (result, this_result);
  159. free (rawcmd);
  160. free (cmd);
  161. }
  162. return result;
  163. }
  164. /* process command-line arguments */
  165. int
  166. process_arguments (int argc, char **argv)
  167. {
  168. int c = 1;
  169. char *ptr;
  170. int option = 0;
  171. static struct option longopts[] = {
  172. STD_LONG_OPTS,
  173. {"packets", required_argument, 0, 'p'},
  174. {"show-resolution", no_argument, 0, 's'},
  175. {"nohtml", no_argument, 0, 'n'},
  176. {"link", no_argument, 0, 'L'},
  177. {"use-ipv4", no_argument, 0, '4'},
  178. {"use-ipv6", no_argument, 0, '6'},
  179. {0, 0, 0, 0}
  180. };
  181. if (argc < 2)
  182. return ERROR;
  183. for (c = 1; c < argc; c++) {
  184. if (strcmp ("-to", argv[c]) == 0)
  185. strcpy (argv[c], "-t");
  186. if (strcmp ("-nohtml", argv[c]) == 0)
  187. strcpy (argv[c], "-n");
  188. }
  189. while (1) {
  190. c = getopt_long (argc, argv, "VvhsnL46t:c:w:H:p:", longopts, &option);
  191. if (c == -1 || c == EOF)
  192. break;
  193. switch (c) {
  194. case '?': /* usage */
  195. usage5 ();
  196. case 'h': /* help */
  197. print_help ();
  198. exit (STATE_OK);
  199. break;
  200. case 'V': /* version */
  201. print_revision (progname, NP_VERSION);
  202. exit (STATE_OK);
  203. break;
  204. case 't': /* timeout period */
  205. timeout_interval = parse_timeout_string(optarg);
  206. break;
  207. case 'v': /* verbose mode */
  208. verbose++;
  209. break;
  210. case '4': /* IPv4 only */
  211. address_family = AF_INET;
  212. break;
  213. case '6': /* IPv6 only */
  214. #ifdef USE_IPV6
  215. address_family = AF_INET6;
  216. #else
  217. usage (_("IPv6 support not available\n"));
  218. #endif
  219. break;
  220. case 'H': /* hostname */
  221. ptr=optarg;
  222. while (1) {
  223. n_addresses++;
  224. if (n_addresses > max_addr) {
  225. max_addr *= 2;
  226. addresses = realloc (addresses, sizeof(char*) * max_addr);
  227. if (addresses == NULL)
  228. die (STATE_UNKNOWN, _("Could not realloc() addresses\n"));
  229. }
  230. addresses[n_addresses-1] = ptr;
  231. if ((ptr = index (ptr, ','))) {
  232. strcpy (ptr, "");
  233. ptr += sizeof(char);
  234. } else {
  235. break;
  236. }
  237. }
  238. break;
  239. case 'p': /* number of packets to send */
  240. if (is_intnonneg (optarg))
  241. max_packets = atoi (optarg);
  242. else
  243. usage2 (_("<max_packets> (%s) must be a non-negative number\n"), optarg);
  244. break;
  245. case 's':
  246. show_resolution = TRUE;
  247. break;
  248. case 'n': /* no HTML */
  249. display_html = FALSE;
  250. break;
  251. case 'L': /* show HTML */
  252. display_html = TRUE;
  253. break;
  254. case 'c':
  255. get_threshold (optarg, &crta, &cpl);
  256. break;
  257. case 'w':
  258. get_threshold (optarg, &wrta, &wpl);
  259. break;
  260. }
  261. }
  262. c = optind;
  263. if (c == argc)
  264. return validate_arguments ();
  265. if (addresses[0] == NULL) {
  266. if (is_host (argv[c]) == FALSE) {
  267. usage2 (_("Invalid hostname/address"), argv[c]);
  268. } else {
  269. addresses[0] = argv[c++];
  270. n_addresses++;
  271. if (c == argc)
  272. return validate_arguments ();
  273. }
  274. }
  275. if (wpl == UNKNOWN_PACKET_LOSS) {
  276. if (is_intpercent (argv[c]) == FALSE) {
  277. printf (_("<wpl> (%s) must be an integer percentage\n"), argv[c]);
  278. return ERROR;
  279. } else {
  280. wpl = atoi (argv[c++]);
  281. if (c == argc)
  282. return validate_arguments ();
  283. }
  284. }
  285. if (cpl == UNKNOWN_PACKET_LOSS) {
  286. if (is_intpercent (argv[c]) == FALSE) {
  287. printf (_("<cpl> (%s) must be an integer percentage\n"), argv[c]);
  288. return ERROR;
  289. } else {
  290. cpl = atoi (argv[c++]);
  291. if (c == argc)
  292. return validate_arguments ();
  293. }
  294. }
  295. if (wrta < 0.0) {
  296. if (is_negative (argv[c])) {
  297. printf (_("<wrta> (%s) must be a non-negative number\n"), argv[c]);
  298. return ERROR;
  299. } else {
  300. wrta = atof (argv[c++]);
  301. if (c == argc)
  302. return validate_arguments ();
  303. }
  304. }
  305. if (crta < 0.0) {
  306. if (is_negative (argv[c])) {
  307. printf (_("<crta> (%s) must be a non-negative number\n"), argv[c]);
  308. return ERROR;
  309. } else {
  310. crta = atof (argv[c++]);
  311. if (c == argc)
  312. return validate_arguments ();
  313. }
  314. }
  315. if (max_packets == -1) {
  316. if (is_intnonneg (argv[c])) {
  317. max_packets = atoi (argv[c++]);
  318. } else {
  319. printf (_("<max_packets> (%s) must be a non-negative number\n"), argv[c]);
  320. return ERROR;
  321. }
  322. }
  323. return validate_arguments ();
  324. }
  325. int
  326. get_threshold (char *arg, float *trta, int *tpl)
  327. {
  328. if (is_intnonneg (arg) && sscanf (arg, "%f", trta) == 1)
  329. return OK;
  330. else if (strpbrk (arg, ",:") && strstr (arg, "%") && sscanf (arg, "%f%*[:,]%d%%", trta, tpl) == 2)
  331. return OK;
  332. else if (strstr (arg, "%") && sscanf (arg, "%d%%", tpl) == 1)
  333. return OK;
  334. usage2 (_("%s: Warning threshold must be integer or percentage!\n\n"), arg);
  335. return STATE_UNKNOWN;
  336. }
  337. int
  338. validate_arguments ()
  339. {
  340. float max_seconds;
  341. int i;
  342. if (wrta < 0.0) {
  343. printf (_("<wrta> was not set\n"));
  344. return ERROR;
  345. }
  346. else if (crta < 0.0) {
  347. printf (_("<crta> was not set\n"));
  348. return ERROR;
  349. }
  350. else if (wpl == UNKNOWN_PACKET_LOSS) {
  351. printf (_("<wpl> was not set\n"));
  352. return ERROR;
  353. }
  354. else if (cpl == UNKNOWN_PACKET_LOSS) {
  355. printf (_("<cpl> was not set\n"));
  356. return ERROR;
  357. }
  358. else if (wrta > crta) {
  359. printf (_("<wrta> (%f) cannot be larger than <crta> (%f)\n"), wrta, crta);
  360. return ERROR;
  361. }
  362. else if (wpl > cpl) {
  363. printf (_("<wpl> (%d) cannot be larger than <cpl> (%d)\n"), wpl, cpl);
  364. return ERROR;
  365. }
  366. if (max_packets == -1)
  367. max_packets = DEFAULT_MAX_PACKETS;
  368. max_seconds = crta / 1000.0 * max_packets + max_packets;
  369. if (max_seconds > timeout_interval)
  370. timeout_interval = (int)max_seconds;
  371. for (i=0; i<n_addresses; i++) {
  372. if (is_host(addresses[i]) == FALSE)
  373. usage2 (_("Invalid hostname/address"), addresses[i]);
  374. }
  375. if (n_addresses == 0) {
  376. usage (_("You must specify a server address or host name"));
  377. }
  378. return OK;
  379. }
  380. int
  381. run_ping (const char *cmd, const char *addr)
  382. {
  383. char buf[MAX_INPUT_BUFFER];
  384. int result = STATE_UNKNOWN;
  385. int match;
  386. if ((child_process = spopen (cmd)) == NULL)
  387. die (STATE_UNKNOWN, _("Could not open pipe: %s\n"), cmd);
  388. child_stderr = fdopen (child_stderr_array[fileno (child_process)], "r");
  389. if (child_stderr == NULL)
  390. printf (_("Cannot open stderr for %s\n"), cmd);
  391. while (fgets (buf, MAX_INPUT_BUFFER - 1, child_process)) {
  392. if (verbose >= 3)
  393. printf("Output: %s", buf);
  394. result = max_state (result, error_scan (buf, addr));
  395. if(sscanf(buf, "PING %255s (%63[^)]", &ping_name, &ping_ip_addr))
  396. continue;
  397. /* get the percent loss statistics */
  398. match = 0;
  399. if((sscanf(buf,"%*d packets transmitted, %*d packets received, +%*d errors, %d%% packet loss%n",&pl,&match) && match) ||
  400. (sscanf(buf,"%*d packets transmitted, %*d packets received, +%*d duplicates, %d%% packet loss%n",&pl,&match) && match) ||
  401. (sscanf(buf,"%*d packets transmitted, %*d received, +%*d duplicates, %d%% packet loss%n",&pl,&match) && match) ||
  402. (sscanf(buf,"%*d packets transmitted, %*d packets received, %d%% packet loss%n",&pl,&match) && match) ||
  403. (sscanf(buf,"%*d packets transmitted, %*d packets received, %d%% loss, time%n",&pl,&match) && match) ||
  404. (sscanf(buf,"%*d packets transmitted, %*d received, %d%% loss, time%n",&pl,&match) && match) ||
  405. (sscanf(buf,"%*d packets transmitted, %*d received, %d%% packet loss, time%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 packets transmitted %*d received, +%*d errors, %d%% packet loss%n",&pl,&match) && match) ||
  408. (sscanf(buf,"%*[^(](%d%% %*[^)])%n",&pl,&match) && match)
  409. )
  410. continue;
  411. /* get the round trip average */
  412. else
  413. if((sscanf(buf,"round-trip min/avg/max = %*f/%f/%*f%n",&rta,&match) && match) ||
  414. (sscanf(buf,"round-trip min/avg/max/mdev = %*f/%f/%*f/%*f%n",&rta,&match) && match) ||
  415. (sscanf(buf,"round-trip min/avg/max/sdev = %*f/%f/%*f/%*f%n",&rta,&match) && match) ||
  416. (sscanf(buf,"round-trip min/avg/max/stddev = %*f/%f/%*f/%*f%n",&rta,&match) && match) ||
  417. (sscanf(buf,"round-trip min/avg/max/std-dev = %*f/%f/%*f/%*f%n",&rta,&match) && match) ||
  418. (sscanf(buf,"round-trip (ms) min/avg/max = %*f/%f/%*f%n",&rta,&match) && match) ||
  419. (sscanf(buf,"round-trip (ms) min/avg/max/stddev = %*f/%f/%*f/%*f%n",&rta,&match) && match) ||
  420. (sscanf(buf,"rtt min/avg/max/mdev = %*f/%f/%*f/%*f ms%n",&rta,&match) && match) ||
  421. (sscanf(buf, "%*[^=] = %*fms, %*[^=] = %*fms, %*[^=] = %fms%n", &rta, &match) && match)
  422. )
  423. continue;
  424. }
  425. /* this is needed because there is no rta if all packets are lost */
  426. if (pl == 100)
  427. rta = crta;
  428. /* check stderr, setting at least WARNING if there is output here */
  429. /* Add warning into warn_text */
  430. while (fgets (buf, MAX_INPUT_BUFFER - 1, child_stderr)) {
  431. if (
  432. ! strstr(buf,"WARNING - no SO_TIMESTAMP support, falling back to SIOCGSTAMP")
  433. && ! strstr(buf,"Warning: time of day goes back")
  434. ) {
  435. if (verbose >= 3) {
  436. printf("Got stderr: %s", buf);
  437. }
  438. if ((result=error_scan(buf, addr)) == STATE_OK) {
  439. result = STATE_WARNING;
  440. if (warn_text == NULL) {
  441. warn_text = strdup(_("System call sent warnings to stderr "));
  442. } else {
  443. xasprintf(&warn_text, "%s %s", warn_text, _("System call sent warnings to stderr "));
  444. }
  445. }
  446. }
  447. }
  448. (void) fclose (child_stderr);
  449. spclose (child_process);
  450. if (warn_text == NULL)
  451. warn_text = strdup("");
  452. return result;
  453. }
  454. int
  455. error_scan (char buf[MAX_INPUT_BUFFER], const char *addr)
  456. {
  457. if (strstr (buf, "Network is unreachable") ||
  458. strstr (buf, "Destination Net Unreachable")
  459. )
  460. die (STATE_CRITICAL, _("CRITICAL - Network Unreachable (%s)\n"), addr);
  461. else if (strstr (buf, "Destination Host Unreachable"))
  462. die (STATE_CRITICAL, _("CRITICAL - Host Unreachable (%s)\n"), addr);
  463. else if (strstr (buf, "Destination Port Unreachable"))
  464. die (STATE_CRITICAL, _("CRITICAL - Bogus ICMP: Port Unreachable (%s)\n"), addr);
  465. else if (strstr (buf, "Destination Protocol Unreachable"))
  466. die (STATE_CRITICAL, _("CRITICAL - Bogus ICMP: Protocol Unreachable (%s)\n"), addr);
  467. else if (strstr (buf, "Destination Net Prohibited"))
  468. die (STATE_CRITICAL, _("CRITICAL - Network Prohibited (%s)\n"), addr);
  469. else if (strstr (buf, "Destination Host Prohibited"))
  470. die (STATE_CRITICAL, _("CRITICAL - Host Prohibited (%s)\n"), addr);
  471. else if (strstr (buf, "Packet filtered"))
  472. die (STATE_CRITICAL, _("CRITICAL - Packet Filtered (%s)\n"), addr);
  473. else if (strstr (buf, "unknown host" ))
  474. die (STATE_CRITICAL, _("CRITICAL - Host not found (%s)\n"), addr);
  475. else if (strstr (buf, "Time to live exceeded"))
  476. die (STATE_CRITICAL, _("CRITICAL - Time to live exceeded (%s)\n"), addr);
  477. else if (strstr (buf, "Destination unreachable: "))
  478. die (STATE_CRITICAL, _("CRITICAL - Destination Unreachable (%s)\n"), addr);
  479. if (strstr (buf, "(DUP!)") || strstr (buf, "DUPLICATES FOUND")) {
  480. if (warn_text == NULL)
  481. warn_text = strdup (_(WARN_DUPLICATES));
  482. else if (! strstr (warn_text, _(WARN_DUPLICATES)) &&
  483. xasprintf (&warn_text, "%s %s", warn_text, _(WARN_DUPLICATES)) == -1)
  484. die (STATE_UNKNOWN, _("Unable to realloc warn_text\n"));
  485. return (STATE_WARNING);
  486. }
  487. return (STATE_OK);
  488. }
  489. void
  490. print_help (void)
  491. {
  492. print_revision (progname, NP_VERSION);
  493. printf ("Copyright (c) 1999 Ethan Galstad <nagios@nagios.org>\n");
  494. printf (COPYRIGHT, copyright, email);
  495. printf (_("Use ping to check connection statistics for a remote host."));
  496. printf ("\n\n");
  497. print_usage ();
  498. printf (UT_HELP_VRSN);
  499. printf (UT_EXTRA_OPTS);
  500. printf (UT_IPv46);
  501. printf (" %s\n", "-H, --hostname=HOST");
  502. printf (" %s\n", _("host to ping"));
  503. printf (" %s\n", "-w, --warning=THRESHOLD");
  504. printf (" %s\n", _("warning threshold pair"));
  505. printf (" %s\n", "-c, --critical=THRESHOLD");
  506. printf (" %s\n", _("critical threshold pair"));
  507. printf (" %s\n", "-p, --packets=INTEGER");
  508. printf (" %s ", _("number of ICMP ECHO packets to send"));
  509. printf (_("(Default: %d)\n"), DEFAULT_MAX_PACKETS);
  510. printf (" %s\n", "-s, --show-resolution");
  511. printf (" %s\n", _("show name resolution in the plugin output (DNS & IP)"));
  512. printf (" %s\n", "-L, --link");
  513. printf (" %s\n", _("show HTML in the plugin output (obsoleted by urlize)"));
  514. printf (UT_CONN_TIMEOUT, DEFAULT_SOCKET_TIMEOUT);
  515. printf ("\n");
  516. printf ("%s\n", _("THRESHOLD is <rta>,<pl>% where <rta> is the round trip average travel"));
  517. printf ("%s\n", _("time (ms) which triggers a WARNING or CRITICAL state, and <pl> is the"));
  518. printf ("%s\n", _("percentage of packet loss to trigger an alarm state."));
  519. printf ("\n");
  520. printf ("%s\n", _("This plugin uses the ping command to probe the specified host for packet loss"));
  521. printf ("%s\n", _("(percentage) and round trip average (milliseconds). It can produce HTML output"));
  522. printf ("%s\n", _("linking to a traceroute CGI contributed by Ian Cass. The CGI can be found in"));
  523. printf ("%s\n", _("the contrib area of the downloads section at http://www.nagios.org/"));
  524. printf (UT_SUPPORT);
  525. }
  526. void
  527. print_usage (void)
  528. {
  529. printf ("%s\n", _("Usage:"));
  530. printf ("%s -H <host_address> -w <wrta>,<wpl>%% -c <crta>,<cpl>%%\n", progname);
  531. printf (" [-p packets] [-t timeout] [-4|-6]\n");
  532. }