Jun 29, 2011 11:50 PM
Toggling zMonitor via ZendMD to enable/disable Process Monitoring
-
Like (0)
Hello all,
I have a requirement to monitor a large number of in-house developed processes that start and stop at different times throughout the day. As such I have built a script that uses zendmd to set the zMonitor property of a process on a given device to True/False at certain times. It sets the property thusly:
procs = device.os.processes.findObjectsById('my_process_name')
for proc in procs:
process.setAqProperty('zMonitor', True, 'boolean') # or False to disable monitoring
commit()
In the GUI, this successfully sets the "Monitored" flag for the given process on the given device to True/False. However when I set the Monitored flag in this way it seems to have no effect at all.
Manually changing the "Monitored" flag in the GUI causes zenprocess to start/stop monitoring the given process, (I can see it doing so in zenprocess.log) but using my script there is no change, even though the flag changes in the GUI.
Does anyone have an idea why this might be? Is there a step I'm missing after process.setAqProperty that would cause the new property take effect?
Thanks... James
Ok, a little more information...
I've also tried setting proc.monitor = True, but this doesnt seem to help either. Here is a zendmd session in which I try to enable process monitoring of 'my_test_process':
As you can see, all of the various monitoring vars seem to be set correctly and have been committed. And yet zenprocess still will not monitor the test process. However if I go to the GUI and set the 'Monitored' flag there, zenprocess begins monitoring immediately.
It may be worth noting that I have applied changeset 25791 to my Zenoss 3.1.0 install: http://dev.zenoss.com/trac/changeset/25791
This was to fix a bug that prevented process monitoring being enabled/disabled from the GUI. Not sure if this may have caused a problem?
Any suggestions would be greatly appreciated...
I was advised to try setting zMonitor using setZenProperty, like this:
proc.setZenProperty('zMonitor', True)
However after doing this and commit()ing, the process in question is still not monitored.
This appears to be a major bug. It seems that there is no way to turn monitoring on and off for a process via zendmd.
Does anybody have any ideas or suggestions? Otherwise I guess I'll raise a trac ticket...
For anybody that's interested, I've raised a trac ticket for this: http://dev.zenoss.com/trac/ticket/7853
You can find the code that the web interface goes through to set the monitor
flag in the ServiceMonitor method in
$ZENHOME/Products/Zuul/infos/compnent/__init__.py. The only difference
between what you're doing, and what it does is that it indexes the process
object after running the setAqProperty method and setting the monitor
attribute.
So try this in zendmd..
proc = device.os.processes.findObjectsById('my_test_process')[0]
proc.setAqProperty('zMonitor', True)
proc.monitor = True
proc.index_object()
commit()
Thanks Chet, that was it...
I had tried proc.index_object() before (honestly!!!) but that was before I'd started doing proc.monitor=True as well as proc.setZenProperty('zMonitor', True).
So with all together in combination I am able to turn individual proc monitoring on/off with zendmd. Awesome!...:-)
Follow Us On Twitter »
|
Latest from the Zenoss Blog » | Community | Products | Services Resources | Customers Partners | About Us | ||
Copyright © 2005-2011 Zenoss, Inc.
|
||||||||