From 13d76111fb9481b596f4c40ad211ca80ef951b8d Mon Sep 17 00:00:00 2001 From: Simon Pasquier Date: Fri, 11 Mar 2016 15:30:09 +0100 Subject: [PATCH] Use 'meta' in the rabbitmq collectd plugin This change modifies the rabbitmq collectd plugin to provide the 'queue' value in the 'meta' dict instead of 'type_instance'. Change-Id: I9ac36657796e92c7b7d322ccd1adc60b6bd1de5a --- .../files/collectd/rabbitmq_info.py | 24 ++++++++++++++----- .../files/plugins/decoders/collectd.lua | 21 +++------------- 2 files changed, 21 insertions(+), 24 deletions(-) diff --git a/deployment_scripts/puppet/modules/lma_collector/files/collectd/rabbitmq_info.py b/deployment_scripts/puppet/modules/lma_collector/files/collectd/rabbitmq_info.py index b549654f0..729c2ef3a 100644 --- a/deployment_scripts/puppet/modules/lma_collector/files/collectd/rabbitmq_info.py +++ b/deployment_scripts/puppet/modules/lma_collector/files/collectd/rabbitmq_info.py @@ -191,10 +191,24 @@ class RabbitMqPlugin(base.Base): queue_name = ctl_stats[0] if self._matching_queue(queue_name): - queue_name = ctl_stats[0][:self.MAX_QUEUE_IDENTIFIER_LENGTH] - stats['%s.messages' % queue_name] = ctl_stats[1] - stats['%s.memory' % queue_name] = ctl_stats[2] - stats['%s.consumers' % queue_name] = ctl_stats[3] + meta = { + 'queue': ctl_stats[0][:self.MAX_QUEUE_IDENTIFIER_LENGTH] + } + yield { + 'type_instance': 'queue_messages', + 'values': ctl_stats[1], + 'meta': meta + } + yield { + 'type_instance': 'queue_memory', + 'values': ctl_stats[2], + 'meta': meta + } + yield { + 'type_instance': 'queue_consumers', + 'values': ctl_stats[3], + 'meta': meta + } # we need to check if the list of synchronised slaves is # equal to the list of slaves. @@ -238,8 +252,6 @@ class RabbitMqPlugin(base.Base): self.logger.warning('%s returned something strange.' % self.pmap_bin) - # TODO(pasquier-s): define and use own types instead of the generic - # GAUGE type for k, v in stats.iteritems(): yield {'type_instance': k, 'values': v} diff --git a/deployment_scripts/puppet/modules/lma_collector/files/plugins/decoders/collectd.lua b/deployment_scripts/puppet/modules/lma_collector/files/plugins/decoders/collectd.lua index 59e320cde..e905b5f2f 100644 --- a/deployment_scripts/puppet/modules/lma_collector/files/plugins/decoders/collectd.lua +++ b/deployment_scripts/puppet/modules/lma_collector/files/plugins/decoders/collectd.lua @@ -194,25 +194,10 @@ function process_message () msg['Fields']['name'] = msg['Fields']['name'] .. sample['type_instance'] end elseif metric_source == 'rabbitmq_info' then - if sample['type_instance'] ~= 'consumers' and - sample['type_instance'] ~= 'messages' and - sample['type_instance'] ~= 'memory' and - sample['type_instance'] ~= 'used_memory' and - sample['type_instance'] ~= 'unmirrored_queues' and - sample['type_instance'] ~= 'vm_memory_limit' and - sample['type_instance'] ~= 'disk_free_limit' and - sample['type_instance'] ~= 'disk_free' and - sample['type_instance'] ~= 'remaining_memory' and - sample['type_instance'] ~= 'remaining_disk' and - (string.match(sample['type_instance'], '%.consumers$') or - string.match(sample['type_instance'], '%.messages$') or - string.match(sample['type_instance'], '%.memory$')) then - local q, m = string.match(sample['type_instance'], '^(.+)%.([^.]+)$') - msg['Fields']['name'] = 'rabbitmq_queue' .. sep .. m - msg['Fields']['queue'] = q + msg['Fields']['name'] = 'rabbitmq' .. sep .. sample['type_instance'] + if sample['meta'] and sample['meta']['queue'] then + msg['Fields']['queue'] = sample['meta']['queue'] msg['Fields']['tag_fields'] = { 'queue' } - else - msg['Fields']['name'] = 'rabbitmq' .. sep .. sample['type_instance'] end elseif metric_source == 'nova' then msg['Fields']['name'] = 'openstack' .. sep .. 'nova' .. sep .. replace_dot_by_sep(sample['plugin_instance'])