Quantcast
Viewing all articles
Browse latest Browse all 853

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

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


Viewing all articles
Browse latest Browse all 853

Trending Articles