Drop patches applied upstream
This commit is contained in:
parent
dda4a52c26
commit
c31ba979ad
66
debian/patches/13_check_http_fix_superflous_crlf
vendored
66
debian/patches/13_check_http_fix_superflous_crlf
vendored
|
@ -1,66 +0,0 @@
|
||||||
From f089d660902b726072f4e2fe619d8647d23914d3 Mon Sep 17 00:00:00 2001
|
|
||||||
From: rincewind <rincewind@vulgrim.de>
|
|
||||||
Date: Tue, 20 Apr 2021 12:15:27 +0200
|
|
||||||
Subject: [PATCH 1/2] Remove superflous CRLF in HTTP-Requests in check_http
|
|
||||||
|
|
||||||
---
|
|
||||||
plugins/check_http.c | 5 ++---
|
|
||||||
1 file changed, 2 insertions(+), 3 deletions(-)
|
|
||||||
|
|
||||||
diff --git a/plugins/check_http.c b/plugins/check_http.c
|
|
||||||
index ff39c5912..a606cbed0 100644
|
|
||||||
--- a/plugins/check_http.c
|
|
||||||
+++ b/plugins/check_http.c
|
|
||||||
@@ -966,8 +966,7 @@ check_http (void)
|
|
||||||
}
|
|
||||||
asprintf (&buf, "%sProxy-Connection: keep-alive\r\n", buf);
|
|
||||||
asprintf (&buf, "%sHost: %s\r\n", buf, host_name);
|
|
||||||
- /* we finished our request, send empty line with CRLF */
|
|
||||||
- asprintf (&buf, "%s%s", buf, CRLF);
|
|
||||||
+
|
|
||||||
if (verbose) printf ("%s\n", buf);
|
|
||||||
send(sd, buf, strlen (buf), 0);
|
|
||||||
buf[0]='\0';
|
|
||||||
@@ -1070,7 +1069,7 @@ check_http (void)
|
|
||||||
}
|
|
||||||
|
|
||||||
xasprintf (&buf, "%sContent-Length: %i\r\n\r\n", buf, (int)strlen (http_post_data));
|
|
||||||
- xasprintf (&buf, "%s%s%s", buf, http_post_data, CRLF);
|
|
||||||
+ xasprintf (&buf, "%s%s", buf, http_post_data);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
/* or just a newline so the server knows we're done with the request */
|
|
||||||
|
|
||||||
From 0ac75e22bb729ca3adcc355aba8d451ce3a41c4e Mon Sep 17 00:00:00 2001
|
|
||||||
From: RincewindsHat <12514511+RincewindsHat@users.noreply.github.com>
|
|
||||||
Date: Fri, 4 Nov 2022 12:41:08 +0100
|
|
||||||
Subject: [PATCH 2/2] Readd some end of lines
|
|
||||||
|
|
||||||
---
|
|
||||||
plugins/check_http.c | 6 +++---
|
|
||||||
1 file changed, 3 insertions(+), 3 deletions(-)
|
|
||||||
|
|
||||||
diff --git a/plugins/check_http.c b/plugins/check_http.c
|
|
||||||
index a606cbed0..41d478163 100644
|
|
||||||
--- a/plugins/check_http.c
|
|
||||||
+++ b/plugins/check_http.c
|
|
||||||
@@ -966,7 +966,8 @@ check_http (void)
|
|
||||||
}
|
|
||||||
asprintf (&buf, "%sProxy-Connection: keep-alive\r\n", buf);
|
|
||||||
asprintf (&buf, "%sHost: %s\r\n", buf, host_name);
|
|
||||||
-
|
|
||||||
+ /* we finished our request, send empty line with CRLF */
|
|
||||||
+ asprintf (&buf, "%s%s", buf, CRLF);
|
|
||||||
if (verbose) printf ("%s\n", buf);
|
|
||||||
send(sd, buf, strlen (buf), 0);
|
|
||||||
buf[0]='\0';
|
|
||||||
@@ -1070,8 +1071,7 @@ check_http (void)
|
|
||||||
|
|
||||||
xasprintf (&buf, "%sContent-Length: %i\r\n\r\n", buf, (int)strlen (http_post_data));
|
|
||||||
xasprintf (&buf, "%s%s", buf, http_post_data);
|
|
||||||
- }
|
|
||||||
- else {
|
|
||||||
+ } else {
|
|
||||||
/* or just a newline so the server knows we're done with the request */
|
|
||||||
xasprintf (&buf, "%s%s", buf, CRLF);
|
|
||||||
}
|
|
81
debian/patches/14_PRId64_PRIu64_1
vendored
81
debian/patches/14_PRId64_PRIu64_1
vendored
|
@ -1,81 +0,0 @@
|
||||||
From 817ac2e5dad1ce5d0e0ea96fa7f726566251b08d Mon Sep 17 00:00:00 2001
|
|
||||||
From: Andreas Baumann <202930+andreasbaumann@users.noreply.github.com>
|
|
||||||
Date: Fri, 21 Oct 2022 18:31:12 +0200
|
|
||||||
Subject: [PATCH] using PRId64 and PRIu64 instead of %ld directly (#1800)
|
|
||||||
|
|
||||||
---
|
|
||||||
plugins/utils.c | 24 ++++++++++++------------
|
|
||||||
1 file changed, 12 insertions(+), 12 deletions(-)
|
|
||||||
|
|
||||||
diff --git a/plugins/utils.c b/plugins/utils.c
|
|
||||||
index 17dd58146..f75cf03b7 100644
|
|
||||||
--- a/plugins/utils.c
|
|
||||||
+++ b/plugins/utils.c
|
|
||||||
@@ -615,27 +615,27 @@ char *perfdata_uint64 (const char *label,
|
|
||||||
char *data = NULL;
|
|
||||||
|
|
||||||
if (strpbrk (label, "'= "))
|
|
||||||
- xasprintf (&data, "'%s'=%ld%s;", label, val, uom);
|
|
||||||
+ xasprintf (&data, "'%s'=%" PRId64 "%s;", label, val, uom);
|
|
||||||
else
|
|
||||||
- xasprintf (&data, "%s=%ld%s;", label, val, uom);
|
|
||||||
+ xasprintf (&data, "%s=%" PRId64 "%s;", label, val, uom);
|
|
||||||
|
|
||||||
if (warnp)
|
|
||||||
- xasprintf (&data, "%s%lu;", data, warn);
|
|
||||||
+ xasprintf (&data, "%s%" PRIu64 ";", data, warn);
|
|
||||||
else
|
|
||||||
xasprintf (&data, "%s;", data);
|
|
||||||
|
|
||||||
if (critp)
|
|
||||||
- xasprintf (&data, "%s%lu;", data, crit);
|
|
||||||
+ xasprintf (&data, "%s%" PRIu64 ";", data, crit);
|
|
||||||
else
|
|
||||||
xasprintf (&data, "%s;", data);
|
|
||||||
|
|
||||||
if (minp)
|
|
||||||
- xasprintf (&data, "%s%lu;", data, minv);
|
|
||||||
+ xasprintf (&data, "%s%" PRIu64 ";", data, minv);
|
|
||||||
else
|
|
||||||
xasprintf (&data, "%s;", data);
|
|
||||||
|
|
||||||
if (maxp)
|
|
||||||
- xasprintf (&data, "%s%lu", data, maxv);
|
|
||||||
+ xasprintf (&data, "%s%" PRIu64, data, maxv);
|
|
||||||
|
|
||||||
return data;
|
|
||||||
}
|
|
||||||
@@ -656,27 +656,27 @@ char *perfdata_int64 (const char *label,
|
|
||||||
char *data = NULL;
|
|
||||||
|
|
||||||
if (strpbrk (label, "'= "))
|
|
||||||
- xasprintf (&data, "'%s'=%ld%s;", label, val, uom);
|
|
||||||
+ xasprintf (&data, "'%s'=%" PRId64 "%s;", label, val, uom);
|
|
||||||
else
|
|
||||||
- xasprintf (&data, "%s=%ld%s;", label, val, uom);
|
|
||||||
+ xasprintf (&data, "%s=%" PRId64 "%s;", label, val, uom);
|
|
||||||
|
|
||||||
if (warnp)
|
|
||||||
- xasprintf (&data, "%s%ld;", data, warn);
|
|
||||||
+ xasprintf (&data, "%s%" PRId64 ";", data, warn);
|
|
||||||
else
|
|
||||||
xasprintf (&data, "%s;", data);
|
|
||||||
|
|
||||||
if (critp)
|
|
||||||
- xasprintf (&data, "%s%ld;", data, crit);
|
|
||||||
+ xasprintf (&data, "%s%" PRId64 ";", data, crit);
|
|
||||||
else
|
|
||||||
xasprintf (&data, "%s;", data);
|
|
||||||
|
|
||||||
if (minp)
|
|
||||||
- xasprintf (&data, "%s%ld;", data, minv);
|
|
||||||
+ xasprintf (&data, "%s%" PRId64 ";", data, minv);
|
|
||||||
else
|
|
||||||
xasprintf (&data, "%s;", data);
|
|
||||||
|
|
||||||
if (maxp)
|
|
||||||
- xasprintf (&data, "%s%ld", data, maxv);
|
|
||||||
+ xasprintf (&data, "%s%" PRId64, data, maxv);
|
|
||||||
|
|
||||||
return data;
|
|
||||||
}
|
|
25
debian/patches/15_PRId64_PRIu64_2
vendored
25
debian/patches/15_PRId64_PRIu64_2
vendored
|
@ -1,25 +0,0 @@
|
||||||
From eb2dfdd5c24b87198b66397b224d6406c468a0bc Mon Sep 17 00:00:00 2001
|
|
||||||
From: Andreas Baumann <202930+andreasbaumann@users.noreply.github.com>
|
|
||||||
Date: Thu, 27 Oct 2022 22:48:18 +0200
|
|
||||||
Subject: [PATCH] fixed two PRId64 to PRIu64 in perfdata_uint64 (#1802)
|
|
||||||
|
|
||||||
---
|
|
||||||
plugins/utils.c | 4 ++--
|
|
||||||
1 file changed, 2 insertions(+), 2 deletions(-)
|
|
||||||
|
|
||||||
diff --git a/plugins/utils.c b/plugins/utils.c
|
|
||||||
index f75cf03b..b4214c61 100644
|
|
||||||
--- a/plugins/utils.c
|
|
||||||
+++ b/plugins/utils.c
|
|
||||||
@@ -615,9 +615,9 @@ char *perfdata_uint64 (const char *label,
|
|
||||||
char *data = NULL;
|
|
||||||
|
|
||||||
if (strpbrk (label, "'= "))
|
|
||||||
- xasprintf (&data, "'%s'=%" PRId64 "%s;", label, val, uom);
|
|
||||||
+ xasprintf (&data, "'%s'=%" PRIu64 "%s;", label, val, uom);
|
|
||||||
else
|
|
||||||
- xasprintf (&data, "%s=%" PRId64 "%s;", label, val, uom);
|
|
||||||
+ xasprintf (&data, "%s=%" PRIu64 "%s;", label, val, uom);
|
|
||||||
|
|
||||||
if (warnp)
|
|
||||||
xasprintf (&data, "%s%" PRIu64 ";", data, warn);
|
|
88
debian/patches/16_check_pgsql_dbname_too_strict
vendored
88
debian/patches/16_check_pgsql_dbname_too_strict
vendored
|
@ -1,88 +0,0 @@
|
||||||
From 508f8e875210ec140457d58463589626a761bb2e Mon Sep 17 00:00:00 2001
|
|
||||||
From: Florian Lohoff <f@zz.de>
|
|
||||||
Date: Mon, 15 Feb 2021 15:26:33 +0100
|
|
||||||
Subject: [PATCH] Removing is_pg_dbname alltogether,using postgres API.
|
|
||||||
(Closes: #1660)
|
|
||||||
|
|
||||||
The problem is that check_pgsql validates the Database name and has different assumptions
|
|
||||||
that postgres itself.
|
|
||||||
|
|
||||||
I fail to see a reason to validate the database name here. Postgres'es API should
|
|
||||||
do this - So i would suggest a fix like this by removing is_pg_dbname alltogether.
|
|
||||||
---
|
|
||||||
plugins/check_pgsql.c | 48 ++++---------------------------------------
|
|
||||||
1 file changed, 4 insertions(+), 44 deletions(-)
|
|
||||||
|
|
||||||
diff --git a/plugins/check_pgsql.c b/plugins/check_pgsql.c
|
|
||||||
index c893386cb..c26cd439c 100644
|
|
||||||
--- a/plugins/check_pgsql.c
|
|
||||||
+++ b/plugins/check_pgsql.c
|
|
||||||
@@ -69,7 +69,6 @@ int process_arguments (int, char **);
|
|
||||||
int validate_arguments (void);
|
|
||||||
void print_usage (void);
|
|
||||||
void print_help (void);
|
|
||||||
-int is_pg_dbname (char *);
|
|
||||||
int is_pg_logname (char *);
|
|
||||||
int do_query (PGconn *, char *);
|
|
||||||
|
|
||||||
@@ -347,10 +346,10 @@ process_arguments (int argc, char **argv)
|
|
||||||
pgport = optarg;
|
|
||||||
break;
|
|
||||||
case 'd': /* database name */
|
|
||||||
- if (!is_pg_dbname (optarg)) /* checks length and valid chars */
|
|
||||||
- usage2 (_("Database name is not valid"), optarg);
|
|
||||||
- else /* we know length, and know optarg is terminated, so us strcpy */
|
|
||||||
- snprintf(dbName, NAMEDATALEN, "%s", optarg);
|
|
||||||
+ if (strlen(optarg) >= NAMEDATALEN) {
|
|
||||||
+ usage2 (_("Database name exceeds the maximum length"), optarg);
|
|
||||||
+ }
|
|
||||||
+ snprintf(dbName, NAMEDATALEN, "%s", optarg);
|
|
||||||
break;
|
|
||||||
case 'l': /* login name */
|
|
||||||
if (!is_pg_logname (optarg))
|
|
||||||
@@ -414,45 +413,6 @@ validate_arguments ()
|
|
||||||
return OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
-
|
|
||||||
-/******************************************************************************
|
|
||||||
-
|
|
||||||
-@@-
|
|
||||||
-<sect3>
|
|
||||||
-<title>is_pg_dbname</title>
|
|
||||||
-
|
|
||||||
-<para>&PROTO_is_pg_dbname;</para>
|
|
||||||
-
|
|
||||||
-<para>Given a database name, this function returns TRUE if the string
|
|
||||||
-is a valid PostgreSQL database name, and returns false if it is
|
|
||||||
-not.</para>
|
|
||||||
-
|
|
||||||
-<para>Valid PostgreSQL database names are less than &NAMEDATALEN;
|
|
||||||
-characters long and consist of letters, numbers, and underscores. The
|
|
||||||
-first character cannot be a number, however.</para>
|
|
||||||
-
|
|
||||||
-</sect3>
|
|
||||||
--@@
|
|
||||||
-******************************************************************************/
|
|
||||||
-
|
|
||||||
-
|
|
||||||
-
|
|
||||||
-int
|
|
||||||
-is_pg_dbname (char *dbname)
|
|
||||||
-{
|
|
||||||
- char txt[NAMEDATALEN];
|
|
||||||
- char tmp[NAMEDATALEN];
|
|
||||||
- if (strlen (dbname) > NAMEDATALEN - 1)
|
|
||||||
- return (FALSE);
|
|
||||||
- strncpy (txt, dbname, NAMEDATALEN - 1);
|
|
||||||
- txt[NAMEDATALEN - 1] = 0;
|
|
||||||
- if (sscanf (txt, "%[_a-zA-Z]%[^_a-zA-Z0-9-]", tmp, tmp) == 1)
|
|
||||||
- return (TRUE);
|
|
||||||
- if (sscanf (txt, "%[_a-zA-Z]%[_a-zA-Z0-9-]%[^_a-zA-Z0-9-]", tmp, tmp, tmp) ==
|
|
||||||
- 2) return (TRUE);
|
|
||||||
- return (FALSE);
|
|
||||||
-}
|
|
||||||
-
|
|
||||||
/**
|
|
||||||
|
|
||||||
the tango program should eventually create an entity here based on the
|
|
134
debian/patches/17_check_curl_detect_ipv6
vendored
134
debian/patches/17_check_curl_detect_ipv6
vendored
|
@ -1,134 +0,0 @@
|
||||||
From 4a5ddd201119260028db6a4f27027d72aa9a160a Mon Sep 17 00:00:00 2001
|
|
||||||
From: Lorenz <12514511+RincewindsHat@users.noreply.github.com>
|
|
||||||
Date: Mon, 7 Nov 2022 17:48:28 +0100
|
|
||||||
Subject: [PATCH] Check curl detect ipv6 (#1809)
|
|
||||||
|
|
||||||
* If server_address is an IPv6 address surround it with brackets
|
|
||||||
|
|
||||||
* If the message is too short, we should not have an underflow
|
|
||||||
|
|
||||||
* Add simple conditional test case available if IPv6 is
|
|
||||||
---
|
|
||||||
|
|
||||||
diff --git a/plugins/check_curl.c b/plugins/check_curl.c
|
|
||||||
index a69854a80..2ad373c05 100644
|
|
||||||
--- a/plugins/check_curl.c
|
|
||||||
+++ b/plugins/check_curl.c
|
|
||||||
@@ -476,6 +476,18 @@ check_http (void)
|
|
||||||
printf ("* curl CURLOPT_RESOLVE: %s\n", dnscache);
|
|
||||||
}
|
|
||||||
|
|
||||||
+ // If server_address is an IPv6 address it must be surround by square brackets
|
|
||||||
+ struct in6_addr tmp_in_addr;
|
|
||||||
+ if (inet_pton(AF_INET6, server_address, &tmp_in_addr) == 1) {
|
|
||||||
+ char *new_server_address = malloc(strlen(server_address) + 3);
|
|
||||||
+ if (new_server_address == NULL) {
|
|
||||||
+ die(STATE_UNKNOWN, "HTTP UNKNOWN - Unable to allocate memory\n");
|
|
||||||
+ }
|
|
||||||
+ snprintf(new_server_address, strlen(server_address)+3, "[%s]", server_address);
|
|
||||||
+ free(server_address);
|
|
||||||
+ server_address = new_server_address;
|
|
||||||
+ }
|
|
||||||
+
|
|
||||||
/* compose URL: use the address we want to connect to, set Host: header later */
|
|
||||||
snprintf (url, DEFAULT_BUFFER_SIZE, "%s://%s:%d%s",
|
|
||||||
use_ssl ? "https" : "http",
|
|
||||||
@@ -999,10 +1011,12 @@ check_http (void)
|
|
||||||
result = max_state_alt(get_status(total_time, thlds), result);
|
|
||||||
|
|
||||||
/* Cut-off trailing characters */
|
|
||||||
- if(msg[strlen(msg)-2] == ',')
|
|
||||||
- msg[strlen(msg)-2] = '\0';
|
|
||||||
- else
|
|
||||||
- msg[strlen(msg)-3] = '\0';
|
|
||||||
+ if (strlen(msg) >= 2) {
|
|
||||||
+ if(msg[strlen(msg)-2] == ',')
|
|
||||||
+ msg[strlen(msg)-2] = '\0';
|
|
||||||
+ else
|
|
||||||
+ msg[strlen(msg)-3] = '\0';
|
|
||||||
+ }
|
|
||||||
|
|
||||||
/* TODO: separate _() msg and status code: die (result, "HTTP %s: %s\n", state_text(result), msg); */
|
|
||||||
die (result, "HTTP %s: %s %d %s%s%s - %d bytes in %.3f second response time %s|%s\n%s%s",
|
|
||||||
diff --git a/plugins/t/check_curl.t b/plugins/t/check_curl.t
|
|
||||||
index 693f4b25e..eae98cc1f 100644
|
|
||||||
--- a/plugins/t/check_curl.t
|
|
||||||
+++ b/plugins/t/check_curl.t
|
|
||||||
@@ -1,15 +1,22 @@
|
|
||||||
#! /usr/bin/perl -w -I ..
|
|
||||||
#
|
|
||||||
-# HyperText Transfer Protocol (HTTP) Test via check_http
|
|
||||||
+# HyperText Transfer Protocol (HTTP) Test via check_curl
|
|
||||||
#
|
|
||||||
#
|
|
||||||
|
|
||||||
use strict;
|
|
||||||
use Test::More;
|
|
||||||
use POSIX qw/mktime strftime/;
|
|
||||||
-use NPTest;
|
|
||||||
|
|
||||||
-plan tests => 57;
|
|
||||||
+use vars qw($tests $has_ipv6);
|
|
||||||
+
|
|
||||||
+BEGIN {
|
|
||||||
+ use NPTest;
|
|
||||||
+ $has_ipv6 = NPTest::has_ipv6();
|
|
||||||
+ $tests = $has_ipv6 ? 59 : 57;
|
|
||||||
+ plan tests => $tests;
|
|
||||||
+}
|
|
||||||
+
|
|
||||||
|
|
||||||
my $successOutput = '/OK.*HTTP.*second/';
|
|
||||||
|
|
||||||
@@ -18,6 +25,7 @@ my $plugin = 'check_http';
|
|
||||||
$plugin = 'check_curl' if $0 =~ m/check_curl/mx;
|
|
||||||
|
|
||||||
my $host_tcp_http = getTestParameter("NP_HOST_TCP_HTTP", "A host providing the HTTP Service (a web server)", "localhost");
|
|
||||||
+my $host_tcp_http_ipv6 = getTestParameter("NP_HOST_TCP_HTTP_IPV6", "An IPv6 address providing a HTTP Service (a web server)", "::1");
|
|
||||||
my $host_tls_http = getTestParameter("NP_HOST_TLS_HTTP", "A host providing the HTTPS Service (a tls web server)", "localhost");
|
|
||||||
my $host_tls_cert = getTestParameter("NP_HOST_TLS_CERT", "the common name of the certificate.", "localhost");
|
|
||||||
my $host_nonresponsive = getTestParameter("NP_HOST_NONRESPONSIVE", "The hostname of system not responsive to network requests", "10.0.0.1");
|
|
||||||
@@ -31,26 +39,35 @@ my $faketime = -x '/usr/bin/faketime' ? 1 : 0;
|
|
||||||
|
|
||||||
|
|
||||||
$res = NPTest->testCmd(
|
|
||||||
- "./$plugin $host_tcp_http -wt 300 -ct 600"
|
|
||||||
- );
|
|
||||||
+ "./$plugin $host_tcp_http -wt 300 -ct 600"
|
|
||||||
+ );
|
|
||||||
cmp_ok( $res->return_code, '==', 0, "Webserver $host_tcp_http responded" );
|
|
||||||
like( $res->output, $successOutput, "Output OK" );
|
|
||||||
|
|
||||||
+if ($has_ipv6) {
|
|
||||||
+ # Test for IPv6 formatting
|
|
||||||
+ $res = NPTest->testCmd(
|
|
||||||
+ "./$plugin -I $host_tcp_http_ipv6 -wt 300 -ct 600"
|
|
||||||
+ );
|
|
||||||
+ cmp_ok( $res->return_code, '==', 0, "IPv6 URL formatting is working" );
|
|
||||||
+ like( $res->output, $successOutput, "Output OK" );
|
|
||||||
+}
|
|
||||||
+
|
|
||||||
$res = NPTest->testCmd(
|
|
||||||
- "./$plugin $host_tcp_http -wt 300 -ct 600 -v -v -v -k 'bob:there' -k 'carl:frown'"
|
|
||||||
- );
|
|
||||||
+ "./$plugin $host_tcp_http -wt 300 -ct 600 -v -v -v -k 'bob:there' -k 'carl:frown'"
|
|
||||||
+ );
|
|
||||||
like( $res->output, '/bob:there\r\ncarl:frown\r\n/', "Got headers with multiple -k options" );
|
|
||||||
|
|
||||||
$res = NPTest->testCmd(
|
|
||||||
- "./$plugin $host_nonresponsive -wt 1 -ct 2 -t 3"
|
|
||||||
- );
|
|
||||||
+ "./$plugin $host_nonresponsive -wt 1 -ct 2 -t 3"
|
|
||||||
+ );
|
|
||||||
cmp_ok( $res->return_code, '==', 2, "Webserver $host_nonresponsive not responding" );
|
|
||||||
# was CRITICAL only, but both check_curl and check_http print HTTP CRITICAL (puzzle?!)
|
|
||||||
like( $res->output, "/HTTP CRITICAL - Invalid HTTP response received from host on port 80: cURL returned 28 - Connection timed out after/", "Output OK");
|
|
||||||
|
|
||||||
$res = NPTest->testCmd(
|
|
||||||
- "./$plugin $hostname_invalid -wt 1 -ct 2"
|
|
||||||
- );
|
|
||||||
+ "./$plugin $hostname_invalid -wt 1 -ct 2"
|
|
||||||
+ );
|
|
||||||
cmp_ok( $res->return_code, '==', 2, "Webserver $hostname_invalid not valid" );
|
|
||||||
# The first part of the message comes from the OS catalogue, so cannot check this.
|
|
||||||
# On Debian, it is Name or service not known, on Darwin, it is No address associated with nodename
|
|
59
debian/patches/18_check_icmp_help
vendored
59
debian/patches/18_check_icmp_help
vendored
|
@ -1,59 +0,0 @@
|
||||||
From e5db81bb29544b1be6500ad4a4dec5b4002c9962 Mon Sep 17 00:00:00 2001
|
|
||||||
From: =?UTF-8?q?Aksel=20Sj=C3=B6gren?= <asjogren@itrsgroup.com>
|
|
||||||
Date: Tue, 29 Nov 2022 13:55:32 +0100
|
|
||||||
Subject: [PATCH] check_icmp: fix parsing help/version long options
|
|
||||||
MIME-Version: 1.0
|
|
||||||
Content-Type: text/plain; charset=UTF-8
|
|
||||||
Content-Transfer-Encoding: 8bit
|
|
||||||
|
|
||||||
Fix parsing of the long options --help and --version. The special
|
|
||||||
handling must be done before calling getopt().
|
|
||||||
This fixes erroneous output like:
|
|
||||||
|
|
||||||
./check_icmp --version
|
|
||||||
./check_icmp: invalid option -- '-'
|
|
||||||
./check_icmp: invalid option -- 'e'
|
|
||||||
./check_icmp: invalid option -- 'r'
|
|
||||||
./check_icmp: invalid option -- '-'
|
|
||||||
./check_icmp: invalid option -- 'e'
|
|
||||||
./check_icmp: invalid option -- 'r'
|
|
||||||
|
|
||||||
Signed-off-by: Aksel Sjögren <asjogren@itrsgroup.com>
|
|
||||||
---
|
|
||||||
plugins-root/check_icmp.c | 16 ++++++++--------
|
|
||||||
1 file changed, 8 insertions(+), 8 deletions(-)
|
|
||||||
|
|
||||||
diff --git a/plugins-root/check_icmp.c b/plugins-root/check_icmp.c
|
|
||||||
index f8f153512..1f87b75f9 100644
|
|
||||||
--- a/plugins-root/check_icmp.c
|
|
||||||
+++ b/plugins-root/check_icmp.c
|
|
||||||
@@ -451,6 +451,14 @@ main(int argc, char **argv)
|
|
||||||
packets = 5;
|
|
||||||
}
|
|
||||||
|
|
||||||
+ /* support "--help" and "--version" */
|
|
||||||
+ if(argc == 2) {
|
|
||||||
+ if(!strcmp(argv[1], "--help"))
|
|
||||||
+ strcpy(argv[1], "-h");
|
|
||||||
+ if(!strcmp(argv[1], "--version"))
|
|
||||||
+ strcpy(argv[1], "-V");
|
|
||||||
+ }
|
|
||||||
+
|
|
||||||
/* Parse protocol arguments first */
|
|
||||||
for(i = 1; i < argc; i++) {
|
|
||||||
while((arg = getopt(argc, argv, opts_str)) != EOF) {
|
|
||||||
@@ -555,14 +563,6 @@ main(int argc, char **argv)
|
|
||||||
/* Parse extra opts if any */
|
|
||||||
argv=np_extra_opts(&argc, argv, progname);
|
|
||||||
|
|
||||||
- /* support "--help" and "--version" */
|
|
||||||
- if(argc == 2) {
|
|
||||||
- if(!strcmp(argv[1], "--help"))
|
|
||||||
- strcpy(argv[1], "-h");
|
|
||||||
- if(!strcmp(argv[1], "--version"))
|
|
||||||
- strcpy(argv[1], "-V");
|
|
||||||
- }
|
|
||||||
-
|
|
||||||
argv = &argv[optind];
|
|
||||||
while(*argv) {
|
|
||||||
add_target(*argv);
|
|
46
debian/patches/19_check_disk_fs_usage
vendored
46
debian/patches/19_check_disk_fs_usage
vendored
|
@ -1,46 +0,0 @@
|
||||||
From dd249c5d4bbce1c1250322dab8c8d0d69b0dca34 Mon Sep 17 00:00:00 2001
|
|
||||||
From: christian-2 <49752982+christian-2@users.noreply.github.com>
|
|
||||||
Date: Tue, 13 Dec 2022 23:48:36 +0100
|
|
||||||
Subject: [PATCH] check_disk: Find accessible mount path if multiple are
|
|
||||||
available (#1820)
|
|
||||||
|
|
||||||
* fixes #1819
|
|
||||||
* mount entries also have to be accessible according to get_fs_usage()
|
|
||||||
---
|
|
||||||
lib/utils_disk.c | 6 ++++++
|
|
||||||
1 file changed, 6 insertions(+)
|
|
||||||
|
|
||||||
diff --git a/lib/utils_disk.c b/lib/utils_disk.c
|
|
||||||
index c7c9126e4..4f16068a7 100644
|
|
||||||
--- a/lib/utils_disk.c
|
|
||||||
+++ b/lib/utils_disk.c
|
|
||||||
@@ -28,6 +28,7 @@
|
|
||||||
|
|
||||||
#include "common.h"
|
|
||||||
#include "utils_disk.h"
|
|
||||||
+#include "gl/fsusage.h"
|
|
||||||
|
|
||||||
void
|
|
||||||
np_add_name (struct name_list **list, const char *name)
|
|
||||||
@@ -127,9 +128,12 @@ np_set_best_match(struct parameter_list *desired, struct mount_entry *mount_list
|
|
||||||
size_t name_len = strlen(d->name);
|
|
||||||
size_t best_match_len = 0;
|
|
||||||
struct mount_entry *best_match = NULL;
|
|
||||||
+ struct fs_usage fsp;
|
|
||||||
|
|
||||||
/* set best match if path name exactly matches a mounted device name */
|
|
||||||
for (me = mount_list; me; me = me->me_next) {
|
|
||||||
+ if (get_fs_usage(me->me_mountdir, me->me_devname, &fsp) < 0)
|
|
||||||
+ continue; /* skip if permissions do not suffice for accessing device */
|
|
||||||
if (strcmp(me->me_devname, d->name)==0)
|
|
||||||
best_match = me;
|
|
||||||
}
|
|
||||||
@@ -137,6 +141,8 @@ np_set_best_match(struct parameter_list *desired, struct mount_entry *mount_list
|
|
||||||
/* set best match by directory name if no match was found by devname */
|
|
||||||
if (! best_match) {
|
|
||||||
for (me = mount_list; me; me = me->me_next) {
|
|
||||||
+ if (get_fs_usage(me->me_mountdir, me->me_devname, &fsp) < 0)
|
|
||||||
+ continue; /* skip if permissions do not suffice for accessing device */
|
|
||||||
size_t len = strlen (me->me_mountdir);
|
|
||||||
if ((exact == FALSE && (best_match_len <= len && len <= name_len &&
|
|
||||||
(len == 1 || strncmp (me->me_mountdir, d->name, len) == 0)))
|
|
|
@ -1,22 +0,0 @@
|
||||||
From 28553e8d1cc56de12e4c9f7705a92f0e0e86d9d9 Mon Sep 17 00:00:00 2001
|
|
||||||
From: RincewindsHat <12514511+RincewindsHat@users.noreply.github.com>
|
|
||||||
Date: Mon, 19 Dec 2022 17:15:49 +0100
|
|
||||||
Subject: [PATCH] Fix unknown escape sequence error output
|
|
||||||
|
|
||||||
---
|
|
||||||
plugins/check_apt.c | 2 +-
|
|
||||||
1 file changed, 1 insertion(+), 1 deletion(-)
|
|
||||||
|
|
||||||
diff --git a/plugins/check_apt.c b/plugins/check_apt.c
|
|
||||||
index d7be57505..f70fec16b 100644
|
|
||||||
--- a/plugins/check_apt.c
|
|
||||||
+++ b/plugins/check_apt.c
|
|
||||||
@@ -530,7 +530,7 @@ print_help (void)
|
|
||||||
printf (" %s\n", _("this REGEXP, the plugin will return CRITICAL status. Can be specified"));
|
|
||||||
printf (" %s\n", _("multiple times like above. Default is a regexp matching security"));
|
|
||||||
printf (" %s\n", _("upgrades for Debian and Ubuntu:"));
|
|
||||||
- printf (" \t\%s\n", SECURITY_RE);
|
|
||||||
+ printf (" \t%s\n", SECURITY_RE);
|
|
||||||
printf (" %s\n", _("Note that the package must first match the include list before its"));
|
|
||||||
printf (" %s\n", _("information is compared against the critical list."));
|
|
||||||
printf (" %s\n", "-o, --only-critical");
|
|
|
@ -1,37 +0,0 @@
|
||||||
From 763862a61cf5a7ba1a10f607022aac2434c79f57 Mon Sep 17 00:00:00 2001
|
|
||||||
From: Danijel Tasov <data@consol.de>
|
|
||||||
Date: Wed, 21 Dec 2022 14:48:11 +0100
|
|
||||||
Subject: [PATCH] make check_http faster with larger files
|
|
||||||
|
|
||||||
The current implementation becomes exponentially slower with growing
|
|
||||||
response size.
|
|
||||||
|
|
||||||
See also:
|
|
||||||
|
|
||||||
https://github.com/nagios-plugins/nagios-plugins/blob/release-2.4.2/plugins/check_http.c#L1199-L1204
|
|
||||||
|
|
||||||
---
|
|
||||||
plugins/check_http.c | 9 +++++++--
|
|
||||||
1 file changed, 7 insertions(+), 2 deletions(-)
|
|
||||||
|
|
||||||
diff --git a/plugins/check_http.c b/plugins/check_http.c
|
|
||||||
index 41d478163..1835a2d09 100644
|
|
||||||
--- a/plugins/check_http.c
|
|
||||||
+++ b/plugins/check_http.c
|
|
||||||
@@ -1095,9 +1095,14 @@ check_http (void)
|
|
||||||
*pos = ' ';
|
|
||||||
}
|
|
||||||
buffer[i] = '\0';
|
|
||||||
- xasprintf (&full_page_new, "%s%s", full_page, buffer);
|
|
||||||
- free (full_page);
|
|
||||||
+
|
|
||||||
+ if ((full_page_new = realloc(full_page, pagesize + i + 1)) == NULL)
|
|
||||||
+ die (STATE_UNKNOWN, _("HTTP UNKNOWN - Could not allocate memory for full_page\n"));
|
|
||||||
+
|
|
||||||
+ memmove(&full_page_new[pagesize], buffer, i + 1);
|
|
||||||
+
|
|
||||||
full_page = full_page_new;
|
|
||||||
+
|
|
||||||
pagesize += i;
|
|
||||||
|
|
||||||
if (no_body && document_headers_done (full_page)) {
|
|
|
@ -1,36 +0,0 @@
|
||||||
From 765b29f09bd3bc2a938260caa5f263343aafadb7 Mon Sep 17 00:00:00 2001
|
|
||||||
From: Sven Nierlein <sven@nierlein.de>
|
|
||||||
Date: Thu, 22 Dec 2022 12:51:18 +0100
|
|
||||||
Subject: [PATCH] check_curl: fix checking large bodys (#1823)
|
|
||||||
|
|
||||||
check_curl fails on large pages:
|
|
||||||
|
|
||||||
HTTP CRITICAL - Invalid HTTP response received from host on port 5080: cURL returned 23 - Failure writing output to destination
|
|
||||||
|
|
||||||
for example trying to run check_curl on the test from #1822
|
|
||||||
|
|
||||||
I guess the idea is to double the buffer size each time it is to small. But the code
|
|
||||||
exponentially grows the buffer size which works well 2-3 times, but then fails.
|
|
||||||
---
|
|
||||||
plugins/check_curl.c | 7 +++++--
|
|
||||||
1 file changed, 5 insertions(+), 2 deletions(-)
|
|
||||||
|
|
||||||
diff --git a/plugins/check_curl.c b/plugins/check_curl.c
|
|
||||||
index 2ad373c05..55de22fd2 100644
|
|
||||||
--- a/plugins/check_curl.c
|
|
||||||
+++ b/plugins/check_curl.c
|
|
||||||
@@ -2024,9 +2024,12 @@ curlhelp_buffer_write_callback (void *buffer, size_t size, size_t nmemb, void *s
|
|
||||||
curlhelp_write_curlbuf *buf = (curlhelp_write_curlbuf *)stream;
|
|
||||||
|
|
||||||
while (buf->bufsize < buf->buflen + size * nmemb + 1) {
|
|
||||||
- buf->bufsize *= buf->bufsize * 2;
|
|
||||||
+ buf->bufsize = buf->bufsize * 2;
|
|
||||||
buf->buf = (char *)realloc (buf->buf, buf->bufsize);
|
|
||||||
- if (buf->buf == NULL) return -1;
|
|
||||||
+ if (buf->buf == NULL) {
|
|
||||||
+ fprintf(stderr, "malloc failed (%d) %s\n", errno, strerror(errno));
|
|
||||||
+ return -1;
|
|
||||||
+ }
|
|
||||||
}
|
|
||||||
|
|
||||||
memcpy (buf->buf + buf->buflen, buffer, size * nmemb);
|
|
5976
debian/patches/23_check_http_chunked_encoding
vendored
5976
debian/patches/23_check_http_chunked_encoding
vendored
File diff suppressed because it is too large
Load diff
131
debian/patches/24_check_apt_usage
vendored
131
debian/patches/24_check_apt_usage
vendored
|
@ -1,131 +0,0 @@
|
||||||
From 0899e41f5075d661153eb2c77ace1734a8f66bfa Mon Sep 17 00:00:00 2001
|
|
||||||
From: Lorenz <12514511+RincewindsHat@users.noreply.github.com>
|
|
||||||
Date: Sun, 8 Jan 2023 17:23:53 +0100
|
|
||||||
Subject: [PATCH] Check apt usage (#1793)
|
|
||||||
|
|
||||||
* Remove trailing whitespaces
|
|
||||||
|
|
||||||
* Use real booleans
|
|
||||||
|
|
||||||
* Fix comment
|
|
||||||
|
|
||||||
* Put upgrade options in the root sections
|
|
||||||
|
|
||||||
Co-authored-by: waja <waja@users.noreply.github.com>
|
|
||||||
---
|
|
||||||
plugins/check_apt.c | 40 ++++++++++++++++++++--------------------
|
|
||||||
1 file changed, 20 insertions(+), 20 deletions(-)
|
|
||||||
|
|
||||||
diff --git a/plugins/check_apt.c b/plugins/check_apt.c
|
|
||||||
index af3563a14..312909b7f 100644
|
|
||||||
--- a/plugins/check_apt.c
|
|
||||||
+++ b/plugins/check_apt.c
|
|
||||||
@@ -76,9 +76,9 @@ int cmpstringp(const void *p1, const void *p2);
|
|
||||||
|
|
||||||
/* configuration variables */
|
|
||||||
static int verbose = 0; /* -v */
|
|
||||||
-static int list = 0; /* list packages available for upgrade */
|
|
||||||
-static int do_update = 0; /* whether to call apt-get update */
|
|
||||||
-static int only_critical = 0; /* whether to warn about non-critical updates */
|
|
||||||
+static bool list = false; /* list packages available for upgrade */
|
|
||||||
+static bool do_update = false; /* whether to call apt-get update */
|
|
||||||
+static bool only_critical = false; /* whether to warn about non-critical updates */
|
|
||||||
static upgrade_type upgrade = UPGRADE; /* which type of upgrade to do */
|
|
||||||
static char *upgrade_opts = NULL; /* options to override defaults for upgrade */
|
|
||||||
static char *update_opts = NULL; /* options to override defaults for update */
|
|
||||||
@@ -119,7 +119,7 @@ int main (int argc, char **argv) {
|
|
||||||
|
|
||||||
if(sec_count > 0){
|
|
||||||
result = max_state(result, STATE_CRITICAL);
|
|
||||||
- } else if(packages_available >= packages_warning && only_critical == 0){
|
|
||||||
+ } else if(packages_available >= packages_warning && only_critical == false){
|
|
||||||
result = max_state(result, STATE_WARNING);
|
|
||||||
} else if(result > STATE_UNKNOWN){
|
|
||||||
result = STATE_UNKNOWN;
|
|
||||||
@@ -144,7 +144,7 @@ int main (int argc, char **argv) {
|
|
||||||
|
|
||||||
for(i = 0; i < sec_count; i++)
|
|
||||||
printf("%s (security)\n", secpackages_list[i]);
|
|
||||||
- if (only_critical == 0) {
|
|
||||||
+ if (only_critical == false) {
|
|
||||||
for(i = 0; i < packages_available - sec_count; i++)
|
|
||||||
printf("%s\n", packages_list[i]);
|
|
||||||
}
|
|
||||||
@@ -166,7 +166,7 @@ int process_arguments (int argc, char **argv) {
|
|
||||||
{"upgrade", optional_argument, 0, 'U'},
|
|
||||||
{"no-upgrade", no_argument, 0, 'n'},
|
|
||||||
{"dist-upgrade", optional_argument, 0, 'd'},
|
|
||||||
- {"list", no_argument, 0, 'l'},
|
|
||||||
+ {"list", no_argument, false, 'l'},
|
|
||||||
{"include", required_argument, 0, 'i'},
|
|
||||||
{"exclude", required_argument, 0, 'e'},
|
|
||||||
{"critical", required_argument, 0, 'c'},
|
|
||||||
@@ -212,14 +212,14 @@ int process_arguments (int argc, char **argv) {
|
|
||||||
upgrade=NO_UPGRADE;
|
|
||||||
break;
|
|
||||||
case 'u':
|
|
||||||
- do_update=1;
|
|
||||||
+ do_update=true;
|
|
||||||
if(optarg!=NULL){
|
|
||||||
update_opts=strdup(optarg);
|
|
||||||
if(update_opts==NULL) die(STATE_UNKNOWN, "strdup failed");
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case 'l':
|
|
||||||
- list=1;
|
|
||||||
+ list=true;
|
|
||||||
break;
|
|
||||||
case 'i':
|
|
||||||
do_include=add_to_regexp(do_include, optarg);
|
|
||||||
@@ -231,7 +231,7 @@ int process_arguments (int argc, char **argv) {
|
|
||||||
do_critical=add_to_regexp(do_critical, optarg);
|
|
||||||
break;
|
|
||||||
case 'o':
|
|
||||||
- only_critical=1;
|
|
||||||
+ only_critical=true;
|
|
||||||
break;
|
|
||||||
case INPUT_FILE_OPT:
|
|
||||||
input_filename = optarg;
|
|
||||||
@@ -371,7 +371,7 @@ int run_update(void){
|
|
||||||
struct output chld_out, chld_err;
|
|
||||||
char *cmdline;
|
|
||||||
|
|
||||||
- /* run the upgrade */
|
|
||||||
+ /* run the update */
|
|
||||||
cmdline = construct_cmdline(NO_UPGRADE, update_opts);
|
|
||||||
result = np_runcmd(cmdline, &chld_out, &chld_err, 0);
|
|
||||||
/* apt-get update changes exit status if it can't fetch packages.
|
|
||||||
@@ -501,16 +501,6 @@ print_help (void)
|
|
||||||
|
|
||||||
printf(UT_PLUG_TIMEOUT, timeout_interval);
|
|
||||||
|
|
||||||
- printf (" %s\n", "-U, --upgrade=OPTS");
|
|
||||||
- printf (" %s\n", _("[Default] Perform an upgrade. If an optional OPTS argument is provided,"));
|
|
||||||
- printf (" %s\n", _("apt-get will be run with these command line options instead of the"));
|
|
||||||
- printf (" %s", _("default "));
|
|
||||||
- printf ("(%s).\n", UPGRADE_DEFAULT_OPTS);
|
|
||||||
- printf (" %s\n", _("Note that you may be required to have root privileges if you do not use"));
|
|
||||||
- printf (" %s\n", _("the default options."));
|
|
||||||
- printf (" %s\n", "-d, --dist-upgrade=OPTS");
|
|
||||||
- printf (" %s\n", _("Perform a dist-upgrade instead of normal upgrade. Like with -U OPTS"));
|
|
||||||
- printf (" %s\n", _("can be provided to override the default options."));
|
|
||||||
printf (" %s\n", "-n, --no-upgrade");
|
|
||||||
printf (" %s\n", _("Do not run the upgrade. Probably not useful (without -u at least)."));
|
|
||||||
printf (" %s\n", "-l, --list");
|
|
||||||
@@ -547,6 +537,16 @@ print_help (void)
|
|
||||||
printf (" %s\n", _("the default options. Note: you may also need to adjust the global"));
|
|
||||||
printf (" %s\n", _("timeout (with -t) to prevent the plugin from timing out if apt-get"));
|
|
||||||
printf (" %s\n", _("upgrade is expected to take longer than the default timeout."));
|
|
||||||
+ printf (" %s\n", "-U, --upgrade=OPTS");
|
|
||||||
+ printf (" %s\n", _("Perform an upgrade. If an optional OPTS argument is provided,"));
|
|
||||||
+ printf (" %s\n", _("apt-get will be run with these command line options instead of the"));
|
|
||||||
+ printf (" %s", _("default "));
|
|
||||||
+ printf ("(%s).\n", UPGRADE_DEFAULT_OPTS);
|
|
||||||
+ printf (" %s\n", _("Note that you may be required to have root privileges if you do not use"));
|
|
||||||
+ printf (" %s\n", _("the default options, which will only run a simulation and NOT perform the upgrade"));
|
|
||||||
+ printf (" %s\n", "-d, --dist-upgrade=OPTS");
|
|
||||||
+ printf (" %s\n", _("Perform a dist-upgrade instead of normal upgrade. Like with -U OPTS"));
|
|
||||||
+ printf (" %s\n", _("can be provided to override the default options."));
|
|
||||||
|
|
||||||
printf(UT_SUPPORT);
|
|
||||||
}
|
|
50
debian/patches/25_spell_fixes
vendored
50
debian/patches/25_spell_fixes
vendored
|
@ -1,50 +0,0 @@
|
||||||
From dcb1a53f969da6f53d5b64a96b7988a8975bcc84 Mon Sep 17 00:00:00 2001
|
|
||||||
From: Jan Wagner <waja@cyconet.org>
|
|
||||||
Date: Tue, 17 Jan 2023 13:55:05 +0000
|
|
||||||
Subject: [PATCH] Fixing spelling errors
|
|
||||||
|
|
||||||
---
|
|
||||||
plugins/check_apt.c | 2 +-
|
|
||||||
plugins/check_curl.c | 2 +-
|
|
||||||
plugins/check_fping.c | 2 +-
|
|
||||||
3 files changed, 3 insertions(+), 3 deletions(-)
|
|
||||||
|
|
||||||
diff --git a/plugins/check_apt.c b/plugins/check_apt.c
|
|
||||||
index 312909b7f..fa982ae34 100644
|
|
||||||
--- a/plugins/check_apt.c
|
|
||||||
+++ b/plugins/check_apt.c
|
|
||||||
@@ -528,7 +528,7 @@ print_help (void)
|
|
||||||
printf (" %s\n", _("of upgrades will be printed, but any non-critical upgrades will not cause"));
|
|
||||||
printf (" %s\n", _("the plugin to return WARNING status."));
|
|
||||||
printf (" %s\n", "-w, --packages-warning");
|
|
||||||
- printf (" %s\n", _("Minumum number of packages available for upgrade to return WARNING status."));
|
|
||||||
+ printf (" %s\n", _("Minimum number of packages available for upgrade to return WARNING status."));
|
|
||||||
printf (" %s\n\n", _("Default is 1 package."));
|
|
||||||
|
|
||||||
printf ("%s\n\n", _("The following options require root privileges and should be used with care:"));
|
|
||||||
diff --git a/plugins/check_curl.c b/plugins/check_curl.c
|
|
||||||
index 55de22fd2..c6593df1a 100644
|
|
||||||
--- a/plugins/check_curl.c
|
|
||||||
+++ b/plugins/check_curl.c
|
|
||||||
@@ -1680,7 +1680,7 @@ process_arguments (int argc, char **argv)
|
|
||||||
curl_http_version = CURL_HTTP_VERSION_NONE;
|
|
||||||
#endif /* LIBCURL_VERSION_NUM >= MAKE_LIBCURL_VERSION(7, 33, 0) */
|
|
||||||
} else {
|
|
||||||
- fprintf (stderr, "unkown http-version parameter: %s\n", optarg);
|
|
||||||
+ fprintf (stderr, "unknown http-version parameter: %s\n", optarg);
|
|
||||||
exit (STATE_WARNING);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
diff --git a/plugins/check_fping.c b/plugins/check_fping.c
|
|
||||||
index be9362ad5..db4331624 100644
|
|
||||||
--- a/plugins/check_fping.c
|
|
||||||
+++ b/plugins/check_fping.c
|
|
||||||
@@ -492,7 +492,7 @@ void print_help (void) {
|
|
||||||
printf (" %s\n", "-c, --critical=THRESHOLD");
|
|
||||||
printf (" %s\n", _("critical threshold pair"));
|
|
||||||
printf (" %s\n", "-a, --alive");
|
|
||||||
- printf (" %s\n", _("Return OK after first successfull reply"));
|
|
||||||
+ printf (" %s\n", _("Return OK after first successful reply"));
|
|
||||||
printf (" %s\n", "-b, --bytes=INTEGER");
|
|
||||||
printf (" %s (default: %d)\n", _("size of ICMP packet"),PACKET_SIZE);
|
|
||||||
printf (" %s\n", "-n, --number=INTEGER");
|
|
|
@ -1,28 +0,0 @@
|
||||||
From 7ae8456e7a89faf0d9a10c0e2720910cbe0317b8 Mon Sep 17 00:00:00 2001
|
|
||||||
From: andrew bezella <abezella@archive.org>
|
|
||||||
Date: Wed, 19 Oct 2022 21:33:18 +0200
|
|
||||||
Subject: [PATCH] Fixing nullmailer regex
|
|
||||||
|
|
||||||
attached is a patch that updates the format expected in the nullmailer
|
|
||||||
mailq output. the regex is a little more flexible and less specific
|
|
||||||
than the previous version.
|
|
||||||
---
|
|
||||||
plugins-scripts/check_mailq.pl | 4 ++--
|
|
||||||
1 file changed, 2 insertions(+), 2 deletions(-)
|
|
||||||
|
|
||||||
diff --git a/plugins-scripts/check_mailq.pl b/plugins-scripts/check_mailq.pl
|
|
||||||
index 4c72332a5..27073d3cc 100755
|
|
||||||
--- a/plugins-scripts/check_mailq.pl
|
|
||||||
+++ b/plugins-scripts/check_mailq.pl
|
|
||||||
@@ -537,9 +537,9 @@
|
|
||||||
}
|
|
||||||
|
|
||||||
while (<MAILQ>) {
|
|
||||||
- #2006-06-22 16:00:00 282 bytes
|
|
||||||
+ #2022-08-25 01:30:40 502 bytes from <user@example.com>
|
|
||||||
|
|
||||||
- if (/^[1-9][0-9]*-[01][0-9]-[0-3][0-9]\s[0-2][0-9]\:[0-5][0-9]\:[0-5][0-9]\s+[0-9]+\sbytes/) {
|
|
||||||
+ if (/^\d{4}-\d{2}-\d{2}\s+\d{2}\:\d{2}\:\d{2}\s+\d+\sbytes/) {
|
|
||||||
$msg_q++ ;
|
|
||||||
}
|
|
||||||
}
|
|
372
debian/patches/27_check_snmp_add_multiplier
vendored
372
debian/patches/27_check_snmp_add_multiplier
vendored
|
@ -1,372 +0,0 @@
|
||||||
From 403cbe5d8bd073277f188bdb729ad3333855ab39 Mon Sep 17 00:00:00 2001
|
|
||||||
From: Wolfgang Nieder <wnd@gmx.net>
|
|
||||||
Date: Sat, 7 Jul 2018 09:12:44 +0200
|
|
||||||
Subject: [PATCH 1/3] add 'multiplier' to modify current value
|
|
||||||
|
|
||||||
---
|
|
||||||
plugins/check_snmp.c | 84 +++++++++++++++++++++++++++-----------
|
|
||||||
plugins/tests/check_snmp.t | 12 ++++--
|
|
||||||
2 files changed, 70 insertions(+), 26 deletions(-)
|
|
||||||
|
|
||||||
diff --git a/plugins/check_snmp.c b/plugins/check_snmp.c
|
|
||||||
index 2601ccd89..d407609f5 100644
|
|
||||||
--- a/plugins/check_snmp.c
|
|
||||||
+++ b/plugins/check_snmp.c
|
|
||||||
@@ -1,31 +1,31 @@
|
|
||||||
/*****************************************************************************
|
|
||||||
-*
|
|
||||||
+*
|
|
||||||
* Monitoring check_snmp plugin
|
|
||||||
-*
|
|
||||||
+*
|
|
||||||
* License: GPL
|
|
||||||
* Copyright (c) 1999-2007 Monitoring Plugins Development Team
|
|
||||||
-*
|
|
||||||
+*
|
|
||||||
* Description:
|
|
||||||
-*
|
|
||||||
+*
|
|
||||||
* This file contains the check_snmp plugin
|
|
||||||
-*
|
|
||||||
+*
|
|
||||||
* Check status of remote machines and obtain system information via SNMP
|
|
||||||
-*
|
|
||||||
-*
|
|
||||||
+*
|
|
||||||
+*
|
|
||||||
* This program is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
-*
|
|
||||||
+*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
-*
|
|
||||||
+*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
-*
|
|
||||||
-*
|
|
||||||
+*
|
|
||||||
+*
|
|
||||||
*****************************************************************************/
|
|
||||||
|
|
||||||
const char *progname = "check_snmp";
|
|
||||||
@@ -90,6 +90,7 @@ char *thisarg (char *str);
|
|
||||||
char *nextarg (char *str);
|
|
||||||
void print_usage (void);
|
|
||||||
void print_help (void);
|
|
||||||
+char *multiply (char *str);
|
|
||||||
|
|
||||||
#include "regex.h"
|
|
||||||
char regex_expect[MAX_INPUT_BUFFER] = "";
|
|
||||||
@@ -154,6 +155,8 @@ double *previous_value;
|
|
||||||
size_t previous_size = OID_COUNT_STEP;
|
|
||||||
int perf_labels = 1;
|
|
||||||
char* ip_version = "";
|
|
||||||
+double multiplier = 1.0;
|
|
||||||
+char *fmtstr = "";
|
|
||||||
|
|
||||||
static char *fix_snmp_range(char *th)
|
|
||||||
{
|
|
||||||
@@ -316,7 +319,7 @@ main (int argc, char **argv)
|
|
||||||
for (i = 0; i < numcontext; i++) {
|
|
||||||
command_line[10 + i] = contextargs[i];
|
|
||||||
}
|
|
||||||
-
|
|
||||||
+
|
|
||||||
for (i = 0; i < numauthpriv; i++) {
|
|
||||||
command_line[10 + numcontext + i] = authpriv[i];
|
|
||||||
}
|
|
||||||
@@ -330,7 +333,7 @@ main (int argc, char **argv)
|
|
||||||
|
|
||||||
for (i = 0; i < numoids; i++) {
|
|
||||||
command_line[10 + numcontext + numauthpriv + 1 + i] = oids[i];
|
|
||||||
- xasprintf(&cl_hidden_auth, "%s %s", cl_hidden_auth, oids[i]);
|
|
||||||
+ xasprintf(&cl_hidden_auth, "%s %s", cl_hidden_auth, oids[i]);
|
|
||||||
}
|
|
||||||
|
|
||||||
command_line[10 + numcontext + numauthpriv + 1 + numoids] = NULL;
|
|
||||||
@@ -398,15 +401,15 @@ main (int argc, char **argv)
|
|
||||||
is_counter=0;
|
|
||||||
/* We strip out the datatype indicator for PHBs */
|
|
||||||
if (strstr (response, "Gauge: ")) {
|
|
||||||
- show = strstr (response, "Gauge: ") + 7;
|
|
||||||
- }
|
|
||||||
+ show = multiply (strstr (response, "Gauge: ") + 7);
|
|
||||||
+ }
|
|
||||||
else if (strstr (response, "Gauge32: ")) {
|
|
||||||
- show = strstr (response, "Gauge32: ") + 9;
|
|
||||||
- }
|
|
||||||
+ show = multiply (strstr (response, "Gauge32: ") + 9);
|
|
||||||
+ }
|
|
||||||
else if (strstr (response, "Counter32: ")) {
|
|
||||||
show = strstr (response, "Counter32: ") + 11;
|
|
||||||
is_counter=1;
|
|
||||||
- if(!calculate_rate)
|
|
||||||
+ if(!calculate_rate)
|
|
||||||
strcpy(type, "c");
|
|
||||||
}
|
|
||||||
else if (strstr (response, "Counter64: ")) {
|
|
||||||
@@ -416,7 +419,10 @@ main (int argc, char **argv)
|
|
||||||
strcpy(type, "c");
|
|
||||||
}
|
|
||||||
else if (strstr (response, "INTEGER: ")) {
|
|
||||||
- show = strstr (response, "INTEGER: ") + 9;
|
|
||||||
+ show = multiply (strstr (response, "INTEGER: ") + 9);
|
|
||||||
+ if (fmtstr != "") {
|
|
||||||
+ conv = fmtstr;
|
|
||||||
+ }
|
|
||||||
}
|
|
||||||
else if (strstr (response, "OID: ")) {
|
|
||||||
show = strstr (response, "OID: ") + 5;
|
|
||||||
@@ -616,7 +622,7 @@ main (int argc, char **argv)
|
|
||||||
state_string=malloc(string_length);
|
|
||||||
if(state_string==NULL)
|
|
||||||
die(STATE_UNKNOWN, _("Cannot malloc"));
|
|
||||||
-
|
|
||||||
+
|
|
||||||
current_length=0;
|
|
||||||
for(i=0; i<total_oids; i++) {
|
|
||||||
xasprintf(&temp_string,"%.0f",response_value[i]);
|
|
||||||
@@ -638,7 +644,7 @@ main (int argc, char **argv)
|
|
||||||
state_string[--current_length]='\0';
|
|
||||||
if (verbose > 2)
|
|
||||||
printf("State string=%s\n",state_string);
|
|
||||||
-
|
|
||||||
+
|
|
||||||
/* This is not strictly the same as time now, but any subtle variations will cancel out */
|
|
||||||
np_state_write_string(current_time, state_string );
|
|
||||||
if(previous_state==NULL) {
|
|
||||||
@@ -698,6 +704,8 @@ process_arguments (int argc, char **argv)
|
|
||||||
{"perf-oids", no_argument, 0, 'O'},
|
|
||||||
{"ipv4", no_argument, 0, '4'},
|
|
||||||
{"ipv6", no_argument, 0, '6'},
|
|
||||||
+ {"multiplier", required_argument, 0, 'M'},
|
|
||||||
+ {"fmtstr", required_argument, 0, 'f'},
|
|
||||||
{0, 0, 0, 0}
|
|
||||||
};
|
|
||||||
|
|
||||||
@@ -715,7 +723,7 @@ process_arguments (int argc, char **argv)
|
|
||||||
}
|
|
||||||
|
|
||||||
while (1) {
|
|
||||||
- c = getopt_long (argc, argv, "nhvVO46t:c:w:H:C:o:e:E:d:D:s:t:R:r:l:u:p:m:P:N:L:U:a:x:A:X:z:",
|
|
||||||
+ c = getopt_long (argc, argv, "nhvVO46t:c:w:H:C:o:e:E:d:D:s:t:R:r:l:u:p:m:P:N:L:U:a:x:A:X:M:f:z:",
|
|
||||||
longopts, &option);
|
|
||||||
|
|
||||||
if (c == -1 || c == EOF)
|
|
||||||
@@ -953,6 +961,16 @@ process_arguments (int argc, char **argv)
|
|
||||||
if(verbose>2)
|
|
||||||
printf("IPv6 detected! Will pass \"udp6:\" to snmpget.\n");
|
|
||||||
break;
|
|
||||||
+ case 'M':
|
|
||||||
+ if ( strspn( optarg, "0123456789.," ) == strlen( optarg ) ) {
|
|
||||||
+ multiplier=strtod(optarg,NULL);
|
|
||||||
+ }
|
|
||||||
+ break;
|
|
||||||
+ case 'f':
|
|
||||||
+ if (multiplier != 1.0) {
|
|
||||||
+ fmtstr=optarg;
|
|
||||||
+ }
|
|
||||||
+ break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@@ -1022,7 +1040,7 @@ validate_arguments ()
|
|
||||||
contextargs[0] = strdup ("-n");
|
|
||||||
contextargs[1] = strdup (context);
|
|
||||||
}
|
|
||||||
-
|
|
||||||
+
|
|
||||||
if (seclevel == NULL)
|
|
||||||
xasprintf(&seclevel, "noAuthNoPriv");
|
|
||||||
|
|
||||||
@@ -1143,6 +1161,21 @@ nextarg (char *str)
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
+/* multiply result (values 0 < n < 1 work as divider) */
|
|
||||||
+char *
|
|
||||||
+multiply (char *str)
|
|
||||||
+{
|
|
||||||
+ double val = strtod (str, NULL);
|
|
||||||
+ val *= multiplier;
|
|
||||||
+ if (val == (int)val) {
|
|
||||||
+ sprintf(str, "%.0f", val);
|
|
||||||
+ } else {
|
|
||||||
+ sprintf(str, "%f", val);
|
|
||||||
+ }
|
|
||||||
+ return str;
|
|
||||||
+}
|
|
||||||
+
|
|
||||||
+
|
|
||||||
void
|
|
||||||
print_help (void)
|
|
||||||
{
|
|
||||||
@@ -1235,6 +1268,10 @@ print_help (void)
|
|
||||||
printf (" %s\n", _("Units label(s) for output data (e.g., 'sec.')."));
|
|
||||||
printf (" %s\n", "-D, --output-delimiter=STRING");
|
|
||||||
printf (" %s\n", _("Separates output on multiple OID requests"));
|
|
||||||
+ printf (" %s\n", "-M, --multiplier=FLOAT");
|
|
||||||
+ printf (" %s\n", _("Multiplies current value, 0 < n < 1 works as divider, defaults to 1"));
|
|
||||||
+ printf (" %s\n", "-f, --fmtstr=STRING");
|
|
||||||
+ printf (" %s\n", _("C-style format string for float values (see option -M)"));
|
|
||||||
|
|
||||||
printf (UT_CONN_TIMEOUT, DEFAULT_SOCKET_TIMEOUT);
|
|
||||||
printf (" %s\n", _("NOTE the final timeout value is calculated using this formula: timeout_interval * retries + 5"));
|
|
||||||
@@ -1287,4 +1324,5 @@ print_usage (void)
|
|
||||||
printf ("[-l label] [-u units] [-p port-number] [-d delimiter] [-D output-delimiter]\n");
|
|
||||||
printf ("[-m miblist] [-P snmp version] [-N context] [-L seclevel] [-U secname]\n");
|
|
||||||
printf ("[-a authproto] [-A authpasswd] [-x privproto] [-X privpasswd] [-4|6]\n");
|
|
||||||
+ printf ("[-M multiplier [-f format]]\n");
|
|
||||||
}
|
|
||||||
diff --git a/plugins/tests/check_snmp.t b/plugins/tests/check_snmp.t
|
|
||||||
index 0a77fa8ad..e9cc02135 100755
|
|
||||||
--- a/plugins/tests/check_snmp.t
|
|
||||||
+++ b/plugins/tests/check_snmp.t
|
|
||||||
@@ -9,7 +9,7 @@ use NPTest;
|
|
||||||
use FindBin qw($Bin);
|
|
||||||
use POSIX qw/strftime/;
|
|
||||||
|
|
||||||
-my $tests = 73;
|
|
||||||
+my $tests = 75;
|
|
||||||
# Check that all dependent modules are available
|
|
||||||
eval {
|
|
||||||
require NetSNMP::OID;
|
|
||||||
@@ -57,9 +57,9 @@ if ($pid) {
|
|
||||||
exec("snmpd -c tests/conf/snmpd.conf -C -f -r udp:$port_snmp");
|
|
||||||
}
|
|
||||||
|
|
||||||
-END {
|
|
||||||
+END {
|
|
||||||
foreach my $pid (@pids) {
|
|
||||||
- if ($pid) { print "Killing $pid\n"; kill "INT", $pid }
|
|
||||||
+ if ($pid) { print "Killing $pid\n"; kill "INT", $pid }
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
@@ -268,3 +268,9 @@ like($res->output, '/SNMP WARNING - \d+ \*-4\* | iso.3.6.1.4.1.8072.3.2.67.10=\d
|
|
||||||
$res = NPTest->testCmd( "./check_snmp -H 127.0.0.1 -C public -p $port_snmp -o .1.3.6.1.4.1.8072.3.2.67.10,.1.3.6.1.4.1.8072.3.2.67.17 -w 1,2 -c 1" );
|
|
||||||
is($res->return_code, 2, "Multiple OIDs with some thresholds" );
|
|
||||||
like($res->output, '/SNMP CRITICAL - \*\d+\* \*-4\* | iso.3.6.1.4.1.8072.3.2.67.10=\d+c;1;2 iso.3.6.1.4.1.8072.3.2.67.17=-4;;/', "Multiple OIDs with thresholds output" );
|
|
||||||
+
|
|
||||||
+$res = NPTest->testCmd( "./check_snmp -H 127.0.0.1 -C public -p $port_snmp -o .1.3.6.1.2.1.25.2.2.0 -M .125 ");
|
|
||||||
+is($res->return_code, 0, "Multiply OK" );
|
|
||||||
+
|
|
||||||
+$res = NPTest->testCmd( "./check_snmp -H 127.0.0.1 -C public -p $port_snmp -o .1.3.6.1.2.1.25.2.2.0 --multiplier=.0009765625 -f '%.3f' ");
|
|
||||||
+is($res->return_code, 0, "Multiply format OK" );
|
|
||||||
|
|
||||||
From fdde61e978c4251b67ce4db42e4f5797c087cbec Mon Sep 17 00:00:00 2001
|
|
||||||
From: Robert Bohne <robert.bohne@redhat.com>
|
|
||||||
Date: Fri, 11 Nov 2022 11:10:44 +0100
|
|
||||||
Subject: [PATCH 2/3] Improve tests for check_snmp & multiply option
|
|
||||||
|
|
||||||
---
|
|
||||||
plugins/tests/check_snmp.t | 20 +++++++++++++++-----
|
|
||||||
plugins/tests/check_snmp_agent.pl | 8 ++++----
|
|
||||||
2 files changed, 19 insertions(+), 9 deletions(-)
|
|
||||||
|
|
||||||
diff --git a/plugins/tests/check_snmp.t b/plugins/tests/check_snmp.t
|
|
||||||
index e9cc02135..bb5b8db66 100755
|
|
||||||
--- a/plugins/tests/check_snmp.t
|
|
||||||
+++ b/plugins/tests/check_snmp.t
|
|
||||||
@@ -9,7 +9,7 @@ use NPTest;
|
|
||||||
use FindBin qw($Bin);
|
|
||||||
use POSIX qw/strftime/;
|
|
||||||
|
|
||||||
-my $tests = 75;
|
|
||||||
+my $tests = 81;
|
|
||||||
# Check that all dependent modules are available
|
|
||||||
eval {
|
|
||||||
require NetSNMP::OID;
|
|
||||||
@@ -269,8 +269,18 @@ $res = NPTest->testCmd( "./check_snmp -H 127.0.0.1 -C public -p $port_snmp -o .1
|
|
||||||
is($res->return_code, 2, "Multiple OIDs with some thresholds" );
|
|
||||||
like($res->output, '/SNMP CRITICAL - \*\d+\* \*-4\* | iso.3.6.1.4.1.8072.3.2.67.10=\d+c;1;2 iso.3.6.1.4.1.8072.3.2.67.17=-4;;/', "Multiple OIDs with thresholds output" );
|
|
||||||
|
|
||||||
-$res = NPTest->testCmd( "./check_snmp -H 127.0.0.1 -C public -p $port_snmp -o .1.3.6.1.2.1.25.2.2.0 -M .125 ");
|
|
||||||
-is($res->return_code, 0, "Multiply OK" );
|
|
||||||
+$res = NPTest->testCmd( "./check_snmp -H 127.0.0.1 -C public -p $port_snmp -o .1.3.6.1.4.1.8072.3.2.67.19");
|
|
||||||
+is($res->return_code, 0, "Test plain .1.3.6.1.4.1.8072.3.2.67.6 RC" );
|
|
||||||
+is($res->output,'SNMP OK - 42 | iso.3.6.1.4.1.8072.3.2.67.19=42 ', "Test plain value of .1.3.6.1.4.1.8072.3.2.67.1" );
|
|
||||||
|
|
||||||
-$res = NPTest->testCmd( "./check_snmp -H 127.0.0.1 -C public -p $port_snmp -o .1.3.6.1.2.1.25.2.2.0 --multiplier=.0009765625 -f '%.3f' ");
|
|
||||||
-is($res->return_code, 0, "Multiply format OK" );
|
|
||||||
+$res = NPTest->testCmd( "./check_snmp -H 127.0.0.1 -C public -p $port_snmp -o .1.3.6.1.4.1.8072.3.2.67.19 -M .1");
|
|
||||||
+is($res->return_code, 0, "Test multiply RC" );
|
|
||||||
+is($res->output,'SNMP OK - 4.200000 | iso.3.6.1.4.1.8072.3.2.67.19=4.200000 ' , "Test multiply .1 output" );
|
|
||||||
+
|
|
||||||
+$res = NPTest->testCmd( "./check_snmp -H 127.0.0.1 -C public -p $port_snmp -o .1.3.6.1.4.1.8072.3.2.67.19 --multiplier=.1 -f '%.2f' ");
|
|
||||||
+is($res->return_code, 0, "Test multiply RC + format" );
|
|
||||||
+is($res->output, 'SNMP OK - 4.200000 | iso.3.6.1.4.1.8072.3.2.67.19=4.200000 ', "Test multiply .1 output + format" );
|
|
||||||
+
|
|
||||||
+$res = NPTest->testCmd( "./check_snmp -H 127.0.0.1 -C public -p $port_snmp -o .1.3.6.1.4.1.8072.3.2.67.19 --multiplier=.1 -f '%.2f' -w 1");
|
|
||||||
+is($res->return_code, 1, "Test multiply RC + format + thresholds" );
|
|
||||||
+is($res->output, 'SNMP WARNING - *4.20* | iso.3.6.1.4.1.8072.3.2.67.19=4.20;1 ', "Test multiply .1 output + format + thresholds" );
|
|
||||||
diff --git a/plugins/tests/check_snmp_agent.pl b/plugins/tests/check_snmp_agent.pl
|
|
||||||
index 0e41d575d..38912e98b 100644
|
|
||||||
--- a/plugins/tests/check_snmp_agent.pl
|
|
||||||
+++ b/plugins/tests/check_snmp_agent.pl
|
|
||||||
@@ -32,11 +32,11 @@
|
|
||||||
because we\'re not done yet!';
|
|
||||||
|
|
||||||
# Next are arrays of indexes (Type, initial value and increments)
|
|
||||||
-# 0..16 <---- please update comment when adding/removing fields
|
|
||||||
-my @fields = (ASN_OCTET_STR, ASN_OCTET_STR, ASN_OCTET_STR, ASN_OCTET_STR, ASN_OCTET_STR, ASN_UNSIGNED, ASN_UNSIGNED, ASN_COUNTER, ASN_COUNTER64, ASN_UNSIGNED, ASN_COUNTER, ASN_OCTET_STR, ASN_OCTET_STR, ASN_OCTET_STR, ASN_OCTET_STR, ASN_OCTET_STR, ASN_INTEGER, ASN_OCTET_STR, ASN_OCTET_STR );
|
|
||||||
-my @values = ($multiline, $multilin2, $multilin3, $multilin4, $multilin5, 4294965296, 1000, 4294965296, uint64("18446744073709351616"), int(rand(2**32)), 64000, "stringtests", "3.5", "87.4startswithnumberbutshouldbestring", '555"I said"', 'CUSTOM CHECK OK: foo is 12345', -2, '-4', '-6.6' );
|
|
||||||
+# 0..19 <---- please update comment when adding/removing fields
|
|
||||||
+my @fields = (ASN_OCTET_STR, ASN_OCTET_STR, ASN_OCTET_STR, ASN_OCTET_STR, ASN_OCTET_STR, ASN_UNSIGNED, ASN_UNSIGNED, ASN_COUNTER, ASN_COUNTER64, ASN_UNSIGNED, ASN_COUNTER, ASN_OCTET_STR, ASN_OCTET_STR, ASN_OCTET_STR, ASN_OCTET_STR, ASN_OCTET_STR, ASN_INTEGER, ASN_OCTET_STR, ASN_OCTET_STR, ASN_INTEGER );
|
|
||||||
+my @values = ($multiline, $multilin2, $multilin3, $multilin4, $multilin5, 4294965296, 1000, 4294965296, uint64("18446744073709351616"), int(rand(2**32)), 64000, "stringtests", "3.5", "87.4startswithnumberbutshouldbestring", '555"I said"', 'CUSTOM CHECK OK: foo is 12345', -2, '-4', '-6.6', 42 );
|
|
||||||
# undef increments are randomized
|
|
||||||
-my @incrts = (undef, undef, undef, undef, undef, 1000, -500, 1000, 100000, undef, 666, undef, undef, undef, undef, undef, -1, undef, undef );
|
|
||||||
+my @incrts = (undef, undef, undef, undef, undef, 1000, -500, 1000, 100000, undef, 666, undef, undef, undef, undef, undef, -1, undef, undef, 0 );
|
|
||||||
|
|
||||||
# Number of elements in our OID
|
|
||||||
my $oidelts;
|
|
||||||
|
|
||||||
From 84dddab6fe6315bbe4ad5197b9a4b56ebc89e007 Mon Sep 17 00:00:00 2001
|
|
||||||
From: Sven Nierlein <sven@nierlein.de>
|
|
||||||
Date: Thu, 22 Dec 2022 12:02:52 +0100
|
|
||||||
Subject: [PATCH 3/3] check_snmp: always apply format when applying multiplier
|
|
||||||
|
|
||||||
---
|
|
||||||
plugins/check_snmp.c | 6 +++++-
|
|
||||||
plugins/tests/check_snmp.t | 2 +-
|
|
||||||
2 files changed, 6 insertions(+), 2 deletions(-)
|
|
||||||
|
|
||||||
diff --git a/plugins/check_snmp.c b/plugins/check_snmp.c
|
|
||||||
index d407609f5..56bad8800 100644
|
|
||||||
--- a/plugins/check_snmp.c
|
|
||||||
+++ b/plugins/check_snmp.c
|
|
||||||
@@ -1167,10 +1167,14 @@ multiply (char *str)
|
|
||||||
{
|
|
||||||
double val = strtod (str, NULL);
|
|
||||||
val *= multiplier;
|
|
||||||
+ char *conv = "%f";
|
|
||||||
+ if (fmtstr != "") {
|
|
||||||
+ conv = fmtstr;
|
|
||||||
+ }
|
|
||||||
if (val == (int)val) {
|
|
||||||
sprintf(str, "%.0f", val);
|
|
||||||
} else {
|
|
||||||
- sprintf(str, "%f", val);
|
|
||||||
+ sprintf(str, conv, val);
|
|
||||||
}
|
|
||||||
return str;
|
|
||||||
}
|
|
||||||
diff --git a/plugins/tests/check_snmp.t b/plugins/tests/check_snmp.t
|
|
||||||
index bb5b8db66..bc03ec604 100755
|
|
||||||
--- a/plugins/tests/check_snmp.t
|
|
||||||
+++ b/plugins/tests/check_snmp.t
|
|
||||||
@@ -279,7 +279,7 @@ is($res->output,'SNMP OK - 4.200000 | iso.3.6.1.4.1.8072.3.2.67.19=4.200000 ' ,
|
|
||||||
|
|
||||||
$res = NPTest->testCmd( "./check_snmp -H 127.0.0.1 -C public -p $port_snmp -o .1.3.6.1.4.1.8072.3.2.67.19 --multiplier=.1 -f '%.2f' ");
|
|
||||||
is($res->return_code, 0, "Test multiply RC + format" );
|
|
||||||
-is($res->output, 'SNMP OK - 4.200000 | iso.3.6.1.4.1.8072.3.2.67.19=4.200000 ', "Test multiply .1 output + format" );
|
|
||||||
+is($res->output, 'SNMP OK - 4.20 | iso.3.6.1.4.1.8072.3.2.67.19=4.20 ', "Test multiply .1 output + format" );
|
|
||||||
|
|
||||||
$res = NPTest->testCmd( "./check_snmp -H 127.0.0.1 -C public -p $port_snmp -o .1.3.6.1.4.1.8072.3.2.67.19 --multiplier=.1 -f '%.2f' -w 1");
|
|
||||||
is($res->return_code, 1, "Test multiply RC + format + thresholds" );
|
|
78
debian/patches/28_check_snmp_fix_regex_matches
vendored
78
debian/patches/28_check_snmp_fix_regex_matches
vendored
|
@ -1,78 +0,0 @@
|
||||||
From 12d1b0cbab5469e230ea5b69b5f1fc411836de21 Mon Sep 17 00:00:00 2001
|
|
||||||
From: Sven Nierlein <sven@nierlein.de>
|
|
||||||
Date: Thu, 19 Jan 2023 23:29:01 +0100
|
|
||||||
Subject: [PATCH] fix check_snmp regex matches
|
|
||||||
|
|
||||||
the multiplier function always tried to extract a number, even if the result
|
|
||||||
is a string because of using a mib.
|
|
||||||
|
|
||||||
before:
|
|
||||||
```
|
|
||||||
./check_snmp -H hostname -P2c -c public -o IF-MIB::ifAdminStatus.11466 -vvv -r 0
|
|
||||||
/usr/bin/snmpget -Le -t 10 -r 5 -m ALL -v 2c [context] [authpriv] 10.0.13.11:161 IF-MIB::ifAdminStatus.11466
|
|
||||||
IF-MIB::ifAdminStatus.11466 = INTEGER: up(1)
|
|
||||||
Processing oid 1 (line 1)
|
|
||||||
oidname: IF-MIB::ifAdminStatus.11466
|
|
||||||
response: = INTEGER: up(1)
|
|
||||||
SNMP OK - 0 | IF-MIB::ifAdminStatus.11466=0;;
|
|
||||||
```
|
|
||||||
|
|
||||||
the regexp 0 matches, even if the actual result is "up(1)".
|
|
||||||
|
|
||||||
after this patch:
|
|
||||||
```
|
|
||||||
./check_snmp -H hostname -P2c -c public -o IF-MIB::ifAdminStatus.11466 -vvv -r 0
|
|
||||||
/usr/bin/snmpget -Le -t 10 -r 5 -m ALL -v 2c [context] [authpriv] 10.0.13.11:161 IF-MIB::ifAdminStatus.11466
|
|
||||||
IF-MIB::ifAdminStatus.11466 = INTEGER: up(1)
|
|
||||||
Processing oid 1 (line 1)
|
|
||||||
oidname: IF-MIB::ifAdminStatus.11466
|
|
||||||
response: = INTEGER: up(1)
|
|
||||||
SNMP CRITICAL - *up(1)* |
|
|
||||||
```
|
|
||||||
---
|
|
||||||
plugins/check_snmp.c | 23 +++++++++++++++++++++--
|
|
||||||
1 file changed, 21 insertions(+), 2 deletions(-)
|
|
||||||
|
|
||||||
diff --git a/plugins/check_snmp.c b/plugins/check_snmp.c
|
|
||||||
index 56bad8800..d3968a27d 100644
|
|
||||||
--- a/plugins/check_snmp.c
|
|
||||||
+++ b/plugins/check_snmp.c
|
|
||||||
@@ -1165,17 +1165,36 @@ nextarg (char *str)
|
|
||||||
char *
|
|
||||||
multiply (char *str)
|
|
||||||
{
|
|
||||||
- double val = strtod (str, NULL);
|
|
||||||
- val *= multiplier;
|
|
||||||
+ char *endptr;
|
|
||||||
+ double val;
|
|
||||||
char *conv = "%f";
|
|
||||||
+
|
|
||||||
+ if(verbose>2)
|
|
||||||
+ printf(" multiply input: %s\n", str);
|
|
||||||
+
|
|
||||||
+ val = strtod (str, &endptr);
|
|
||||||
+ if ((val == 0.0) && (endptr == str)) {
|
|
||||||
+ if(multiplier != 1) {
|
|
||||||
+ die(STATE_UNKNOWN, _("multiplier set (%.1f), but input is not a number: %s"), multiplier, str);
|
|
||||||
+ }
|
|
||||||
+ return str;
|
|
||||||
+ }
|
|
||||||
+
|
|
||||||
+ if(verbose>2)
|
|
||||||
+ printf(" multiply extracted double: %f\n", val);
|
|
||||||
+ val *= multiplier;
|
|
||||||
if (fmtstr != "") {
|
|
||||||
conv = fmtstr;
|
|
||||||
}
|
|
||||||
if (val == (int)val) {
|
|
||||||
sprintf(str, "%.0f", val);
|
|
||||||
} else {
|
|
||||||
+ if(verbose>2)
|
|
||||||
+ printf(" multiply using format: %s\n", conv);
|
|
||||||
sprintf(str, conv, val);
|
|
||||||
}
|
|
||||||
+ if(verbose>2)
|
|
||||||
+ printf(" multiply result: %s\n", str);
|
|
||||||
return str;
|
|
||||||
}
|
|
||||||
|
|
319
debian/patches/29_check_log_polish
vendored
319
debian/patches/29_check_log_polish
vendored
|
@ -1,319 +0,0 @@
|
||||||
From 6408677bb1cefd03364965bf0e09a6dd450154d9 Mon Sep 17 00:00:00 2001
|
|
||||||
From: lgmu <80966566+lgmu@users.noreply.github.com>
|
|
||||||
Date: Thu, 19 Jan 2023 11:33:25 +0100
|
|
||||||
Subject: [PATCH 1/3] Added --exclude, cleanup args, fix -a count bug
|
|
||||||
|
|
||||||
Added --exclude to exclude patterns
|
|
||||||
Cleaned up duplicated code in the args
|
|
||||||
Fixed a bug when using --all because the count always returned "1" even when nothing matched
|
|
||||||
|
|
||||||
entry=$($GREP "$query" "$tempdiff")
|
|
||||||
count=$(echo "$entry" | wc -l)
|
|
||||||
|
|
||||||
Example:
|
|
||||||
|
|
||||||
$ touch testfile
|
|
||||||
$ TEST123=$(grep 'test' testfile)
|
|
||||||
$ echo "$TEST123" | wc -l
|
|
||||||
1
|
|
||||||
---
|
|
||||||
plugins-scripts/check_log.sh | 91 ++++++++++++------------------------
|
|
||||||
1 file changed, 31 insertions(+), 60 deletions(-)
|
|
||||||
|
|
||||||
diff --git a/plugins-scripts/check_log.sh b/plugins-scripts/check_log.sh
|
|
||||||
index fdb574168..1ea70b562 100755
|
|
||||||
--- a/plugins-scripts/check_log.sh
|
|
||||||
+++ b/plugins-scripts/check_log.sh
|
|
||||||
@@ -18,7 +18,7 @@
|
|
||||||
# On the first run of the plugin, it will return an OK state with a message
|
|
||||||
# of "Log check data initialized". On successive runs, it will return an OK
|
|
||||||
# state if *no* pattern matches have been found in the *difference* between the
|
|
||||||
-# log file and the older copy of the log file. If the plugin detects any
|
|
||||||
+# log file and the older copy of the log file. If the plugin detects any
|
|
||||||
# pattern matches in the log diff, it will return a CRITICAL state and print
|
|
||||||
# out a message is the following format: "(x) last_match", where "x" is the
|
|
||||||
# total number of pattern matches found in the file and "last_match" is the
|
|
||||||
@@ -76,6 +76,7 @@ print_usage() {
|
|
||||||
echo ""
|
|
||||||
echo "Other parameters:"
|
|
||||||
echo " -a|--all : Print all matching lines"
|
|
||||||
+ echo " --exclude: Exclude a pattern (-p or -e also applies here when used)"
|
|
||||||
echo " -p|--perl-regex : Use perl style regular expressions in the query"
|
|
||||||
echo " -e|--extended-regex : Use extended style regular expressions in the query (not necessary for GNU grep)"
|
|
||||||
}
|
|
||||||
@@ -99,82 +100,46 @@ if [ $# -lt 1 ]; then
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Grab the command line arguments
|
|
||||||
-
|
|
||||||
-#logfile=$1
|
|
||||||
-#oldlog=$2
|
|
||||||
-#query=$3
|
|
||||||
exitstatus=$STATE_WARNING #default
|
|
||||||
while test -n "$1"; do
|
|
||||||
case "$1" in
|
|
||||||
- --help)
|
|
||||||
- print_help
|
|
||||||
- exit "$STATE_OK"
|
|
||||||
- ;;
|
|
||||||
- -h)
|
|
||||||
+ -h | --help)
|
|
||||||
print_help
|
|
||||||
exit "$STATE_OK"
|
|
||||||
;;
|
|
||||||
- --version)
|
|
||||||
- print_revision "$PROGNAME" "$REVISION"
|
|
||||||
- exit "$STATE_OK"
|
|
||||||
- ;;
|
|
||||||
- -V)
|
|
||||||
+ -V | --version)
|
|
||||||
print_revision "$PROGNAME" "$REVISION"
|
|
||||||
exit "$STATE_OK"
|
|
||||||
;;
|
|
||||||
- --filename)
|
|
||||||
+ -F | --filename)
|
|
||||||
logfile=$2
|
|
||||||
shift 2
|
|
||||||
;;
|
|
||||||
- -F)
|
|
||||||
- logfile=$2
|
|
||||||
- shift 2
|
|
||||||
- ;;
|
|
||||||
- --oldlog)
|
|
||||||
+ -O | --oldlog)
|
|
||||||
oldlog=$2
|
|
||||||
shift 2
|
|
||||||
;;
|
|
||||||
- -O)
|
|
||||||
- oldlog=$2
|
|
||||||
- shift 2
|
|
||||||
- ;;
|
|
||||||
- --query)
|
|
||||||
- query=$2
|
|
||||||
- shift 2
|
|
||||||
- ;;
|
|
||||||
- -q)
|
|
||||||
+ -q | --query)
|
|
||||||
query=$2
|
|
||||||
shift 2
|
|
||||||
;;
|
|
||||||
- -x)
|
|
||||||
- exitstatus=$2
|
|
||||||
+ --exclude)
|
|
||||||
+ exclude=$2
|
|
||||||
shift 2
|
|
||||||
;;
|
|
||||||
- --exitstatus)
|
|
||||||
+ -x | --exitstatus)
|
|
||||||
exitstatus=$2
|
|
||||||
shift 2
|
|
||||||
;;
|
|
||||||
- --extended-regex)
|
|
||||||
+ -e | --extended-regex)
|
|
||||||
ERE=1
|
|
||||||
shift
|
|
||||||
;;
|
|
||||||
- -e)
|
|
||||||
- ERE=1
|
|
||||||
- shift
|
|
||||||
- ;;
|
|
||||||
- --perl-regex)
|
|
||||||
- PRE=1
|
|
||||||
- shift
|
|
||||||
- ;;
|
|
||||||
- -p)
|
|
||||||
+ -p | --perl-regex)
|
|
||||||
PRE=1
|
|
||||||
shift
|
|
||||||
;;
|
|
||||||
- --all)
|
|
||||||
- ALL=1
|
|
||||||
- shift
|
|
||||||
- ;;
|
|
||||||
- -a)
|
|
||||||
+ -a | --all)
|
|
||||||
ALL=1
|
|
||||||
shift
|
|
||||||
;;
|
|
||||||
@@ -213,8 +178,8 @@ elif [ ! -r "$logfile" ] ; then
|
|
||||||
fi
|
|
||||||
# If no oldlog was given this can not work properly, abort then
|
|
||||||
if [ -z "$oldlog" ]; then
|
|
||||||
- echo "Oldlog parameter is needed"
|
|
||||||
- exit $STATE_UNKNOWN
|
|
||||||
+ echo "Oldlog parameter is needed"
|
|
||||||
+ exit $STATE_UNKNOWN
|
|
||||||
fi
|
|
||||||
|
|
||||||
# If the old log file doesn't exist, this must be the first time
|
|
||||||
@@ -245,18 +210,24 @@ diff "$logfile" "$oldlog" | grep -v "^>" > "$tempdiff"
|
|
||||||
|
|
||||||
|
|
||||||
if [ $ALL ]; then
|
|
||||||
- # Get the last matching entry in the diff file
|
|
||||||
- entry=$($GREP "$query" "$tempdiff")
|
|
||||||
-
|
|
||||||
- # Count the number of matching log entries we have
|
|
||||||
- count=$(echo "$entry" | wc -l)
|
|
||||||
+ # Get all matching entries in the diff file
|
|
||||||
+ if [ -n "$exclude" ]; then
|
|
||||||
+ entry=$($GREP "$query" "$tempdiff" | $GREP -v "$exclude")
|
|
||||||
+ count=$($GREP "$query" "$tempdiff" | $GREP -vc "$exclude")
|
|
||||||
+ else
|
|
||||||
+ entry=$($GREP "$query" "$tempdiff")
|
|
||||||
+ count=$($GREP -c "$query" "$tempdiff")
|
|
||||||
+ fi
|
|
||||||
|
|
||||||
else
|
|
||||||
- # Count the number of matching log entries we have
|
|
||||||
- count=$($GREP -c "$query" "$tempdiff")
|
|
||||||
-
|
|
||||||
- # Get the last matching entry in the diff file
|
|
||||||
- entry=$($GREP "$query" "$tempdiff" | tail -1)
|
|
||||||
+ # Get the last matching entry in the diff file
|
|
||||||
+ if [ -n "$exclude" ]; then
|
|
||||||
+ entry=$($GREP "$query" "$tempdiff" | $GREP -v "$exclude" | tail -1)
|
|
||||||
+ count=$($GREP "$query" "$tempdiff" | $GREP -vc "$exclude")
|
|
||||||
+ else
|
|
||||||
+ entry=$($GREP "$query" "$tempdiff" | tail -1)
|
|
||||||
+ count=$($GREP -c "$query" "$tempdiff")
|
|
||||||
+ fi
|
|
||||||
fi
|
|
||||||
|
|
||||||
rm -f "$tempdiff"
|
|
||||||
|
|
||||||
From 8eaf03494fc401da4d3db79105586907b41525ed Mon Sep 17 00:00:00 2001
|
|
||||||
From: lgmu <80966566+lgmu@users.noreply.github.com>
|
|
||||||
Date: Thu, 19 Jan 2023 11:37:45 +0100
|
|
||||||
Subject: [PATCH 2/3] Fix indents
|
|
||||||
|
|
||||||
---
|
|
||||||
plugins-scripts/check_log.sh | 8 ++++----
|
|
||||||
1 file changed, 4 insertions(+), 4 deletions(-)
|
|
||||||
|
|
||||||
diff --git a/plugins-scripts/check_log.sh b/plugins-scripts/check_log.sh
|
|
||||||
index 1ea70b562..c623a8d6b 100755
|
|
||||||
--- a/plugins-scripts/check_log.sh
|
|
||||||
+++ b/plugins-scripts/check_log.sh
|
|
||||||
@@ -153,18 +153,18 @@ done
|
|
||||||
|
|
||||||
# Parameter sanity check
|
|
||||||
if [ $ERE ] && [ $PRE ] ; then
|
|
||||||
- echo "Can not use extended and perl regex at the same time"
|
|
||||||
- exit "$STATE_UNKNOWN"
|
|
||||||
+ echo "Can not use extended and perl regex at the same time"
|
|
||||||
+ exit "$STATE_UNKNOWN"
|
|
||||||
fi
|
|
||||||
|
|
||||||
GREP="grep"
|
|
||||||
|
|
||||||
if [ $ERE ]; then
|
|
||||||
- GREP="grep -E"
|
|
||||||
+ GREP="grep -E"
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ $PRE ]; then
|
|
||||||
- GREP="grep -P"
|
|
||||||
+ GREP="grep -P"
|
|
||||||
fi
|
|
||||||
|
|
||||||
# If the source log file doesn't exist, exit
|
|
||||||
|
|
||||||
From 5b2d1c5bf38dfffe1c980d9425d60a96b99513cc Mon Sep 17 00:00:00 2001
|
|
||||||
From: lorenzg <lorenz.gruenwald@consol.de>
|
|
||||||
Date: Fri, 20 Jan 2023 08:52:38 +0100
|
|
||||||
Subject: [PATCH 3/3] add tests for check_log
|
|
||||||
|
|
||||||
---
|
|
||||||
plugins-scripts/t/check_log.t | 82 +++++++++++++++++++++++++++++++++++
|
|
||||||
1 file changed, 82 insertions(+)
|
|
||||||
create mode 100644 plugins-scripts/t/check_log.t
|
|
||||||
|
|
||||||
diff --git a/plugins-scripts/t/check_log.t b/plugins-scripts/t/check_log.t
|
|
||||||
new file mode 100644
|
|
||||||
index 000000000..b66e0fd88
|
|
||||||
--- /dev/null
|
|
||||||
+++ b/plugins-scripts/t/check_log.t
|
|
||||||
@@ -0,0 +1,82 @@
|
|
||||||
+#!/usr/bin/perl -w -I ..
|
|
||||||
+#
|
|
||||||
+# check_log tests
|
|
||||||
+#
|
|
||||||
+#
|
|
||||||
+
|
|
||||||
+use strict;
|
|
||||||
+use Test::More;
|
|
||||||
+use NPTest;
|
|
||||||
+
|
|
||||||
+my $tests = 18;
|
|
||||||
+plan tests => $tests;
|
|
||||||
+
|
|
||||||
+my $firstTimeOutput ='/^Log check data initialized/';
|
|
||||||
+my $okOutput = '/^Log check ok - 0 pattern matches found/';
|
|
||||||
+my $criticalOutput = '/^\(\d+\) < /';
|
|
||||||
+my $multilineOutput = '/\(3\) <.*\n.*\n.*$/';
|
|
||||||
+my $unknownOutput = '/^Usage: /';
|
|
||||||
+my $unknownArgOutput = '/^Unknown argument: /';
|
|
||||||
+my $bothRegexOutput = '/^Can not use extended and perl regex/';
|
|
||||||
+
|
|
||||||
+my $result;
|
|
||||||
+my $temp_file = "/tmp/check_log.tmp";
|
|
||||||
+my $oldlog = "/tmp/oldlog.tmp";
|
|
||||||
+
|
|
||||||
+open(FH, '>', $temp_file) or die $!;
|
|
||||||
+close(FH);
|
|
||||||
+
|
|
||||||
+$result = NPTest->testCmd("./check_log");
|
|
||||||
+cmp_ok( $result->return_code, '==', 3, "Missing parameters" );
|
|
||||||
+like ( $result->output, $unknownOutput, "Output for unknown correct" );
|
|
||||||
+
|
|
||||||
+$result = NPTest->testCmd("./check_log -f");
|
|
||||||
+cmp_ok( $result->return_code, '==', 3, "Wrong parameters" );
|
|
||||||
+like ( $result->output, $unknownArgOutput, "Output for unknown correct" );
|
|
||||||
+
|
|
||||||
+$result = NPTest->testCmd("./check_log -F ".$temp_file." -O ".$oldlog." -q 'Simple match' -e -p");
|
|
||||||
+cmp_ok( $result->return_code, '==', 3, "Both regex parameters" );
|
|
||||||
+like ( $result->output, $bothRegexOutput, "Output for unknown correct" );
|
|
||||||
+
|
|
||||||
+$result = NPTest->testCmd("./check_log -F ".$temp_file." -O ".$oldlog." -q 'Simple match'");
|
|
||||||
+cmp_ok( $result->return_code, '==', 0, "First time executing" );
|
|
||||||
+like ( $result->output, $firstTimeOutput, "Output for first time executing correct" );
|
|
||||||
+
|
|
||||||
+open(FH, '>>', $temp_file) or die $!;
|
|
||||||
+print FH "This is some text, that should not match\n";
|
|
||||||
+close(FH);
|
|
||||||
+
|
|
||||||
+$result = NPTest->testCmd("./check_log -F ".$temp_file." -O ".$oldlog." -q 'No match'");
|
|
||||||
+cmp_ok( $result->return_code, '==', 0, "No match" );
|
|
||||||
+like ( $result->output, $okOutput, "Output for no match correct" );
|
|
||||||
+
|
|
||||||
+open(FH, '>>', $temp_file) or die $!;
|
|
||||||
+print FH "This text should match\n";
|
|
||||||
+close(FH);
|
|
||||||
+
|
|
||||||
+$result = NPTest->testCmd("./check_log -F ".$temp_file." -O ".$oldlog." -q 'should match'");
|
|
||||||
+cmp_ok( $result->return_code, '==', 2, "Pattern match" );
|
|
||||||
+like ( $result->output, $criticalOutput, "Output for match correct" );
|
|
||||||
+
|
|
||||||
+open(FH, '>>', $temp_file) or die $!;
|
|
||||||
+print FH "This text should not match, because it is excluded\n";
|
|
||||||
+close(FH);
|
|
||||||
+
|
|
||||||
+$result = NPTest->testCmd("./check_log -F ".$temp_file." -O ".$oldlog." -q 'match' --exclude 'because'");
|
|
||||||
+cmp_ok( $result->return_code, '==', 0, "Exclude a pattern" );
|
|
||||||
+like ( $result->output, $okOutput, "Output for no match correct" );
|
|
||||||
+
|
|
||||||
+open(FH, '>>', $temp_file) or die $!;
|
|
||||||
+print FH "Trying\nwith\nmultiline\nignore me\n";
|
|
||||||
+close(FH);
|
|
||||||
+
|
|
||||||
+$result = NPTest->testCmd("./check_log -F ".$temp_file." -O ".$oldlog." -q 'Trying\\|with\\|multiline\\|ignore' --exclude 'me' --all");
|
|
||||||
+cmp_ok( $result->return_code, '==', 2, "Multiline pattern match with --all" );
|
|
||||||
+like ( $result->output, $multilineOutput, "Output for multiline match correct" );
|
|
||||||
+
|
|
||||||
+$result = NPTest->testCmd("./check_log -F ".$temp_file." -O ".$oldlog." -q 'match' -a");
|
|
||||||
+cmp_ok( $result->return_code, '==', 0, "Non matching --all" );
|
|
||||||
+like ( $result->output, $okOutput, "Output for no match correct" );
|
|
||||||
+
|
|
||||||
+unlink($oldlog);
|
|
||||||
+unlink($temp_file);
|
|
|
@ -1,20 +0,0 @@
|
||||||
From 4fa72f14e814ca94e8ee75b444011bd553870ebe Mon Sep 17 00:00:00 2001
|
|
||||||
From: RincewindsHat <12514511+RincewindsHat@users.noreply.github.com>
|
|
||||||
Date: Sat, 29 Jan 2022 15:50:03 +0100
|
|
||||||
Subject: [PATCH 1/4] Clarify usage possibilites of check_disk
|
|
||||||
|
|
||||||
---
|
|
||||||
plugins/check_disk.c | 5 ++++-
|
|
||||||
1 file changed, 4 insertions(+), 1 deletion(-)
|
|
||||||
|
|
||||||
--- a/plugins/check_disk.c
|
|
||||||
+++ b/plugins/check_disk.c
|
|
||||||
@@ -951,7 +951,7 @@
|
|
||||||
print_usage (void)
|
|
||||||
{
|
|
||||||
printf ("%s\n", _("Usage:"));
|
|
||||||
- printf (" %s -w limit -c limit [-W limit] [-K limit] {-p path | -x device}\n", progname);
|
|
||||||
+ printf (" %s {-w absolute_limit |-w percentage_limit% | -W inode_percentage_limit } {-c absolute_limit|-c percentage_limit% | -K inode_percentage_limit } {-p path | -x device}\n", progname);
|
|
||||||
printf ("[-C] [-E] [-e] [-f] [-g group ] [-k] [-l] [-M] [-m] [-R path ] [-r path ]\n");
|
|
||||||
printf ("[-t timeout] [-u unit] [-v] [-X type] [-N type]\n");
|
|
||||||
}
|
|
|
@ -1,91 +0,0 @@
|
||||||
From d9528c265b96a5a0f0c2e43ac74ab3921a2987e1 Mon Sep 17 00:00:00 2001
|
|
||||||
From: =?UTF-8?q?Lorenz=20K=C3=A4stle?=
|
|
||||||
<12514511+RincewindsHat@users.noreply.github.com>
|
|
||||||
Date: Mon, 30 Jan 2023 12:45:20 +0100
|
|
||||||
Subject: [PATCH 1/2] check_http: Fix memory reallocation error in chunk
|
|
||||||
decoding logic
|
|
||||||
|
|
||||||
This patch should fix an error with the way memory reallocation was
|
|
||||||
used, which resulted in "realloc(): invalid next size".
|
|
||||||
It is not completely clear to me as to what caused this problem, but
|
|
||||||
apparently one can not depend handing a pointer to "realloc(3)" and
|
|
||||||
expect that it still works afterwards, but one should/must use the one
|
|
||||||
returned by the function.
|
|
||||||
|
|
||||||
Also this patch replaces a variable which was used to remember the
|
|
||||||
position in the array by just computing that from the current values.
|
|
||||||
---
|
|
||||||
plugins/check_http.c | 7 +++----
|
|
||||||
1 file changed, 3 insertions(+), 4 deletions(-)
|
|
||||||
|
|
||||||
diff --git a/plugins/check_http.c b/plugins/check_http.c
|
|
||||||
index a9c22389e..c23625e9b 100644
|
|
||||||
--- a/plugins/check_http.c
|
|
||||||
+++ b/plugins/check_http.c
|
|
||||||
@@ -1399,7 +1399,6 @@ char *unchunk_content(const char *content) {
|
|
||||||
char *endptr;
|
|
||||||
long length_of_chunk = 0;
|
|
||||||
size_t overall_size = 0;
|
|
||||||
- char *result_ptr;
|
|
||||||
|
|
||||||
while (true) {
|
|
||||||
size_of_chunk = strtol(pointer, &endptr, 16);
|
|
||||||
@@ -1446,7 +1445,6 @@ char *unchunk_content(const char *content) {
|
|
||||||
}
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
- result_ptr = result;
|
|
||||||
} else {
|
|
||||||
void *tmp = realloc(result, overall_size);
|
|
||||||
if (tmp == NULL) {
|
|
||||||
@@ -1454,11 +1452,12 @@ char *unchunk_content(const char *content) {
|
|
||||||
printf("Failed to allocate memory for unchunked body\n");
|
|
||||||
}
|
|
||||||
return NULL;
|
|
||||||
+ } else {
|
|
||||||
+ result = tmp;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
- memcpy(result_ptr, start_of_chunk, size_of_chunk);
|
|
||||||
- result_ptr = result_ptr + size_of_chunk;
|
|
||||||
+ memcpy(result + (overall_size - size_of_chunk), start_of_chunk, size_of_chunk);
|
|
||||||
}
|
|
||||||
|
|
||||||
result[overall_size] = '\0';
|
|
||||||
|
|
||||||
From d3fbcd122012af7733de3b80a692f79ad69057b2 Mon Sep 17 00:00:00 2001
|
|
||||||
From: =?UTF-8?q?Lorenz=20K=C3=A4stle?=
|
|
||||||
<12514511+RincewindsHat@users.noreply.github.com>
|
|
||||||
Date: Mon, 30 Jan 2023 13:33:46 +0100
|
|
||||||
Subject: [PATCH 2/2] check_http: Add space for ending NULL byte in array for
|
|
||||||
chunked encoding
|
|
||||||
|
|
||||||
---
|
|
||||||
plugins/check_http.c | 6 ++++--
|
|
||||||
1 file changed, 4 insertions(+), 2 deletions(-)
|
|
||||||
|
|
||||||
diff --git a/plugins/check_http.c b/plugins/check_http.c
|
|
||||||
index c23625e9b..5fa310f5d 100644
|
|
||||||
--- a/plugins/check_http.c
|
|
||||||
+++ b/plugins/check_http.c
|
|
||||||
@@ -1438,7 +1438,8 @@ char *unchunk_content(const char *content) {
|
|
||||||
overall_size += length_of_chunk;
|
|
||||||
|
|
||||||
if (result == NULL) {
|
|
||||||
- result = (char *)calloc(length_of_chunk, sizeof(char));
|
|
||||||
+ // Size of the chunk plus the ending NULL byte
|
|
||||||
+ result = (char *)malloc(length_of_chunk +1);
|
|
||||||
if (result == NULL) {
|
|
||||||
if (verbose) {
|
|
||||||
printf("Failed to allocate memory for unchunked body\n");
|
|
||||||
@@ -1446,7 +1447,8 @@ char *unchunk_content(const char *content) {
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
- void *tmp = realloc(result, overall_size);
|
|
||||||
+ // Enlarge memory to the new size plus the ending NULL byte
|
|
||||||
+ void *tmp = realloc(result, overall_size +1);
|
|
||||||
if (tmp == NULL) {
|
|
||||||
if (verbose) {
|
|
||||||
printf("Failed to allocate memory for unchunked body\n");
|
|
19
debian/patches/series
vendored
19
debian/patches/series
vendored
|
@ -1,22 +1,3 @@
|
||||||
02_check_icmp_links
|
02_check_icmp_links
|
||||||
03_epn
|
03_epn
|
||||||
# commited upstream
|
# commited upstream
|
||||||
13_check_http_fix_superflous_crlf
|
|
||||||
14_PRId64_PRIu64_1
|
|
||||||
15_PRId64_PRIu64_2
|
|
||||||
16_check_pgsql_dbname_too_strict
|
|
||||||
17_check_curl_detect_ipv6
|
|
||||||
18_check_icmp_help
|
|
||||||
19_check_disk_fs_usage
|
|
||||||
20_check_apt_unknown_escape_sequence
|
|
||||||
21_check_http_faster_with_large_files
|
|
||||||
22_check_curl_faster_with_large_files
|
|
||||||
23_check_http_chunked_encoding
|
|
||||||
24_check_apt_usage
|
|
||||||
25_spell_fixes
|
|
||||||
26_check_mailq_fix_nullmailer_regex
|
|
||||||
27_check_snmp_add_multiplier
|
|
||||||
28_check_snmp_fix_regex_matches
|
|
||||||
29_check_log_polish
|
|
||||||
30_check_disk_clarify_usage_possibilites
|
|
||||||
31_check_http_fix_memory_alloc_error_chunk_decod
|
|
||||||
|
|
Loading…
Reference in a new issue