Difference between revisions of "ZenDMD Tip - Dump zProperties values for a Device"

From Zenoss Wiki
Jump to: navigation, search
(Created page with "For a variety of reasons, you may want to dump the current values of all zProperties on a device. The following snippet will print out the property name and value. You can ge...")
 
m
Line 4: Line 4:
 
want rather than simply printing them to the screen.
 
want rather than simply printing them to the screen.
  
<syntaxhighlight lang="python">d = dmd.Devices.findDevice('device_name') #Set this to your devices name
+
<syntaxhighlight lang="python">
 +
d = dmd.Devices.findDevice('device_name') #Set this to your devices name
 
for prop_id in d.zenPropertyIds():
 
for prop_id in d.zenPropertyIds():
 
     value = d.getProperty(prop_id)
 
     value = d.getProperty(prop_id)
 
     print "{0} - {1}".format(prop_id, value)
 
     print "{0} - {1}".format(prop_id, value)
 
</syntaxhighlight>[[Category:Tips]][[Category:ZenDMD]]
 
</syntaxhighlight>[[Category:Tips]][[Category:ZenDMD]]

Revision as of 01:47, 21 June 2013

For a variety of reasons, you may want to dump the current values of all zProperties on a device.

The following snippet will print out the property name and value. You can get as creative as you want rather than simply printing them to the screen.

d = dmd.Devices.findDevice('device_name') #Set this to your devices name
for prop_id in d.zenPropertyIds():
    value = d.getProperty(prop_id)
    print "{0} - {1}".format(prop_id, value)