From bdc731dd6437524ce491d51f0271367e9cbe2948 Mon Sep 17 00:00:00 2001 From: root Date: Tue, 25 Feb 2014 16:51:58 +0100 Subject: [PATCH] Add Zabbix helper for the *.counter.get method --- src/vpoller/helpers/zabbix.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/vpoller/helpers/zabbix.py b/src/vpoller/helpers/zabbix.py index a48cb5f..b5b24be 100644 --- a/src/vpoller/helpers/zabbix.py +++ b/src/vpoller/helpers/zabbix.py @@ -66,8 +66,10 @@ def run(self): # Methods that the Helper knows about and how to process methods = { 'host.get': self.zabbix_item_value, + 'host.counter.get': self.zabbix_counter_value, 'datastore.get': self.zabbix_item_value, 'vm.get': self.zabbix_item_value, + 'vm.counter.get': self.zabbix_counter_value, 'datacenter.get': self.zabbix_item_value, 'cluster.get': self.zabbix_item_value, 'host.discover': self.zabbix_lld_data, @@ -96,6 +98,20 @@ def zabbix_item_value(self): return self.data['result'][property_name] + def zabbix_counter_value(self): + """ + Processes a single counter value + + The value we return is not for an instance, + so that each item in Zabbix stores a single property value. + + Returns: + The counter value from the result message + + """ + for v in self.data['result']: + if not v['instance']: return v['value'] + def zabbix_lld_data(self): """ Translates a discovery request to Zabbix LLD format