SCOM 2007: Dynamically populating a group from txt file

January 13, 2012 at 10:53 pm in Uncategorized by Dieter Wijckmans

At one of my clients they are using a custom build problem management tool + cmdb tool.

This means there’s not much flexibility of getting data in and out of these systems. At one point the question came to make a division between either critical servers and non critical servers to adapt the level of monitoring accordingly.

The only possible way to get the server list in was by supplying me with a txt file of all the critical servers.

So well… you can go and click away daily to compare the list with the group or automate the process… Of course I choose the second option.

By creating a new custom management pack that basically will read in the txt file on a regular basis and populate the group by deleting the servers which were removed and adding the new ones. So let’s get going.

The management pack can be downloaded here: Download management pack here

Things to adapt to your needs:

  • Line 52: The interval in my management pack is set to every 3 minutes (180 sec) which is way to high for production reasons but great for testing. Set it to more convenient level as this group will not change multiple times a day. Suggestion: 129600 = 6 hours.
  • Line 75: If you do not want to alter the management pack above you have to have your input file at c:\extract.txt. This can easily be adapted by editing line 75 before importing the management pack into your environment.

So now you have the xml file. Let’s import it in our environment and test:

Fire up your console and navigate to Administration > management packs

printscreen-0001

In the actions pane select Import Management Packs…

printscreen-0002

Select to import the management pack from disk by selecting add…

printscreen-0003

Click no at the following question. Browse to your management pack location and click import

printscreen-0004

Browse to your management pack location and click import.

printscreen-0005

Wait for it to import

printscreen-0006

When the import was successful you’ll notice the management pack listed in your mp list.

Check whether the group was created by going to the author tab > Groups.

printscreen-0008

The critical servers group was created but is empty at the moment because the discovery process did not run for the first time.

printscreen-0010

For this example I’ve created the extract.txt file with 3 servers who are currently residing in my environment.

printscreen-0012

 

After the first run of the script the servers are added to the group and the population has been completed.printscreen-0013

To test whether the servers are dynamically removed I’ve removed VSERVER05 from the file and wait for the following run of the discovery.

printscreen-0015

and eureka! A couple of minutes later the server has been removed from the group:

printscreen-0016

 

Note: Make sure to not have empty lines in the file because this will trigger an End Of File (EOF) command and stop the script.

Now that you are sure that you always have the latest update of your critical servers group you can target this group for more strict monitoring or any additional overrides you specifically want to apply to these critical servers in your environment.

Sources:

I’ve based my management pack on other community members who did similar projects:

Kevin Holman did it with populating groups from a CMDB which is SQL based: Populating groups from a sql server

Steve Rachui did it with a txt file and included several groups based on location: Populating from text file based on location

Share on FacebookTweet about this on TwitterShare on Google+Share on RedditShare on LinkedIn