Quantcast
Channel: Zenoss Community: Message List
Viewing all articles
Browse latest Browse all 1097

Re: Zenoss Maintenance Window for multiple devices in different groups

$
0
0

zendmd.

 

Login to the Linux machine and change to the "zenoss" user (su - zenoss).  then simply type "zendmd"

 

you'll be logged into a sort of python command-line system for zenoss.

zhelp() to get help

commit() to commit any changes you've made

quit() to exit

 

type "dmd." then hit "tab" twice and it'll show you all the options available under the root.  from there you can generally pick what looks like the path you want to look in and add go further down the rabbit hole as they say.

 

so dmd.Location "tab-tab"

dmd.Devices "tab-tab"

dmd.Devices.Discovered. "tab-tab"

dmd.Devices.Discovered.maintenanceWindows. "tab-tab"

 

For examples just search the forums for "ZenScriptBase" and you're likely to run into the right stuff

 

If you're looking to make and call some sort of python script then it'll likely look something like this (again, all just a quick pile together):

 

#!/usr/bin/env python
#
# mkGroupMW.py
#
# import the stuff that zendmd needs and create the dmd context
import Globals
import sys
from Products.ZenUtils.ZenScriptBase import ZenScriptBase
from transaction import commit
dmd = ZenScriptBase(connect=True, noopts=True).dmd

# inputs as follows:
# 1 - change identifier
# 2 - maintenance window start date (format M/D/Y)
# 3 - maintenance window start hour
# 4 - maintenance window start minute
# 5 - maintenance window duration days
# 6 - maintenance window duration hours
# 7 - maintenance windows duration minutes

# get the first input which should be the change identifier. e.g. "CH00286"
CHANGEID=sys.argv[1]

# create the "Groups" organizer
dmd.Groups.manage_addOrganizer("/ChangeWindow/"+CHANGEID)

# create the maintenance windows against the group
dmd.Groups.CHANGEID.manage_addMaintenanceWindow(newId="MW_"+CHANGEID)

# set the maintenance window start time and duration
dmd.Groups.CHANGEID.maintenanceWindows.MW_CHANGEID.manage_editMaintenanceWindow(startDate=sys.argv[2],startHours=sys.argv[3],startMinutes=sys.argv[4],durationDays=sys.argv[5],durationHours=sys.argv[6],durationMinutes=sys.argv[7])

sys.exit()

 

so you would call it by typing something like:

./mkGroupMW.py CH00286 7/31/2013 22 45 0 1 35

to create a change windows called "CH00286 for the 31st of July 2013 to start at 10:45pm and run for 0 days, 1 hour and 35 minutes

 

Then call a script something like the following for each of the devices you add to that Group (again, quick and dirty)

 

#!/usr/bin/env python
#
# addDevMW.py
#
# import the stuff that zendmd needs and create the dmd context
import Globals
import sys
from Products.ZenUtils.ZenScriptBase import ZenScriptBase
from transaction import commit
dmd = ZenScriptBase(connect=True, noopts=True).dmd

# inputs as follows:
# 1 - change identifier
# 2 - device IP

# find device from IP
dev = dmd.Devices.findDevice(sys.argv[2])

# add device to maintenance window group
dev.manage_addGroup("/ChangeWindow/"+sys.argv[1])


sys.exit()

 

so you would call it by typing something like:

 

./addDevMW.py CH00286 192.168.0.12

 

and again for each device you want to be part of the maintenance window.


Viewing all articles
Browse latest Browse all 1097

Trending Articles