diff --git a/bird/bird-4.5.mkp b/bird/bird-4.5.mkp deleted file mode 100644 index a8c6f86..0000000 Binary files a/bird/bird-4.5.mkp and /dev/null differ diff --git a/bird/bird-4.9.0.mkp b/bird/bird-4.9.0.mkp new file mode 100644 index 0000000..80825c4 Binary files /dev/null and b/bird/bird-4.9.0.mkp differ diff --git a/bird/lib/check_mk/base/plugins/agent_based/bird.py b/bird/lib/check_mk/base/plugins/agent_based/bird.py index bded2c3..a627ce7 100644 --- a/bird/lib/check_mk/base/plugins/agent_based/bird.py +++ b/bird/lib/check_mk/base/plugins/agent_based/bird.py @@ -114,9 +114,6 @@ import time import datetime -from cmk.utils import debug -from pprint import pprint - _bird_status_default_levels = { "uptime_low_threshold": 300, "config_file_min_age": 60, @@ -128,7 +125,7 @@ def _bird_strptime(string): # bird uses different time formats depending on the version/settings - for f in ['%d-%m-%Y %H:%M:%S', '%Y-%m-%d %H:%M:%S']: + for f in ['%d-%m-%Y %H:%M:%S.%f', '%Y-%m-%d %H:%M:%S.%f', '%d-%m-%Y %H:%M:%S', '%Y-%m-%d %H:%M:%S']: try: return datetime.datetime.strptime(string, f) except ValueError: @@ -137,7 +134,7 @@ def _bird_strptime(string): def _bird_si_to_int(value, unit): _prefix = {'': 1, 'k': 1024, 'M': 1048576, 'G': 1073741824} - return int(value) * _prefix[unit.rstrip('B')] + return int(float(value) * _prefix[unit.rstrip('B')]) def _bird_x_to_key(value): return "_".join(value).rstrip(':') @@ -173,9 +170,14 @@ def parse_bird(string_table): elif code == 1018: if line[-1][-1] == 'B': # ignore lines which don't end vith B (not memory stats) memory = section.setdefault('memory', []) - name = " ".join(line[1:-2]).rstrip(":") - value_text = " ".join(line[-2:]) - value_bytes = _bird_si_to_int(line[-2], line[-1]) + split_index = next(filter(lambda i: ':' in line[i], range(1, len(line)))) + name = " ".join(line[1:split_index+1]).rstrip(":") + if split_index == len(line) - 5: + value_text = "E={} {}; O={} {}".format(*line[-4:]) + value_bytes = _bird_si_to_int(line[-4], line[-3]) + _bird_si_to_int(line[-2], line[-1]) + else: + value_text = " ".join(line[split_index+1:]) + value_bytes = _bird_si_to_int(line[-2], line[-1]) memory.append((name, value_text, value_bytes)) elif code == 1002: protocols = section.setdefault('protocols', {}) @@ -194,17 +196,17 @@ def parse_bird(string_table): last_protocol['description'] = " ".join(line[2:]) if line[1] == "Preference:": last_protocol['preference'] = line[2] - elif line[2] == "filter:": + elif len(line) >= 3 and line[2] == "filter:": key = _bird_x_to_key(line[1:3]) last_protocol[key] = " ".join(line[3:]) - elif line[2] == "limit:" and line[1] != 'Route': + elif len(line) >= 3 and line[2] == "limit:" and line[1] != 'Route': limits = last_protocol.setdefault('limits', {}) last_limit = limits[line[1]] = {} last_limit['value'] = int(line[3]) last_limit['hit'] = (len(line) >= 5 and line[4] == "[HIT]") elif line[1] == "Action:": last_limit['action'] = line[2] - elif line[2] == "limit:" and line[1] == 'Route': # legacy "route limit" option + elif len(line) >= 3 and line[2] == "limit:" and line[1] == 'Route': # legacy "route limit" option limits = last_protocol.setdefault('limits', {}) if 'Import' in limits: continue # ignore in case we already have a import limit @@ -254,10 +256,9 @@ def parse_bird(string_table): def discover_bird_status(section) -> DiscoveryResult: if 'status' in section: # bird is running - yield Service(parameters=section) + yield Service() def check_bird_status(params, section) -> CheckResult: - # params is a snapshot of the parsed data at the point of time of inventory if 'error' in section: yield Result(state=State.CRIT, summary="ERROR: "+section['error']) @@ -306,10 +307,9 @@ def check_bird_status(params, section) -> CheckResult: def discover_bird_memory(section) -> DiscoveryResult: if 'memory' in section: # bird is running - yield Service(parameters=section) + yield Service() def check_bird_memory(params, section) -> CheckResult: - # params is a snapshot of the parsed data at the point of time of inventory if 'error' in section: yield Result(state=State.CRIT, summary="ERROR: "+section['error']) @@ -319,7 +319,7 @@ def check_bird_memory(params, section) -> CheckResult: summary="No memory data available") return for name, value_text, value_bytes in section['memory']: - key = name.replace(" ", "_") + key = name.replace(" ", "_").split(":")[0] # memory part wasn't parsed correctly, quick fix warn, crit = params.get('memory_levels_'+key, (None, None)) yield from check_levels(value_bytes, levels_upper=(warn, crit), @@ -328,14 +328,10 @@ def check_bird_memory(params, section) -> CheckResult: label=name) def discover_bird_protocols(section) -> DiscoveryResult: - if debug.enabled(): - pprint(section) for protocol in section.get('protocols', {}): - yield Service(item=protocol, parameters=section) + yield Service(item=protocol, parameters={'protocols': { protocol: section['protocols'][protocol] }}) def check_bird_protocols(item, params, section) -> CheckResult: - # params is a snapshot of the parsed data at the point of time of inventory - this_time = time.time() if 'error' in section: yield Result(state=State.CRIT, diff --git a/bird/lib/check_mk/base/cee/plugins/bakery/bird.py b/bird/lib/python3/cmk/base/cee/plugins/bakery/bird.py similarity index 100% rename from bird/lib/check_mk/base/cee/plugins/bakery/bird.py rename to bird/lib/python3/cmk/base/cee/plugins/bakery/bird.py diff --git a/bird/web/plugins/perfometer/bird.py b/bird/web/plugins/perfometer/bird.py index cb0302b..3aa9595 100644 --- a/bird/web/plugins/perfometer/bird.py +++ b/bird/web/plugins/perfometer/bird.py @@ -19,8 +19,8 @@ # # Copyright 2014 by Frederik Kriewitz . -from cmk.gui.plugins.views.perfometers.check_mk import perfometer_check_mk_uptime -from cmk.gui.plugins.views.perfometers import perfometer_logarithmic +from cmk.gui.views.perfometer.legacy_perfometers.check_mk import perfometer_check_mk_uptime +from cmk.gui.views.perfometer.legacy_perfometers.utils import perfometer_logarithmic perfometers["check_mk-bird_status"] = perfometer_check_mk_uptime perfometers["check_mk-bird6_status"] = perfometer_check_mk_uptime