In many scenarios you have a list of servers, a database query result or a place in your Active Directory that contains servers that you want to monitor in some special way. Often you need the machines in a group in Operations Manager so you can for example create overrides, maintenance mode and views for that group. It is a pretty boring work to build the group manually and then to keep the group updated.
A way to get the Operations Manager group in sync with the machine list is to use a runbook that creates a management pack including a group based on the list. This set of example runbooks reads a list of machine, creates a management pack with a group that includes the machines. The list of servers could be generated by another runbook or another tool. The last runbook also imports the management pack into Operations Manager.
This first runbook execute the following steps. In general this runbook checks if the machines in the list has a Operations Manager agent, if they are monitored by Operations Manager
- Delete File. Deletes old Machines_IDS.txt file if it exists. Machines_IDS.txt is used later in the runbook and needs to be blank before we begin
- Get Lines. Read all lines in the list. The list is simple a text file with servers, one server per row
- Get Monitor. Check if Operations Manager have a Microsoft.Windows.Computer monitor for the servers in the text file
- Append Line. For each machine that has a monitor, we write the machine name to a temporary file. This is the same file as step one deleted any old version of
- Junction. We merge multiple threads together
- Invoke Runbook. Trigger next runbook
- Delete File. Deletes old MP files
- Modify Counter. We use a counter to keep track of the management pack version number. This step adds one to that counter value
- Get Counter Value. Get the counter value for the same counter as in step 2
- Append Line. This steps writes the first half of the XML code that needs to be in the management pack. The GroupInstanceID is a random ID that the Operations Manager console generated when I test created a group in the console. You could replace that and all the other names in the management packs.
- Read Line. This step reads every machine that we wrote in the machine list in the first runbook, step 4,
- Append Line. This steps writes all the machines from step 5 into the management pack file
- Junction. We merge multiple threads together
- Append Line. Writes the end of the management pack, some more XML
- Invoke Runbook. Starts the last runbook and pass the path to the management pack file
The result is that each time you run this set of runbooks they will generate a new management pack version with a group that includes all the machines from your list, that has a agent. The management pack is imported into Operations Manager and you can use the updated group. You could include a step to seal the management pack too. You can download my runbook example here, 20120410_GroupSync_WOLF. Please note that this is provided “as is” with no warranties at all.
Recent Comments