Module: check_mk
Branch: master
Commit: 5c06a837b89dcf9d45ca952e3deeae1c4eacdfca
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=5c06a837b89dcf…
Author: Mathias Kettner <mk(a)mathias-kettner.de>
Date: Fri May 23 15:48:53 2014 +0200
Add options -I and -T to check_traceroute
---
checks/check_traceroute | 7 +++++++
doc/treasures/active_checks/check_traceroute | 15 +++++++++++----
web/plugins/wato/active_checks.py | 12 +++++++++++-
3 files changed, 29 insertions(+), 5 deletions(-)
diff --git a/checks/check_traceroute b/checks/check_traceroute
index ff26112..6a48f4f 100644
--- a/checks/check_traceroute
+++ b/checks/check_traceroute
@@ -28,6 +28,13 @@ def check_traceroute_arguments(params):
args = ""
if params["dns"]:
args += "-n "
+ method = params["method"]
+ if method == "icmp":
+ args += "-I "
+ elif method == "tcp":
+ args += "-T "
+ # else: None -> default method
+
for router, state in params["routers"]:
args += "-%s %s " % (state, quote_shell_string(router))
args += '"$HOSTADDRESS$"'
diff --git a/doc/treasures/active_checks/check_traceroute
b/doc/treasures/active_checks/check_traceroute
index 6b6f8f9..6f57927 100755
--- a/doc/treasures/active_checks/check_traceroute
+++ b/doc/treasures/active_checks/check_traceroute
@@ -63,15 +63,17 @@ import os, sys, getopt, subprocess
def option_to_state(c):
return { "w" : 1, "c" : 2 }[c.lower()]
-def check_traceroute(target, routes, nodns):
+def check_traceroute(target, routes, nodns, method):
args = ["traceroute"]
if nodns:
args.append("-n")
+ if method:
+ args.append(method)
args.append(target)
p = subprocess.Popen(args, stdout=subprocess.PIPE, stderr=subprocess.PIPE,
shell=False)
sto, ste = p.communicate()
if p.returncode:
- return 3, "UNKNOWN - " + ste.replace("\n", " ")
+ return 3, "UNKNOWN - " + ste.replace("\n", " "),
""
# find all visited routers
routers = set([])
@@ -123,6 +125,8 @@ Other options:
-h, --help show this help and exit
--debug show Python exceptions verbosely
-n disable reverse DNS lookups
+ -I Use ICMP ECHO for probes
+ -T Use TCP SYN for probes
"""
@@ -131,8 +135,9 @@ os.unsetenv("LANG")
opt_verbose = 0
opt_debug = False
opt_nodns = False
+opt_method = None
-short_options = "hw:W:c:C:n"
+short_options = "hw:W:c:C:nTI"
long_options = [ "verbose", "help", "debug", ]
routes = []
@@ -150,6 +155,8 @@ try:
routes.append((o[1], a))
elif o == '-n':
opt_nodns = True
+ elif o in [ '-T', '-I' ]:
+ opt_method = o
# now handle action options
for o, a in opts:
@@ -162,7 +169,7 @@ try:
target = args[0]
- status, output, long_output = check_traceroute(target, routes, opt_nodns)
+ status, output, long_output = check_traceroute(target, routes, opt_nodns,
opt_method)
sys.stdout.write(output.strip() + "\n" + long_output)
sys.exit(status)
diff --git a/web/plugins/wato/active_checks.py b/web/plugins/wato/active_checks.py
index 24eeb5d..1ad90b7 100644
--- a/web/plugins/wato/active_checks.py
+++ b/web/plugins/wato/active_checks.py
@@ -1353,8 +1353,18 @@ register_rule(group,
add_label = _("Add Condition"),
)
),
+ ( "method",
+ DropdownChoice(
+ title = _("Method or probing"),
+ choices = [
+ ( None, _("UDP (default behaviour of tcpdump)") ),
+ ( "icmp", _("ICMP Echo Request") ),
+ ( "tcp", _("TCP SYN") ),
+ ]
+ )
+ ),
],
- required_keys = [ "dns", "routers" ],
+ optional_keys = False,
),
match = 'all'
)