dev #2
@@ -104,9 +104,13 @@ def index():
|
|||||||
latest_log = max(log_files, key=os.path.getctime)
|
latest_log = max(log_files, key=os.path.getctime)
|
||||||
with open(latest_log, "r") as f:
|
with open(latest_log, "r") as f:
|
||||||
for line in f:
|
for line in f:
|
||||||
|
line = line.strip()
|
||||||
for dev in devices:
|
for dev in devices:
|
||||||
if dev[1] in line:
|
# exakte Prüfung, Name gefolgt von 'ist erreichbar!' oder 'ist nicht erreichbar!'
|
||||||
status_dict[dev[0]] = "online" if "erreichbar" in line else "offline"
|
if line.startswith(f"{dev[1]} ist erreichbar!"):
|
||||||
|
status_dict[dev[0]] = "online"
|
||||||
|
elif line.startswith(f"{dev[1]} ist nicht erreichbar!"):
|
||||||
|
status_dict[dev[0]] = "offline"
|
||||||
|
|
||||||
# Template rendern mit Devices, Status und Intervall
|
# Template rendern mit Devices, Status und Intervall
|
||||||
return render_template("index.html", devices=devices, status=status_dict, interval=interval)
|
return render_template("index.html", devices=devices, status=status_dict, interval=interval)
|
||||||
|
|||||||
Reference in New Issue
Block a user