Commit e3d098e1 authored by Stephane Bortzmeyer's avatar Stephane Bortzmeyer
Browse files

Merge branch 'master' into option-check

parents e9dc4d65 a34ecfa4
......@@ -129,6 +129,7 @@ monitoring plugins conventions:
* -n: domain name to lookup
* -t: DNS type to query
* -p: (DoH) path in the URLx
* -e: a string to expect in the result
* -P: uses the HTTP method POST
* -h: uses the HTTP method HEAD
* -i: insecure (do not check the certificate)
......@@ -143,6 +144,7 @@ object CheckCommand "doh_monitor" {
"-H" = "$address6$",
"-n" = "$doh_lookup$",
"-p" = "$doh_path$",
"-e" = "$doh_expect$",
"-V" = "$doh_vhost$",
"-t" = "$doh_type$",
"-P" = "$doh_post$",
......@@ -158,6 +160,7 @@ object CheckCommand "dot_monitor" {
"-H" = "$address6$",
"-n" = "$dot_lookup$",
"-p" = "$dot_path$",
"-e" = "$dot_expect$",
"-V" = "$dot_vhost$",
"-t" = "$dot_type$",
"-P" = "$dot_post$",
......@@ -264,7 +267,7 @@ GPL. See LICENSE.
## Author
Stéphane Bortzmeyer <stephane+framagit@bortzmeyer.org>
Stéphane Bortzmeyer <stephane+framagit@bortzmeyer.org> and Alexandre Pion
## Reference site
......
......@@ -55,6 +55,7 @@ check_additional = True
# Monitoring plugin only:
host = None
path = None
expect = None
# Do not change these
re_host = re.compile(r'^([0-9a-z][0-9a-z-\.]*)|([0-9:]+)|([0-9\.])$')
......@@ -533,6 +534,10 @@ def print_result(connection, request, prefix=None, display_err=True):
if not check or verbose:
print(msg)
else:
if expect is not None and expect not in str(request.response):
ok = False
print("%s Cannot find \"%s\" in response" % (server, expect))
sys.exit(STATE_CRITICAL)
if size is not None and size > 0:
print("%s OK - %s" % (server, "No error for %s/%s, %i bytes received" % (name, rtype, size)))
else:
......@@ -771,7 +776,7 @@ else: # Monitoring plugin
dot = (me == "check_dot")
name = None
try:
optlist, args = getopt.getopt (sys.argv[1:], "H:n:p:V:t:Pih46")
optlist, args = getopt.getopt (sys.argv[1:], "H:n:p:V:t:e:Pih46")
for option, value in optlist:
if option == "-H":
host = value
......@@ -781,6 +786,8 @@ else: # Monitoring plugin
name = value
elif option == "-t":
rtype = value
elif option == "-e":
expect = value
elif option == "-p":
path = value
elif option == "-P":
......
......@@ -407,6 +407,40 @@ tests:
stderr: ''
partstdout: 'litteral IPv6'
- exe: './check_dot'
name: '[check_dot] Test there is the expected string'
markers:
- 'dot'
- 'monitoring'
- 'exception'
args:
- '-H'
- 'dot.bortzmeyer.fr'
- '-n'
- 'ressources-pedagogiques.org'
- '-e'
- '2605:4500:2:245b::42'
retcode: 0
stderr: ''
partstdout: 'OK - No error'
- exe: './check_dot'
name: '[check_dot] Test there is *not* the expected string'
markers:
- 'dot'
- 'monitoring'
- 'exception'
args:
- '-H'
- 'dot.bortzmeyer.fr'
- '-n'
- 'ressources-pedagogiques.org'
- '-e'
- 'foobar'
retcode: 2
stderr: ''
partstdout: 'Cannot find'
################################################################################
......@@ -551,6 +585,40 @@ tests:
stderr: ''
partstdout: 'litteral IPv6'
- exe: './check_doh'
name: '[check_doh] Test there is the expected string'
markers:
- 'doh'
- 'monitoring'
- 'exception'
args:
- '-H'
- 'doh.bortzmeyer.fr'
- '-n'
- 'ressources-pedagogiques.org'
- '-e'
- '2605:4500:2:245b::42'
retcode: 0
stderr: ''
partstdout: 'OK - No error'
- exe: './check_doh'
name: '[check_doh] Test there is *not* the expected string'
markers:
- 'doh'
- 'monitoring'
- 'exception'
args:
- '-H'
- 'doh.bortzmeyer.fr'
- '-n'
- 'ressources-pedagogiques.org'
- '-e'
- 'foobar'
retcode: 2
stderr: ''
partstdout: 'Cannot find'
################################################################################
- exe: './homer.py'
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment