-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathping_worker.py
More file actions
executable file
·41 lines (28 loc) · 914 Bytes
/
ping_worker.py
File metadata and controls
executable file
·41 lines (28 loc) · 914 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#!/usr/bin/env python3
from main import *
import time
session = get_session()
nodeset = NodeSet()
nodeset.update_from_db(session)
print("ping_worker.py, " + str(len(nodeset.nodes)) + " nodes loaded.")
try:
while True:
nodeset.update_from_db(session)
# Update last_seen_at from nodes.json...
nodes_json_cache = NodesJSONCache()
nodes_json_cache.update()
for node in nodeset.nodes:
nodes_json_cache.update_db_node(node)
session.add(node)
session.commit()
for n in nodeset.nodes:
alarm = n.check(session)
if alarm is None:
continue
if alarm.is_resolved:
print("node " + n.name + ": resolved")
else:
print("node " + n.name + ": alarm")
time.sleep(60)
except KeyboardInterrupt:
print("CTRL + C pressed. Exiting.")