Useful Zendmd Tricks

The Zenoss Zendmd Tips Wiki page contains a few useful tricks using zendmd to perform tasks. In this post I am adding more tricks that I discover and learn along the way.

Removing Device Classes

We can easily remove device classes within zendmd with a simple command. Assuming we want to remove the default “KVM” device class:


Change Zenoss User’s Password

Let’s say we want to change the default admin user’s password (zenoss) in the Ubuntu auto deploy:

app.acl_users.userManager.updateUserPassword('admin', 'newpassword')

Creating Zendmd Scripts

We can create zendmd scripts that can be run in a zendmd environment when called. For example we can take one of the scripts above and place it in a file called change_password.zendmd (The zendmd extension is just good practice for identifying this script as a zendmd script):

#!/usr/bin/env zendmd

app.acl_users.userManager.updateUserPassword('admin', 'newpassword')

Next we should give it executable permissions:

chmod 0755 change_password.zendmd

Finally we can execute the script:


Obtaining zProperty Values

We can easily obtain values from zProperties added by ZenPacks:


Use zendmd as a Standalone Program

From a simple Python file, we can get access to zendmd by using the right imports. We can then work with the dmd object as usual:

#!/usr/bin/env python
import Globals
from Products.ZenUtils.ZenScriptBase import ZenScriptBase
from transaction import commit

dmd = ZenScriptBase(connect=True).dmd
zenoss zendmd python devops linux


comments powered by Disqus