[checkmk-commits] Check_MK Git: check_mk: mkeventd: fix crash when no rules defined

git version control git at mathias-kettner.de
Wed Nov 14 16:15:28 CET 2012


Module: check_mk
Branch: master
Commit: d90881c52ff33c82a4f089eca72d8fe17ed495a2
URL:    http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=d90881c52ff33c82a4f089eca72d8fe17ed495a2

Author: Mathias Kettner <mk at mathias-kettner.de>
Date:   Wed Nov 14 10:47:37 2012 +0100

mkeventd: fix crash when no rules defined

---

 mkeventd/bin/mkeventd |   13 ++++++++-----
 1 files changed, 8 insertions(+), 5 deletions(-)

diff --git a/mkeventd/bin/mkeventd b/mkeventd/bin/mkeventd
index ddaf1d3..7911d81 100755
--- a/mkeventd/bin/mkeventd
+++ b/mkeventd/bin/mkeventd
@@ -871,7 +871,9 @@ class EventServer:
 
                 if g_config["rule_optimizer"]:
                     self.hash_rule(rule)
-                    if "match_facility" not in rule and "match_priority" not in rule and "cancel_priority" not in rule:
+                    if "match_facility" not in rule \
+                        and "match_priority" not in rule \
+                        and "cancel_priority" not in rule:
                         count_unspecific += 1
 
 
@@ -880,10 +882,11 @@ class EventServer:
             log("Rule hash: %d rules - %d hashed, %d unspecific" % 
                (len(self._rules), len(self._rules) - count_unspecific, count_unspecific))
             for facility in range(24):
-                stats = []
-                for prio, entries in self._rule_hash[facility].items():
-                    stats.append("%s(%d)" % (syslog_priorities[prio], len(entries)))
-                log(" %-12s: %s" % (syslog_facilities[facility], " ".join(stats)))
+                if facility in self._rule_hash:
+                    stats = []
+                    for prio, entries in self._rule_hash[facility].items():
+                        stats.append("%s(%d)" % (syslog_priorities[prio], len(entries)))
+                    log(" %-12s: %s" % (syslog_facilities[facility], " ".join(stats)))
 
 
     def hash_rule(self, rule):



More information about the checkmk-commits mailing list