diff options
author | RincewindsHat <12514511+RincewindsHat@users.noreply.github.com> | 2023-10-08 23:57:37 (GMT) |
---|---|---|
committer | RincewindsHat <12514511+RincewindsHat@users.noreply.github.com> | 2023-10-08 23:57:37 (GMT) |
commit | 9da06d562515d6b443e4bbb54652a88f6a1cb4ca (patch) | |
tree | 9289bb57581973b7ba9f2a6e119a37713cf2ca24 /plugins-root | |
parent | c568ad207c7284f301120698d20aec57ed4f24f6 (diff) | |
download | monitoring-plugins-9da06d562515d6b443e4bbb54652a88f6a1cb4ca.tar.gz |
Do some more formatting
Diffstat (limited to 'plugins-root')
-rw-r--r-- | plugins-root/check_icmp.c | 214 |
1 files changed, 107 insertions, 107 deletions
diff --git a/plugins-root/check_icmp.c b/plugins-root/check_icmp.c index 5a9485d..1573dca 100644 --- a/plugins-root/check_icmp.c +++ b/plugins-root/check_icmp.c | |||
@@ -109,24 +109,24 @@ typedef struct rta_host { | |||
109 | unsigned char icmp_type, icmp_code; /* type and code from errors */ | 109 | unsigned char icmp_type, icmp_code; /* type and code from errors */ |
110 | unsigned short flags; /* control/status flags */ | 110 | unsigned short flags; /* control/status flags */ |
111 | double rta; /* measured RTA */ | 111 | double rta; /* measured RTA */ |
112 | int rta_status; | 112 | int rta_status; // check result for RTA checks |
113 | double rtmax; /* max rtt */ | 113 | double rtmax; /* max rtt */ |
114 | double rtmin; /* min rtt */ | 114 | double rtmin; /* min rtt */ |
115 | double jitter; /* measured jitter */ | 115 | double jitter; /* measured jitter */ |
116 | int jitter_status; | 116 | int jitter_status; // check result for Jitter checks |
117 | double jitter_max; /* jitter rtt */ | 117 | double jitter_max; /* jitter rtt maximum */ |
118 | double jitter_min; /* jitter rtt */ | 118 | double jitter_min; /* jitter rtt minimum */ |
119 | double EffectiveLatency; | 119 | double EffectiveLatency; |
120 | double mos; /* Mean opnion score */ | 120 | double mos; /* Mean opnion score */ |
121 | int mos_status; | 121 | int mos_status; // check result for MOS checks |
122 | double score; /* score */ | 122 | double score; /* score */ |
123 | int score_status; | 123 | int score_status; // check result for score checks |
124 | u_int last_tdiff; | 124 | u_int last_tdiff; |
125 | u_int last_icmp_seq; /* Last ICMP_SEQ to check out of order pkts */ | 125 | u_int last_icmp_seq; /* Last ICMP_SEQ to check out of order pkts */ |
126 | unsigned char pl; /* measured packet loss */ | 126 | unsigned char pl; /* measured packet loss */ |
127 | int pl_status; | 127 | int pl_status; // check result for packet loss checks |
128 | struct rta_host *next; /* linked list */ | 128 | struct rta_host *next; /* linked list */ |
129 | int order_status; | 129 | int order_status; // check result for packet order checks |
130 | } rta_host; | 130 | } rta_host; |
131 | 131 | ||
132 | #define FLAG_LOST_CAUSE 0x01 /* decidedly dead target. */ | 132 | #define FLAG_LOST_CAUSE 0x01 /* decidedly dead target. */ |
@@ -228,7 +228,7 @@ static void finish(int); | |||
228 | static void crash(const char *, ...); | 228 | static void crash(const char *, ...); |
229 | 229 | ||
230 | /** external **/ | 230 | /** external **/ |
231 | extern int optind, opterr, optopt; | 231 | extern int optind; |
232 | extern char *optarg; | 232 | extern char *optarg; |
233 | extern char **environ; | 233 | extern char **environ; |
234 | 234 | ||
@@ -459,7 +459,7 @@ main(int argc, char **argv) | |||
459 | * that before pointer magic (esp. on network data) */ | 459 | * that before pointer magic (esp. on network data) */ |
460 | icmp_sockerrno = udp_sockerrno = tcp_sockerrno = sockets = 0; | 460 | icmp_sockerrno = udp_sockerrno = tcp_sockerrno = sockets = 0; |
461 | 461 | ||
462 | address_family = -1; | 462 | address_family = -1; |
463 | int icmp_proto = IPPROTO_ICMP; | 463 | int icmp_proto = IPPROTO_ICMP; |
464 | 464 | ||
465 | /* get calling name the old-fashioned way for portability instead | 465 | /* get calling name the old-fashioned way for portability instead |
@@ -1361,7 +1361,7 @@ finish(int sig) | |||
1361 | status = STATE_CRITICAL; | 1361 | status = STATE_CRITICAL; |
1362 | host->rta_status=STATE_CRITICAL; | 1362 | host->rta_status=STATE_CRITICAL; |
1363 | } else if(status!=STATE_CRITICAL && (rta >= warn.rta)) { | 1363 | } else if(status!=STATE_CRITICAL && (rta >= warn.rta)) { |
1364 | this_status = (this_status <= STATE_WARNING ? STATE_WARNING : this_status) | 1364 | this_status = (this_status <= STATE_WARNING ? STATE_WARNING : this_status); |
1365 | status = STATE_WARNING; | 1365 | status = STATE_WARNING; |
1366 | host->rta_status=STATE_WARNING; | 1366 | host->rta_status=STATE_WARNING; |
1367 | } | 1367 | } |
@@ -1373,7 +1373,7 @@ finish(int sig) | |||
1373 | status = STATE_CRITICAL; | 1373 | status = STATE_CRITICAL; |
1374 | host->pl_status=STATE_CRITICAL; | 1374 | host->pl_status=STATE_CRITICAL; |
1375 | } else if(status!=STATE_CRITICAL && (pl >= warn.pl)) { | 1375 | } else if(status!=STATE_CRITICAL && (pl >= warn.pl)) { |
1376 | this_status = (this_status <= STATE_WARNING ? STATE_WARNING : this_status) | 1376 | this_status = (this_status <= STATE_WARNING ? STATE_WARNING : this_status); |
1377 | status = STATE_WARNING; | 1377 | status = STATE_WARNING; |
1378 | host->pl_status=STATE_WARNING; | 1378 | host->pl_status=STATE_WARNING; |
1379 | } | 1379 | } |
@@ -1385,7 +1385,7 @@ finish(int sig) | |||
1385 | status = STATE_CRITICAL; | 1385 | status = STATE_CRITICAL; |
1386 | host->jitter_status=STATE_CRITICAL; | 1386 | host->jitter_status=STATE_CRITICAL; |
1387 | } else if(status!=STATE_CRITICAL && (host->jitter >= warn.jitter)) { | 1387 | } else if(status!=STATE_CRITICAL && (host->jitter >= warn.jitter)) { |
1388 | this_status = (this_status <= STATE_WARNING ? STATE_WARNING : this_status) | 1388 | this_status = (this_status <= STATE_WARNING ? STATE_WARNING : this_status); |
1389 | status = STATE_WARNING; | 1389 | status = STATE_WARNING; |
1390 | host->jitter_status=STATE_WARNING; | 1390 | host->jitter_status=STATE_WARNING; |
1391 | } | 1391 | } |
@@ -1397,7 +1397,7 @@ finish(int sig) | |||
1397 | status = STATE_CRITICAL; | 1397 | status = STATE_CRITICAL; |
1398 | host->mos_status=STATE_CRITICAL; | 1398 | host->mos_status=STATE_CRITICAL; |
1399 | } else if(status!=STATE_CRITICAL && (host->mos <= warn.mos)) { | 1399 | } else if(status!=STATE_CRITICAL && (host->mos <= warn.mos)) { |
1400 | this_status = (this_status <= STATE_WARNING ? STATE_WARNING : this_status) | 1400 | this_status = (this_status <= STATE_WARNING ? STATE_WARNING : this_status); |
1401 | status = STATE_WARNING; | 1401 | status = STATE_WARNING; |
1402 | host->mos_status=STATE_WARNING; | 1402 | host->mos_status=STATE_WARNING; |
1403 | } | 1403 | } |
@@ -1409,7 +1409,7 @@ finish(int sig) | |||
1409 | status = STATE_CRITICAL; | 1409 | status = STATE_CRITICAL; |
1410 | host->score_status=STATE_CRITICAL; | 1410 | host->score_status=STATE_CRITICAL; |
1411 | } else if(status!=STATE_CRITICAL && (host->score <= warn.score)) { | 1411 | } else if(status!=STATE_CRITICAL && (host->score <= warn.score)) { |
1412 | this_status = (this_status <= STATE_WARNING ? STATE_WARNING : this_status) | 1412 | this_status = (this_status <= STATE_WARNING ? STATE_WARNING : this_status); |
1413 | status = STATE_WARNING; | 1413 | status = STATE_WARNING; |
1414 | host->score_status=STATE_WARNING; | 1414 | host->score_status=STATE_WARNING; |
1415 | } | 1415 | } |
@@ -1763,7 +1763,7 @@ add_target(char *arg) | |||
1763 | } | 1763 | } |
1764 | break; | 1764 | break; |
1765 | } | 1765 | } |
1766 | freeaddrinfo(res); | 1766 | freeaddrinfo(res); |
1767 | 1767 | ||
1768 | return 0; | 1768 | return 0; |
1769 | } | 1769 | } |
@@ -1985,91 +1985,91 @@ icmp_checksum(uint16_t *p, size_t n) | |||
1985 | void | 1985 | void |
1986 | print_help(void) | 1986 | print_help(void) |
1987 | { | 1987 | { |
1988 | /*print_revision (progname);*/ /* FIXME: Why? */ | 1988 | /*print_revision (progname);*/ /* FIXME: Why? */ |
1989 | printf ("Copyright (c) 2005 Andreas Ericsson <ae@op5.se>\n"); | 1989 | printf ("Copyright (c) 2005 Andreas Ericsson <ae@op5.se>\n"); |
1990 | 1990 | ||
1991 | printf (COPYRIGHT, copyright, email); | 1991 | printf (COPYRIGHT, copyright, email); |
1992 | 1992 | ||
1993 | printf ("\n\n"); | 1993 | printf ("\n\n"); |
1994 | 1994 | ||
1995 | print_usage (); | 1995 | print_usage (); |
1996 | 1996 | ||
1997 | printf (UT_HELP_VRSN); | 1997 | printf (UT_HELP_VRSN); |
1998 | printf (UT_EXTRA_OPTS); | 1998 | printf (UT_EXTRA_OPTS); |
1999 | 1999 | ||
2000 | printf (" %s\n", "-H"); | 2000 | printf (" %s\n", "-H"); |
2001 | printf (" %s\n", _("specify a target")); | 2001 | printf (" %s\n", _("specify a target")); |
2002 | printf (" %s\n", "[-4|-6]"); | 2002 | printf (" %s\n", "[-4|-6]"); |
2003 | printf (" %s\n", _("Use IPv4 (default) or IPv6 to communicate with the targets")); | 2003 | printf (" %s\n", _("Use IPv4 (default) or IPv6 to communicate with the targets")); |
2004 | printf (" %s\n", "-w"); | 2004 | printf (" %s\n", "-w"); |
2005 | printf (" %s", _("warning threshold (currently ")); | 2005 | printf (" %s", _("warning threshold (currently ")); |
2006 | printf ("%0.3fms,%u%%)\n", (float)warn.rta / 1000, warn.pl); | 2006 | printf ("%0.3fms,%u%%)\n", (float)warn.rta / 1000, warn.pl); |
2007 | printf (" %s\n", "-c"); | 2007 | printf (" %s\n", "-c"); |
2008 | printf (" %s", _("critical threshold (currently ")); | 2008 | printf (" %s", _("critical threshold (currently ")); |
2009 | printf ("%0.3fms,%u%%)\n", (float)crit.rta / 1000, crit.pl); | 2009 | printf ("%0.3fms,%u%%)\n", (float)crit.rta / 1000, crit.pl); |
2010 | 2010 | ||
2011 | printf (" %s\n", "-R"); | 2011 | printf (" %s\n", "-R"); |
2012 | printf (" %s\n", _("RTA, round trip average, mode warning,critical, ex. 100ms,200ms unit in ms")); | 2012 | printf (" %s\n", _("RTA, round trip average, mode warning,critical, ex. 100ms,200ms unit in ms")); |
2013 | printf (" %s\n", "-P"); | 2013 | printf (" %s\n", "-P"); |
2014 | printf (" %s\n", _("packet loss mode, ex. 40%,50% , unit in %")); | 2014 | printf (" %s\n", _("packet loss mode, ex. 40%,50% , unit in %")); |
2015 | printf (" %s\n", "-J"); | 2015 | printf (" %s\n", "-J"); |
2016 | printf (" %s\n", _("jitter mode warning,critical, ex. 40.000ms,50.000ms , unit in ms ")); | 2016 | printf (" %s\n", _("jitter mode warning,critical, ex. 40.000ms,50.000ms , unit in ms ")); |
2017 | printf (" %s\n", "-M"); | 2017 | printf (" %s\n", "-M"); |
2018 | printf (" %s\n", _("MOS mode, between 0 and 4.4 warning,critical, ex. 3.5,3.0")); | 2018 | printf (" %s\n", _("MOS mode, between 0 and 4.4 warning,critical, ex. 3.5,3.0")); |
2019 | printf (" %s\n", "-S"); | 2019 | printf (" %s\n", "-S"); |
2020 | printf (" %s\n", _("score mode, max value 100 warning,critical, ex. 80,70 ")); | 2020 | printf (" %s\n", _("score mode, max value 100 warning,critical, ex. 80,70 ")); |
2021 | printf (" %s\n", "-O"); | 2021 | printf (" %s\n", "-O"); |
2022 | printf (" %s\n", _("detect out of order ICMP packts ")); | 2022 | printf (" %s\n", _("detect out of order ICMP packts ")); |
2023 | printf (" %s\n", "-H"); | 2023 | printf (" %s\n", "-H"); |
2024 | printf (" %s\n", _("specify a target")); | 2024 | printf (" %s\n", _("specify a target")); |
2025 | printf (" %s\n", "-s"); | 2025 | printf (" %s\n", "-s"); |
2026 | printf (" %s\n", _("specify a source IP address or device name")); | 2026 | printf (" %s\n", _("specify a source IP address or device name")); |
2027 | printf (" %s\n", "-n"); | 2027 | printf (" %s\n", "-n"); |
2028 | printf (" %s", _("number of packets to send (currently ")); | 2028 | printf (" %s", _("number of packets to send (currently ")); |
2029 | printf ("%u)\n",packets); | 2029 | printf ("%u)\n",packets); |
2030 | printf (" %s\n", "-p"); | 2030 | printf (" %s\n", "-p"); |
2031 | printf (" %s", _("number of packets to send (currently ")); | 2031 | printf (" %s", _("number of packets to send (currently ")); |
2032 | printf ("%u)\n",packets); | 2032 | printf ("%u)\n",packets); |
2033 | printf (" %s\n", "-i"); | 2033 | printf (" %s\n", "-i"); |
2034 | printf (" %s", _("max packet interval (currently ")); | 2034 | printf (" %s", _("max packet interval (currently ")); |
2035 | printf ("%0.3fms)\n",(float)pkt_interval / 1000); | 2035 | printf ("%0.3fms)\n",(float)pkt_interval / 1000); |
2036 | printf (" %s\n", "-I"); | 2036 | printf (" %s\n", "-I"); |
2037 | printf (" %s", _("max target interval (currently ")); | 2037 | printf (" %s", _("max target interval (currently ")); |
2038 | printf ("%0.3fms)\n", (float)target_interval / 1000); | 2038 | printf ("%0.3fms)\n", (float)target_interval / 1000); |
2039 | printf (" %s\n", "-m"); | 2039 | printf (" %s\n", "-m"); |
2040 | printf (" %s",_("number of alive hosts required for success")); | 2040 | printf (" %s",_("number of alive hosts required for success")); |
2041 | printf ("\n"); | 2041 | printf ("\n"); |
2042 | printf (" %s\n", "-l"); | 2042 | printf (" %s\n", "-l"); |
2043 | printf (" %s", _("TTL on outgoing packets (currently ")); | 2043 | printf (" %s", _("TTL on outgoing packets (currently ")); |
2044 | printf ("%u)\n", ttl); | 2044 | printf ("%u)\n", ttl); |
2045 | printf (" %s\n", "-t"); | 2045 | printf (" %s\n", "-t"); |
2046 | printf (" %s",_("timeout value (seconds, currently ")); | 2046 | printf (" %s",_("timeout value (seconds, currently ")); |
2047 | printf ("%u)\n", timeout); | 2047 | printf ("%u)\n", timeout); |
2048 | printf (" %s\n", "-b"); | 2048 | printf (" %s\n", "-b"); |
2049 | printf (" %s\n", _("Number of icmp data bytes to send")); | 2049 | printf (" %s\n", _("Number of icmp data bytes to send")); |
2050 | printf (" %s %u + %d)\n", _("Packet size will be data bytes + icmp header (currently"),icmp_data_size, ICMP_MINLEN); | 2050 | printf (" %s %u + %d)\n", _("Packet size will be data bytes + icmp header (currently"),icmp_data_size, ICMP_MINLEN); |
2051 | printf (" %s\n", "-v"); | 2051 | printf (" %s\n", "-v"); |
2052 | printf (" %s\n", _("verbose")); | 2052 | printf (" %s\n", _("verbose")); |
2053 | printf ("\n"); | 2053 | printf ("\n"); |
2054 | printf ("%s\n", _("Notes:")); | 2054 | printf ("%s\n", _("Notes:")); |
2055 | printf (" %s\n", _("If none of R,P,J,M,S or O is specified, default behavior is -R -P")); | 2055 | printf (" %s\n", _("If none of R,P,J,M,S or O is specified, default behavior is -R -P")); |
2056 | printf (" %s\n", _("The -H switch is optional. Naming a host (or several) to check is not.")); | 2056 | printf (" %s\n", _("The -H switch is optional. Naming a host (or several) to check is not.")); |
2057 | printf ("\n"); | 2057 | printf ("\n"); |
2058 | printf (" %s\n", _("Threshold format for -w and -c is 200.25,60% for 200.25 msec RTA and 60%")); | 2058 | printf (" %s\n", _("Threshold format for -w and -c is 200.25,60% for 200.25 msec RTA and 60%")); |
2059 | printf (" %s\n", _("packet loss. The default values should work well for most users.")); | 2059 | printf (" %s\n", _("packet loss. The default values should work well for most users.")); |
2060 | printf (" %s\n", _("You can specify different RTA factors using the standardized abbreviations")); | 2060 | printf (" %s\n", _("You can specify different RTA factors using the standardized abbreviations")); |
2061 | printf (" %s\n", _("us (microseconds), ms (milliseconds, default) or just plain s for seconds.")); | 2061 | printf (" %s\n", _("us (microseconds), ms (milliseconds, default) or just plain s for seconds.")); |
2062 | /* -d not yet implemented */ | 2062 | /* -d not yet implemented */ |
2063 | /* printf ("%s\n", _("Threshold format for -d is warn,crit. 12,14 means WARNING if >= 12 hops")); | 2063 | /* printf ("%s\n", _("Threshold format for -d is warn,crit. 12,14 means WARNING if >= 12 hops")); |
2064 | printf ("%s\n", _("are spent and CRITICAL if >= 14 hops are spent.")); | 2064 | printf ("%s\n", _("are spent and CRITICAL if >= 14 hops are spent.")); |
2065 | printf ("%s\n\n", _("NOTE: Some systems decrease TTL when forming ICMP_ECHOREPLY, others do not."));*/ | 2065 | printf ("%s\n\n", _("NOTE: Some systems decrease TTL when forming ICMP_ECHOREPLY, others do not."));*/ |
2066 | printf ("\n"); | 2066 | printf ("\n"); |
2067 | printf (" %s\n", _("The -v switch can be specified several times for increased verbosity.")); | 2067 | printf (" %s\n", _("The -v switch can be specified several times for increased verbosity.")); |
2068 | /* printf ("%s\n", _("Long options are currently unsupported.")); | 2068 | /* printf ("%s\n", _("Long options are currently unsupported.")); |
2069 | printf ("%s\n", _("Options marked with * require an argument")); | 2069 | printf ("%s\n", _("Options marked with * require an argument")); |
2070 | */ | 2070 | */ |
2071 | 2071 | ||
2072 | printf (UT_SUPPORT); | 2072 | printf (UT_SUPPORT); |
2073 | } | 2073 | } |
2074 | 2074 | ||
2075 | 2075 | ||
@@ -2077,6 +2077,6 @@ print_help(void) | |||
2077 | void | 2077 | void |
2078 | print_usage (void) | 2078 | print_usage (void) |
2079 | { | 2079 | { |
2080 | printf ("%s\n", _("Usage:")); | 2080 | printf ("%s\n", _("Usage:")); |
2081 | printf(" %s [options] [-H] host1 host2 hostN\n", progname); | 2081 | printf(" %s [options] [-H] host1 host2 hostN\n", progname); |
2082 | } | 2082 | } |