cloud-pydashie/pydashie/openstack_app.py
adriant 267888ff74 setting up the graph to auto clear if out of sync
Due to possible api outages, and since we aren't using true
time series for the graphs, their x values may get out of sync,
and thus need to be cleared and reset.
also some minor pep8 fixes

Change-Id: I7a355df6705d8bc7d2eae8239ab17302a1f09fea
2015-01-07 11:59:00 +13:00

62 lines
2.0 KiB
Python

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, 30, conf['openstack'], client_cache,
response_cache),
ServiceAPISampler(xyzzy, 30, 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"