Module: check_mk
Branch: master
Commit: 2b05636ddbbba3ebefc267e50d06727b31bb8b7d
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=2b05636ddbbba3…
Author: Sven Panne <sp(a)mathias-kettner.de>
Date: Wed Feb 14 14:54:15 2018 +0100
Handle history files from older EC versions, which have fewer columns.
Change-Id: Id7dba3fcb2416f5a89a9ad496c3bc97b95a61c6c
---
bin/mkeventd | 38 +++++++++++++++++++++++++-------------
1 file changed, 25 insertions(+), 13 deletions(-)
diff --git a/bin/mkeventd b/bin/mkeventd
index 2fbc162..b173ac8 100755
--- a/bin/mkeventd
+++ b/bin/mkeventd
@@ -189,6 +189,7 @@ def unsplit(s):
# Speed-critical function for converting string representation
# of log line back to Python values
def convert_history_line(values):
+ # NOTE: history_line column is missing here, so indices are off by 1! :-P
values[0] = float(values[0]) # history_time
values[4] = int(values[4]) # event_id
values[5] = int(values[5]) # event_count
@@ -200,16 +201,27 @@ def convert_history_line(values):
values[16] = int(values[16]) # event_facility
values[18] = int(values[18]) # event_state
values[21] = unsplit(values[21]) # event_match_groups
- if len(values) >= 23:
- values[22] = unsplit(values[22]) # event_contact_groups
- else:
+ num_values = len(values)
+ if num_values <= 22: # event_contact_groups
values.append(None)
-
- if len(values) >= 28:
- values[27] = values[27] == "1" # event_host_in_downtime
-
- if len(values) >= 29:
- values[28] = unsplit(values[28]) # event_match_groups_syslog_application
+ else:
+ values[22] = unsplit(values[22])
+ if num_values <= 23: # event_ipaddress
+ values.append(history_columns[24][1])
+ if num_values <= 24: # event_orig_host
+ values.append(history_columns[25][1])
+ if num_values <= 25: # event_contact_groups_precedence
+ values.append(history_columns[26][1])
+ if num_values <= 26: # event_core_host
+ values.append(history_columns[27][1])
+ if num_values <= 27: # event_host_in_downtime
+ values.append(history_columns[28][1])
+ else:
+ values[27] = values[27] == "1"
+ if num_values <= 28: # event_match_groups_syslog_application
+ values.append(history_columns[29][1])
+ else:
+ values[28] = unsplit(values[28])
filter_operators = {
@@ -3447,10 +3459,10 @@ class StatusTableEvents(StatusTable):
("event_state", 0),
("event_phase", ""),
("event_owner", ""),
- ("event_match_groups", ""),
- ("event_contact_groups", ""),
- ("event_ipaddress", ""), # introduced in 1.2.7
- ("event_orig_host", ""),
+ ("event_match_groups", ""), # last column up to 1.2.4
+ ("event_contact_groups", ""), # introduced in 1.2.5i2
+ ("event_ipaddress", ""), # introduced in 1.2.7i1
+ ("event_orig_host", ""), # introduced in 1.4.0b1
("event_contact_groups_precedence", "host"), # introduced in
1.4.0b1
("event_core_host", ""), # introduced in 1.5.0i1
("event_host_in_downtime", False), # introduced in 1.5.0i1