check_opnsense_traffic_for_host: unknown when list
This commit is contained in:
parent
b1d78df28c
commit
3e86cc3614
|
@ -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)
|
||||||
|
|
Loading…
Reference in New Issue