Module: check_mk
Branch: master
Commit: 2f3575bbde4cb97740d5a499d7fe6b7a737d151e
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=2f3575bbde4cb9…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Thu Sep 12 14:35:19 2013 +0200
check_form_submit: Finished implementing checking multiple hosts ; added number of
succeeded check levels
---
checks/check_form_submit | 17 ++++++-----
doc/treasures/active_checks/check_form_submit | 8 +++--
web/htdocs/userdb.py | 2 +-
web/plugins/wato/active_checks.py | 40 ++++++++++++-------------
4 files changed, 35 insertions(+), 32 deletions(-)
diff --git a/checks/check_form_submit b/checks/check_form_submit
index 6a76dfa..ee69015 100644
--- a/checks/check_form_submit
+++ b/checks/check_form_submit
@@ -29,12 +29,7 @@ def check_form_submit_arguments(params):
args = ''
if "virthost" in settings:
- vhost, omit_ip = settings["virthost"]
- args += ' -H %s' % quote_shell_string(vhost)
- if omit_ip:
- args += ' -I %s' % quote_shell_string(vhost)
- else:
- omit_ip = False
+ args += ' -H %s' % quote_shell_string(settings["virthost"])
if "port" in settings:
args += ' -p %d' % settings["port"]
@@ -57,8 +52,14 @@ def check_form_submit_arguments(params):
if "query" in settings:
args += ' -q %s' % quote_shell_string(settings["query"])
- if not omit_ip:
- args = " -I $HOSTADDRESS$" + args
+ if "num_succeeded" in settings:
+ args += ' -n %s' % ','.join(map(str,
settings["num_succeeded"]))
+
+ if not settings.get('hosts'):
+ args += " -I $HOSTADDRESS$"
+ else:
+ for address in settings['hosts']:
+ args += " -I %s" % quote_shell_string(address)
return args
diff --git a/doc/treasures/active_checks/check_form_submit
b/doc/treasures/active_checks/check_form_submit
index dcd3858..cb69f80 100755
--- a/doc/treasures/active_checks/check_form_submit
+++ b/doc/treasures/active_checks/check_form_submit
@@ -48,7 +48,7 @@
#
# ./check_form_submit -I localhost -u /event -q
'_origtarget=wato.py&_username=omdadmin&_password=omd' -e 'WATO'
-import sys, getopt, urllib2, urllib, re
+import sys, getopt, urllib2, urllib, re, socket
def usage():
sys.stderr.write("""
@@ -200,6 +200,8 @@ def open_url(url, method = 'GET', data = None):
new_state(2, 'Unable to open %s: [%d] %s' % (url, e.code, e.reason))
except urllib2.URLError, e:
new_state(2, 'Unable to open %s: %s' % (url, e.reason))
+ except socket.timeout, e:
+ new_state(2, 'Unable to open %s: %s' % (url, e))
real_url = fd.geturl()
code = fd.getcode()
content = fd.read()
@@ -324,10 +326,10 @@ try:
# use the worst state as summary state
sum_state = max_state
- elif num_crit is not None and len(failed) >= num_crit:
+ elif num_crit is not None and len(success) <= num_crit:
sum_state = 2
- elif num_warn is not None and len(failed) >= num_warn:
+ elif num_warn is not None and len(success) <= num_warn:
sum_state = 1
txt = '%d succeeded, %d failed' % (len(success), len(failed))
diff --git a/web/htdocs/userdb.py b/web/htdocs/userdb.py
index 2e9b55e..13281b9 100644
--- a/web/htdocs/userdb.py
+++ b/web/htdocs/userdb.py
@@ -302,7 +302,7 @@ def load_users(lock = False):
id = d
# read special values from own files
- for val, conv_func in [ ('num_failed', int), ('last_seen',
float) ]:
+ for val, conv_func in [ ('num_failed', saveint),
('last_seen', savefloat) ]:
if id in result:
try:
result[id][val] = conv_func(file(dir + d + '/' + val +
'.mk').read().strip())
diff --git a/web/plugins/wato/active_checks.py b/web/plugins/wato/active_checks.py
index f8dfe06..449693a 100644
--- a/web/plugins/wato/active_checks.py
+++ b/web/plugins/wato/active_checks.py
@@ -928,27 +928,20 @@ register_rule(group,
Dictionary(
title = _("Check the URL"),
elements = [
- ("virthost", Tuple(
+ ("hosts", ListOfStrings(
+ title = _('Check specific host(s)'),
+ help = _('By default, if you do not specify any host
addresses here, '
+ 'the host address of the host this service is
assigned to will '
+ 'be used. But by specifying one or several host
addresses here, '
+ 'it is possible to let the check monitor one or
multiple hosts.')
+ )),
+ ("virthost", TextAscii(
title = _("Virtual host"),
- elements = [
- TextAscii(
- title = _("Name of the virtual host"),
- help = _("Set this in order to specify the name of
the "
- "virtual host for the query (using HTTP/1.1). When
you "
- "leave this empty, then the IP address of the host
"
- "will be used instead."),
- allow_empty = False
- ),
- Checkbox(
- label = _("Omit specifying an IP address"),
- help = _("Usually Check_MK will nail this check to
the "
- "IP address of the host it is attached to. With
this "
- "option you can have the check use the name of the
"
- "virtual host instead and do a dynamic DNS
lookup."),
- true_label = _("omit IP address"),
- false_label = _("specify IP address"),
- ),
- ]
+ help = _("Set this in order to specify the name of the
"
+ "virtual host for the query (using HTTP/1.1). When you
"
+ "leave this empty, then the IP address of the host "
+ "will be used instead."),
+ allow_empty = False,
)),
("uri", TextAscii(
title = _("URI to fetch (default is
<tt>/</tt>)"),
@@ -990,6 +983,13 @@ register_rule(group,
"is URL-encoded (for example
\"key1=val1&key2=val2\")."),
size = 40,
)),
+ ("num_succeeded", Tuple(
+ title = _("Multiple Hosts: Number of successful
results"),
+ elements = [
+ Integer(title = _("Warning if equal or below")),
+ Integer(title = _("Critical if equal or below")),
+ ]
+ )),
]
),
]