AM nagios/plc2nagios.py
[monitor.git] / bwlimit.py
1 #!/usr/bin/python
2
3 import os
4 import sys
5 import string
6 import time
7 import soltesz
8 import plc
9
10 bwlimit = {}
11
12 def main():
13         global bwlimit
14
15         l_nodes = plc.getNodes()
16         d_nodes = {}
17         for host in l_nodes:
18                 h = host['hostname']
19                 d_nodes[h] = host
20
21         for h in d_nodes:
22                 host = d_nodes[h]
23                 for nw_id in host['nodenetwork_ids']:
24                         l_nw = plc.getNodeNetworks({'nodenetwork_id': host['nodenetwork_ids']})
25                         bwlimit[h] = []
26                         for nw in l_nw:
27                                 if nw['bwlimit'] != None and nw['bwlimit'] < 500000:
28                                         bwlimit[h].append(nw['bwlimit'])
29                         if len(bwlimit[h]) == 0:
30                                 del bwlimit[h]
31         
32         for host in bwlimit:
33                 print "%s %s" % (host, bwlimit[host])
34                         
35         
36 if __name__ == '__main__':
37         main()