forked from unexceptable/pydashie
-
Notifications
You must be signed in to change notification settings - Fork 2
/
openstack_app.py
59 lines (51 loc) · 1.9 KB
/
openstack_app.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
import collections
from openstack_samplers import (
CPUSampler,
RAMSampler,
IPSampler,
RegionsRAMSampler,
RegionsCPUSampler,
RegionIPSampler,
NagiosSampler,
NagiosRegionSampler,
ResourceSampler,
APIRegionSampler,
ServiceAPISampler
)
def run(args, conf, app, xyzzy):
client_cache = {}
response_cache = {'regions': {}, 'services': {},
'events': {'service': collections.deque(),
'region': collections.deque()}}
samplers = [
CPUSampler(xyzzy, 60, conf['openstack'], client_cache, response_cache),
RAMSampler(xyzzy, 60, conf['openstack'], client_cache, response_cache),
IPSampler(xyzzy, 60, conf['openstack'], client_cache, response_cache),
RegionsCPUSampler(xyzzy, 60, conf['openstack'], client_cache,
response_cache),
RegionsRAMSampler(xyzzy, 60, conf['openstack'], client_cache,
response_cache),
RegionIPSampler(xyzzy, 60, conf['openstack'], client_cache,
response_cache),
NagiosSampler(xyzzy, 15, conf['nagios']),
NagiosRegionSampler(xyzzy, 15, conf['nagios']),
ResourceSampler(xyzzy, 60, conf['openstack'], client_cache,
response_cache),
APIRegionSampler(xyzzy, 15, conf['openstack'], client_cache, response_cache),
ServiceAPISampler(xyzzy, 15, conf['openstack'], client_cache, response_cache),
]
try:
app.run(debug=True,
host=args.ip,
port=args.port,
threaded=True,
use_reloader=False,
use_debugger=True
)
finally:
print "Disconnecting clients"
xyzzy.stopped = True
print "Stopping %d timers" % len(samplers)
for (i, sampler) in enumerate(samplers):
sampler.stop()
print "Done"