Commercial Open Source Network, Systems & Application Monitoring

Zenoss Newsletter
Monitored by Zenoss
SourceForge.net Logo

use a zendmd script as standalone program

Wouldn't it be cool to run a python script directly without using the zendmd program?

This is quite easy to do.
The zendmd creates a python env special for zenoss.

When you have a zendmd script which you have created or downloaded somewhere you would add something to run it without zendmd.

just use this code:

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

dmd = ZenScriptBase(connect=True).dmd

#add your script here

#EOF

Save the file somewhere on the zenoss server and make it executable.

# chmod +x your-python-script.py

 

Now you are able to just run your script.

./your-python-script.py

 

 

Document Actions