TypeError on disconnected client
I have a client device which is frequently disconnecting and connecting, what apparently makes unify to skip some of the stats and that causes crash:
TypeError (unsupported operand type(s) for /: 'NoneType' and 'int')
File "/omd/sites/cmk/lib/python3/cmk/base/agent_based/checking/_checking.py", line 413, in get_aggregated_result
consume_check_results(
File "/omd/sites/cmk/lib/python3/cmk/base/api/agent_based/checking_classes.py", line 484, in consume_check_results
for subr in subresults:
File "/omd/sites/cmk/lib/python3/cmk/base/api/agent_based/register/check_plugins.py", line 93, in filtered_generator
for element in generator(*args, **kwargs):
File "/omd/sites/cmk/local/lib/python3/cmk/base/plugins/agent_based/unifi.py", line 987, in check_unifi_user
yield Result(state=State.OK, notice=f"RX-Rate: %sMbps" % int(users.get('rx_rate') / 1000))
This is the users
variable:
'users': {'_id': '614c50ffcd175e7e7c84dd42',
'_is_guest_by_ugw': False,
'_is_guest_by_usw': False,
'_last_reachable_by_gw': 1707395661,
'_last_seen_by_ugw': 1707395663,
'_last_seen_by_usw': 1707395661,
'_uptime_by_ugw': 2023627,
'_uptime_by_usw': 2023625,
'anomalies': -1,
'assoc_time': 1705372036,
'authorized': True,
'bytes-r': 0.0,
'confidence': 37,
'dev_cat': 51,
'dev_family': 7,
'dev_id': 3262,
'dev_vendor': 381,
'device_name': 'LIFX lighting',
'disconnect_timestamp': 1707395602,
'eagerly_discovered': True,
'fingerprint_engine_version': '0.0.0',
'fingerprint_source': 0,
'first_seen': 1632391423,
'fixed_ap_enabled': False,
'fixed_ip': 'X',
'fw_version': '',
'gw_mac': 'X',
'gw_vlan': 3,
'hostname': 'ESP-C4A40A',
'hostname_source': 'ubios',
'is_guest': False,
'is_wired': False,
'last_connection_network_id': '61580ae7cd175e7e7c880323',
'last_connection_network_name': 'IOT',
'last_ip': '192.168.103.31',
'last_seen': 1707395661,
'latest_assoc_time': 1705372036,
'mac': 'X',
'name': 'Meteostanice',
'network': 'IOT',
'network_id': 'X',
'noted': True,
'os_name': 1,
'oui': 'Espressif Inc.',
'qos_policy_applied': True,
'rx_bytes': 0,
'rx_bytes-r': 0.0,
'rx_packets': 0,
'satisfaction_avg': {'count': 2, 'total': 0},
'score': 57,
'site_id': 'X',
'tx_bytes': 0,
'tx_bytes-r': 0.0,
'tx_packets': 0,
'uptime': 2023625,
'use_fixedip': False,
'user_id': 'X',
'usergroup_id': '',
'wlanconf_id': 'X'}}
I think using users.get('rx_rate', 0)
could be an appropriate solution here (and same for tx_rate
).