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

From Zenoss Wiki
Jump to: navigation, search
m
(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...")
(One intermediate revision by one other user not shown)
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">
+
<syntaxhighlight lang="python">d = dmd.Devices.findDevice('device_name') #Set this to your devices name
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>
+
</syntaxhighlight>[[Category:Tips]][[Category:ZenDMD]]
 
+
[[Category:Tips]]
+
[[Category:ZenDMD]]
+

Revision as of 01:20, 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)