Module: check_mk
Branch: master
Commit: ab07d442026c05a84f65c19c2d807f9a50f7e209
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=ab07d442026c05…
Author: Bernd Stroessenreuther <bs(a)mathias-kettner.de>
Date: Thu Jul 3 17:42:46 2014 +0200
raritan_pdu_outletcount: got levels now to check the value against and a WATO rule to set them
---
checkman/raritan_pdu_outletcount | 15 ++++++++++++---
checks/raritan_pdu_outletcount | 18 +++++++++++++++---
web/plugins/wato/check_parameters.py | 18 ++++++++++++++++++
3 files changed, 45 insertions(+), 6 deletions(-)
diff --git a/checkman/raritan_pdu_outletcount b/checkman/raritan_pdu_outletcount
index 6725d86..f5c6a97 100644
--- a/checkman/raritan_pdu_outletcount
+++ b/checkman/raritan_pdu_outletcount
@@ -4,14 +4,23 @@ catalog: hw/other
license: GPL
distribution: check_mk
description:
- This check displays the current outlet count of the Raritan PX-2000
+ Checks the current outlet count of the Raritan PX-2000
family of intelligent rack power distribution units (iPDUs).
- It is for reporting only and returns always {OK}.
+ By default this check does report only and returns always {OK}.
+ Only if you set levels explicitly, it returns {WARN} or {CRIT} if
+ the value is outside the given ranges.
perfdata:
- Exactly one number: The outlet count.
+ Exactly one number: The outlet count. If levels are given: Together
+ with it's levels.
inventory:
Creates exactly one check per host called Outlet Count.
+[parameters]
+tuple(int, int, int, int): crit_low, warn_low, warn_high, crit_high:
+ If the value is lower or equal crit_low, the check returns {CRIT}.
+ If the value is lower or equal warn_low, the check returns {WARN}.
+ If the value is higher or equal warn_high, the check returns {WARN}.
+ If the value is higher or equal crit_high, the check returns {CRIT}.
diff --git a/checks/raritan_pdu_outletcount b/checks/raritan_pdu_outletcount
index f55fa3a..0f3fb72 100644
--- a/checks/raritan_pdu_outletcount
+++ b/checks/raritan_pdu_outletcount
@@ -31,14 +31,26 @@ def inventory_raritan_pdu_outletcount(info):
return []
def check_raritan_pdu_outletcount(item, params, info):
- message = "Outlet Count is %s" % info[0][0]
- perfdata = [ ("outletcount", int(info[0][0])) ]
- return 0, message, perfdata
+ outletcount = int(info[0][0])
+ status = 0
+ if params:
+ crit_low, warn_low, warn_high, crit_high = params
+ perfdata = [ ("outletcount", outletcount, "%d:%d" % (warn_low, warn_high), "%d:%d" % (crit_low, crit_high), 0) ]
+ if outletcount <= warn_low or outletcount >= warn_high:
+ status = 1
+ if outletcount <= crit_low or outletcount >= crit_high:
+ status = 2
+ else:
+ perfdata = [ ("outletcount", outletcount, None, None, 0) ]
+
+ message = "Outlet Count is %s" % outletcount
+ return status, message, perfdata
check_info['raritan_pdu_outletcount'] = {
"inventory_function" : inventory_raritan_pdu_outletcount,
"check_function" : check_raritan_pdu_outletcount,
"service_description" : "Outlet Count",
+ "group" : "plug_count",
"has_perfdata" : True,
"snmp_info" : (".1.3.6.1.4.1.13742.6.3.2.2.1.4", ["1"]), # outletCount
"snmp_scan_function" : lambda oid: \
diff --git a/web/plugins/wato/check_parameters.py b/web/plugins/wato/check_parameters.py
index 9a3a1f0..4785542 100644
--- a/web/plugins/wato/check_parameters.py
+++ b/web/plugins/wato/check_parameters.py
@@ -5365,3 +5365,21 @@ register_check_parameters(
),
"first"
)
+
+register_check_parameters(
+ subgroup_environment,
+ "plug_count",
+ _("Number of active Plugs"),
+ Tuple(
+ help = _("Levels for the number of active plugs in a devices."),
+ elements = [
+ Integer(title = _("critical if below or equal"), default_value = 30),
+ Integer(title = _("warning if below or equal"), default_value = 32),
+ Integer(title = _("warning if above or equal"), default_value = 38),
+ Integer(title = _("critical if above or equal"), default_value = 40),
+ ]),
+ None,
+ "first"
+)
+
+
Module: check_mk
Branch: master
Commit: 4017bd67e1594df300f426d91c32db2d93262c09
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=4017bd67e1594d…
Author: Mathias Kettner <mk(a)mathias-kettner.de>
Date: Thu Jul 3 16:41:45 2014 +0200
FIX Remove icon for service parameters in WATO service list for missing services
In the services list of a host in WATO in the section <i>Available (missing) services</i>
the icon for the service parameters has been removed. It didn't work properly because
Check_MK cannot safely analyse non-existent services. It is dangerous anyway if the user
thinks he could do configuration for those services.
---
.werks/1044 | 11 +++++++++++
ChangeLog | 1 +
modules/automation.py | 2 +-
web/htdocs/wato.py | 11 ++++++-----
4 files changed, 19 insertions(+), 6 deletions(-)
diff --git a/.werks/1044 b/.werks/1044
new file mode 100644
index 0000000..c5061b4
--- /dev/null
+++ b/.werks/1044
@@ -0,0 +1,11 @@
+Title: Remove icon for service parameters in WATO service list for missing services
+Level: 1
+Component: wato
+Version: 1.2.5i5
+Date: 1404398390
+Class: fix
+
+In the services list of a host in WATO in the section <i>Available (missing) services</i>
+the icon for the service parameters has been removed. It didn't work properly because
+Check_MK cannot safely analyse non-existent services. It is dangerous anyway if the user
+thinks he could do configuration for those services.
diff --git a/ChangeLog b/ChangeLog
index b501045..9228911 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -43,6 +43,7 @@
* 1004 FIX: Fix exception when saving rules, caused by empty item
* 0947 FIX: WATO snapshots: fixed missing files on restoring nagvis backup domains
* 0826 FIX: Fixed problem where user access times were not updated correctly
+ * 1044 FIX: Remove icon for service parameters in WATO service list for missing services...
Notifications:
* 1042 Rule based notifications: allow matching on host groups...
diff --git a/modules/automation.py b/modules/automation.py
index e0eca6c..2882a54 100644
--- a/modules/automation.py
+++ b/modules/automation.py
@@ -637,7 +637,7 @@ def automation_analyse_service(args):
"item" : item,
"inv_parameters" : params,
"factory_settings" : fs,
- "parameters" : compute_check_parameters(hostname, ct, item, params),
+ "parameters" : compute_check_parameters(hostname, ct, item, params),
}
except:
if opt_debug:
diff --git a/web/htdocs/wato.py b/web/htdocs/wato.py
index 4fb4a60..a96c89a 100644
--- a/web/htdocs/wato.py
+++ b/web/htdocs/wato.py
@@ -3343,12 +3343,13 @@ def show_service_table(host, firsttime):
# #html.write('<a href="%s"><img title="%s" class=icon src="images/icon_rulesets.png"></a>' %
# # (url, title))
- # Icon for Service parameters
+ # Icon for Service parameters. Not for missing services!
table.cell("", "")
- params_url = make_link([("mode", "object_parameters"),
- ("host", hostname),
- ("service", descr)])
- html.icon_button(params_url, _("View and modify the parameters for this service"), "rulesets")
+ if state_type != "new":
+ params_url = make_link([("mode", "object_parameters"),
+ ("host", hostname),
+ ("service", descr)])
+ html.icon_button(params_url, _("View and modify the parameters for this service"), "rulesets")
# Permanently disable icon
Module: check_mk
Branch: master
Commit: a4443cd72ef6bff7af26ba3126ae327cb73e4d7b
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=a4443cd72ef6bf…
Author: Mathias Kettner <mk(a)mathias-kettner.de>
Date: Thu Jul 3 11:02:27 2014 +0200
Rule based notifications: allow matching on host groups
In the rule based notifications you can now use host group membership
for matching. It is allowed to select severel groups at once, one of
which the host must be member of.
---
.werks/1042 | 10 ++++++++++
ChangeLog | 3 +++
check_mk_templates.cfg | 1 +
modules/notify.py | 22 ++++++++++++++++++++++
web/htdocs/valuespec.py | 4 ++++
web/htdocs/wato.py | 25 ++++++++++++++++++++-----
6 files changed, 60 insertions(+), 5 deletions(-)
diff --git a/.werks/1042 b/.werks/1042
new file mode 100644
index 0000000..1ab41e6
--- /dev/null
+++ b/.werks/1042
@@ -0,0 +1,10 @@
+Title: Rule based notifications: allow matching on host groups
+Level: 2
+Component: notifications
+Version: 1.2.5i5
+Date: 1404378080
+Class: feature
+
+In the rule based notifications you can now use host group membership
+for matching. It is allowed to select severel groups at once, one of
+which the host must be member of.
diff --git a/ChangeLog b/ChangeLog
index 0d6e465..0f2e3e9 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -42,6 +42,9 @@
* 0947 FIX: WATO snapshots: fixed missing files on restoring nagvis backup domains
* 0826 FIX: Fixed problem where user access times were not updated correctly
+ Notifications:
+ * 1042 Rule based notifications: allow matching on host groups...
+
Reporting & Availability:
* 0991 FIX: Availability: optionally show time stamps as UNIX epoch time...
diff --git a/check_mk_templates.cfg b/check_mk_templates.cfg
index 406fc57..117cd50 100644
--- a/check_mk_templates.cfg
+++ b/check_mk_templates.cfg
@@ -395,6 +395,7 @@ define command {
NOTIFY_NOTIFICATIONAUTHOR='$NOTIFICATIONAUTHOR$' \
NOTIFY_NOTIFICATIONAUTHORNAME='$NOTIFICATIONAUTHORNAME$' \
NOTIFY_NOTIFICATIONAUTHORALIAS='$NOTIFICATIONAUTHORALIAS$' \
+ NOTIFY_HOSTGROUPNAMES='$HOSTGROUPNAMES$' \
NOTIFY_HOSTTAGS='$_HOSTTAGS$' \
NOTIFY_HOST_SL='$_HOSTEC_SL$' \
NOTIFY_SVC_SL='$_SERVICEEC_SL$' \
diff --git a/modules/notify.py b/modules/notify.py
index b39c8da..d9db00e 100644
--- a/modules/notify.py
+++ b/modules/notify.py
@@ -617,6 +617,7 @@ def rbn_match_rule(rule, context):
return \
rbn_match_folder(rule, context) or \
rbn_match_hosttags(rule, context) or \
+ rbn_match_hostgroups(rule, context) or \
rbn_match_hosts(rule, context) or \
rbn_match_exclude_hosts(rule, context) or \
rbn_match_services(rule, context) or \
@@ -662,6 +663,27 @@ def rbn_match_hosttags(rule, context):
"|".join(tags), "|".join(required))
+def rbn_match_hostgroups(rule, context):
+ required_groups = rule.get("match_hostgroups")
+ if required_groups != None:
+ hgn = context.get("HOSTGROUPNAMES")
+ if hgn == None:
+ return "No information about host groups is in the context, but host " \
+ "must be in group %s" % ( " or ".join(required_groups))
+ if hgn:
+ hostgroups = hgn.split(",")
+ else:
+ return "The host is in no group, but %s is required" % (
+ " or ".join(required_groups))
+
+ for group in required_groups:
+ if group in hostgroups:
+ return
+
+ return "The host only is the groups %s, but %s is required" % (
+ hgn, " or ".join(required_groups))
+
+
def rbn_match_hosts(rule, context):
if "match_hosts" in rule:
hostlist = rule["match_hosts"]
diff --git a/web/htdocs/valuespec.py b/web/htdocs/valuespec.py
index c3997b5..cbd72f5 100644
--- a/web/htdocs/valuespec.py
+++ b/web/htdocs/valuespec.py
@@ -1372,6 +1372,10 @@ class DualListChoice(ListChoice):
def render_input(self, varprefix, value):
self.load_elements()
+ if not self._elements:
+ html.write(_("There are no elements for selection."))
+ return
+
selected = []
unselected = []
if self._custom_order:
diff --git a/web/htdocs/wato.py b/web/htdocs/wato.py
index d8ac8ca..4fb4a60 100644
--- a/web/htdocs/wato.py
+++ b/web/htdocs/wato.py
@@ -8057,6 +8057,17 @@ def FolderChoice(**kwargs):
return DropdownChoice(**kwargs)
+class HostgroupChoice(DualListChoice):
+ def __init__(self, **kwargs):
+ DualListChoice.__init__(self, **kwargs)
+ self._choices = lambda: self.load_groups()
+
+ def load_groups(self):
+ all_groups = userdb.load_group_information()
+ this_group = all_groups.get("host", {})
+ return [ (k, t and t or k) for (k, t) in this_group.items() ]
+
+
def vs_notification_bulkby():
return ListChoice(
title = _("Create separate notification bulks based on"),
@@ -8193,6 +8204,13 @@ def vs_notification_rule(userid = None):
HostTagCondition(
title = _("Match Host Tags"))
),
+ ( "match_hostgroups",
+ HostgroupChoice(
+ title = _("Match Host Groups"),
+ help = _("The host must be in one of the selected host groups"),
+ allow_empty = False,
+ )
+ ),
( "match_hosts",
ListOfStrings(
title = _("Match only the following hosts"),
@@ -8423,7 +8441,7 @@ def vs_notification_rule(userid = None):
),
],
- optional_keys = [ "match_folder", "match_hosttags", "match_hosts", "match_exclude_hosts",
+ optional_keys = [ "match_folder", "match_hosttags", "match_hostgroups", "match_hosts", "match_exclude_hosts",
"match_services", "match_exclude_services", "match_plugin_output",
"match_timeperiod", "match_escalation", "match_escalation_throttle",
"match_sl", "match_host_event", "match_service_event",
@@ -8433,7 +8451,7 @@ def vs_notification_rule(userid = None):
( _("Notification Method"), [ "notify_plugin", "notify_method", "bulk" ] ),]
+ contact_headers
+ [
- ( _("Conditions"), [ "match_folder", "match_hosttags", "match_hosts", "match_exclude_hosts",
+ ( _("Conditions"), [ "match_folder", "match_hosttags", "match_hostgroups", "match_hosts", "match_exclude_hosts",
"match_services", "match_exclude_services", "match_plugin_output",
"match_checktype", "match_timeperiod",
"match_escalation", "match_escalation_throttle",
@@ -15791,8 +15809,6 @@ class HostTagCondition(ValueSpec):
raise MKUserError(varprefix, _("The list of host tags must only contain strings "
"but also contains %r") % x)
-
-
def validate_value(self, value, varprefix):
pass
@@ -15800,7 +15816,6 @@ class HostTagCondition(ValueSpec):
-
# We need to replace the BI constants internally with something
# that we can replace back after writing the BI-Rules out
# with pprint.pformat