From 0d73b499dd939924d49f955ac84550fab5f3cdde Mon Sep 17 00:00:00 2001 From: Jan Wagner Date: Tue, 17 Jan 2017 16:34:32 +0100 Subject: NEWS: Add missing changes --- NEWS | 3 +++ 1 file changed, 3 insertions(+) (limited to 'NEWS') diff --git a/NEWS b/NEWS index 7be8048f..2db2a2cb 100644 --- a/NEWS +++ b/NEWS @@ -4,6 +4,9 @@ This file documents the major additions and syntax changes between releases. ENHANCEMENTS check_dns: allow 'expected address' (-a) to be specified in CIDR notation (IPv4 only). + check_dns: allow for IPv6 RDNS + check_apt: add --only-critical switch + check_apt: add -l/--list option to print packages FIXES Fix regression where check_dhcp was rereading response in a tight loop -- cgit v1.2.3-74-g34f1 From a03068743f3694cbdbe84bb6e802a41f270cc105 Mon Sep 17 00:00:00 2001 From: Rolf Eike Beer Date: Wed, 25 Jul 2018 20:18:47 +0200 Subject: check_dns: allow returned addresses to be in any order --- NEWS | 1 + THANKS.in | 1 + plugins/check_dns.c | 14 +++++++++----- 3 files changed, 11 insertions(+), 5 deletions(-) (limited to 'NEWS') diff --git a/NEWS b/NEWS index 2db2a2cb..ac06aa67 100644 --- a/NEWS +++ b/NEWS @@ -5,6 +5,7 @@ This file documents the major additions and syntax changes between releases. check_dns: allow 'expected address' (-a) to be specified in CIDR notation (IPv4 only). check_dns: allow for IPv6 RDNS + check_dns: allow unsorted addresses check_apt: add --only-critical switch check_apt: add -l/--list option to print packages diff --git a/THANKS.in b/THANKS.in index ebc81556..9bb43828 100644 --- a/THANKS.in +++ b/THANKS.in @@ -356,3 +356,4 @@ Sven Geggus Thomas Kurschel Yannick Charton Nicolai Søborg +Rolf Eike Beer diff --git a/plugins/check_dns.c b/plugins/check_dns.c index ae4123bf..75a9dcaa 100644 --- a/plugins/check_dns.c +++ b/plugins/check_dns.c @@ -230,10 +230,15 @@ main (int argc, char **argv) temp_buffer = ""; for (i=0; i Date: Wed, 25 Jul 2018 21:14:47 +0200 Subject: check_dns: allow forcing complete match of all addresses --- NEWS | 1 + plugins/check_dns.c | 20 +++++++++++++++++--- 2 files changed, 18 insertions(+), 3 deletions(-) (limited to 'NEWS') diff --git a/NEWS b/NEWS index ac06aa67..0848705c 100644 --- a/NEWS +++ b/NEWS @@ -6,6 +6,7 @@ This file documents the major additions and syntax changes between releases. (IPv4 only). check_dns: allow for IPv6 RDNS check_dns: allow unsorted addresses + check_dns: allow forcing complete match of all addresses check_apt: add --only-critical switch check_apt: add -l/--list option to print packages diff --git a/plugins/check_dns.c b/plugins/check_dns.c index 75a9dcaa..25bd31dc 100644 --- a/plugins/check_dns.c +++ b/plugins/check_dns.c @@ -56,6 +56,7 @@ char **expected_address = NULL; int expected_address_cnt = 0; int expect_authority = FALSE; +int all_match = FALSE; thresholds *time_thresholds = NULL; static int @@ -228,6 +229,8 @@ main (int argc, char **argv) if (result == STATE_OK && expected_address_cnt > 0) { result = STATE_CRITICAL; temp_buffer = ""; + unsigned long expect_match = (1 << expected_address_cnt) - 1; + unsigned long addr_match = (1 << n_addresses) - 1; for (i=0; i Date: Wed, 9 Dec 2020 15:33:18 +0100 Subject: Draft NEWS --- NEWS | 36 +++++++++++++++++++++++++++++++++++- 1 file changed, 35 insertions(+), 1 deletion(-) (limited to 'NEWS') diff --git a/NEWS b/NEWS index 0848705c..f9f2da6b 100644 --- a/NEWS +++ b/NEWS @@ -1,17 +1,51 @@ This file documents the major additions and syntax changes between releases. -2.3 [...] +2.3 10th December 2020 ENHANCEMENTS check_dns: allow 'expected address' (-a) to be specified in CIDR notation (IPv4 only). check_dns: allow for IPv6 RDNS + check_dns: Accept CIDR check_dns: allow unsorted addresses check_dns: allow forcing complete match of all addresses check_apt: add --only-critical switch check_apt: add -l/--list option to print packages + check_file_age: add range checking + check_file_age: enable to test for maximum file size + check_apt: adding packages-warning option + check_load: Adding top consuming processes option + check_http: Adding Proxy-Authorization and extra headers + check_snmp: make calcualtion of timeout value in help output more clear + check_uptime: new plugin for checking uptime to see how long the system is running + check_curl: check_http replacement based on libcurl + check_http: Allow user to specify HTTP method after proxy CONNECT + check_http: Add new flag --show-body/-B to print body + check_cluster: Added data argument validation + check_icmp: Add IPv6 support + check_icmp: Automatically detect IP protocol + check_icmp: emit error if multiple protocol version + check_disk: add support to display inodes usage in perfdata + check_hpjd: Added -D option to disable warning on 'out of paper' + check_http: support the --show-body/-B flag when --expect is used + check_mysql: allow mariadbclient to be used + check_tcp: add --sni + check_dns: detect unreachable dns service in nslookup output FIXES Fix regression where check_dhcp was rereading response in a tight loop + check_dns: fix error detection on sles nslookup + check_disk_smb: fix timeout issue + check_swap: repaired "-n" behaviour + check_icmp: Correctly set address_family on lookup + check_icmp: Do not overwrite -4,-6 on lookup + check_smtp: initializes n before it is used + check_dns: fix typo in parameter description + check_by_ssh: fix child process leak on timeouts + check_mysql: Allow sockets to be specified to -H + check_procs: improve command examples for 'at least' processes + check_swap: repaired "-n" behaviour + check_disk: include -P switch in help + check_mailq: restore accidentially removed options 2.2 29th November 2016 ENHANCEMENTS -- cgit v1.2.3-74-g34f1 From b42294b1ebcb7d4661596d487894114a893dff17 Mon Sep 17 00:00:00 2001 From: Jan Wagner Date: Wed, 9 Dec 2020 22:52:08 +0100 Subject: New version in NEWS --- NEWS | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'NEWS') diff --git a/NEWS b/NEWS index f9f2da6b..4061c033 100644 --- a/NEWS +++ b/NEWS @@ -1,5 +1,10 @@ This file documents the major additions and syntax changes between releases. +2.4 [...] + ENHANCEMENTS + + FIXES + 2.3 10th December 2020 ENHANCEMENTS check_dns: allow 'expected address' (-a) to be specified in CIDR notation -- cgit v1.2.3-74-g34f1 From 70f55ca9db87f639856e0548a57081c886e09d14 Mon Sep 17 00:00:00 2001 From: Jonny007-MKD Date: Sun, 23 Feb 2020 15:02:43 +0100 Subject: check_dns: add --expect-nxdomain --- NEWS | 1 + plugins/check_dns.c | 61 +++++++++++++++++++++++++++++++++++++-------------- plugins/t/check_dns.t | 12 ++++++++-- 3 files changed, 56 insertions(+), 18 deletions(-) (limited to 'NEWS') diff --git a/NEWS b/NEWS index 4061c033..3790e8a0 100644 --- a/NEWS +++ b/NEWS @@ -13,6 +13,7 @@ This file documents the major additions and syntax changes between releases. check_dns: Accept CIDR check_dns: allow unsorted addresses check_dns: allow forcing complete match of all addresses + check_dns: option to expect NXDOMAIN check_apt: add --only-critical switch check_apt: add -l/--list option to print packages check_file_age: add range checking diff --git a/plugins/check_dns.c b/plugins/check_dns.c index 0f2e6541..0c10f09b 100644 --- a/plugins/check_dns.c +++ b/plugins/check_dns.c @@ -41,7 +41,7 @@ const char *email = "devel@monitoring-plugins.org"; int process_arguments (int, char **); int validate_arguments (void); -int error_scan (char *); +int error_scan (char *, int*); int ip_match_cidr(const char *, const char *); unsigned long ip2long(const char *); void print_help (void); @@ -54,6 +54,7 @@ char ptr_server[ADDRESS_LENGTH] = ""; int verbose = FALSE; char **expected_address = NULL; int expected_address_cnt = 0; +int expect_nxdomain = FALSE; int expect_authority = FALSE; int all_match = FALSE; @@ -87,6 +88,7 @@ main (int argc, char **argv) int parse_address = FALSE; /* This flag scans for Address: but only after Name: */ output chld_out, chld_err; size_t i; + int is_nxdomain = FALSE; setlocale (LC_ALL, ""); bindtextdomain (PACKAGE, LOCALEDIR); @@ -186,7 +188,7 @@ main (int argc, char **argv) } - result = error_scan (chld_out.line[i]); + result = error_scan (chld_out.line[i], &is_nxdomain); if (result != STATE_OK) { msg = strchr (chld_out.line[i], ':'); if(msg) msg++; @@ -199,8 +201,8 @@ main (int argc, char **argv) if (verbose) puts(chld_err.line[i]); - if (error_scan (chld_err.line[i]) != STATE_OK) { - result = max_state (result, error_scan (chld_err.line[i])); + if (error_scan (chld_err.line[i], &is_nxdomain) != STATE_OK) { + result = max_state (result, error_scan (chld_err.line[i], &is_nxdomain)); msg = strchr(input_buffer, ':'); if(msg) msg++; @@ -209,6 +211,10 @@ main (int argc, char **argv) } } + if (is_nxdomain && !expect_nxdomain) { + die (STATE_CRITICAL, _("Domain '%s' was not found by the server\n"), query_address); + } + if (addresses) { int i,slen; char *adrp; @@ -260,6 +266,16 @@ main (int argc, char **argv) } } + if (expect_nxdomain) { + if (!is_nxdomain) { + result = STATE_CRITICAL; + xasprintf(&msg, _("Domain '%s' was found by the server: '%s'\n"), query_address, address); + } else { + if (address == NULL) free(address); + address = "NXDOMAIN"; + } + } + /* check if authoritative */ if (result == STATE_OK && expect_authority && non_authoritative) { result = STATE_CRITICAL; @@ -339,9 +355,15 @@ ip2long(const char* src) { } int -error_scan (char *input_buffer) +error_scan (char *input_buffer, int* is_nxdomain) { + const int nxdomain = strstr (input_buffer, "Non-existent") || + strstr (input_buffer, "** server can't find") || + strstr (input_buffer, "** Can't find") || + strstr (input_buffer, "NXDOMAIN"); + if (nxdomain) *is_nxdomain = TRUE; + /* the DNS lookup timed out */ if (strstr (input_buffer, _("Note: nslookup is deprecated and may be removed from future releases.")) || strstr (input_buffer, _("Consider using the `dig' or `host' programs instead. Run nslookup with")) || @@ -360,7 +382,7 @@ error_scan (char *input_buffer) /* Connection was refused */ else if (strstr (input_buffer, "Connection refused") || - strstr (input_buffer, "Couldn't find server") || + strstr (input_buffer, "Couldn't find server") || strstr (input_buffer, "Refused") || (strstr (input_buffer, "** server can't find") && strstr (input_buffer, ": REFUSED"))) @@ -374,13 +396,6 @@ error_scan (char *input_buffer) else if (strstr (input_buffer, "No information")) die (STATE_CRITICAL, _("No information returned by DNS server at %s\n"), dns_server); - /* Host or domain name does not exist */ - else if (strstr (input_buffer, "Non-existent") || - strstr (input_buffer, "** server can't find") || - strstr (input_buffer, "** Can't find") || - strstr (input_buffer,"NXDOMAIN")) - die (STATE_CRITICAL, _("Domain %s was not found by the server\n"), query_address); - /* Network is unreachable */ else if (strstr (input_buffer, "Network is unreachable")) die (STATE_CRITICAL, _("Network is unreachable\n")); @@ -417,6 +432,7 @@ process_arguments (int argc, char **argv) {"server", required_argument, 0, 's'}, {"reverse-server", required_argument, 0, 'r'}, {"expected-address", required_argument, 0, 'a'}, + {"expect-nxdomain", no_argument, 0, 'n'}, {"expect-authority", no_argument, 0, 'A'}, {"all", no_argument, 0, 'L'}, {"warning", required_argument, 0, 'w'}, @@ -432,7 +448,7 @@ process_arguments (int argc, char **argv) strcpy (argv[c], "-t"); while (1) { - c = getopt_long (argc, argv, "hVvALt:H:s:r:a:w:c:", long_opts, &opt_index); + c = getopt_long (argc, argv, "hVvALnt:H:s:r:a:w:c:", long_opts, &opt_index); if (c == -1 || c == EOF) break; @@ -491,6 +507,9 @@ process_arguments (int argc, char **argv) expected_address_cnt++; } break; + case 'n': /* expect NXDOMAIN */ + expect_nxdomain = TRUE; + break; case 'A': /* expect authority */ expect_authority = TRUE; break; @@ -532,8 +551,15 @@ process_arguments (int argc, char **argv) int validate_arguments () { - if (query_address[0] == 0) + if (query_address[0] == 0) { + printf ("missing --host argument\n"); + return ERROR; + } + + if (expected_address_cnt > 0 && expect_nxdomain) { + printf ("--expected-address and --expect-nxdomain cannot be combined\n"); return ERROR; + } return OK; } @@ -566,6 +592,9 @@ print_help (void) printf (" %s\n", _("Optional IP-ADDRESS/CIDR you expect the DNS server to return. HOST must end")); printf (" %s\n", _("with a dot (.). This option can be repeated multiple times (Returns OK if any")); printf (" %s\n", _("value matches).")); + printf (" -n, --expect-nxdomain\n"); + printf (" %s\n", _("Expect the DNS server to return NXDOMAIN (i.e. the domain was not found)")); + printf (" %s\n", _("Cannot be used together with -a")); printf (" -A, --expect-authority\n"); printf (" %s\n", _("Optionally expect the DNS server to be authoritative for the lookup")); printf (" -w, --warning=seconds\n"); @@ -586,5 +615,5 @@ void print_usage (void) { printf ("%s\n", _("Usage:")); - printf ("%s -H host [-s server] [-a expected-address] [-A] [-t timeout] [-w warn] [-c crit] [-L]\n", progname); + printf ("%s -H host [-s server] [-a expected-address] [-n] [-A] [-t timeout] [-w warn] [-c crit] [-L]\n", progname); } diff --git a/plugins/t/check_dns.t b/plugins/t/check_dns.t index cdfbe60d..1e7d5340 100644 --- a/plugins/t/check_dns.t +++ b/plugins/t/check_dns.t @@ -10,7 +10,7 @@ use NPTest; plan skip_all => "check_dns not compiled" unless (-x "check_dns"); -plan tests => 19; +plan tests => 23; my $successOutput = '/DNS OK: [\.0-9]+ seconds? response time/'; @@ -58,7 +58,7 @@ my $dns_server = getTestParameter( my $host_nonresponsive = getTestParameter( "NP_HOST_NONRESPONSIVE", "The hostname of system not responsive to network requests", - "10.0.0.1", + "192.0.2.0", ); my $res; @@ -105,3 +105,11 @@ cmp_ok( $res->return_code, '==', 0, "Got expected address"); $res = NPTest->testCmd("./check_dns -H $hostname_valid -a $hostname_invalid_cidr -t 5"); cmp_ok( $res->return_code, '==', 2, "Got wrong address"); like ( $res->output, "/^DNS CRITICAL.*expected '$hostname_invalid_cidr' but got '$hostname_valid_ip'".'$/', "Output OK"); + +$res = NPTest->testCmd("./check_dns -H $hostname_valid -n"); +cmp_ok( $res->return_code, '==', 2, "Found $hostname_valid"); +like ( $res->output, "/^DNS CRITICAL.*Domain '$hostname_valid' was found by the server:/", "Output OK"); + +$res = NPTest->testCmd("./check_dns -H $hostname_invalid -n"); +cmp_ok( $res->return_code, '==', 0, "Did not find $hostname_invalid"); +like ( $res->output, $successOutput, "Output OK" ); -- cgit v1.2.3-74-g34f1