Skip to content

Check dns misc improvements#417

Open
inqrphl wants to merge 8 commits into
mainfrom
check-dns-misc-improvements
Open

Check dns misc improvements#417
inqrphl wants to merge 8 commits into
mainfrom
check-dns-misc-improvements

Conversation

@inqrphl

@inqrphl inqrphl commented Jul 16, 2026

Copy link
Copy Markdown
Contributor

make 'time' metric track the total time needed for queries. add warning and critical thresholds to its perfdata

improve argument description text for norec,warning,critical,timeout

fix some grammatical issues and typos

return unknown when getting a timeout and exit immediately

ai pass - add validator functions to the arguments and tests

rework output when no valid query answer is present. output line says that host cant be resolved, following lines give error types for each nameserver

add query-timeout parameter. uses the timeout in the DNS library client

make --server argument save to a []string. multiple namesvers can be passed by arguments now

example output:

./snclient -vvv --logfile stdout run check_dns -H thishostdoesnotexist.com --server 1.1.1.1 --server 8.8.8.8 --server 192.168.178.21 --search-path de --search-path tr --search-path uk --timeout 100

[14:40:26.616][T][check_dns:137] DNS nameservers: [1.1.1.1:53 8.8.8.8:53 192.168.178.21:53] 
[14:40:26.616][T][check_dns:147] DNS search paths: [de tr uk] 
[14:40:26.616][T][check_dns:163] DNS host candidates: [thishostdoesnotexist.com.de. thishostdoesnotexist.com.tr. thishostdoesnotexist.com.uk. thishostdoesnotexist.com.] 
[14:40:26.677][T][check_dns:106] DNS query returned empty result (NXDOMAIN), continuing to next combination, host: thishostdoesnotexist.com.de., nameserver: 1.1.1.1:53, duration: 61ms
[14:40:26.731][T][check_dns:106] DNS query returned empty result (NXDOMAIN), continuing to next combination, host: thishostdoesnotexist.com.de., nameserver: 8.8.8.8:53, duration: 53ms
[14:40:31.731][T][check_dns:106] DNS query failed, host: thishostdoesnotexist.com.de., nameserver: 192.168.178.21:53, duration: 5000ms, error: read udp 192.168.178.22:56811->192.168.178.21:53: i/o timeout
[14:40:31.763][T][check_dns:106] DNS query returned empty result (NXDOMAIN), continuing to next combination, host: thishostdoesnotexist.com.tr., nameserver: 1.1.1.1:53, duration: 31ms
[14:40:31.842][T][check_dns:106] DNS query returned empty result (NXDOMAIN), continuing to next combination, host: thishostdoesnotexist.com.tr., nameserver: 8.8.8.8:53, duration: 79ms
[14:40:36.843][T][check_dns:106] DNS query failed, host: thishostdoesnotexist.com.tr., nameserver: 192.168.178.21:53, duration: 5001ms, error: read udp 192.168.178.22:36156->192.168.178.21:53: i/o timeout
[14:40:36.897][T][check_dns:106] DNS query returned empty result (NXDOMAIN), continuing to next combination, host: thishostdoesnotexist.com.uk., nameserver: 1.1.1.1:53, duration: 53ms
[14:40:36.920][T][check_dns:106] DNS query returned empty result (NXDOMAIN), continuing to next combination, host: thishostdoesnotexist.com.uk., nameserver: 8.8.8.8:53, duration: 23ms
[14:40:41.921][T][check_dns:106] DNS query failed, host: thishostdoesnotexist.com.uk., nameserver: 192.168.178.21:53, duration: 5000ms, error: read udp 192.168.178.22:52099->192.168.178.21:53: i/o timeout
[14:40:41.964][T][check_dns:106] DNS query returned empty result (NXDOMAIN), continuing to next combination, host: thishostdoesnotexist.com., nameserver: 1.1.1.1:53, duration: 43ms
[14:40:41.996][T][check_dns:106] DNS query returned empty result (NXDOMAIN), continuing to next combination, host: thishostdoesnotexist.com., nameserver: 8.8.8.8:53, duration: 31ms
[14:40:46.997][T][check_dns:106] DNS query failed, host: thishostdoesnotexist.com., nameserver: 192.168.178.21:53, duration: 5000ms, error: read udp 192.168.178.22:40246->192.168.178.21:53: i/o timeout
...
CRITICAL - dns lookup failed for host 'thishostdoesnotexist.com':
1.1.1.1:53: NXDOMAIN
8.8.8.8:53: NXDOMAIN
192.168.178.21:53: query failed: timeout

./snclient -vvv --logfile stdout run check_dns -H google.com --server thisdnsnameserverdoesnotexist --serve
r 8.8.8.8 --search-path de --search-path tr --search-path uk --timeout 100 --query-timeout 5

OK - google.com returns 142.251.143.3 (A) |time=0.205451s;;
HEADER-> ;; opcode: QUERY, status: NOERROR, id: 16721
;; flags: qr rd ra;
ANSWER-> google.com.tr. 300     IN      A       142.251.143.3

Ahmet Oeztuerk added 2 commits July 16, 2026 18:23
improve argument description text for norec,warning,critical,timeout

fix some grammatical issues and typos

return unknown when getting a timeout and exit immediately
@inqrphl
inqrphl marked this pull request as draft July 17, 2026 06:34
@inqrphl
inqrphl marked this pull request as ready for review July 17, 2026 07:36
Ahmet Oeztuerk added 3 commits July 17, 2026 13:56
…nse came

save them in a slice with details, then generate an output that looks like this:

dns lookup failed for host: 'host' :
nameserver1: err1, err2, err3
nameserver2:  err1, err2

tests written completely using ai

add test function that creates local dns nameserver that always replies with a specific return code

use it to check errored output when every query is errored/empty.
…dividual query.

adjust global timeout to 30 seconds, and query timeout to 5 seconds

add tests, ai generated, checking query timeout parameter
split up test functions, rename some variables
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant