Print a List of Devices with Locally Defined Templates

From Zenoss Wiki
This is the approved revision of this page, as well as being the most recent.
Jump to: navigation, search

Find Locally Defined Monitoring Templates

Run "zendmd" on your ZenHub server and paste in the following, then press enter:

for dev in dmd.Devices.getSubDevices():
  for tpl in dev.getRRDTemplates():
    if dev == tpl.__primary_parent__:
      print "%s has local templates: %s" % (dev.id, tpl.id)

You will get an output similar to:

server1.zenoss.org has local templates: Device
server2.zenoss.org has local templates: Device_WMI
server3.zenoss.org has local templates: Device
server4.zenoss.org has local templates: Apache
server4.zenoss.org has local templates: Device_WMI

Find Locally Defined Filesystem Templates

Run "zendmd" on your ZenHub server and paste in the following, then press enter:

for dev in dmd.Devices.getSubDevices():
    for fs in dev.os.filesystems():
        for tpl in fs.getRRDTemplates():
            tplpath=tpl.getRRDPath()
            if tplpath.find(dev.id) >= 0:
                 print "%s %s %s" % (dev.id, fs.id, tplpath)

Since most filesystems' templates will be the default template for the class (probably /Device/Server), this prints out ones that have a template specific to the object (based on pattern matching device.id in the path of the template).

For example:

NETAPP2 RES_LUN01_vol /Devices/Storage/NetApp/devices/NETAPP2/os/filesystems/RES_LUN01_vol
NETAPP2 RES_LUN02_vol /Devices/Storage/NetApp/devices/NETAPP2/os/filesystems/RES_LUN02_vol