-
Notifications
You must be signed in to change notification settings - Fork 5
/
NetworkMLTelemetryCollector.py
65 lines (52 loc) · 1.89 KB
/
NetworkMLTelemetryCollector.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
#!/usr/bin/env python
# NOT USED ANYMORE
import threading
# from threading import Thread
import copy
import json
# import hashlib
import collector
import siteMapping
class NetworkMLTelementryCollector(collector.Collector):
def __init__(self):
self.TOPIC = "/topic/telemetry.perfsonar"
self.INDEX = 'ps_telemetry_write'
super(NetworkMLTelementryCollector, self).__init__()
def eventCreator(self, message):
m = json.loads(message)
data = {}
source = m['meta']['source']
destination = m['meta']['destination']
data['MA'] = m['meta']['measurement_agent']
data['src'] = source
data['dest'] = destination
so = siteMapping.getPS(source)
de = siteMapping.getPS(destination)
if so is not None:
data['src_site'] = so[0]
data['src_VO'] = so[1]
if de is not None:
data['dest_site'] = de[0]
data['dest_VO'] = de[1]
data['src_production'] = siteMapping.isProductionLatency(source)
data['dest_production'] = siteMapping.isProductionLatency(destination)
if 'summaries' not in m:
print(threading.current_thread().name, "no summaries found in the message")
return
su = m['summaries']
for s in su:
if s['summary_window'] == '60' and s['summary_type'] == 'statistics':
results = s['summary_data']
# print(results)
for r in results:
data['_index'] = self.INDEX
data['timestamp'] = r[0] * 1000
data['_id'] = self.calculateId(m, data['timestamp'])
data['sim_util'] = r[1]['ml']
# print(data)
self.aLotOfData.append(copy.copy(data))
def main():
collector = NetworkMLTelementryCollector()
collector.start()
if __name__ == "__main__":
main()