ZenDMD Tip - Move Devices to Proper Device Class

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

When performing a network discovery using either zendisc on the command line or through the web interface, all discovered devices are placed into the /Discovered device class by default. Oftentimes the minimum modeling done for devices in the /Discovered device class is enough to make a more intelligent choice about where the devices should go. The following zendmd snippets show a couple of these approaches.

Classify on Operating System Name

# Iterage through all devices in the /Discovered device class.
for device in dmd.Devices.Discovered.getSubDevices():
    # Move devices with IOS in their product name to the /Network/Cisco class.
    if "IOS" in device.getOSProductName():
        print "Moving %s to /Network/Cisco." % device.titleOrId()
    if device.id.startswith('CUCM-'):

Classify on SNMP sysObjectID

oidToClassMap = {
    '.': '/Server/Linux',
    '.': '/Network/Cisco',
    '.': '/Network/Cisco/IDS',
    '.': '/Network/Cisco',
    '.': '/Network/Cisco/ASA',
    '.': '/Network/Cisco',
    '.': '/Network/Cisco/Nexus',
for device in dmd.Devices.Discovered.getSubDevicesGen():
    if device.snmpOid not in oidToClassMap:
        print "No class mapping for %s." % device.titleOrId()
    new_class = oidToClassMap[device.snmpOid]
    print "Moving %s to %s." % (device.titleOrId(), new_class)