Discussion:
Zendmd script to output all devices, device class, data source, thresholds to csv
kenhen93
2014-01-16 19:38:12 UTC
Permalink
kenhen93 [http://community.zenoss.org/people/kenhen93] created the discussion

"Zendmd script to output all devices, device class, data source, thresholds to csv"

To view the discussion, visit: http://community.zenoss.org/message/75644#75644

--------------------------------------------------------------
I thought this little script could be helpful to others. I put it together looking through other different zendmd code I found on the internet and the zenoss community. It will output

Datasource/Threshold,DeviceName,DeviceClass,TemplateName,DS/ThName,Enabled/Disabled?,Severity,EventClass

into a csv comma delimeted format. This is really helpful as I have many zenoss users and its great way to help them audit their monitors. I have tested and ran this script on Zenoss Core 4.2.4 but I am sure it will probably work on 3.x too. Feel free to comment if you think this need improvement or have a question or comment. Thanks!

#!/usr/bin/env python
import Globals
from Products.ZenUtils.ZenScriptBase import ZenScriptBase
from transaction import commit
dmd = ZenScriptBase(connect=True).dmd
#This script makes a report of Datasource/Threshold,DeviceName,DeviceClass,TemplateName,DS/ThName,Enabled/Disabled?,Severity,EventClass via Zenoss zendmd shell and outputs it in a comma delimited CSV

f = open('/opt/zenoss/libexec/Zenoss_Template_Device_Info.csv', 'w')

f.write("Datasource/Threshold,DeviceName,DeviceClass,TemplateName,DS/ThName,Enabled/Disabled?,Severity,EventClass\n")

for d in dmd.Devices.getSubDevices():
        org = d.getOrganizerName()
        for template in d.getRRDTemplates():
                for ds in template.getRRDDataSources():
                        f.write("DS,%s,%s,%s,%s,%s,%s,%s\n" % (d.id,org,template.id,ds.id,ds.enabled,ds.severity,ds.eventClass))
                for tholds in template.thresholds():
                        f.write("Th,%s,%s,%s,%s,%s,%s,%s\n" % (d.id,org,template.id,tholds.id,tholds.enabled,tholds.severity,tholds.eventClass))
#EOF
--------------------------------------------------------------

Reply to this message by replying to this email -or- go to the discussion on Zenoss Community
[http://community.zenoss.org/message/75644#75644]

Start a new discussion in zenoss-users at Zenoss Community
[http://community.zenoss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2003]
Loading...