diff --git a/CHANGELOG b/CHANGELOG index ae57d41bb9f86d92587e8c8017589aa77556cd0e..8c0802fa0266630f66af10c4390da91ae312f4be 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -12,3 +12,4 @@ 2021-07-17: added basic support for IOS-XE based WLAN controllers (C9800 family), without most of perfdata fixed _render_mac_address/_render_ip_address, code cleanup, removed WIPS check added lwap_uptime/time taken to join. changed perfdata to 1/s +2021-07-29: fix missing data from discovery (inv_ap_info) diff --git a/agent_based/cisco_wlc.py b/agent_based/cisco_wlc.py index 7640fe622458f09c9da3c86dcd4559dcc4696465..b59170c6cc1e67f915bdd7bd6ad0dd37790b8638 100644 --- a/agent_based/cisco_wlc.py +++ b/agent_based/cisco_wlc.py @@ -21,6 +21,7 @@ # 2021-07-17: added basic support for IOS-XE based WLAN controllers (C9800 family), without most of perfdata # fixed _render_mac_address/_render_ip_address, code cleanup, removed WIPS check # added lwap_uptime/time taken to join. changed perfdata to 1/s +# 2021-07-29: fix missing data from discovery (inv_ap_info) # from time import time from dataclasses import dataclass @@ -165,11 +166,10 @@ _interface_displayhints = { def _get_short_if_name(ifname: str) -> str: """ - returns short interface name from long interface name + Return short interface name from long interface name. ifname: is the long interface name :type ifname: str """ - for ifname_prefix in _interface_displayhints.keys(): if ifname.lower().startswith(ifname_prefix.lower()): ifname_short = _interface_displayhints[ifname_prefix] @@ -329,17 +329,20 @@ def discovery_cisco_wlc(section: Dict[str, Ap]) -> DiscoveryResult: def check_cisco_wlc(item, params, section: Dict[str, Ap]) -> CheckResult: ap_missing_state = params.get('state_ap_missing', 1) - inv_ap_info = InvApInfo( - ap_location=params.get('inv_ap_info').get('ap_location'), - ap_model=params.get('inv_ap_info').get('ap_model'), - ap_serialnumber=params.get('inv_ap_info').get('ap_serialnumber'), - ap_ipaddress=params.get('inv_ap_info').get('ap_ipaddress'), - ap_ethernetmacaddress=params.get('inv_ap_info').get('ap_ethernetmacaddress'), - cdp_neigh_name=params.get('inv_ap_info').get('cdp_neigh_name', None), - cdp_neigh_address=params.get('inv_ap_info').get('cdp_neigh_address', None), - cdp_neigh_interface=params.get('inv_ap_info').get('cdp_neigh_interface', None), - cdp_neigh_platform=params.get('inv_ap_info').get('cdp_neigh_platform', None), - ) + if params.get('inv_ap_info'): + inv_ap_info = InvApInfo( + ap_location=params.get('inv_ap_info').get('ap_location'), + ap_model=params.get('inv_ap_info').get('ap_model'), + ap_serialnumber=params.get('inv_ap_info').get('ap_serialnumber'), + ap_ipaddress=params.get('inv_ap_info').get('ap_ipaddress'), + ap_ethernetmacaddress=params.get('inv_ap_info').get('ap_ethernetmacaddress'), + cdp_neigh_name=params.get('inv_ap_info').get('cdp_neigh_name', None), + cdp_neigh_address=params.get('inv_ap_info').get('cdp_neigh_address', None), + cdp_neigh_interface=params.get('inv_ap_info').get('cdp_neigh_interface', None), + cdp_neigh_platform=params.get('inv_ap_info').get('cdp_neigh_platform', None), + ) + else: + inv_ap_info = None for ap_name, ap_alias in params.get('ap_list', []): if item == ap_name: @@ -541,21 +544,24 @@ def check_cisco_wlc(item, params, section: Dict[str, Ap]) -> CheckResult: yield Result(state=State(params.get('state_cdp_change', 1)), notice=' - CDP info missing', ) # ap has wrong serial number --> AP H/W changed. - if ap_info.ap_serialnumber != inv_ap_info.ap_serialnumber or \ - ap_info.ap_model != inv_ap_info.ap_model or \ - ap_info.ap_ethernetmacaddress != inv_ap_info.ap_ethernetmacaddress or \ - ap_info.ap_ipaddress != inv_ap_info.ap_ipaddress or \ - ap_info.ap_location != inv_ap_info.ap_location: - yield Result( - state=State(params.get('state_ap_change', 1)), - notice='Hardware changed', - details=f'\nAP hardware changed. Run inventory again. ' - f'\n - Serial number (found/expected): {ap_info.ap_serialnumber} / {inv_ap_info.ap_serialnumber} ' - f'\n - Model (found/expected): {ap_info.ap_model} / {inv_ap_info.ap_model} ' - f'\n - MAC address (found/expected): {ap_info.ap_ethernetmacaddress} / {inv_ap_info.ap_ethernetmacaddress} ' - f'\n - IP address (found/expected): {ap_info.ap_ipaddress} / {inv_ap_info.ap_ipaddress} ' - f'\n - Location (found/expected): {ap_info.ap_location} / {inv_ap_info.ap_location}', - ) + if inv_ap_info: + if ap_info.ap_serialnumber != inv_ap_info.ap_serialnumber or \ + ap_info.ap_model != inv_ap_info.ap_model or \ + ap_info.ap_ethernetmacaddress != inv_ap_info.ap_ethernetmacaddress or \ + ap_info.ap_ipaddress != inv_ap_info.ap_ipaddress or \ + ap_info.ap_location != inv_ap_info.ap_location: + yield Result( + state=State(params.get('state_ap_change', 1)), + notice='Hardware changed', + details=f'\nAP hardware changed. Run inventory again. ' + f'\n - Serial number (found/expected): {ap_info.ap_serialnumber} / {inv_ap_info.ap_serialnumber} ' + f'\n - Model (found/expected): {ap_info.ap_model} / {inv_ap_info.ap_model} ' + f'\n - MAC address (found/expected): {ap_info.ap_ethernetmacaddress} / {inv_ap_info.ap_ethernetmacaddress} ' + f'\n - IP address (found/expected): {ap_info.ap_ipaddress} / {inv_ap_info.ap_ipaddress} ' + f'\n - Location (found/expected): {ap_info.ap_location} / {inv_ap_info.ap_location}', + ) + else: + yield Result(state=State.WARN, summary='AP data from discovery missing.') register.snmp_section( diff --git a/cisco_wlc.mkp b/cisco_wlc.mkp index 28b28305d4210bd68bcd0b0c0a5b8399ffd1f500..0976ce4c1266461f7ab3771e6ba8c0b79f74b2e7 100644 Binary files a/cisco_wlc.mkp and b/cisco_wlc.mkp differ