Update fastgate_check.py
This commit is contained in:
parent
0851aec7da
commit
6a12ae975c
1 changed files with 6 additions and 7 deletions
|
|
@ -1,9 +1,9 @@
|
||||||
from .agent_based_api.v1 import register, Result, Service, State
|
from .agent_based_api.v1 import register, Result, Service, State
|
||||||
|
|
||||||
|
|
||||||
###############
|
###############
|
||||||
# DEVICE LIST #
|
# DEVICE LIST #
|
||||||
###############
|
###############
|
||||||
|
|
||||||
def parse_fastgate_device_list(string_table):
|
def parse_fastgate_device_list(string_table):
|
||||||
result = {}
|
result = {}
|
||||||
|
|
||||||
|
|
@ -104,15 +104,13 @@ def parse_fastgate_port_mapping(string_table):
|
||||||
|
|
||||||
for line in string_table:
|
for line in string_table:
|
||||||
parts = line
|
parts = line
|
||||||
name, state, start, end, device, ip, prot = parts
|
name, state, start, end, ip, prot = parts
|
||||||
result [name] = {
|
result [name] = {
|
||||||
"state": int(state),
|
"state": int(state),
|
||||||
"start": int(start),
|
"start": int(start),
|
||||||
"end": int(end),
|
"end": int(end),
|
||||||
"device": str(device),
|
|
||||||
"ip": str(ip),
|
"ip": str(ip),
|
||||||
"prot": str(prot)
|
"prot": str(prot)
|
||||||
|
|
||||||
}
|
}
|
||||||
return result
|
return result
|
||||||
|
|
||||||
|
|
@ -127,12 +125,13 @@ def check_fastgate_port_mapping(item, section):
|
||||||
state = section[item]["state"]
|
state = section[item]["state"]
|
||||||
start = section[item]["start"]
|
start = section[item]["start"]
|
||||||
end = section[item]["end"]
|
end = section[item]["end"]
|
||||||
device = section[item]["device"]
|
|
||||||
ip = section[item]["ip"]
|
ip = section[item]["ip"]
|
||||||
protocol = section[item]["prot"]
|
protocol = section[item]["prot"]
|
||||||
|
|
||||||
if state == 1:
|
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:
|
except Exception as e:
|
||||||
print(e)
|
print(e)
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue