Module: check_mk
Branch: master
Commit: 755595451c05e075eb046903671ae10c88d60c1f
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=755595451c05e0…
Author: Mathias Kettner <mk(a)mathias-kettner.de>
Date: Tue Feb 25 16:52:37 2014 +0100
RBN: Implement further conditions
---
modules/notify.py | 31 ++++++++++++++++++++++++-------
web/htdocs/wato.py | 8 +++++---
2 files changed, 29 insertions(+), 10 deletions(-)
diff --git a/modules/notify.py b/modules/notify.py
index 97acb51..8f39b79 100644
--- a/modules/notify.py
+++ b/modules/notify.py
@@ -339,10 +339,6 @@ def notify_keepalive():
global g_inactive_timerperiods
g_inactive_timerperiods = None
- # Invalidate timeperiod cache
- global g_inactive_timerperiods
- g_inactive_timerperiods = None
-
# If the configuration has changed, we do a restart. But we do
# this check just before the next notification arrives. We must
# *not* read data from stdin, just peek! There is still one
@@ -840,8 +836,6 @@ def format_exception():
# '----------------------------------------------------------------------'
def notify_rulebased(context):
- notify_log("RBN2!")
-
# First step: go through all rules and construct our table of
# notification plugins to call. This is a dict from (user, plugin) to
# a pair if (locked, parameters). If locked is True, then a user
@@ -900,7 +894,9 @@ def rbn_match_rule(rule, context):
rbn_match_services(rule, context) or \
rbn_match_exclude_services(rule, context) or \
rbn_match_checktype(rule, context) or \
- rbn_match_timeperiod(rule)
+ rbn_match_timeperiod(rule) or \
+ rbn_match_escalation(rule, context) or \
+ rbn_match_servicelevel(rule, context)
def rbn_match_hosttags(rule, context):
@@ -960,6 +956,27 @@ def rbn_match_timeperiod(rule):
return "The timeperiod '%s' is currently not active." % timeperiod
+def rbn_match_escalation(rule, context):
+ if "match_escalation" in rule:
+ from_number, to_number = rule["match_escalation"]
+ if context["WHAT"] == "HOST":
+ notification_number = int(context.get("HOSTNOTIFICATIONNUMBER", 1))
+ else:
+ notification_number = int(context.get("SERVICENOTIFICATIONNUMBER", 1))
+ if notification_number < from_number or notification_number > to_number:
+ return "The notification number %d does not lie in range %d ... %d" % (
+ notification_number, from_number, to_number)
+
+def rbn_match_servicelevel(rule, context):
+ from_sl, to_sl = rule["match_sl"]
+ if context['WHAT'] == "SERVICE" and context.get('SVC_SL','').isdigit():
+ sl = saveint(context.get('SVC_SL'))
+ else:
+ sl = saveint(context.get('HOST_SL'))
+
+ if sl < from_sl or sl > to_sl:
+ return "The service level %d is not between %d and %d." % (sl, from_sl, to_sl)
+
def rbn_rule_contacts(rule, context):
contacts = set([])
diff --git a/web/htdocs/wato.py b/web/htdocs/wato.py
index da4f276..1ff23b7 100644
--- a/web/htdocs/wato.py
+++ b/web/htdocs/wato.py
@@ -7453,9 +7453,11 @@ def vs_notification_rule():
elements = [
Integer(
label = _("from"),
- help = _("Let through notifications counting from this number"),
- default_value = 1,
- minvalue = 1,
+ help = _("Let through notifications counting from this number. "
+ "For normal alerts The first notification has the number 1. "
+ "For custom notifications the number is 0."),
+ default_value = 0,
+ minvalue = 0,
maxvalue = 999999,
),
Integer(
Module: check_mk
Branch: master
Commit: df182d9abf76b5325c05cde400f11e824dc7b5eb
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=df182d9abf76b5…
Author: Mathias Kettner <mk(a)mathias-kettner.de>
Date: Tue Feb 25 16:33:11 2014 +0100
RBN: implement some of the rule conditions
---
modules/notify.py | 71 +++++++++++++++++++++++++++++++++++++++++++++++
web/htdocs/valuespec.py | 6 +++-
web/htdocs/wato.py | 20 +++++++++----
3 files changed, 90 insertions(+), 7 deletions(-)
diff --git a/modules/notify.py b/modules/notify.py
index 39b1bd8..04fa0bb 100644
--- a/modules/notify.py
+++ b/modules/notify.py
@@ -336,6 +336,10 @@ def notify_keepalive():
while True:
try:
+ # Invalidate timeperiod cache
+ global g_inactive_timerperiods
+ g_inactive_timerperiods = None
+
# If the configuration has changed, we do a restart. But we do
# this check just before the next notification arrives. We must
# *not* read data from stdin, just peek! There is still one
@@ -886,6 +890,73 @@ def rbn_match_rule(rule, context):
if rule.get("disabled"):
return "This rule is disabled"
+ return \
+ rbn_match_hosttags(rule, context) or \
+ rbn_match_hosts(rule, context) or \
+ rbn_match_exclude_hosts(rule, context) or \
+ rbn_match_services(rule, context) or \
+ rbn_match_exclude_services(rule, context) or \
+ rbn_match_checktype(rule, context) or \
+ rbn_match_timeperiod(rule)
+
+
+def rbn_match_hosttags(rule, context):
+ required = rule.get("match_hosttags")
+ if required:
+ tags = context.get("HOSTTAGS", "").split()
+ if not hosttags_match_taglist(tags, required):
+ return "The host's tags %s do not match the required tags %s" % (
+ "|".join(tags), "|".join(required))
+
+def rbn_match_hosts(rule, context):
+ if "match_hosts" in rule:
+ hostlist = rule["match_hosts"]
+ if context["HOSTNAME"] not in hostlist:
+ return "The host's name '%s' is not on the list of allowed hosts (%s)" % (
+ context["HOSTNAME"], ", ".join(hostlist))
+
+def rbn_match_exclude_hosts(rule, context):
+ if context["HOSTNAME"] in rule.get("match_exclude_hosts", []):
+ return "The host's name '%s' is on the list of excluded hosts" % context["HOSTNAME"]
+
+
+def rbn_match_services(rule, context):
+ if "match_services" in rule:
+ if context["WHAT"] != "SERVICE":
+ return "The rule specifies a list of services, but this is a host notification."
+ servicelist = rule["match_services"]
+ service = context["SERVICEDESC"]
+ if not in_extraconf_servicelist(servicelist, service):
+ return "The service's description '%s' dows not match by the list of " \
+ "allowed services (%s)" % (service, ", ".join(servicelist))
+
+def rbn_match_exclude_services(rule, context):
+ excludelist = rule.get("match_exclude_services", [])
+ service = context["SERVICEDESC"]
+ if in_extraconf_servicelist(excludelist, service):
+ return "The service's description '%s' matches the list of excluded services" \
+ % context["SERVICEDESC"]
+
+def rbn_match_checktype(rule, context):
+ if "match_checktype" in rule:
+ if context["WHAT"] != "SERVICE":
+ return "The rule specifies a list of Check_MK plugins, but this is a host notification."
+ command = context["SERVICECHECKCOMMAND"]
+ if not command.startswith("check_mk-"):
+ return "The rule specified a list of Check_MK plugins, but his is no Check_MK service."
+ plugin = command[9:]
+ allowed = rule["match_checktype"]
+ if plugin not in allowed:
+ return "The Check_MK plugin '%s' is not on the list of allowed plugins (%s)" % \
+ (plugin, ", ".join(allowed))
+
+def rbn_match_timeperiod(rule):
+ if "match_timeperiod" in rule:
+ timeperiod = rule["match_timeperiod"]
+ if timeperiod != "24X7" and not check_timeperiod(timeperiod):
+ return "The timeperiod '%s' is currently not active." % timeperiod
+
+
def rbn_rule_contacts(rule, context):
contacts = set([])
diff --git a/web/htdocs/valuespec.py b/web/htdocs/valuespec.py
index fdb2ec2..c47ad63 100644
--- a/web/htdocs/valuespec.py
+++ b/web/htdocs/valuespec.py
@@ -707,7 +707,11 @@ class ListOfStrings(ValueSpec):
def validate_value(self, value, vp):
if len(value) == 0 and not self._allow_empty:
- raise MKUserError(vp + "_0", _("Please specify at least one value"))
+ if self._empty_text:
+ msg = self._empty_text
+ else:
+ msg = _("Please specify at least one value")
+ raise MKUserError(vp + "_0", msg)
if self._valuespec:
for nr, s in enumerate(value):
self._valuespec.validate_value(s, vp + "_%d" % nr)
diff --git a/web/htdocs/wato.py b/web/htdocs/wato.py
index 0040a3a..da4f276 100644
--- a/web/htdocs/wato.py
+++ b/web/htdocs/wato.py
@@ -6374,13 +6374,13 @@ def factory_reset():
# '----------------------------------------------------------------------'
-class CheckTypeSelection(ListChoice):
+class CheckTypeSelection(DualListChoice):
def __init__(self, **kwargs):
- ListChoice.__init__(self, columns=3, **kwargs)
+ DualListChoice.__init__(self, **kwargs)
def get_elements(self):
checks = check_mk_local_automation("get-check-information")
- elements = [ (cn, "<span title=\"%s\">%s</span>" % (c["title"], cn)) for (cn, c) in checks.items()]
+ elements = [ (cn, (cn + " - " + c["title"])[:60]) for (cn, c) in checks.items()]
elements.sort()
return elements
@@ -7402,7 +7402,8 @@ def vs_notification_rule():
title = _("Match only the following hosts"),
size = 24,
orientation = "horizontal",
-
+ allow_empty = False,
+ empty_text = _("Please specify at least one host. Disable the option if you want to allow all hosts."),
)
),
( "match_exclude_hosts",
@@ -7414,9 +7415,14 @@ def vs_notification_rule():
),
( "match_services",
ListOfStrings(
- title = _("Match only the following hosts"),
+ title = _("Match only the following services"),
+ help = _("Specify a list of regular expressions that must match the <b>beginning</b> of the "
+ "service name in order for the rule to match. Note: Host notifications never match this "
+ "rule if this option is being used."),
valuespec = TextUnicode(size = 32),
orientation = "horizontal",
+ allow_empty = False,
+ empty_text = _("Please specify at least one service regex. Disable the option if you want to allow all services."),
)
),
( "match_exclude_services",
@@ -7428,7 +7434,9 @@ def vs_notification_rule():
),
( "match_checktype",
CheckTypeSelection(
- title = _("Match the following check types")
+ title = _("Match the following check types"),
+ help = _("Only apply the rule if the notification originates from certain types of check plugins. "
+ "Note: Host notifications never match this rule if this option is being used."),
)
),
( "match_timeperiod",
Module: check_mk
Branch: master
Commit: 2b17ca094253b3e8a2adf198cfd8ba9e627cd7e2
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=2b17ca094253b3…
Author: Bernd Stroessenreuther <bs(a)mathias-kettner.de>
Date: Tue Feb 25 14:59:51 2014 +0100
FIX brocade_mlx: omit inventory of cpu and memory on more states
If for a module the status is "Blocked for full height card" it is omitted
during inventory for CPU and Memory checks, because there is no sense in
checking them.
---
.werks/703 | 10 ++++++++++
ChangeLog | 3 ++-
checkman/brocade_mlx.module_cpu | 4 ++--
checkman/brocade_mlx.module_mem | 4 ++--
checks/brocade_mlx | 8 ++++----
5 files changed, 20 insertions(+), 9 deletions(-)
diff --git a/.werks/703 b/.werks/703
new file mode 100644
index 0000000..b99be07
--- /dev/null
+++ b/.werks/703
@@ -0,0 +1,10 @@
+Title: brocade_mlx: omit inventory of cpu and memory on more states
+Level: 1
+Component: checks
+Version: 1.2.5i1
+Date: 1393336534
+Class: fix
+
+If for a module the status is "Blocked for full height card" it is omitted
+during inventory for CPU and Memory checks, because there is no sense in
+checking them.
diff --git a/ChangeLog b/ChangeLog
index d6ac156..3c1e5b2 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -93,8 +93,8 @@
* 0556 esx_vsphere_counters.diskio: now also shows disk latency
* 0583 stulz_pump: now monitors the pumps rpm in precent of maximum and gathers performance data
* 0560 check_mk_agent.solaris: report statgrab_mem section if solaris_mem section is missing...
- * 0586 rmon_stats: new snmp check to gather network traffic statistics on RMON enabled network interfaces
* 0702 Rule for checking agents for wanted version...
+ * 0586 rmon_stats: new snmp check to gather network traffic statistics on RMON enabled network interfaces
* 0103 FIX: services: Fixed bug with service inventory defined in main.mk...
* 0299 FIX: borcade_mlx_fan: Prettified output, handling "other" state now
* 0300 FIX: cisco_fru_power: Trying not to inventorize not plugged in FRUs...
@@ -187,6 +187,7 @@
* 0719 FIX: postfix_mailq: fix Linux agent in case of ssmtp being installed
* 0584 FIX: agent_vsphere: special agent now handles non-standard https port correctly...
* 0585 FIX: check_mk_agent.linux: more efficient handling of cups printer queues...
+ * 0703 FIX: brocade_mlx: omit inventory of cpu and memory on more states...
Multisite:
* 0371 Added log class filter to hostsvcevents view
diff --git a/checkman/brocade_mlx.module_cpu b/checkman/brocade_mlx.module_cpu
index 876f9c3..4c79c8e 100644
--- a/checkman/brocade_mlx.module_cpu
+++ b/checkman/brocade_mlx.module_cpu
@@ -38,8 +38,8 @@ perfdata:
cpu_util60 together with warn and crit levels.
inventory:
- Finds one item per NI-MLX module.
- Empty modules are omitted.
+ Finds one item per NI-MLX or BR-MLX module.
+ Modules with state "empty" or "Blocked for full height card" are omitted.
[parameters]
parameters (dict): with the element
diff --git a/checkman/brocade_mlx.module_mem b/checkman/brocade_mlx.module_mem
index e3d3974..b8df961 100644
--- a/checkman/brocade_mlx.module_mem
+++ b/checkman/brocade_mlx.module_mem
@@ -33,8 +33,8 @@ perfdata:
together with warn and crit levels and maximum value
inventory:
- Finds one item per NI-MLX module.
- Empty modules are omitted.
+ Finds one item per NI-MLX or BR-MLX module.
+ Modules with state "empty" or "Blocked for full height card" are omitted.
[parameters]
parameters (dict): with the element
diff --git a/checks/brocade_mlx b/checks/brocade_mlx
index c8eb27d..7707820 100644
--- a/checks/brocade_mlx
+++ b/checks/brocade_mlx
@@ -102,9 +102,9 @@ brocade_mlx_mem_default_levels = { "levels": (80.0, 90.0) }
def inventory_brocade_mlx_module_mem(info):
inventory = []
for module_id, module_descr, module_state, mem_total, mem_avail in info[0]:
- # do not inventorize modules reported as empty
+ # do not inventorize modules reported as empty or "Blocked for full height card"
# and: monitor cpu only on NI-MLX and BR-MLX modules
- if module_state != "0" and ( module_descr.startswith("NI-MLX") or module_descr.startswith("BR-MLX") ):
+ if module_state != "0" and module_state != "11" and ( module_descr.startswith("NI-MLX") or module_descr.startswith("BR-MLX") ):
inventory.append( (brocade_mlx_combine_item(module_id, module_descr), "brocade_mlx_mem_default_levels") )
return inventory
@@ -170,9 +170,9 @@ brocade_mlx_cpu_default_levels = { "levels" : (80.0, 90.0) }
def inventory_brocade_mlx_module_cpu(info):
inventory = []
for module_id, module_descr, module_state, mem_total, mem_avail in info[0]:
- # do not inventorize modules reported as empty
+ # do not inventorize modules reported as empty or "Blocked for full height card"
# and: monitor cpu only on NI-MLX and BR-MLX modules
- if module_state != "0" and ( module_descr.startswith("NI-MLX") or module_descr.startswith("BR-MLX") ):
+ if module_state != "0" and module_state != "11" and ( module_descr.startswith("NI-MLX") or module_descr.startswith("BR-MLX") ):
inventory.append( (brocade_mlx_combine_item(module_id, module_descr), "brocade_mlx_cpu_default_levels") )
return inventory
Module: check_mk
Branch: master
Commit: 7a6816344c36585bcddc3e96237056ed1a20712c
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=7a6816344c3658…
Author: Götz Golla <gg(a)mathias-kettner.de>
Date: Tue Feb 25 13:50:59 2014 +0100
rmon_stats: new snmp check to gather network traffic statistics on RMON enabled network interfaces
---
.werks/586 | 8 ++++
ChangeLog | 1 +
checkman/rmon_stats | 30 +++++++++++++
checks/rmon_stats | 75 +++++++++++++++++++++++++++++++++
pnp-templates/check_mk-rmon_stats.php | 47 +++++++++++++++++++++
5 files changed, 161 insertions(+)
diff --git a/.werks/586 b/.werks/586
new file mode 100644
index 0000000..5c17b92
--- /dev/null
+++ b/.werks/586
@@ -0,0 +1,8 @@
+Title: rmon_stats: new snmp check to gather network traffic statistics on RMON enabled network interfaces
+Level: 2
+Component: checks
+Version: 1.2.5i1
+Date: 1393332564
+Class: feature
+
+
diff --git a/ChangeLog b/ChangeLog
index 6aa1a7c..a8528ee 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -93,6 +93,7 @@
* 0556 esx_vsphere_counters.diskio: now also shows disk latency
* 0583 stulz_pump: now monitors the pumps rpm in precent of maximum and gathers performance data
* 0560 check_mk_agent.solaris: report statgrab_mem section if solaris_mem section is missing...
+ * 0586 rmon_stats: new snmp check to gather network traffic statistics on RMON enabled network interfaces
* 0103 FIX: services: Fixed bug with service inventory defined in main.mk...
* 0299 FIX: borcade_mlx_fan: Prettified output, handling "other" state now
* 0300 FIX: cisco_fru_power: Trying not to inventorize not plugged in FRUs...
diff --git a/checkman/rmon_stats b/checkman/rmon_stats
new file mode 100644
index 0000000..cf0f566
--- /dev/null
+++ b/checkman/rmon_stats
@@ -0,0 +1,30 @@
+title: Traffic Analysis of Network Interfaces using RMON
+agents: snmp
+catalog: hw/network/generic
+license: GPL
+distribution: check_mk
+description:
+ This check extracts data from the RMON statistics group of RMON enabled network
+ interfaces. The data are described in the Remote MONitoring MIB. Several devices
+ of various vendors are capable of supplying RMON data via SNMP, among them
+ are some CISCO devices. It may be necessary to enable RMON for every single network
+ interface you want to gather information for.
+
+ The check always returns the state {OK}. The main purpose of the check is to gather
+ network traffic statistics as performance data.
+
+item:
+ The ID of the network interface within RMON (etherStatsIndex)
+
+inventory:
+ The inventory creates one service for each network port for which RMON is activated.
+
+perfdata:
+ {bcast}: The number of broadcast packets received per second.
+ {mcast}: The number of multicast packets received per second.
+ {0-63b}: The number of octects of size 0-63 bytes
+ {64-127b}: The number of octects pre second of size 64-127 bytes
+ {128-255b}: The number of octects pre second of size 128-255 bytes
+ {256-511b}: The number of octects pre second of size 256-511 bytes
+ {512-1023b}: The number of octects pre second of size 512-1023 bytes
+ {1024-1518b}: The number of octects pre second of size 1024-1518 bytes
diff --git a/checks/rmon_stats b/checks/rmon_stats
new file mode 100644
index 0000000..d0ab8ea
--- /dev/null
+++ b/checks/rmon_stats
@@ -0,0 +1,75 @@
+#!/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.
+
+# This check extracts data from 1.3.6.1.2.1.16.1.1.1 =
+# iso(1). org(3). dod(6). internet(1). mgmt(2). mib-2(1). rmon(16).
+# statistics(1). etherStatsTable(1). etherStatsEntry(1)
+# The MIB is called RMON-MIB
+
+
+def inventory_rmon_stats(info):
+ inventory = []
+ for line in info:
+ inventory.append((line[0], None))
+ return inventory
+
+def check_rmon_stats(item, _no_params, info):
+ bytes = { 1: 'bcast', 2: 'mcast', 3: '0-63b', 4: '64-127b', 5: '128-255b', 6: '256-511b', 7: '512-1023b', 8: '1024-1518b' }
+ perfdata = []
+ infotext = ''
+ now = time.time()
+ for line in info:
+ if line[0] == item:
+ for i, val in bytes.items():
+ octets = int(re.sub(' Packets','',line[i]))
+ timedif, rate = get_counter("%s-%s" % (item, val), now, octets)
+ perfdata.append((val, rate, 0, 0, 0))
+ infotext += "%s=%.0f " % (val, rate)
+ infotext += 'octets/sec'
+ return 0, infotext, perfdata
+
+ return (3, "port not found")
+
+check_info["rmon_stats"] = {
+ 'check_function' : check_rmon_stats,
+ 'inventory_function' : inventory_rmon_stats,
+ 'service_description' : 'RMON Stats IF %s',
+ 'has_perfdata' : True,
+ 'snmp_info' : ('.1.3.6.1.2.1.16.1.1.1', [ #
+ '1', # etherStatsIndex = Item
+ '6', # etherStatsBroadcastPkts
+ '7', # etherStatsMulticastPkts
+ '14', # etherStatsPkts64Octets
+ '15', # etherStatsPkts65to127Octets
+ '16', # etherStatsPkts128to255Octets
+ '17', # etherStatsPkts256to511Octets
+ '18', # etherStatsPkts512to1023Octets
+ '19', # etherStatsPkts1024to1518Octets
+ ]),
+ # for the scan we need to check for any single object in the RMON tree,
+ # we choose netDefaultGateway in the hope that it will always be present
+ 'snmp_scan_function' : lambda oid: oid(".1.3.6.1.2.1.16.19.12.0") != None,
+}
diff --git a/pnp-templates/check_mk-rmon_stats.php b/pnp-templates/check_mk-rmon_stats.php
new file mode 100644
index 0000000..52cdcb3
--- /dev/null
+++ b/pnp-templates/check_mk-rmon_stats.php
@@ -0,0 +1,47 @@
+<?php
+# +------------------------------------------------------------------+
+# | ____ _ _ __ __ _ __ |
+# | / ___| |__ ___ ___| | __ | \/ | |/ / |
+# | | | | '_ \ / _ \/ __| |/ / | |\/| | ' / |
+# | | |___| | | | __/ (__| < | | | | . \ |
+# | \____|_| |_|\___|\___|_|\_\___|_| |_|_|\_\ |
+# | |
+# | 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.
+
+$opt[1] = "--vertical-label 'pkts/sec' -u 10 -X0 --title \"$servicedesc on $hostname\" ";
+
+$stats = array(
+ array(1, "BCAST", "", "#777777", ""),
+ array(2, "MCAST", " ", "#a00000", ""),
+ array(3, "0-63B", " ", "#ff0000", ""),
+ array(4, "64-127B", " ", "#ffc000", "\\n"),
+ array(5, "128-255B", " ", "#f000f0", ""),
+ array(6, "256-511B", " ", "#00b0b0", ""),
+ array(7, "512-1024B", " ", "#c060ff", ""),
+ array(8, "1024-1518B", " ", "#00f040", "\\n")
+);
+
+$def[1] = "";
+
+foreach ($stats as $entry) {
+ list($i, $stat, $spaces, $color, $nl) = $entry;
+ $def[1] .= "DEF:$stat=$RRDFILE[$i]:$DS[$i]:MAX ";
+ $def[1] .= "AREA:$stat$color:\"$stat\":STACK ";
+ $def[1] .= "GPRINT:$stat:LAST:\"$spaces%3.0lf$nl\" ";
+}
+
Module: check_mk
Branch: master
Commit: 4fc078d2b5b99fd4af98322e4ca7d5f8245482ee
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=4fc078d2b5b99f…
Author: Bernd Stroessenreuther <bs(a)mathias-kettner.de>
Date: Tue Feb 25 11:47:27 2014 +0100
Rule for checking agents for wanted version
You can now define a rule (in WATO it is called "Check for correct version of
Check_MK agent") to check if the Check_MK Agents have one wanted version.
You may give a version number manually or take the version number of the
monitoring site as a reference.
If the Agent has a different version, the Check_MK service on this host returns
a WARN status, or what ever status you did define in the rule "Status of the
Check_MK service".
---
.werks/702 | 15 +++++++++++++++
ChangeLog | 1 +
modules/check_mk.py | 1 +
modules/check_mk_base.py | 14 ++++++++++++++
web/plugins/wato/check_mk_configuration.py | 17 +++++++++++++++++
5 files changed, 48 insertions(+)
diff --git a/.werks/702 b/.werks/702
new file mode 100644
index 0000000..12c7d3d
--- /dev/null
+++ b/.werks/702
@@ -0,0 +1,15 @@
+Title: Rule for checking agents for wanted version
+Level: 2
+Component: checks
+Version: 1.2.5i1
+Date: 1393324817
+Class: feature
+
+You can now define a rule (in WATO it is called "Check for correct version of
+Check_MK agent") to check if the Check_MK Agents have one wanted version.
+You may give a version number manually or take the version number of the
+monitoring site as a reference.
+
+If the Agent has a different version, the Check_MK service on this host returns
+a WARN status, or what ever status you did define in the rule "Status of the
+Check_MK service".
diff --git a/ChangeLog b/ChangeLog
index 6aa1a7c..9c0c30f 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -93,6 +93,7 @@
* 0556 esx_vsphere_counters.diskio: now also shows disk latency
* 0583 stulz_pump: now monitors the pumps rpm in precent of maximum and gathers performance data
* 0560 check_mk_agent.solaris: report statgrab_mem section if solaris_mem section is missing...
+ * 0702 Rule for checking agents for wanted version...
* 0103 FIX: services: Fixed bug with service inventory defined in main.mk...
* 0299 FIX: borcade_mlx_fan: Prettified output, handling "other" state now
* 0300 FIX: cisco_fru_power: Trying not to inventorize not plugged in FRUs...
diff --git a/modules/check_mk.py b/modules/check_mk.py
index e1844ff..52477f7 100755
--- a/modules/check_mk.py
+++ b/modules/check_mk.py
@@ -340,6 +340,7 @@ host_attributes = {} # needed by WATO, ignored by Check_MK
ping_levels = [] # special parameters for host/PING check_command
host_check_commands = [] # alternative host check instead of check_icmp
check_mk_exit_status = [] # Rule for specifying CMK's exit status in case of various errors
+check_mk_agent_target_versions = [] # Rule for defining expected version for agents
check_periods = []
snmp_check_interval = []
inv_exports = {} # Rulesets for inventory export hooks
diff --git a/modules/check_mk_base.py b/modules/check_mk_base.py
index 829f9ed..d0939c1 100644
--- a/modules/check_mk_base.py
+++ b/modules/check_mk_base.py
@@ -946,6 +946,17 @@ def do_check(hostname, ipaddress, only_check_types = None):
start_time = time.time()
+ agent_target_versions = host_extra_conf(hostname, check_mk_agent_target_versions)
+ if len(agent_target_versions) > 0:
+ if agent_target_versions[0] == "ignore":
+ check_mk_agent_target_version = None
+ elif agent_target_versions[0] == "site":
+ check_mk_agent_target_version = check_mk_version
+ else:
+ check_mk_agent_target_version = agent_target_versions[0]
+ else:
+ check_mk_agent_target_version = None
+
# Exit state in various situations is confiugrable since 1.2.3i1
exit_spec = exit_code_spec(hostname)
@@ -963,6 +974,9 @@ def do_check(hostname, ipaddress, only_check_types = None):
elif num_errors > 0:
output = "Got no information from host, "
status = exit_spec.get("empty_output", 2)
+ elif check_mk_agent_target_version and agent_version != check_mk_agent_target_version:
+ output = "different agent version %s (should be %s), " % (agent_version, check_mk_agent_target_version)
+ status = exit_spec.get("wrong_version", 1)
elif agent_min_version and agent_version < agent_min_version:
output = "old plugin version %s (should be at least %s), " % (agent_version, agent_min_version)
status = exit_spec.get("wrong_version", 1)
diff --git a/web/plugins/wato/check_mk_configuration.py b/web/plugins/wato/check_mk_configuration.py
index a378f52..13a7aa0 100644
--- a/web/plugins/wato/check_mk_configuration.py
+++ b/web/plugins/wato/check_mk_configuration.py
@@ -2221,6 +2221,23 @@ register_rule(group,
)
register_rule(group,
+ "check_mk_agent_target_versions",
+ OptionalDropdownChoice(
+ title = _("Check for correct version of Check_MK agent"),
+ help = _("If you want to make sure all of your Check_MK agents are running"
+ " one specific version, you may set it by this rule. Agents running "
+ " some different version return a none ok state then"),
+ choices = [
+ ("ignore", _("Ignore version")),
+ ("site", _("Same version as the monitoring site")),
+ ],
+ otherlabel = _("Custom ->"),
+ explicit = TextAscii(allow_empty = False),
+ default_value = "ignore",
+ )
+)
+
+register_rule(group,
"piggyback_translation",
HostnameTranslation(
title = _("Hostname translation for piggybacked hosts"),
Module: check_mk
Branch: master
Commit: 7b6a5fa84721238aa33a90613f8b6e25ee7789ee
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=7b6a5fa8472123…
Author: Götz Golla <gg(a)mathias-kettner.de>
Date: Mon Feb 24 18:09:44 2014 +0100
FIX check_mk_agent.linux: more efficient handling of cups printer queues
The handling of printer queues has been made more efficient for cases when
many printer queues (>> 100) are to be monitored. This part of the agent
is now a factor of 10-20 faster !
---
.werks/585 | 10 ++++++++++
ChangeLog | 1 +
agents/check_mk_agent.linux | 43 ++++++++++++++++++++++++++-----------------
3 files changed, 37 insertions(+), 17 deletions(-)
diff --git a/.werks/585 b/.werks/585
new file mode 100644
index 0000000..55a064c
--- /dev/null
+++ b/.werks/585
@@ -0,0 +1,10 @@
+Title: check_mk_agent.linux: more efficient handling of cups printer queues
+Level: 2
+Component: checks
+Version: 1.2.5i1
+Date: 1393261649
+Class: fix
+
+The handling of printer queues has been made more efficient for cases when
+many printer queues (>> 100) are to be monitored. This part of the agent
+is now a factor of 10-20 faster !
diff --git a/ChangeLog b/ChangeLog
index 598e2da..6aa1a7c 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -184,6 +184,7 @@
* 0673 FIX: zfsget: Fixed broken check - was not compatible to current agent output of "df"
* 0719 FIX: postfix_mailq: fix Linux agent in case of ssmtp being installed
* 0584 FIX: agent_vsphere: special agent now handles non-standard https port correctly...
+ * 0585 FIX: check_mk_agent.linux: more efficient handling of cups printer queues...
Multisite:
* 0371 Added log class filter to hostsvcevents view
diff --git a/agents/check_mk_agent.linux b/agents/check_mk_agent.linux
index c5f6ac9..639421c 100755
--- a/agents/check_mk_agent.linux
+++ b/agents/check_mk_agent.linux
@@ -372,23 +372,32 @@ fi
# Status of CUPS printer queues
if type lpstat > /dev/null 2>&1; then
- if pgrep cups > /dev/null 2>&1; then
- echo '<<<cups_queues>>>'
- WAITMAX="waitmax 3"
- CPRINTCONF=/etc/cups/printers.conf
- PRINTERS=$(waitmax 10 lpstat -a | awk '{print $1}')
- if [ -r "$CPRINTCONF" ] ; then
- for PQ in $PRINTERS ; do
- grep -q -x -E "<(Default)?Printer $PQ>" $CPRINTCONF && $WAITMAX lpstat -p $PQ
- done
- echo '---'
- for PQ in $PRINTERS ; do
- grep -q -x -E "<(Default)?Printer $PQ>" $CPRINTCONF && $WAITMAX lpstat -o $PQ
- done
- else
- $WAITMAX lpstat -p ; echo '---' ; $WAITMAX lpstat -o | sort
- fi
- fi
+ if pgrep cups > /dev/null 2>&1; then
+ echo '<<<cups_queues>>>'
+ CPRINTCONF=/etc/cups/printers.conf
+ if [ -r "$CPRINTCONF" ] ; then
+ LOCAL_PRINTERS=$(grep -E "<(Default)?Printer .*>" $CPRINTCONF | awk '{print $2}' | sed -e 's/>//')
+ lpstat -p | while read LINE
+ do
+ PRINTER=$(echo $LINE | awk '{print $2}')
+ if echo "$LOCAL_PRINTERS" | grep -q "$PRINTER"; then
+ echo $LINE
+ fi
+ done
+ echo '---'
+ lpstat -o | while read LINE
+ do
+ PRINTER=$(echo $LINE | awk '{print $2}')
+ if echo "$LOCAL_PRINTERS" | grep -q "$PRINTER"; then
+ echo $LINE
+ fi
+ done
+ else
+ lpstat -p
+ echo '---'
+ lpstat -o | sort
+ fi
+ fi
fi
# Heartbeat monitoring
Module: check_mk
Branch: master
Commit: dbd4b915155cc22d4773f4e39e06a2448f9983e2
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=dbd4b915155cc2…
Author: Mathias Kettner <mk(a)mathias-kettner.de>
Date: Mon Feb 24 11:55:40 2014 +0100
Inventory: make agent caching dependent on remote address
---
agents/check_mk_agent.linux | 9 ++++++++-
agents/plugins/mk_inventory.linux | 2 +-
web/plugins/icons/inventory.py | 3 ++-
3 files changed, 11 insertions(+), 3 deletions(-)
diff --git a/agents/check_mk_agent.linux b/agents/check_mk_agent.linux
index d8105a7..c5f6ac9 100755
--- a/agents/check_mk_agent.linux
+++ b/agents/check_mk_agent.linux
@@ -30,6 +30,14 @@ unset LANG
export MK_LIBDIR="/usr/lib/check_mk_agent"
export MK_CONFDIR="/etc/check_mk"
+# Provide information about the remote host. That helps when data
+# is being sent only once to each remote host.
+if [ "$REMOTE_HOST" ] ; then
+ export REMOTE=$REMOTE_HOST
+elif [ "$SSH_CLIENT" ] ; then
+ export REMOTE=${SSH_CLIENT%% *}
+fi
+
# Make sure, locally installed binaries are found
PATH=$PATH:/usr/local/bin
@@ -47,7 +55,6 @@ LOCALDIR=$MK_LIBDIR/local
# output if they are not outdated (see below)
SPOOLDIR=$MK_CONFDIR/spool
-
# close standard input (for security reasons) and stderr
if [ "$1" = -d ]
then
diff --git a/agents/plugins/mk_inventory.linux b/agents/plugins/mk_inventory.linux
index 9e08e07..8fc1c14 100755
--- a/agents/plugins/mk_inventory.linux
+++ b/agents/plugins/mk_inventory.linux
@@ -3,7 +3,7 @@
# Run and *send* only once every 4 hours
INTERVAL=14400
-FLAGFILE=$MK_CONFDIR/mk_inventory.last
+FLAGFILE=$MK_CONFDIR/mk_inventory.last.$REMOTE
LAST_RUN=$(stat -c %Y $FLAGFILE)
NOW=$(date +%s)
UNTIL=$((NOW + INTERVAL))
diff --git a/web/plugins/icons/inventory.py b/web/plugins/icons/inventory.py
index d4b006f..c78a5ed 100644
--- a/web/plugins/icons/inventory.py
+++ b/web/plugins/icons/inventory.py
@@ -25,7 +25,8 @@
# Boston, MA 02110-1301 USA.
def paint_icon_inventory(what, row, tags, customer_vars):
- if what == "host" and inventory.has_inventory(row["host_name"]):
+ if (what == "host" or row.get("service_check_command","").startswith("check_mk_active-cmk_inv!")) \
+ and inventory.has_inventory(row["host_name"]):
return link_to_view("<img class=icon title='%s' src='images/icon_inv.png'>" %
_("Show Hardware/Software-Inventory of this host"),
row, 'inv_host' )