check_opnsense_traffic_for_host: unknown when list

This commit is contained in:
Cyberes 2023-06-11 19:25:33 -06:00
parent b1d78df28c
commit 3e86cc3614
1 changed files with 3 additions and 0 deletions

View File

@ -88,6 +88,9 @@ def main():
if response.status_code != 200: if response.status_code != 200:
print(f'UNKNOWN: unable to query OPNsense API for {interface}: {response.status_code}\n{response.text}') print(f'UNKNOWN: unable to query OPNsense API for {interface}: {response.status_code}\n{response.text}')
sys.exit(nagios.UNKNOWN) sys.exit(nagios.UNKNOWN)
if isinstance(response.json(), list):
print(F'UNKNOWN - OPNsense returned wrong datatype:\n{response.json()}')
for item in response.json().get(interface, {}).get('records', False): for item in response.json().get(interface, {}).get('records', False):
if item['address'] == args.host: if item['address'] == args.host:
traffic_data.append(item) traffic_data.append(item)