Update fastgate_check.py

This commit is contained in:
nicole 2024-11-13 17:33:19 +00:00
parent 0851aec7da
commit 6a12ae975c

View file

@ -1,9 +1,9 @@
from .agent_based_api.v1 import register, Result, Service, State
###############
# DEVICE LIST #
###############
def parse_fastgate_device_list(string_table):
result = {}
@ -104,15 +104,13 @@ def parse_fastgate_port_mapping(string_table):
for line in string_table:
parts = line
name, state, start, end, device, ip, prot = parts
name, state, start, end, ip, prot = parts
result [name] = {
"state": int(state),
"start": int(start),
"end": int(end),
"device": str(device),
"ip": str(ip),
"prot": str(prot)
}
return result
@ -127,12 +125,13 @@ def check_fastgate_port_mapping(item, section):
state = section[item]["state"]
start = section[item]["start"]
end = section[item]["end"]
device = section[item]["device"]
ip = section[item]["ip"]
protocol = section[item]["prot"]
if state == 1:
yield Result(state=State.OK, summary=f"{protocol}: {start}:{end} - ip: {ip}({device})")
yield Result(state=State.OK, summary=f"{protocol}: {start}:{end} - ip: {ip}")
else:
yield Result(state=State.OK, summary=f"[DISABLED] {protocol}: {start}:{end} - ip: {ip}")
except Exception as e:
print(e)