Add metrics to get the percentage of workers per state

This patch adds a new metric that computes the percentage of workers
that are up, down and disabled.

Blueprint: allow-all-alarms-to-be-specified-in-alarming-file
Change-Id: Id31280273b6176cd415ce9b9ac10162e891479f9
This commit is contained in:
Guillaume Thouvenin 2016-09-07 15:26:04 +02:00
parent 76987240a9
commit 506196dcef
5 changed files with 40 additions and 1 deletions

View File

@ -55,7 +55,14 @@ class CinderStatsPlugin(openstack.CollectdPlugin):
'state': state})
for service in aggregated_workers:
totalw = sum(aggregated_workers[service].values())
for state in self.states:
prct = (100.0 * aggregated_workers[service][state]) / totalw
self.dispatch_value('cinder_services_percent', '',
prct,
{'state': state, 'service': service})
self.dispatch_value('cinder_services', '',
aggregated_workers[service][state],
{'state': state, 'service': service})

View File

@ -85,7 +85,14 @@ class NeutronStatsPlugin(openstack.CollectdPlugin):
'state': state})
for service in aggregated_agents:
totala = sum(aggregated_agents[service].values())
for state in self.states:
prct = (100.0 * aggregated_agents[service][state]) / totala
self.dispatch_value('neutron_agents_percent',
prct,
{'service': service, 'state': state})
self.dispatch_value('neutron_agents',
aggregated_agents[service][state],
{'service': service, 'state': state})

View File

@ -53,7 +53,14 @@ class NovaStatsPlugin(openstack.CollectdPlugin):
'state': state})
for service in aggregated_workers:
totalw = sum(aggregated_workers[service].values())
for state in self.states:
prct = (100.0 * aggregated_workers[service][state]) / totalw
self.dispatch_value('nova_services_percent', '',
prct,
{'state': state, 'service': service})
self.dispatch_value('nova_services', '',
aggregated_workers[service][state],
{'state': state, 'service': service})

View File

@ -244,7 +244,8 @@ function process_message ()
end
elseif metric_source == 'nova' then
if sample['plugin_instance'] == 'nova_services' or
sample['plugin_instance'] == 'nova_service' then
sample['plugin_instance'] == 'nova_services_percent' or
sample['plugin_instance'] == 'nova_service' then
msg['Fields']['name'] = 'openstack_' .. sample['plugin_instance']
msg['Fields']['service'] = sample['meta']['service']
msg['Fields']['state'] = sample['meta']['state']
@ -260,6 +261,7 @@ function process_message ()
end
elseif metric_source == 'cinder' then
if sample['plugin_instance'] == 'cinder_services' or
sample['plugin_instance'] == 'cinder_services_percent' or
sample['plugin_instance'] == 'cinder_service' then
msg['Fields']['name'] = 'openstack_' .. sample['plugin_instance']
msg['Fields']['service'] = sample['meta']['service']
@ -292,6 +294,7 @@ function process_message ()
elseif sample['type_instance'] == 'subnets' then
msg['Fields']['name'] = 'openstack' .. sep .. 'neutron' .. sep .. 'subnets'
elseif sample['type_instance'] == 'neutron_agents' or
sample['type_instance'] == 'neutron_agents_percent' or
sample['type_instance'] == 'neutron_agent' then
msg['Fields']['name'] = 'openstack_' .. sample['type_instance']
msg['Fields']['service'] = sample['meta']['service']

View File

@ -92,6 +92,11 @@ The following metrics are retrieved from the Nova API:
'conductor', 'scheduler', 'cert' or 'consoleauth') and a ``state`` field (one
of 'up', 'down', or 'disabled').
* ``openstack_nova_services_percent``, the percentage of Nova
services by state. The metric contains a ``service`` field (one of 'compute',
'conductor', 'scheduler', 'cert' or 'consoleauth') and a ``state`` field (one
of 'up', 'down', or 'disabled').
Identity
^^^^^^^^
@ -142,6 +147,11 @@ The following metrics are retrieved from the Cinder API:
The metric contains a ``service`` field (one of 'volume', 'backup',
'scheduler') and a ``state`` field (one of 'up', 'down' or 'disabled').
* ``openstack_cinder_services_percent``, the percentage of Cinder
services by state. The metric contains a ``service`` field (one of 'volume',
'backup', 'scheduler') and a ``state`` field (one of 'up', 'down', or
'disabled').
Image
^^^^^
@ -193,6 +203,11 @@ The following metrics are retrieved from the Neutron API:
and state. The metric contains ``service`` (one of 'dhcp', 'l3', 'metadata'
or 'openvswitch') and ``state`` (one of 'up', 'down' or 'disabled') fields.
* ``openstack_neutron_agents_percent``, the percentage of Neutron
agents by state. The metric contains a ``service`` field (one of 'dhcp',
'l3', 'metadata' or 'openvswitch') and a ``state`` field (one of 'up',
'down', or 'disabled').
API response times
^^^^^^^^^^^^^^^^^^