-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrpc-curses.py
84 lines (66 loc) · 2.03 KB
/
rpc-curses.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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
#!/usr/bin/python
connectString = "http://freeswitch:fs@sarah.athnex.com:8080"
import curses
from xmlrpc.client import ServerProxy
import re
import time
mainscreen = curses.initscr()
pTotal = re.compile('\d+ total.')
server = ServerProxy(connectString)
x = 0
mainscreen.nodelay(1)
while True:
ServerStatusLine = server.freeswitch.api("status","").split('\n')
ShowRegistrations = server.freeswitch.api("show","registrations").split("\n")
ShowChannels = server.freeswitch.api("show","channels").split("\n")
mainscreen.clear()
i = 0
mainscreen.border(0)
mainscreen.addstr(i + 1,2, ServerStatusLine[0])
mainscreen.addstr(i + 2,2, ServerStatusLine[2])
mainscreen.addstr(i + 3,2, ServerStatusLine[3])
mainscreen.addstr(i + 4,2, ServerStatusLine[4])
mainscreen.addstr(i + 5,2, ServerStatusLine[6])
mainscreen.addstr(i+7,2, "Registrations ===")
i += 8
for regStr in ShowRegistrations:
if regStr == '0 total.':
mainscreen.addstr(i+2,2, "No Registered users.")
break
elif regStr == '' or regStr[0:8] == 'reg_user':
continue
elif pTotal.match(regStr):
continue
regLine = regStr.split(',')
mainscreen.addstr(i,2,
"User: " + regLine[0] + "@" + regLine[1] + " " + regLine[7] +
" " + regLine[5] + ":" + regLine[6])
i += 1
mainscreen.addstr(i + 1,2, "Channel List ===")
for chanStr in ShowChannels:
if chanStr == '0 total.':
mainscreen.addstr(i+2,2, "No Open Channels.")
break
elif chanStr == '' or chanStr[0:4] == 'uuid':
continue
elif pTotal.match(chanStr):
continue
chanLine = chanStr.split(',')
mainscreen.addstr(i + 2,2,
chanLine[2] + " UUID: " + chanLine[0] + " Direction: " +
chanLine[1])
mainscreen.addstr(i + 3,2,
" " + chanLine[6] + " ( " + chanLine[7] + " ) Src IP: " +
chanLine[8] + " >> Dest " + chanLine[9] + " [Codec " +
chanLine[17] + "]")
mainscreen.addstr(i + 4,2,
" Application: " + chanLine[10] +
" (" + chanLine[11] + ")")
i += 4
mainscreen.refresh()
x = mainscreen.getch()
if x == ord('q'):
break
else:
time.sleep(1)
curses.endwin()