Skip to content

Commit

Permalink
Make sure to cast bool values to integeres, so that Zabbix can unders…
Browse files Browse the repository at this point in the history
…tand the output
  • Loading branch information
dnaeon committed Jul 1, 2013
1 parent 5f1b99b commit 97dac09
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 6 deletions.
10 changes: 8 additions & 2 deletions poller/vm-discoverer.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,10 @@ def discover_hosts(self):
d = {}

for p in item.PropSet:
d[property_macros[p.Name]] = p.Val
if isinstance(p.Val, bool):
d[property_macros[p.Name]] = int(p.Val)
else:
d[property_macros[p.Name]] = p.Val

# remember on which vCenter this ESX host runs on
d['{#VCENTER_SERVER}'] = self._vcenter
Expand Down Expand Up @@ -99,7 +102,10 @@ def discover_datastores(self):
d = {}

for p in item.PropSet:
d[property_macros[p.Name]] = p.Val
if isinstance(p.Val, bool):
d[property_macros[p.Name]] = int(p.Val)
else:
d[property_macros[p.Name]] = p.Val

# remember on which vCenter is this datastore
d['{#VCENTER_SERVER}'] = self._vcenter
Expand Down
15 changes: 11 additions & 4 deletions poller/vm-poller.py
Original file line number Diff line number Diff line change
Expand Up @@ -186,12 +186,19 @@ def main():
poller.connect()

if pollInfo == 'datastores':
print poller.get_datastore_property(name, ds_url, myProperty)
result = poller.get_datastore_property(name, ds_url, myProperty)
elif pollInfo == 'hosts':
print poller.get_host_property(name, myProperty)
result = poller.get_host_property(name, myProperty)

poller.disconnect()


# Make sure to cast bools to int's so that Zabbix can understand them
if isinstance(result, bool):
print int(result)
else:
print result


if __name__ == '__main__':
main()

0 comments on commit 97dac09

Please sign in to comment.