diff options
| -rw-r--r-- | plugins-root/check_icmp.c | 12 | ||||
| -rw-r--r-- | plugins/check_by_ssh.c | 18 | ||||
| -rw-r--r-- | plugins/check_snmp.c | 2 | ||||
| -rw-r--r-- | plugins/check_swap.c | 24 | ||||
| -rw-r--r-- | plugins/t/check_curl.t | 7 | ||||
| -rw-r--r-- | plugins/t/check_http.t | 8 |
6 files changed, 39 insertions, 32 deletions
diff --git a/plugins-root/check_icmp.c b/plugins-root/check_icmp.c index 61198237..f8f15351 100644 --- a/plugins-root/check_icmp.c +++ b/plugins-root/check_icmp.c | |||
| @@ -213,7 +213,7 @@ static int mode, protocols, sockets, debug = 0, timeout = 10; | |||
| 213 | static unsigned short icmp_data_size = DEFAULT_PING_DATA_SIZE; | 213 | static unsigned short icmp_data_size = DEFAULT_PING_DATA_SIZE; |
| 214 | static unsigned short icmp_pkt_size = DEFAULT_PING_DATA_SIZE + ICMP_MINLEN; | 214 | static unsigned short icmp_pkt_size = DEFAULT_PING_DATA_SIZE + ICMP_MINLEN; |
| 215 | 215 | ||
| 216 | static unsigned int icmp_sent = 0, icmp_recv = 0, icmp_lost = 0; | 216 | static unsigned int icmp_sent = 0, icmp_recv = 0, icmp_lost = 0, ttl = 0; |
| 217 | #define icmp_pkts_en_route (icmp_sent - (icmp_recv + icmp_lost)) | 217 | #define icmp_pkts_en_route (icmp_sent - (icmp_recv + icmp_lost)) |
| 218 | static unsigned short targets_down = 0, targets = 0, packets = 0; | 218 | static unsigned short targets_down = 0, targets = 0, packets = 0; |
| 219 | #define targets_alive (targets - targets_down) | 219 | #define targets_alive (targets - targets_down) |
| @@ -223,7 +223,6 @@ static pid_t pid; | |||
| 223 | static struct timezone tz; | 223 | static struct timezone tz; |
| 224 | static struct timeval prog_start; | 224 | static struct timeval prog_start; |
| 225 | static unsigned long long max_completion_time = 0; | 225 | static unsigned long long max_completion_time = 0; |
| 226 | static unsigned char ttl = 0; /* outgoing ttl */ | ||
| 227 | static unsigned int warn_down = 1, crit_down = 1; /* host down threshold values */ | 226 | static unsigned int warn_down = 1, crit_down = 1; /* host down threshold values */ |
| 228 | static int min_hosts_alive = -1; | 227 | static int min_hosts_alive = -1; |
| 229 | float pkt_backoff_factor = 1.5; | 228 | float pkt_backoff_factor = 1.5; |
| @@ -520,7 +519,7 @@ main(int argc, char **argv) | |||
| 520 | add_target(optarg); | 519 | add_target(optarg); |
| 521 | break; | 520 | break; |
| 522 | case 'l': | 521 | case 'l': |
| 523 | ttl = (unsigned char)strtoul(optarg, NULL, 0); | 522 | ttl = (int)strtoul(optarg, NULL, 0); |
| 524 | break; | 523 | break; |
| 525 | case 'm': | 524 | case 'm': |
| 526 | min_hosts_alive = (int)strtoul(optarg, NULL, 0); | 525 | min_hosts_alive = (int)strtoul(optarg, NULL, 0); |
| @@ -948,6 +947,7 @@ static int | |||
| 948 | send_icmp_ping(int sock, struct rta_host *host) | 947 | send_icmp_ping(int sock, struct rta_host *host) |
| 949 | { | 948 | { |
| 950 | long int len; | 949 | long int len; |
| 950 | size_t addrlen; | ||
| 951 | struct icmp_ping_data data; | 951 | struct icmp_ping_data data; |
| 952 | struct msghdr hdr; | 952 | struct msghdr hdr; |
| 953 | struct iovec iov; | 953 | struct iovec iov; |
| @@ -979,6 +979,7 @@ send_icmp_ping(int sock, struct rta_host *host) | |||
| 979 | 979 | ||
| 980 | if (address_family == AF_INET) { | 980 | if (address_family == AF_INET) { |
| 981 | struct icmp *icp = (struct icmp*)buf; | 981 | struct icmp *icp = (struct icmp*)buf; |
| 982 | addrlen = sizeof(struct sockaddr_in); | ||
| 982 | 983 | ||
| 983 | memcpy(&icp->icmp_data, &data, sizeof(data)); | 984 | memcpy(&icp->icmp_data, &data, sizeof(data)); |
| 984 | 985 | ||
| @@ -995,7 +996,10 @@ send_icmp_ping(int sock, struct rta_host *host) | |||
| 995 | } | 996 | } |
| 996 | else { | 997 | else { |
| 997 | struct icmp6_hdr *icp6 = (struct icmp6_hdr*)buf; | 998 | struct icmp6_hdr *icp6 = (struct icmp6_hdr*)buf; |
| 999 | addrlen = sizeof(struct sockaddr_in6); | ||
| 1000 | |||
| 998 | memcpy(&icp6->icmp6_dataun.icmp6_un_data8[4], &data, sizeof(data)); | 1001 | memcpy(&icp6->icmp6_dataun.icmp6_un_data8[4], &data, sizeof(data)); |
| 1002 | |||
| 999 | icp6->icmp6_type = ICMP6_ECHO_REQUEST; | 1003 | icp6->icmp6_type = ICMP6_ECHO_REQUEST; |
| 1000 | icp6->icmp6_code = 0; | 1004 | icp6->icmp6_code = 0; |
| 1001 | icp6->icmp6_cksum = 0; | 1005 | icp6->icmp6_cksum = 0; |
| @@ -1016,7 +1020,7 @@ send_icmp_ping(int sock, struct rta_host *host) | |||
| 1016 | 1020 | ||
| 1017 | memset(&hdr, 0, sizeof(hdr)); | 1021 | memset(&hdr, 0, sizeof(hdr)); |
| 1018 | hdr.msg_name = (struct sockaddr *)&host->saddr_in; | 1022 | hdr.msg_name = (struct sockaddr *)&host->saddr_in; |
| 1019 | hdr.msg_namelen = sizeof(struct sockaddr_storage); | 1023 | hdr.msg_namelen = addrlen; |
| 1020 | hdr.msg_iov = &iov; | 1024 | hdr.msg_iov = &iov; |
| 1021 | hdr.msg_iovlen = 1; | 1025 | hdr.msg_iovlen = 1; |
| 1022 | 1026 | ||
diff --git a/plugins/check_by_ssh.c b/plugins/check_by_ssh.c index 39d49070..1ad547ed 100644 --- a/plugins/check_by_ssh.c +++ b/plugins/check_by_ssh.c | |||
| @@ -50,6 +50,7 @@ unsigned int services = 0; | |||
| 50 | int skip_stdout = 0; | 50 | int skip_stdout = 0; |
| 51 | int skip_stderr = 0; | 51 | int skip_stderr = 0; |
| 52 | int warn_on_stderr = 0; | 52 | int warn_on_stderr = 0; |
| 53 | bool unknown_timeout = FALSE; | ||
| 53 | char *remotecmd = NULL; | 54 | char *remotecmd = NULL; |
| 54 | char **commargv = NULL; | 55 | char **commargv = NULL; |
| 55 | int commargc = 0; | 56 | int commargc = 0; |
| @@ -101,6 +102,13 @@ main (int argc, char **argv) | |||
| 101 | 102 | ||
| 102 | result = cmd_run_array (commargv, &chld_out, &chld_err, 0); | 103 | result = cmd_run_array (commargv, &chld_out, &chld_err, 0); |
| 103 | 104 | ||
| 105 | /* SSH returns 255 if connection attempt fails; include the first line of error output */ | ||
| 106 | if (result == 255 && unknown_timeout) { | ||
| 107 | printf (_("SSH connection failed: %s\n"), | ||
| 108 | chld_err.lines > 0 ? chld_err.line[0] : "(no error output)"); | ||
| 109 | return STATE_UNKNOWN; | ||
| 110 | } | ||
| 111 | |||
| 104 | if (verbose) { | 112 | if (verbose) { |
| 105 | for(i = 0; i < chld_out.lines; i++) | 113 | for(i = 0; i < chld_out.lines; i++) |
| 106 | printf("stdout: %s\n", chld_out.line[i]); | 114 | printf("stdout: %s\n", chld_out.line[i]); |
| @@ -180,6 +188,7 @@ process_arguments (int argc, char **argv) | |||
| 180 | {"verbose", no_argument, 0, 'v'}, | 188 | {"verbose", no_argument, 0, 'v'}, |
| 181 | {"fork", no_argument, 0, 'f'}, | 189 | {"fork", no_argument, 0, 'f'}, |
| 182 | {"timeout", required_argument, 0, 't'}, | 190 | {"timeout", required_argument, 0, 't'}, |
| 191 | {"unknown-timeout", no_argument, 0, 'U'}, | ||
| 183 | {"host", required_argument, 0, 'H'}, /* backward compatibility */ | 192 | {"host", required_argument, 0, 'H'}, /* backward compatibility */ |
| 184 | {"hostname", required_argument, 0, 'H'}, | 193 | {"hostname", required_argument, 0, 'H'}, |
| 185 | {"port", required_argument,0,'p'}, | 194 | {"port", required_argument,0,'p'}, |
| @@ -212,7 +221,7 @@ process_arguments (int argc, char **argv) | |||
| 212 | strcpy (argv[c], "-t"); | 221 | strcpy (argv[c], "-t"); |
| 213 | 222 | ||
| 214 | while (1) { | 223 | while (1) { |
| 215 | c = getopt_long (argc, argv, "Vvh1246fqt:H:O:p:i:u:l:C:S::E::n:s:o:F:", longopts, | 224 | c = getopt_long (argc, argv, "Vvh1246fqt:UH:O:p:i:u:l:C:S::E::n:s:o:F:", longopts, |
| 216 | &option); | 225 | &option); |
| 217 | 226 | ||
| 218 | if (c == -1 || c == EOF) | 227 | if (c == -1 || c == EOF) |
| @@ -234,6 +243,9 @@ process_arguments (int argc, char **argv) | |||
| 234 | else | 243 | else |
| 235 | timeout_interval = atoi (optarg); | 244 | timeout_interval = atoi (optarg); |
| 236 | break; | 245 | break; |
| 246 | case 'U': | ||
| 247 | unknown_timeout = TRUE; | ||
| 248 | break; | ||
| 237 | case 'H': /* host */ | 249 | case 'H': /* host */ |
| 238 | hostname = optarg; | 250 | hostname = optarg; |
| 239 | break; | 251 | break; |
| @@ -445,6 +457,8 @@ print_help (void) | |||
| 445 | printf (" %s\n", _("Tell ssh to suppress warning and diagnostic messages [optional]")); | 457 | printf (" %s\n", _("Tell ssh to suppress warning and diagnostic messages [optional]")); |
| 446 | printf (UT_WARN_CRIT); | 458 | printf (UT_WARN_CRIT); |
| 447 | printf (UT_CONN_TIMEOUT, DEFAULT_SOCKET_TIMEOUT); | 459 | printf (UT_CONN_TIMEOUT, DEFAULT_SOCKET_TIMEOUT); |
| 460 | printf (" %s\n","-U, --unknown-timeout"); | ||
| 461 | printf (" %s\n", _("Make connection problems return UNKNOWN instead of CRITICAL")); | ||
| 448 | printf (UT_VERBOSE); | 462 | printf (UT_VERBOSE); |
| 449 | printf("\n"); | 463 | printf("\n"); |
| 450 | printf (" %s\n", _("The most common mode of use is to refer to a local identity file with")); | 464 | printf (" %s\n", _("The most common mode of use is to refer to a local identity file with")); |
| @@ -474,7 +488,7 @@ void | |||
| 474 | print_usage (void) | 488 | print_usage (void) |
| 475 | { | 489 | { |
| 476 | printf ("%s\n", _("Usage:")); | 490 | printf ("%s\n", _("Usage:")); |
| 477 | printf (" %s -H <host> -C <command> [-fqv] [-1|-2] [-4|-6]\n" | 491 | printf (" %s -H <host> -C <command> [-fqvU] [-1|-2] [-4|-6]\n" |
| 478 | " [-S [lines]] [-E [lines]] [-W] [-t timeout] [-i identity]\n" | 492 | " [-S [lines]] [-E [lines]] [-W] [-t timeout] [-i identity]\n" |
| 479 | " [-l user] [-n name] [-s servicelist] [-O outputfile]\n" | 493 | " [-l user] [-n name] [-s servicelist] [-O outputfile]\n" |
| 480 | " [-p port] [-o ssh-option] [-F configfile]\n", | 494 | " [-p port] [-o ssh-option] [-F configfile]\n", |
diff --git a/plugins/check_snmp.c b/plugins/check_snmp.c index bd13e579..2601ccd8 100644 --- a/plugins/check_snmp.c +++ b/plugins/check_snmp.c | |||
| @@ -376,7 +376,7 @@ main (int argc, char **argv) | |||
| 376 | } | 376 | } |
| 377 | } | 377 | } |
| 378 | 378 | ||
| 379 | for (line=0, i=0; line < chld_out.lines; line++, i++) { | 379 | for (line=0, i=0; line < chld_out.lines && i < numoids ; line++, i++) { |
| 380 | if(calculate_rate) | 380 | if(calculate_rate) |
| 381 | conv = "%.10g"; | 381 | conv = "%.10g"; |
| 382 | else | 382 | else |
diff --git a/plugins/check_swap.c b/plugins/check_swap.c index bb854beb..ff58b15f 100644 --- a/plugins/check_swap.c +++ b/plugins/check_swap.c | |||
| @@ -1,30 +1,30 @@ | |||
| 1 | /***************************************************************************** | 1 | /***************************************************************************** |
| 2 | * | 2 | * |
| 3 | * Monitoring check_swap plugin | 3 | * Monitoring check_swap plugin |
| 4 | * | 4 | * |
| 5 | * License: GPL | 5 | * License: GPL |
| 6 | * Copyright (c) 2000 Karl DeBisschop (kdebisschop@users.sourceforge.net) | 6 | * Copyright (c) 2000 Karl DeBisschop (kdebisschop@users.sourceforge.net) |
| 7 | * Copyright (c) 2000-2007 Monitoring Plugins Development Team | 7 | * Copyright (c) 2000-2007 Monitoring Plugins Development Team |
| 8 | * | 8 | * |
| 9 | * Description: | 9 | * Description: |
| 10 | * | 10 | * |
| 11 | * This file contains the check_swap plugin | 11 | * This file contains the check_swap plugin |
| 12 | * | 12 | * |
| 13 | * | 13 | * |
| 14 | * This program is free software: you can redistribute it and/or modify | 14 | * This program is free software: you can redistribute it and/or modify |
| 15 | * it under the terms of the GNU General Public License as published by | 15 | * it under the terms of the GNU General Public License as published by |
| 16 | * the Free Software Foundation, either version 3 of the License, or | 16 | * the Free Software Foundation, either version 3 of the License, or |
| 17 | * (at your option) any later version. | 17 | * (at your option) any later version. |
| 18 | * | 18 | * |
| 19 | * This program is distributed in the hope that it will be useful, | 19 | * This program is distributed in the hope that it will be useful, |
| 20 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | 20 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 21 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 21 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 22 | * GNU General Public License for more details. | 22 | * GNU General Public License for more details. |
| 23 | * | 23 | * |
| 24 | * You should have received a copy of the GNU General Public License | 24 | * You should have received a copy of the GNU General Public License |
| 25 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | 25 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 26 | * | 26 | * |
| 27 | * | 27 | * |
| 28 | *****************************************************************************/ | 28 | *****************************************************************************/ |
| 29 | 29 | ||
| 30 | const char *progname = "check_swap"; | 30 | const char *progname = "check_swap"; |
| @@ -150,7 +150,7 @@ main (int argc, char **argv) | |||
| 150 | * The following sscanf call looks for lines looking like: "SwapTotal: 123" and "SwapFree: 123" | 150 | * The following sscanf call looks for lines looking like: "SwapTotal: 123" and "SwapFree: 123" |
| 151 | * This format exists at least on Debian Linux with a 5.* kernel | 151 | * This format exists at least on Debian Linux with a 5.* kernel |
| 152 | */ | 152 | */ |
| 153 | else if (sscanf (input_buffer, "%*[S]%*[w]%*[a]%*[p]%[TotalFreCchd]%*[:] %f %*[k]%*[B]", str, &tmp_KB)) { | 153 | else if (sscanf (input_buffer, "%*[S]%*[w]%*[a]%*[p]%[TotalFreCchd]%*[:] %lu %*[k]%*[B]", str, &tmp_KB)) { |
| 154 | if (verbose >= 3) { | 154 | if (verbose >= 3) { |
| 155 | printf("Got %s with %lu\n", str, tmp_KB); | 155 | printf("Got %s with %lu\n", str, tmp_KB); |
| 156 | } | 156 | } |
| @@ -389,7 +389,7 @@ main (int argc, char **argv) | |||
| 389 | TRUE, warn_print, | 389 | TRUE, warn_print, |
| 390 | TRUE, crit_print, | 390 | TRUE, crit_print, |
| 391 | TRUE, 0, | 391 | TRUE, 0, |
| 392 | TRUE, (long) total_swap_mb)); | 392 | TRUE, (long) total_swap_mb * 1024 * 1024)); |
| 393 | 393 | ||
| 394 | return result; | 394 | return result; |
| 395 | } | 395 | } |
diff --git a/plugins/t/check_curl.t b/plugins/t/check_curl.t index ada6a045..693f4b25 100644 --- a/plugins/t/check_curl.t +++ b/plugins/t/check_curl.t | |||
| @@ -9,7 +9,7 @@ use Test::More; | |||
| 9 | use POSIX qw/mktime strftime/; | 9 | use POSIX qw/mktime strftime/; |
| 10 | use NPTest; | 10 | use NPTest; |
| 11 | 11 | ||
| 12 | plan tests => 58; | 12 | plan tests => 57; |
| 13 | 13 | ||
| 14 | my $successOutput = '/OK.*HTTP.*second/'; | 14 | my $successOutput = '/OK.*HTTP.*second/'; |
| 15 | 15 | ||
| @@ -188,11 +188,6 @@ SKIP: { | |||
| 188 | like ( $res->output, '/time_connect=[\d\.]+/', 'Extended Performance Data Output OK' ); | 188 | like ( $res->output, '/time_connect=[\d\.]+/', 'Extended Performance Data Output OK' ); |
| 189 | like ( $res->output, '/time_ssl=[\d\.]+/', 'Extended Performance Data SSL Output OK' ); | 189 | like ( $res->output, '/time_ssl=[\d\.]+/', 'Extended Performance Data SSL Output OK' ); |
| 190 | 190 | ||
| 191 | $res = NPTest->testCmd( | ||
| 192 | "./$plugin --ssl -H www.e-paycobalt.com" | ||
| 193 | ); | ||
| 194 | cmp_ok( $res->return_code, "==", 0, "Can read https for www.e-paycobalt.com (uses AES certificate)" ); | ||
| 195 | |||
| 196 | $res = NPTest->testCmd( "./$plugin -H www.mozilla.com -u /firefox -f curl" ); | 191 | $res = NPTest->testCmd( "./$plugin -H www.mozilla.com -u /firefox -f curl" ); |
| 197 | is( $res->return_code, 0, "Redirection based on location is okay"); | 192 | is( $res->return_code, 0, "Redirection based on location is okay"); |
| 198 | 193 | ||
diff --git a/plugins/t/check_http.t b/plugins/t/check_http.t index c137f7b4..0c866229 100644 --- a/plugins/t/check_http.t +++ b/plugins/t/check_http.t | |||
| @@ -9,7 +9,7 @@ use Test::More; | |||
| 9 | use POSIX qw/mktime strftime/; | 9 | use POSIX qw/mktime strftime/; |
| 10 | use NPTest; | 10 | use NPTest; |
| 11 | 11 | ||
| 12 | plan tests => 50; | 12 | plan tests => 49; |
| 13 | 13 | ||
| 14 | my $successOutput = '/OK.*HTTP.*second/'; | 14 | my $successOutput = '/OK.*HTTP.*second/'; |
| 15 | 15 | ||
| @@ -166,12 +166,6 @@ SKIP: { | |||
| 166 | like ( $res->output, '/time_connect=[\d\.]+/', 'Extended Performance Data Output OK' ); | 166 | like ( $res->output, '/time_connect=[\d\.]+/', 'Extended Performance Data Output OK' ); |
| 167 | like ( $res->output, '/time_ssl=[\d\.]+/', 'Extended Performance Data SSL Output OK' ); | 167 | like ( $res->output, '/time_ssl=[\d\.]+/', 'Extended Performance Data SSL Output OK' ); |
| 168 | 168 | ||
| 169 | $res = NPTest->testCmd( | ||
| 170 | "./$plugin --ssl -H www.e-paycobalt.com" | ||
| 171 | ); | ||
| 172 | cmp_ok( $res->return_code, "==", 0, "Can read https for www.e-paycobalt.com (uses AES certificate)" ); | ||
| 173 | |||
| 174 | |||
| 175 | $res = NPTest->testCmd( "./$plugin -H www.mozilla.com -u /firefox -f follow" ); | 169 | $res = NPTest->testCmd( "./$plugin -H www.mozilla.com -u /firefox -f follow" ); |
| 176 | is( $res->return_code, 0, "Redirection based on location is okay"); | 170 | is( $res->return_code, 0, "Redirection based on location is okay"); |
| 177 | 171 | ||
