This tech tip describes using the sg_autocreate script to automatically create service groups.
The use case for this script is as follows:
You need to generate service groups in the Foundation database so that they show up in the UI.
You have a lot of hosts and services, so using the UI to create these servicegroups is time consuming and tedious.
You have changes to the hosts-service combinations that you want represented in the service groups, and these happen regularly enough that it is desirable to automate the service group creation.
This script will make it possible to create service groups automatically on the commit of the configuration, using data from the existing hosts and services.
While you can run this script at the command line and so integrate it into your existing provisioning systems, we have included an example of calling it from the commit process using the MonarchCallOut.pm integration module.
The script itself is heavily modular and commented, making it an ideal example for extending to other, similar functions as needed. We welcome your contributions in this regard, as always, and your suggestions for improvement and more use cases.
Here's how to install it and get it going:
Download all the files:
Place the files on the GroundWork server. Put:
in a directory on the GroundWork server where they can be accessed by the nagios user, e.g. /usr/local/groundwork/scripts.
You can lput agent_id in there too, if you like.
Make all the files owned by user nagios
Make sure that the sg_autocreate script is executeable:
Use the agent_id script to generate a unique id for the creation (and deletion) of the servicegroups you make using this script. You can use any string, as long as it is unique, but this makes a nice example.
The quoted string is randomized enough to be used as a unique agent identifier in the foundation database. Edit the file /usr/