Module: check_mk
Branch: master
Commit: 0955d471405a6b4498b5b89641fba0f8c5b69569
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=0955d471405a6b…
Author: Mathias Kettner <mk(a)mathias-kettner.de>
Date: Tue Oct 1 11:55:01 2013 +0200
check_icmp: New WATO rule for custom PING checks
---
ChangeLog | 2 +
checks/check_icmp | 52 ++++++++++++++++++++++++++
pnp-templates/check_mk_active-icmp.php | 1 +
web/plugins/wato/active_checks.py | 64 ++++++++++++++++++++++++++++++++
web/plugins/wato/check_parameters.py | 40 +-------------------
5 files changed, 121 insertions(+), 38 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index ac14720..72e4315 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,11 +1,13 @@
1.2.3i3:
Checks & Agents:
* windows_agent: increased maximum plugin output buffer size to 2MB
+ * check_icmp: New WATO rule for custom PING checks
* FIX: windows_agent: fixed bug in cleanup of open thread handles
* FIX: cups default printer is now monitored again in linux agent
* FIX: host notification email in html format: fixed formating error
(typo in tag)
+
Multisite:
* FIX: add missing service icons to view "All Services with this descr..."
* FIX: ldap attribute plugins: fixed crash when parameters are None
diff --git a/checks/check_icmp b/checks/check_icmp
new file mode 100644
index 0000000..cd8eeee
--- /dev/null
+++ b/checks/check_icmp
@@ -0,0 +1,52 @@
+#!/usr/bin/python
+# -*- encoding: utf-8; py-indent-offset: 4 -*-
+# +------------------------------------------------------------------+
+# | ____ _ _ __ __ _ __ |
+# | / ___| |__ ___ ___| | __ | \/ | |/ / |
+# | | | | '_ \ / _ \/ __| |/ / | |\/| | ' / |
+# | | |___| | | | __/ (__| < | | | | . \ |
+# | \____|_| |_|\___|\___|_|\_\___|_| |_|_|\_\ |
+# | |
+# | Copyright Mathias Kettner 2013 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_icmp_arguments(params):
+ args = []
+ rta = 200, 500
+ loss = 80, 100
+ for key, value in params.items():
+ if key == "timeout":
+ args.append("-t %d" % value)
+ elif key == "packets":
+ args.append("-n %d" % value)
+ elif key == "rta":
+ rta = value
+ elif key == "loss":
+ loss = value
+ args.append("-w %.2f,%.2f%%" % (rta[0], loss[0]))
+ args.append("-c %.2f,%.2f%%" % (rta[1], loss[1]))
+ args.append("'$HOSTADDRESS$'")
+ return " ".join(args)
+
+
+active_check_info['icmp'] = {
+ "command_line" : '$USER1$/check_icmp $ARG1$',
+ "argument_function" : check_icmp_arguments,
+ "service_description" : lambda args: args.get("description", "PING"),
+ "has_perfdata" : True,
+}
+
diff --git a/pnp-templates/check_mk_active-icmp.php b/pnp-templates/check_mk_active-icmp.php
new file mode 120000
index 0000000..98c29f2
--- /dev/null
+++ b/pnp-templates/check_mk_active-icmp.php
@@ -0,0 +1 @@
+check-mk-ping.php
\ No newline at end of file
diff --git a/web/plugins/wato/active_checks.py b/web/plugins/wato/active_checks.py
index 1ee64a0..a622d4f 100644
--- a/web/plugins/wato/active_checks.py
+++ b/web/plugins/wato/active_checks.py
@@ -29,6 +29,70 @@ register_rulegroup("activechecks",
_("Configure active networking checks like HTTP and TCP"))
group = "activechecks"
+# This elements are also used in check_parameters.py
+check_icmp_params = [
+ ( "rta",
+ Tuple(
+ title = _("Round trip average"),
+ elements = [
+ Float(title = _("Warning if above"), unit = "ms", default_value = 200.0),
+ Float(title = _("Critical if above"), unit = "ms", default_value = 500.0),
+ ])),
+ ( "loss",
+ Tuple(
+ title = _("Packet loss"),
+ help = _("When the percentual number of lost packets is equal or greater then "
+ "the level, then the according state is triggered. The default for critical "
+ "is 100%. That means that the check is only critical if <b>all</b> packets "
+ "are lost."),
+ elements = [
+ Percentage(title = _("Warning if above"), default_value = 80.0),
+ Percentage(title = _("Critical if above"), default_value = 100.0),
+ ])),
+
+ ( "packets",
+ Integer(
+ title = _("Number of packets"),
+ help = _("Number ICMP echo request packets to send to the target host on each "
+ "check execution. All packets are sent directly on check execution. Afterwards "
+ "the check waits for the incoming packets."),
+ minvalue = 1,
+ maxvalue = 20,
+ default_value = 5,
+ )),
+
+ ( "timeout",
+ Integer(
+ title = _("Total timeout of check"),
+ help = _("After this time (in seconds) the check is aborted, regardless "
+ "of how many packets have been received yet."),
+ minvalue = 1,
+ )),
+]
+
+
+register_rule(group,
+ "active_checks:icmp",
+ Dictionary(
+ title = _("Check hosts with PING (ICMP Echo Request)"),
+ help = _("This ruleset allows you to configure explizit PING monitoring of hosts. "
+ "Usually a PING is being used as a host check, so this is not neccessary. "
+ "There are some situations, however, where this can be useful. One of them "
+ "is when using the Check_MK Micro Core with SMART Ping and you want to "
+ "track performance data of the PING to some hosts, nevertheless."),
+ elements = [
+ ( "description",
+ TextUnicode(
+ title = _("Service Description"),
+ allow_empty = False,
+ default_value = "PING",
+ ))
+ ] + check_icmp_params,
+ match = "all",
+ )
+)
+
+
register_rule(group,
"active_checks:dns",
Tuple(
diff --git a/web/plugins/wato/check_parameters.py b/web/plugins/wato/check_parameters.py
index 3b6995c..438e24a 100644
--- a/web/plugins/wato/check_parameters.py
+++ b/web/plugins/wato/check_parameters.py
@@ -50,44 +50,8 @@ register_rule(group + "/" + subgroup_networking,
help = _("This rule sets the parameters for the host checks (via <tt>check_icmp</tt>) "
"and also for PING checks on ping-only-hosts. For the host checks only the "
"critical state is relevant, the warning levels are ignored."),
- elements = [
- ( "rta",
- Tuple(
- title = _("Round trip average"),
- elements = [
- Float(title = _("Warning if above"), unit = "ms"),
- Float(title = _("Critical if above"), unit = "ms"),
- ])),
- ( "loss",
- Tuple(
- title = _("Packet loss"),
- help = _("When the percentual number of lost packets is equal or greater then "
- "the level, then the according state is triggered. The default for critical "
- "is 100%. That means that the check is only critical if <b>all</b> packets "
- "are lost."),
- elements = [
- Percentage(title = _("Warning if above")),
- Percentage(title = _("Critical if above")),
- ])),
-
- ( "packets",
- Integer(
- title = _("Number of packets"),
- help = _("Number ICMP echo request packets to send to the target host on each "
- "check execution. All packets are sent directly on check execution. Afterwards "
- "the check waits for the incoming packets."),
- minvalue = 1,
- maxvalue = 20,
- )),
-
- ( "timeout",
- Integer(
- title = _("Total timeout of check"),
- help = _("After this time (in seconds) the check is aborted, regardless "
- "of how many packets have been received yet."),
- minvalue = 1,
- )),
- ]),
+ elements = check_icmp_params,
+ ),
match="dict")
register_rule(group + '/' + subgroup_applications,