Advertisement
Guest User

Untitled

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