Module: check_mk
Branch: master
Commit: 0512487a221448398e7cd019645dfa1aa6317da7
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=0512487a221448…
Author: Bastian Kuhn <bk(a)mathias-kettner.de>
Date: Tue Aug 21 14:12:23 2012 +0200
Added check_dns for wato active checks
---
checks/check_dns | 55 ++++++++++++++++++++++++++++++++++
web/plugins/wato/active_checks.py | 59 ++++++++++++++++++++++++++++++++++++-
2 files changed, 113 insertions(+), 1 deletions(-)
diff --git a/checks/check_dns b/checks/check_dns
new file mode 100644
index 0000000..4eea0b5
--- /dev/null
+++ b/checks/check_dns
@@ -0,0 +1,55 @@
+#!/usr/bin/python
+# -*- encoding: utf-8; py-indent-offset: 4 -*-
+# +------------------------------------------------------------------+
+# | ____ _ _ __ __ _ __ |
+# | / ___| |__ ___ ___| | __ | \/ | |/ / |
+# | | | | '_ \ / _ \/ __| |/ / | |\/| | ' / |
+# | | |___| | | | __/ (__| < | | | | . \ |
+# | \____|_| |_|\___|\___|_|\_\___|_| |_|_|\_\ |
+# | |
+# | Copyright Mathias Kettner 2012 mk(a)mathias-kettner.de |
+# +------------------------------------------------------------------+
+#
+# This file is part of Check_MK.
+# The official homepage is at
http://mathias-kettner.de/check_mk.
+#
+# check_mk is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License as published by
+# the Free Software Foundation in version 2. check_mk is distributed
+# in the hope that it will be useful, but WITHOUT ANY WARRANTY; with-
+# out even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+# PARTICULAR PURPOSE. See the GNU General Public License for more de-
+# ails. You should have received a copy of the GNU General Public
+# License along with GNU Make; see the file COPYING. If not, write
+# to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
+# Boston, MA 02110-1301 USA.
+
+def check_dns_arguments(params):
+ description, settings = params
+ args = '-H %s' % quote_shell_string(description)
+
+ if "server" in settings:
+ args += ' -s %s' % quote_shell_string(settings["server"])
+
+ if "expected_address" in settings:
+ args += ' -a %s' %
quote_shell_string(settings["expected_address"])
+
+ if "expected_authority" in settings:
+ args += ' -A %s' %
quote_shell_string(settings["expected_authority"])
+
+ if "response_time" in settings:
+ args += ' -w %d' % int(settings["response_time"][0])
+ args += ' -c %d' % int(settings["response_time"][1])
+
+ if "timeout" in settings:
+ args += ' -t %d' % int(settings['timeout'])
+
+ return args
+
+active_check_info['dns'] = {
+ "command_line" : '$USER1$/check_dns $ARG1$',
+ "argument_function" : check_dns_arguments,
+ "service_description" : lambda params: "DNS %s" % params[0],
+ "has_perfdata" : False,
+}
+
diff --git a/web/plugins/wato/active_checks.py b/web/plugins/wato/active_checks.py
index a231038..38606f5 100644
--- a/web/plugins/wato/active_checks.py
+++ b/web/plugins/wato/active_checks.py
@@ -30,6 +30,64 @@ register_rulegroup("activechecks",
group = "activechecks"
register_rule(group,
+ "active_checks:dns",
+ Tuple(
+ title = _("Check DNS service"),
+ help = _("Check optain an IP address for a host or domain"
+ "It uses <tt>check_dns</tt> from standard
plugins."),
+ elements = [
+ TextAscii(title = _("Hostname"), allow_empty = False,
+ help = _('The name or address you want to query')),
+ Dictionary(
+ title = _("Optional parameters"),
+ elements = [
+ ( "server",
+ TextAscii(
+ title = _("DNS Server"),
+ allow_empty = False,
+ help = _("Optional DNS server you want to use for the
lookup"))),
+ ( "expected_address",
+ TextAscii(
+ title = _("Expected Address"),
+ allow_empty = False,
+ help = _("Optional IP-ADDRESS you expect the DNS server to
return. HOST"
+ "must end with a dot (.) " )),
+ ),
+ ( "expected_authority",
+ TextAscii(
+ title = _("Expected Authority"),
+ allow_empty = False,
+ help = _("Optional expect the DNS server to be
authoriative"
+ "for the lookup ")),
+ ),
+ ( "response_time",
+ Tuple(
+ title = _("Expected response time"),
+ elements = [
+ Float(
+ title = _("Warning at"),
+ unit = "sec",
+ default_value = 1),
+ Float(
+ title = _("Critical at"),
+ unit = "sec",
+ default_value = 2),
+ ])
+ ),
+ ( "timeout",
+ Integer(
+ title = _("Seconds before connection times out"),
+ unit = _("sec"),
+ default_value = 10,
+ )
+ ),
+ ]),
+ ]
+ ),
+ match = 'all')
+
+
+register_rule(group,
"active_checks:tcp",
Tuple(
title = _("Check connecting to a TCP port"),
@@ -165,7 +223,6 @@ register_rule(group,
match = 'all')
-
register_rule(group,
"active_checks:http",
Tuple(