zendmd is a command line tool that can either be used as a REPL for Zenoss, or as an interpreter to run scripts. It is installed by Zenoss to $ZENHOME/bin/zendmd.
You can do a lot of powerful things from zendmd. The best thing to start would be to review some of the examples linked from this page to see how it works. There is also a bit of reference on the usage of the language here and a very nice quick start here and here
You can use zendmd in two different modes
Using as a REPL
To use in REPL mode, execute zendmd as the zenoss user.
$ zendmd Welcome to the Zenoss dmd command shell! 'dmd' is bound to the DataRoot. 'zhelp()' to get a list of commands. Use TAB-TAB to see a list of zendmd related commands. Tab completion also works for objects -- hit tab after an object name and '.' (eg dmd. + tab-key). >>>
Using as an Interpreter
zendmd can be used as a script interpreter as of Zenoss 4.2. For example, create a file called example.zendmd. The extension doesn't matter, but is a good convention. Add the following contents.
#!/usr/bin/env zendmd for device in dmd.Devices.getSubDevicesGen(): print "%s (%s)" % (device.titleOrId(), device.manageIp)
You can then make example.zendmd executable, and execute it by running the following commands. As the zenoss user.
$ chmod 0755 example.zendmd $ ./example.zendmd
You should see the name and management IP address of each device in your system printed.
ZenDMD Tips - Don't work hard, work smart!
See the examples in in the ZenDMD category that have been contributed to demonstrate the kinds of things that can be done using zendmd. They are applicable either to the REPL or interpreter modes.
- ZENDMD Tip - Delete Networks
- ZenDMD -Adding Devices in Bulk
- ZenDMD TIP - List Decomissioned devices
- ZenDMD Tip - Add Roles to Users in a jiffy
- ZenDMD Tip - Audit Transforms
- ZenDMD Tip - Audit Triggers and Notifications
- ZenDMD Tip - Audit Users
- ZenDMD Tip - Bulk Device Removal
- ZenDMD Tip - Change Interface Speed
- ZenDMD Tip - Check and Repair Device Objects with Missing DeviceClass
- ZenDMD Tip - Create Users in a Jiffy
- ZenDMD Tip - Dump zProperties values for a Device
- ZenDMD Tip - Fix Broken Graph Report Elements
- ZenDMD Tip - Fix Broken Muiltigraph Collections
- ZenDMD Tip - Fix Duplicate Property Refs
- ZenDMD Tip - Manipulate Events
- ZenDMD Tip - Move Devices to Proper Device Class
- ZenDMD Tip - Move Products to Proper Manufacturer
- ZenDMD Tip - Quickly Audit Enterprise Collectors
- ZenDMD Tip - Recreate Device Rels
- ZenDMD Tip - Refresh DeviceSearch Catalog
- ZenDMD Tip - Remove Invalid Devices from Collectors
- ZenDMD Tip - Remove all MIBS
- ZenDMD Tip - Removing Local Templates
- ZenDMD Tip - Rename Devices
- ZenDMD Tip - Replace modeler plugin programmatically
- ZenDMD Tip - Set Titles via Reverse Lookup (PTR record)
- ZenDMD Tip - ShowAllTransforms
- ZenDMD Tip - ShowEventMappingsAndTransforms
- ZenDMD Tip - Test & Delete Overrides
- ZenDMD Tip - Zet manageIp via Host Lookup (A record)
- ZenDMD Tip Renaming Modifying Device Properties
- ZenDMD Tips
- ZenDMD Tips - Impact
ZenDMD configuration file
If you often have to access some objects in zendmd, or write shortcut functions or test data, you could create script that does this for you, and then runs interactive bpython or ipython session like this:
try: # try to do some imports from ZenPacks.zenoss.Layer2.connections_catalog import CatalogAPI # create some objects cat = CatalogAPI(zport) # create some shortcuts def gc(x): ''' get entities connected to entity x ''' return list(cat.get_connected(x)) except ImportError, e: print e # initialize some variables devices = dmd.Devices.getSubDevices() import bpython; bpython.embed(locals())
Save this file for example in
~/bzendmd.py and add following alias in
alias dmd="zendmd --script=/home/zenoss/bzendmd.py"
Now you could start your custom interactive environment using command