Module: check_mk
Branch: master
Commit: 350c84b2d7a1f05cea52eac63b1207087b233e83
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=350c84b2d7a1f0…
Author: Mathias Kettner <mk(a)mathias-kettner.de>
Date: Fri Apr 4 13:36:30 2014 +0200
FIX FIX: compute correct state transitions for notifications
This fixes a problem with the combination of
<ul>
<li>Rule based notifications</li>
<li>Maximum check attempts > 1</li>
<li>Rule conditions based on the <i>original</i> state of a host or service</li>
</ul>
When a service got CRIT while having more than one check attempt, the previous
(soft) state would be displayed as CRIT, while it is OK in fact. This has
been fixed natively when using the Check_MK Micro Core. When using Nagios then
during the notification the previous hard state is not always known. In doubt
a notification is being sent out rather then omitted.
---
.werks/752 | 20 ++++++++++++++++++++
ChangeLog | 3 +++
check_mk_templates.cfg | 2 ++
modules/notify.py | 49 +++++++++++++++++++++++++++++++++++++++++++-----
4 files changed, 69 insertions(+), 5 deletions(-)
diff --git a/.werks/752 b/.werks/752
new file mode 100644
index 0000000..619cda9
--- /dev/null
+++ b/.werks/752
@@ -0,0 +1,20 @@
+Title: FIX: compute correct state transitions for notifications
+Level: 2
+Component: notifications
+Class: fix
+State: unknown
+Version: 1.2.5i3
+Date: 1396610543
+
+This fixes a problem with the combination of
+<ul>
+<li>Rule based notifications</li>
+<li>Maximum check attempts > 1</li>
+<li>Rule conditions based on the <i>original</i> state of a host or service</li>
+</ul>
+
+When a service got CRIT while having more than one check attempt, the previous
+(soft) state would be displayed as CRIT, while it is OK in fact. This has
+been fixed natively when using the Check_MK Micro Core. When using Nagios then
+during the notification the previous hard state is not always known. In doubt
+a notification is being sent out rather then omitted.
diff --git a/ChangeLog b/ChangeLog
index b7c5b87..ad0bdd2 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -16,6 +16,9 @@
WATO:
* 0781 FIX: host diag page: fixed problem with update of diagnose subwindows...
+ Notifications:
+ * 0752 FIX: FIX: compute correct state transitions for notifications...
+
Livestatus:
* 0747 FIX: livestatus table hostsbygroup: fixed bug with group_authorization strict...
diff --git a/check_mk_templates.cfg b/check_mk_templates.cfg
index 1f295b1..406fc57 100644
--- a/check_mk_templates.cfg
+++ b/check_mk_templates.cfg
@@ -364,6 +364,7 @@ define command {
NOTIFY_HOSTNAME='$HOSTNAME$' \
NOTIFY_HOSTALIAS='$HOSTALIAS$' \
NOTIFY_HOSTADDRESS='$HOSTADDRESS$' \
+ NOTIFY_HOSTATTEMPT='$HOSTATTEMPT$' \
NOTIFY_LASTHOSTSTATE='$LASTHOSTSTATE$' \
NOTIFY_LASTHOSTSTATEID='$LASTHOSTSTATEID$' \
NOTIFY_LASTHOSTSTATECHANGE='$LASTHOSTSTATECHANGE$' \
@@ -379,6 +380,7 @@ define command {
NOTIFY_LASTSERVICESTATEID='$LASTSERVICESTATEID$' \
NOTIFY_LASTSERVICESTATECHANGE='$LASTSERVICESTATECHANGE$' \
NOTIFY_LASTSERVICEOK='$LASTSERVICEOK$' \
+ NOTIFY_SERVICEATTEMPT='$SERVICEATTEMPT$' \
NOTIFY_SERVICESTATE='$SERVICESTATE$' \
NOTIFY_SERVICESTATEID='$SERVICESTATEID$' \
NOTIFY_SERVICEOUTPUT='$SERVICEOUTPUT$' \
diff --git a/modules/notify.py b/modules/notify.py
index 6adc3ef..c638286 100644
--- a/modules/notify.py
+++ b/modules/notify.py
@@ -744,7 +744,7 @@ def rbn_match_host_event(rule, context):
return # Let this be handled by match_service_event
allowed_events = rule["match_host_event"]
state = context["HOSTSTATE"]
- last_state = context["LASTHOSTSTATE"]
+ last_state = context["PREVIOUSHOSTHARDSTATE"]
events = { "UP" : 'r', "DOWN" : 'd', "UNREACHABLE" : 'u' }
return rbn_match_event(context, state, last_state, events, allowed_events)
@@ -758,7 +758,7 @@ def rbn_match_service_event(rule, context):
return # Let this be handled by match_host_event
allowed_events = rule["match_service_event"]
state = context["SERVICESTATE"]
- last_state = context["LASTSERVICESTATE"]
+ last_state = context["PREVIOUSSERVICEHARDSTATE"]
events = { "OK" : 'r', "WARNING" : 'w', "CRITICAL" : 'c', "UNKNOWN" : 'u' }
return rbn_match_event(context, state, last_state, events, allowed_events)
@@ -777,9 +777,16 @@ def rbn_match_event(context, state, last_state, events, allowed_events):
else:
event = events.get(last_state, '?') + events.get(state, '?')
- if event not in allowed_events:
- return "Event type '%s' not handled by this rule. Allowed are: %s" % (
- event, ", ".join(allowed_events))
+ notify_log("Event type is %s" % event)
+
+ # Now go through the allowed events. Handle '?' has matching all types!
+ for allowed in allowed_events:
+ if event == allowed or \
+ event[0] == '?' and event[1] == allowed[1]:
+ return
+
+ return "Event type '%s' not handled by this rule. Allowed are: %s" % (
+ event, ", ".join(allowed_events))
def rbn_rule_contacts(rule, context):
@@ -1495,6 +1502,38 @@ def complete_raw_context(raw_context):
if not contact or contact == "check-mk-notify":
add_rulebased_macros(raw_context)
+
+ # Add the previous hard state. This is neccessary for notification rules that depend on certain transitions,
+ # like OK -> WARN (but not CRIT -> WARN). The CMC sends PREVIOUSHOSTHARDSTATE and PREVIOUSSERVICEHARDSTATE.
+ # Nagios does not have this information and we try to deduct this.
+ if "PREVIOUSHOSTHARDSTATE" not in raw_context:
+ prev_state = raw_context["LASTHOSTSTATE"]
+ # When the attempts are > 1 then the last state could be identical with
+ # the current one, e.g. both critical. In that case we assume the
+ # previous hard state to be OK.
+ if prev_state == raw_context["HOSTSTATE"]:
+ prev_state = "UP"
+ elif "HOSTATTEMPT" not in raw_context or \
+ ("HOSTATTEMPT" in raw_context and raw_context["HOSTATTEMPT"] != "1"):
+ # Here We do not know. The transition might be OK -> WARN -> CRIT and
+ # the initial OK is completely lost. We use the artificial state "?"
+ # here, which matches all states and makes sure that when in doubt a
+ # notification is being sent out.
+ prev_state = "?"
+ notify_log("Previous host hard state not known. Allowing all states.")
+ raw_context["PREVIOUSHOSTHARDSTATE"] = prev_state
+
+ # Same for services
+ if raw_context["WHAT"] == "SERVICE" and "PREVIOUSSERVICEHARDSTATE" not in raw_context:
+ prev_state = raw_context["LASTSERVICESTATE"]
+ if prev_state == raw_context["SERVICESTATE"]:
+ prev_state = "OK"
+ elif "SERVICEATTEMPT" not in raw_context or \
+ ("SERVICEATTEMPT" in raw_context and raw_context["SERVICEATTEMPT"] != "1"):
+ prev_state = "?"
+ notify_log("Previous service hard state not known. Allowing all states.")
+ raw_context["PREVIOUSSERVICEHARDSTATE"] = prev_state
+
convert_context_to_unicode(raw_context)
Module: check_mk
Branch: master
Commit: 17fde02d11e239c8e386e77f08818706618aeec2
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=17fde02d11e239…
Author: Götz Golla <gg(a)mathias-kettner.de>
Date: Thu Apr 3 18:40:25 2014 +0200
Werk descirptions augmented
---
.werks/601 | 2 ++
1 file changed, 2 insertions(+)
diff --git a/.werks/601 b/.werks/601
index 491c2a2..d00a54c 100644
--- a/.werks/601
+++ b/.werks/601
@@ -8,3 +8,5 @@ Class: incomp
If a description of the the alert group state is not available from the device, the check
now displays a textual representation of the alert code instead of the alert code itself.
This makes the service output more readable and useful to the printer admin.
+
+With this change the printer_alerts_state_map is deprecated and will no longer be used.
Module: check_mk
Branch: master
Commit: 386fc83c032240ba8e931e687891eccdf4ef0563
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=386fc83c032240…
Author: Götz Golla <gg(a)mathias-kettner.de>
Date: Thu Apr 3 18:37:16 2014 +0200
printer_alerts: check can now display a textual representation of the alert code
If a description of the the alert group state is not available from the device, the check
now displays a textual representation of the alert code instead of the alert code itself.
This makes the service output more readable and useful to the printer admin.
---
.werks/601 | 10 ++++
ChangeLog | 4 ++
checkman/printer_alerts | 30 ++++------
checks/printer_alerts | 149 +++++++++++++++++++++++++++++++++++++++--------
4 files changed, 149 insertions(+), 44 deletions(-)
Diff: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commitdiff;h=386fc83c03…
Module: check_mk
Branch: master
Commit: d23c8cb5a121876921dfa17ddb58153cbeedd84a
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=d23c8cb5a12187…
Author: Andreas Boesl <ab(a)mathias-kettner.de>
Date: Thu Apr 3 15:15:49 2014 +0200
enterasys_lsnat: new check monitoring the current LSNAT bindings
---
.werks/783 | 8 +++++
ChangeLog | 1 +
checkman/enterasys_lsnat | 17 ++++++++++
checks/enterasys_lsnat | 59 ++++++++++++++++++++++++++++++++++
web/plugins/wato/check_parameters.py | 22 +++++++++++++
5 files changed, 107 insertions(+)
diff --git a/.werks/783 b/.werks/783
new file mode 100644
index 0000000..c4c9727
--- /dev/null
+++ b/.werks/783
@@ -0,0 +1,8 @@
+Title: enterasys_lsnat: new check monitoring the current LSNAT bindings
+Level: 1
+Component: checks
+Version: 1.2.5i3
+Date: 1396530940
+Class: feature
+
+
diff --git a/ChangeLog b/ChangeLog
index 527b30f..8f32594 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -2,6 +2,7 @@
Checks & Agents:
* 0149 cisco_secure: New check for Port Security on Cisco swichtes
* 0751 New localcheck for Linux that makes sure that filesystems in /etc/fstab are mounted...
+ * 0783 enterasys_lsnat: new check monitoring the current LSNAT bindings
* 0777 FIX: special agent emcvnx: did not work with security file authentication...
Multisite:
diff --git a/checkman/enterasys_lsnat b/checkman/enterasys_lsnat
new file mode 100644
index 0000000..4c4953b
--- /dev/null
+++ b/checkman/enterasys_lsnat
@@ -0,0 +1,17 @@
+title: Enterasys: LSNAT bindings
+agents: snmp
+catalog: hw/network/enterasys
+license: GPL
+distribution: check_mk
+description:
+ This check monitors the number of current LSNAT bindings if the feature is activated
+ on this device (oid .1.3.6.1.4.1.5624.1.2.74.1.1.5.0 must contain a value)
+
+inventory:
+ One check is created for each Enterasys device
+
+[parameters]
+parameters (dict): A dictionary with the following optional keys:
+
+ {"current_bindings"}: tuple(int, int) representing the warn and crit limits for this check
+
diff --git a/checks/enterasys_lsnat b/checks/enterasys_lsnat
new file mode 100644
index 0000000..e38169d
--- /dev/null
+++ b/checks/enterasys_lsnat
@@ -0,0 +1,59 @@
+#!/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 inventory_enterasys_lsnat(info):
+ return [ (None, {}) ]
+
+def check_enterasys_lsnat(no_item, params, info):
+ if not info:
+ return 3, "LSNAT bindings info is missing"
+
+ lsnat_bindings = saveint(info[0][0])
+ warn, crit = params.get("current_bindings", (None, None))
+
+ state = 0
+ state_info = ""
+ if warn:
+ if lsnat_bindings > crit:
+ state = 2
+ state_info = state_markers[state]
+ elif lsnat_bindings > warn:
+ state = 1
+ state_info = state_markers[state]
+
+ return state, "Current bindings %d%s" % (lsnat_bindings, state_info)
+
+
+check_info["enterasys_lsnat"] = {
+ "check_function" : check_enterasys_lsnat,
+ "inventory_function" : inventory_enterasys_lsnat,
+ "service_description" : "LSNAT Bindings",
+ "group" : "lsnat",
+ "snmp_info" : ( ".1.3.6.1.4.1.5624.1.2.74.1.1.5", [ "0" ] ),
+ "snmp_scan_function" : lambda oid: oid(".1.3.6.1.2.1.1.2.0").startswith(".1.3.6.1.4.1.5624.2.1") and
+ oid(".1.3.6.1.4.1.5624.1.2.74.1.1.5.0"),
+}
+
diff --git a/web/plugins/wato/check_parameters.py b/web/plugins/wato/check_parameters.py
index 4b80934..2c7918d 100644
--- a/web/plugins/wato/check_parameters.py
+++ b/web/plugins/wato/check_parameters.py
@@ -1295,6 +1295,28 @@ register_check_parameters(
register_check_parameters(
subgroup_networking,
+ "lsnat",
+ _("Enterasys LSNAT Bindings"),
+ Dictionary(
+ elements = [
+ ( "current_bindings",
+ Tuple(
+ title = _("Number of current LSNAT bindings"),
+ elements = [
+ Integer(title = _("Warning if above"), size = 10, unit=_("bindings")),
+ Integer(title = _("Critical if above"), size = 10, unit=_("bindings")),
+ ]
+ )
+ ),
+ ],
+ optional_keys = False,
+ ),
+ None,
+ "dict"
+)
+
+register_check_parameters(
+ subgroup_networking,
"wlc_clients",
_("WLC WiFi client connections"),
Tuple(
Module: check_mk
Branch: master
Commit: d46c7d6fe8a88bceeaddc8df436ad72ff4dafede
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=d46c7d6fe8a88b…
Author: Mathias Kettner <mk(a)mathias-kettner.de>
Date: Thu Apr 3 14:57:57 2014 +0200
New localcheck for Linux that makes sure that filesystems in /etc/fstab are mounted
The new local check is in <tt>share/doc/check_mk/treasures/localchecks/check_fstab_mounts</tt>. Simply
copy it to <tt>/usr/lib/check_mk_agent/local/</tt> on your Linux agents. It will alert you if any
filesystem that is listed in <tt>/etc/fstab</tt> is not being mounted. Filesystems with the option
<tt>noauto</tt> are excluded from the check.
---
.werks/751 | 11 ++++++++
ChangeLog | 1 +
doc/treasures/localchecks/check_fstab_mounts | 37 ++++++++++++++++++++++++++
3 files changed, 49 insertions(+)
diff --git a/.werks/751 b/.werks/751
new file mode 100644
index 0000000..b20f4c2
--- /dev/null
+++ b/.werks/751
@@ -0,0 +1,11 @@
+Title: New localcheck for Linux that makes sure that filesystems in /etc/fstab are mounted
+Level: 1
+Component: checks
+Version: 1.2.5i3
+Date: 1396529750
+Class: feature
+
+The new local check is in <tt>share/doc/check_mk/treasures/localchecks/check_fstab_mounts</tt>. Simply
+copy it to <tt>/usr/lib/check_mk_agent/local/</tt> on your Linux agents. It will alert you if any
+filesystem that is listed in <tt>/etc/fstab</tt> is not being mounted. Filesystems with the option
+<tt>noauto</tt> are excluded from the check.
diff --git a/ChangeLog b/ChangeLog
index d3e785a..527b30f 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,6 +1,7 @@
1.2.5i3:
Checks & Agents:
* 0149 cisco_secure: New check for Port Security on Cisco swichtes
+ * 0751 New localcheck for Linux that makes sure that filesystems in /etc/fstab are mounted...
* 0777 FIX: special agent emcvnx: did not work with security file authentication...
Multisite:
diff --git a/doc/treasures/localchecks/check_fstab_mounts b/doc/treasures/localchecks/check_fstab_mounts
new file mode 100755
index 0000000..40b4e0a
--- /dev/null
+++ b/doc/treasures/localchecks/check_fstab_mounts
@@ -0,0 +1,37 @@
+#!/usr/bin/python
+# This localcheck makes sure that every filesystem that is listed in /etc/fstab to
+# be mounted automatically, also appears mounted in /proc/mounts
+
+# /dev/mapper/vg0-lv--root / ext4 errors=remount-ro 0 1
+# # /boot was on /dev/md0 during installation
+# UUID=bec44dfa-7c70-4da7-857a-2e324cc230bd /boot ext4 defaults 0 2
+# /dev/mapper/vg0-lv--home /home ext4 defaults 0 2
+# tmpfs /omd/sites/aq/tmp tmpfs noauto,user,mode=755,uid=aq,gid=aq 0 0
+# tmpfs /opt/omd/sites/zentrale/tmp tmpfs noauto,user,mode=755,uid=zentrale,gid=zentrale 0 0
+# tmpfs /opt/omd/sites/hirn/tmp tmpfs noauto,user,mode=755,uid=hirn,gid=hirn 0 0
+# tmpfs /opt/omd/sites/heute/tmp tmpfs noauto,user,mode=755,uid=heute,gid=heute 0 0
+
+mounted = [ l.split()[1] for l in file("/proc/mounts") ]
+
+missing = []
+count = 0
+for line in file("/etc/fstab"):
+ if not line.strip() or line.strip().startswith("#"):
+ continue
+
+ device, mountpoint, fstype, options, rest = line.split(None, 4)
+ options = options.split(",")
+ if "noauto" not in options and mountpoint not in mounted:
+ missing.append("%s is not mounted on %s" % (device, mountpoint))
+ else:
+ count += 1
+
+if missing:
+ state = 2
+ output = ", ".join(missing)
+
+else:
+ state = 0
+ output = "All %d expected filesystems of /etc/fstab are mounted" % count
+
+print "%d Mounted_Filesystems - %s" % (state, output)