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

For monitoring, can test that an expected string is here. Closes #14

parent 9cf37711
......@@ -107,6 +107,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)
......@@ -121,6 +122,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$",
......@@ -136,6 +138,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$",
......@@ -242,7 +245,7 @@ GPL. See LICENSE.
## Author
Stéphane Bortzmeyer <stephane+framagit@bortzmeyer.org>
Stéphane Bortzmeyer <stephane+framagit@bortzmeyer.org> and Alexandre Pion
## Reference site
......
......@@ -52,6 +52,7 @@ connectTo = None
# 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\.])$')
......@@ -506,6 +507,10 @@ def print_result(connection, request):
if not monitoring:
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:
......@@ -603,7 +608,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
......@@ -613,6 +618,8 @@ else: # Monitoring plugin
name = value
elif option == "-t":
rtype = value
elif option == "-e":
expect = value
elif option == "-p":
path = value
elif option == "-P":
......
......@@ -337,6 +337,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'
################################################################################
......@@ -481,6 +515,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'
......
Markdown is supported
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