Archived community.zenoss.org | full text search
Skip navigation
3628 Views 5 Replies Latest reply: Jul 6, 2011 1:08 AM by James Stewart RSS
James Stewart Rank: Green Belt 91 posts since
Dec 1, 2010
Currently Being Moderated

Jun 29, 2011 11:50 PM

Toggling zMonitor via ZendMD to enable/disable Process Monitoring

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

  • Chet Luther ZenossEmployee 1,302 posts since
    May 22, 2007

    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()

More Like This

  • Retrieving data ...

Legend

  • Correct Answers - 4 points
  • Helpful Answers - 2 points