ZenDMD Tips

From Zenoss Wiki
Revision as of 06:16, 24 November 2012 by Chet Luther (Talk | contribs)$7

Jump to: navigation, search

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. This page documents some of them.

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

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!

The following examples 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.