From db62588d08a86f5193375aae0e228f1f74b2680a Mon Sep 17 00:00:00 2001 From: Thorsten Spille Date: Tue, 28 Jun 2022 21:38:28 +0200 Subject: [PATCH] Update opnsense_checkmk_agent.py --- opnsense_checkmk_agent.py | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/opnsense_checkmk_agent.py b/opnsense_checkmk_agent.py index 2fc0c5f..23301b5 100644 --- a/opnsense_checkmk_agent.py +++ b/opnsense_checkmk_agent.py @@ -22,7 +22,7 @@ ## copy to /usr/local/etc/rc.syshook.d/start/99-checkmk_agent and chmod +x ## -__VERSION__ = "0.95" +__VERSION__ = "0.952" import sys import os @@ -475,6 +475,8 @@ class checkmk_checker(object): _cidr = _match.group("cidr") _ipaddr = _match.group("ipaddr") _vhid = _match.group("vhid") + if not _vhid: + _interface_dict["cidr"] = _cidr ## cidr wenn kein vhid ## fixme ipaddr dict / vhid dict if _key == "inet6": _match = re.search("^(?P[0-9a-f:]+)\/(?P\d+).*?(?:vhid\s(?P\d+)|$)",_val,re.M) @@ -482,6 +484,8 @@ class checkmk_checker(object): _ipaddr = _match.group("ipaddr") _prefix = _match.group("prefix") _vhid = _match.group("vhid") + if not _vhid: + _interface_dict["prefix"] = _prefix ## fixme ipaddr dict / vhid dict if _key == "carp": _match = re.search("(?PMASTER|BACKUP)\svhid\s(?P\d+)\sadvbase\s(?P\d+)\sadvskew\s(?P\d+)",_val,re.M) @@ -541,7 +545,10 @@ class checkmk_checker(object): def checklocal_carpstatus(self): _ret = [] - _virtual = self._config_reader().get("virtualip").get("vip") + _virtual = self._config_reader().get("virtualip") + if not _virtual: + return [] + _virtual = _virtual.get("vip") if not _virtual: return [] if type(_virtual) != list: @@ -560,7 +567,7 @@ class checkmk_checker(object): _status = 0 if _carpstatus == "BACKUP" else 1 if not _interface: continue - _ret.append(f"{_status} \"CARP: {_interface_name}@{_vhid}\" master={_carpstatus_num} {_carpstatus} {_ipaddr}") + _ret.append(f"{_status} \"CARP: {_interface_name}@{_vhid}\" master={_carpstatus_num} {_carpstatus} {_ipaddr} ({_interface})") return _ret def check_dhcp(self):