-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
44 lines (36 loc) · 1.38 KB
/
main.py
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
42
43
44
#take calls from an added environmental variable
#chron once every 15 min to run a status check of the routes. run a heartbeat first before doing any of the status items.
import sys, os, datetime
from heartbeat.omniPing import omniPing
configFile = open('/home/pi/OMNI/config.conf' , 'r')
configLines = configFile.readlines()
configFile.close()
#args = sys.argv[1]
up = 'false'
traceList = '' #a list of args to run tracerts to, formatted 'dest hop' per line
if len(sys.argv)==1:
print('Use omni -h for list of commands')
args = 'null'
else:
args = sys.argv[1]
########################################################
#if '-h' in args:
#write help doc
if '-status' in args:
up = omniPing('8.8.8.8')
if up:
print('Online. Checking Traces:')
for trace in traceList:
os.system('python /home/pi/OMNI/trace/omniTrace.py ' + trace[0] + ' ' + trace[1])
elif '-trace' in args:
os.system('python /home/pi/OMNI/trace/omniTrace.py ' + sys.argv[2] + ' ' + sys.argv[3])
elif '-addTrace' in args:
#add IP to monitor trace to, format 'OMNI -addTrace dest hop'
configFile = open('config.conf' , 'w')
for line in configLines:
if 'TRACE=' in line.strip():
if len(sys.argv) == 4:
configFile.write(line.strip() + sys.argv[2] + ' ' + sys.argv[3] + ',')
else:
configFile.write(line)
configFile.close()