Discussion:
DMD/REST Help needed
joanypony
2012-05-01 12:57:42 UTC
Permalink
joanypony [http://community.zenoss.org/people/joanypony] created the discussion

"DMD/REST Help needed"

To view the discussion, visit: http://community.zenoss.org/message/66171#66171

--------------------------------------------------------------
Hi,
I'm trying to perform an action with DMD and I'm not getting anywhere.. I think it's possible, but that the issue is my ignorance with DMD.

What I want to do is to put ALL devices into maintenance mode using a REST command...

EG, command to put one server into maintenance mode -

curl " http://username:***@zenossserver:8080/zport/dmd/Devices/Server/Linux/Monitoring/devices/cactiserver/manage_editDevice?productionState=300 http://username:***@zenossserver:8080/zport/dmd/Devices/Server/Linux/Monitoring/devices/cactiserver/manage_editDevice?productionState=300"

This works perfectly. What I want is the equivalent that will put all devices into maintenance mode.

I've been trying to find the correct command to use with DMD but I'm getting nowhere.

The background is that I plan to run with 2 Zenoss monitoring servers in a mirror set up. Every night, Zenoss1 will send a backup to Zenoss2. Zenoss2 will restore from this. This part works fine. We only want to receive alerts from Zenoss1 so after the restore has been done, I want to put all devices on Zenoss2 into maintenance mode.

Thanks!

Joan
--------------------------------------------------------------

Reply to this message by replying to this email -or- go to the discussion on Zenoss Community
[http://community.zenoss.org/message/66171#66171]

Start a new discussion in zenoss-users by email
[discussions-community-forums-zenoss--***@community.zenoss.org] -or- at Zenoss Community
[http://community.zenoss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2003]
dpetzel
2012-05-01 14:13:49 UTC
Permalink
dpetzel [http://community.zenoss.org/people/dpetzel] created the discussion

"Re: DMD/REST Help needed"

To view the discussion, visit: http://community.zenoss.org/message/66177#66177

--------------------------------------------------------------
  dev.productionState = 300
commit()
--------------------------------------------------------------

Reply to this message by replying to this email -or- go to the discussion on Zenoss Community
[http://community.zenoss.org/message/66177#66177]

Start a new discussion in zenoss-users by email
[discussions-community-forums-zenoss--***@community.zenoss.org] -or- at Zenoss Community
[http://community.zenoss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2003]
joanypony
2012-05-02 11:12:58 UTC
Permalink
joanypony [http://community.zenoss.org/people/joanypony] created the discussion

"Re: DMD/REST Help needed"

To view the discussion, visit: http://community.zenoss.org/message/66173#66173

--------------------------------------------------------------
Thanks! That got me sorted. For anyone that needs something like this in future, in script form, it's:

#!/zenoss/python/bin/python
# Joan - this will set all devices to maintenance mode. This is to be used on the backup zenoss box.

import Globals, sys
import transaction

from Products.ZenUtils.ZenScriptBase import ZenScriptBase
dmd = None
try:
    dmd = ZenScriptBase(connect=True).dmd
except Exception, e:
    print "Connection to zenoss dmd failed: %s\n" % e
    sys.exit(1)

for dev in dmd.Devices.getSubDevices_recursive():

  dev.productionState = 300

trans = transaction.get()
trans.commit()
--------------------------------------------------------------

Reply to this message by replying to this email -or- go to the discussion on Zenoss Community
[http://community.zenoss.org/message/66173#66173]

Start a new discussion in zenoss-users by email
[discussions-community-forums-zenoss--***@community.zenoss.org] -or- at Zenoss Community
[http://community.zenoss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2003]
Loading...