1. Zenoss Monitoring – zendmd Scripting Guide
i | P a g e
Table of Contents
Overview.......................................................................................................................................................1
Applies To......................................................................................................................................................1
Launch zendmd.............................................................................................................................................1
Device IP Location / Unknown - Stdout ........................................................................................................1
Write System Information to File..................................................................................................................2
System Information to File – Identify Location Unknown ............................................................................2
Get Device List – Organizer...........................................................................................................................3
Get Device List – By DeviceClassName .........................................................................................................4
Collate Zenoss Database Information...........................................................................................................4
2. Zenoss Monitoring – zendmd Scripting Guide
1 | P a g e
Overview
zendmd is a command line tool that can either be used as a REPL (Read Eval Print Loop) for Zenoss it can
also be used as an interpreter to run scripts. It’s installed by Zenoss monitoring application.
To run execute the command “zendmd” after switching to zenoss user.
Applies To
Zenoss 3.x 4.x
Launch zendmd
sudo su - zenoss
/opt/zenoss/bin/zendmd
Device IP Location / Unknown - Stdout
>>> for d in dmd.Devices.getSubDevices():
… print "%s,%s,%s" % (d.id, d.manageIp, d.getLocationName() or "Location Unknown")
…
Output:
fispl001.effonetech.com,192.168.2.42,Location Unknown
f1india01,,Location Unknown
localhost,127.0.0.1,Location Unknown
f1india02,192.168.2.200,Location Unknown
3. Zenoss Monitoring – zendmd Scripting Guide
2 | P a g e
Write System Information to File
>>> f =open("//tmp//devicesInfo.txt", "w")
>>> for d in dmd.Devices.getSubDevices():
... f.write(d.manageIp+","+d.getLocationName()+","+d.snmpSysName+"n")
... f.close()
… exit()
Output:
192.168.2.42,,FISPL001
Note: In this case Location is unknown
System Information to File – Identify Location Unknown
>>> f =open("//tmp//DevicesInfo.txt", "w")
>>> for d in dmd.Devices.getSubDevices():
... f.write("%s,%s,%s" % (d.id, d.manageIp, d.getLocationName() or "Location Unknown"))
... f.close()
... exit()
...
Output:
fispl001.effonetech.com,192.168.2.42,Location Unknown
4. Zenoss Monitoring – zendmd Scripting Guide
3 | P a g e
Get Device List – Organizer
To get Devices list by Device organizer, in this script we are filtering “/Server”
>>> for Device in dmd.Devices.getSubDevices():
... print Device.title, Device.manageIp
...
Output:
fispl001.effonetech.com 192.168.2.42
localhost 127.0.0.1
f1india02 192.168.2.200
5. Zenoss Monitoring – zendmd Scripting Guide
4 | P a g e
Get Device List – By DeviceClassName
To get Devices list by Device Class Name, in this script we are filtering “/Server”
Script Snippet
>>> for Device in dmd.Devices.getSubDevices():
... if Device.getDeviceClassName().startswith('/Server'):
... print Device.title, Device.manageIp
...
Output:
fispl001.effonetech.com 192.168.2.42
localhost 127.0.0.1
f1india02 192.168.2.200
Collate Zenoss Database Information
To collect the Database information run the below script, this script will display hostname, port, username
and password.
Script Snippet
print "nHost: %sttPort: %snUsername: %sttPassword: %s" % (dmd.ZenEventManager.host,
dmd.ZenEventManager.port, dmd.ZenEventManager.username, dmd.ZenEventManager.password)
Output:
Host: 127.0.0.1 Port: 3306
Username: root Password: