Skip to content

Commit

Permalink
Add a Zabbix 'zabbix_vm_disk_get' helper method
Browse files Browse the repository at this point in the history
  • Loading branch information
dnaeon committed Apr 4, 2014
1 parent 7a6b1df commit bf1dad6
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/vpoller/agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -1215,7 +1215,7 @@ def vm_disk_get(self, msg):
else:
return data

props = data['result']
props = data['result'][0]
disks = props['disk']

for disk in disks:
Expand Down
17 changes: 16 additions & 1 deletion src/vpoller/helpers/zabbix.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ def run(self):
'vm.discover': self.zabbix_lld_data,
'vm.get': self.zabbix_item_value,
'vm.disk.discover': self.zabbix_lld_data,
'vm.disk.get': self.zabbix_item_value,
'vm.disk.get': self.zabbix_vm_disk_get,
'vm.host.get': self.zabbix_item_value,
'datastore.discover': self.zabbix_lld_data,
'datastore.get': self.zabbix_item_value,
Expand Down Expand Up @@ -104,6 +104,21 @@ def zabbix_item_value(self):

return self.data['result'][0][property_name]

def zabbix_vm_disk_get(self):
"""
Processes a single property value for a VM guest disk
The value we return is of the first property only,
so that each item in Zabbix stores a single property value.
Returns:
The property value from the result message
"""
property_name = self.msg['properties'][0]

return self.data['result'][0]['disk'][property_name]

def zabbix_lld_data(self):
"""
Translates a discovery request to Zabbix LLD format
Expand Down

0 comments on commit bf1dad6

Please sign in to comment.