summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLorenz <12514511+RincewindsHat@users.noreply.github.com>2022-09-09 14:56:49 (GMT)
committerGitHub <noreply@github.com>2022-09-09 14:56:49 (GMT)
commitcca769b3155c680b7ec637782ce0ffe539aa482c (patch)
treefe37883c9bd1ad531fc1d9d48b6a9f439727126e
parentb82a1667fe5c063bc9a174a76c665b27bf34b117 (diff)
parent3ad5fe9d84138da1451429bfac3b9b4024393d25 (diff)
downloadmonitoring-plugins-cca769b.tar.gz
Merge branch 'master' into check_load-compiler_warnings
-rw-r--r--plugins-root/check_icmp.c12
-rw-r--r--plugins/check_by_ssh.c18
-rw-r--r--plugins/check_snmp.c2
-rw-r--r--plugins/check_swap.c24
-rw-r--r--plugins/t/check_curl.t7
-rw-r--r--plugins/t/check_http.t8
6 files changed, 39 insertions, 32 deletions
diff --git a/plugins-root/check_icmp.c b/plugins-root/check_icmp.c
index 6119823..f8f1535 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;
213static unsigned short icmp_data_size = DEFAULT_PING_DATA_SIZE; 213static unsigned short icmp_data_size = DEFAULT_PING_DATA_SIZE;
214static unsigned short icmp_pkt_size = DEFAULT_PING_DATA_SIZE + ICMP_MINLEN; 214static unsigned short icmp_pkt_size = DEFAULT_PING_DATA_SIZE + ICMP_MINLEN;
215 215
216static unsigned int icmp_sent = 0, icmp_recv = 0, icmp_lost = 0; 216static 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))
218static unsigned short targets_down = 0, targets = 0, packets = 0; 218static 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;
223static struct timezone tz; 223static struct timezone tz;
224static struct timeval prog_start; 224static struct timeval prog_start;
225static unsigned long long max_completion_time = 0; 225static unsigned long long max_completion_time = 0;
226static unsigned char ttl = 0; /* outgoing ttl */
227static unsigned int warn_down = 1, crit_down = 1; /* host down threshold values */ 226static unsigned int warn_down = 1, crit_down = 1; /* host down threshold values */
228static int min_hosts_alive = -1; 227static int min_hosts_alive = -1;
229float pkt_backoff_factor = 1.5; 228float 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
948send_icmp_ping(int sock, struct rta_host *host) 947send_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 39d4907..1ad547e 100644
--- a/plugins/check_by_ssh.c
+++ b/plugins/check_by_ssh.c
@@ -50,6 +50,7 @@ unsigned int services = 0;
50int skip_stdout = 0; 50int skip_stdout = 0;
51int skip_stderr = 0; 51int skip_stderr = 0;
52int warn_on_stderr = 0; 52int warn_on_stderr = 0;
53bool unknown_timeout = FALSE;
53char *remotecmd = NULL; 54char *remotecmd = NULL;
54char **commargv = NULL; 55char **commargv = NULL;
55int commargc = 0; 56int 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
474print_usage (void) 488print_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 bd13e57..2601ccd 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 bb854be..ff58b15 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
30const char *progname = "check_swap"; 30const 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 ada6a04..693f4b2 100644
--- a/plugins/t/check_curl.t
+++ b/plugins/t/check_curl.t
@@ -9,7 +9,7 @@ use Test::More;
9use POSIX qw/mktime strftime/; 9use POSIX qw/mktime strftime/;
10use NPTest; 10use NPTest;
11 11
12plan tests => 58; 12plan tests => 57;
13 13
14my $successOutput = '/OK.*HTTP.*second/'; 14my $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 c137f7b..0c86622 100644
--- a/plugins/t/check_http.t
+++ b/plugins/t/check_http.t
@@ -9,7 +9,7 @@ use Test::More;
9use POSIX qw/mktime strftime/; 9use POSIX qw/mktime strftime/;
10use NPTest; 10use NPTest;
11 11
12plan tests => 50; 12plan tests => 49;
13 13
14my $successOutput = '/OK.*HTTP.*second/'; 14my $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