-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathEsNetInterfaceCollector.py
65 lines (54 loc) · 1.9 KB
/
EsNetInterfaceCollector.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
import threading
from threading import Thread
import copy
import json
import math
import collector
import hashlib
class EsNetInterfaceCollector(collector.Collector):
def __init__(self):
self.TOPIC = "/topic/esnet_interfaces"
self.INDEX = 'esnet_interfaces_write'
super(EsNetInterfaceCollector, self).__init__()
def eventCreator(self, message):
m = json.loads(message)
data = {
}
data['_index'] = self.INDEX
data['namespace'] = m['namespace']
data['resource'] = m['resource']
data['name'] = m['name']
data['device'] = m['device']
data['ifIndex'] = m['ifIndex']
data['description'] = m['description']
data['speed'] = m['speed']
data['vlan'] = m['vlan']
data['port'] = m['port']
data['nokiaType'] = m['nokiaType']
data['visibility'] = m['visibility']
data['connection'] = m['connection']
data['link'] = m['link']
data['tags'] = m['tags']
data['sector'] = m['sector']
data['site'] = m['site']
data['lhcone'] = m['lhcone']
data['oscars'] = m['oscars']
data['intercloud'] = m['intercloud']
data['intracloud'] = m['intracloud']
data['remoteDevice'] = m['remoteDevice']
data['remotePort'] = m['remotePort']
data['timestamp'] = m['timestamp']
sha1_hash = hashlib.sha1()
sha1_hash.update(str(data['namespace']).encode())
sha1_hash.update(str(data['resource']).encode())
sha1_hash.update(str(data['name']).encode())
sha1_hash.update(str(data['device']).encode())
sha1_hash.update(str(data['timestamp']).encode())
data['_id'] = sha1_hash.hexdigest()
self.aLotOfData.append(copy.copy(data))
def main():
collector = EsNetInterfaceCollector()
collector.start()
if __name__ == "__main__":
main()