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
In the actions pane select Import Management Packs…
Select to import the management pack from disk by selecting add…
Click no at the following question. Browse to your management pack location and click import
Browse to your management pack location and click import.
Wait for it to import
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.
The critical servers group was created but is empty at the moment because the discovery process did not run for the first time.
For this example I’ve created the extract.txt file with 3 servers who are currently residing in my environment.
To test whether the servers are dynamically removed I’ve removed VSERVER05 from the file and wait for the following run of the discovery.
and eureka! A couple of minutes later the server has been removed from the group:
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.
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