-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmonitor_traffic_trunk.py
More file actions
42 lines (37 loc) · 1012 Bytes
/
monitor_traffic_trunk.py
File metadata and controls
42 lines (37 loc) · 1012 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
42
import os
import ossi
import re
import sys
import time
from colorama import Fore, Back
DATE = '0001ff00'
# # S A Q W
# #: Group; S: Grp Size; A: Active Members; Q: Q Length; W: Calls Waiting
if __name__ == '__main__':
status = ossi.Ossi()
status.connect()
trunks = status.list_trunks()
last_group = int(trunks[len(trunks)-1]['800bff00'])
pre_last_group = 0
start_group = 1
command = 'mon tra tru {}'
monitor = {}
while pre_last_group != last_group:
t = status.command(command.format(
pre_last_group if pre_last_group else start_group
))
parse = status.parse(t)
result = status.single_to_dict(parse)
result.pop(DATE)
for r in result:
if not result[r]:
continue
group, size, active, length, waiting = result[r].split()
group = int(group)
monitor.update({
group: '%s-%s-%s-%s' % (size, active, length, waiting),
})
if group > pre_last_group:
pre_last_group = group
print(monitor)
status.disconnect()