Merge "Add 'az' dimension to worker metrics"
diff --git a/collectd/files/plugin/collectd_openstack.py b/collectd/files/plugin/collectd_openstack.py
index a8a72b7..ade9b60 100644
--- a/collectd/files/plugin/collectd_openstack.py
+++ b/collectd/files/plugin/collectd_openstack.py
@@ -209,7 +209,8 @@
         {
           'host': 'node.example.com',
           'service': 'nova-compute',
-          'state': 'up'
+          'state': 'up',
+          'zone': 'az1'
         }
 
         where 'state' can be 'up', 'down' or 'disabled'
@@ -245,11 +246,13 @@
                     data = {'host': val['host'], 'service': val['binary']}
 
                     if service == 'neutron':
+                        data['zone'] = val['availability_zone']
                         if not val['admin_state_up']:
                             data['state'] = 'disabled'
                         else:
                             data['state'] = 'up' if val['alive'] else 'down'
                     else:
+                        data['zone'] = val['zone']
                         if val['status'] == 'disabled':
                             data['state'] = 'disabled'
                         elif val['state'] == 'up' or val['state'] == 'down':
diff --git a/collectd/files/plugin/openstack_cinder_services.py b/collectd/files/plugin/openstack_cinder_services.py
index 6488da1..44bb22d 100644
--- a/collectd/files/plugin/openstack_cinder_services.py
+++ b/collectd/files/plugin/openstack_cinder_services.py
@@ -57,7 +57,8 @@
             yield {
                 'plugin_instance': 'service',
                 'values': self.states[state],
-                'meta': {'hostname': host, 'service': service, 'state': state},
+                'meta': {'hostname': host, 'service': service, 'state': state,
+                         'az': worker['zone']},
             }
 
         for service in aggregated_workers:
diff --git a/collectd/files/plugin/openstack_neutron_agents.py b/collectd/files/plugin/openstack_neutron_agents.py
index e1b3848..fd4b80c 100644
--- a/collectd/files/plugin/openstack_neutron_agents.py
+++ b/collectd/files/plugin/openstack_neutron_agents.py
@@ -44,23 +44,27 @@
         self.interval = INTERVAL
 
     def itermetrics(self):
-
         # Get information of the state per agent
         # State can be up or down
         aggregated_agents = defaultdict(Counter)
 
         for agent in self.iter_workers('neutron'):
+            az = agent['zone']
             host = agent['host'].split('.')[0]
             service = self.agent_re.sub(
                 '', self.neutron_re.sub('', agent['service']))
             state = agent['state']
 
             aggregated_agents[service][state] += 1
+            meta = {'hostname': host, 'service': service, 'state': state}
+            if az:
+                # AZ field is only set for DHCP and L3 agents
+                meta['az'] = az
 
             yield {
                 'plugin_instance': 'agent',
                 'values': self.states[state],
-                'meta': {'hostname': host, 'service': service, 'state': state}
+                'meta': meta,
             }
 
         for service in aggregated_agents:
diff --git a/collectd/files/plugin/openstack_nova_services.py b/collectd/files/plugin/openstack_nova_services.py
index e6860e6..c98840a 100644
--- a/collectd/files/plugin/openstack_nova_services.py
+++ b/collectd/files/plugin/openstack_nova_services.py
@@ -57,7 +57,8 @@
             yield {
                 'plugin_instance': 'service',
                 'values': self.states[state],
-                'meta': {'hostname': host, 'service': service, 'state': state}
+                'meta': {'hostname': host, 'service': service, 'state': state,
+                         'az': worker['zone']}
             }
 
         for service in set(aggregated_workers.keys()).union(