Background
There are some cases where it may be useful to use a command line interface for removing hosts out of the Monarch (or Configuration) subsystem of GroundWork Monitor. One particularly useful case is on a GroundWork Monitor Enterprise Edition system where hosts have been added to Monarch via the Auto Discovery process, such that the total number exceeds the license limit for the installation. If a commit of the Configuration is done as part of that Auto Discovery process then the web interface of GroundWork Monitor may become unavailable. Support is providing a tool in this article to allow for specified hosts to be deleted out of the Monarch subsystem and then for a commit operation to be performed. This will cause the hosts to be removed out of both the Monarch and Foundation subsystems. It may also be necessary to run a second tool against the Foundation subsystem to fully clean the Foundation subsystem of these extra hosts. The article describing that tool is found at How-to Determine and adjust your device count.
The script and steps described in this article have been tested with GroundWork Monitor Enterprise version 6.2, but the should work the same for versions 6.0 and higher.
Installation
Download the delete_hosts.pl script from this article and install in /usr/local/groundwork/tools. Change ownership and permissions on the script so that it looks like the example below:
-rwxr-xr-x 1 nagios nagios 4812 Sep 30 10:06 /usr/local/groundwork/tools/delete_hosts.pl
The script can be run without options, which will cause it to show a list of hosts and ask you to select which ones you wish to delete:
[nagios@dabrhel4es tools]$ ./delete_hosts.pl Getting list of hosts from Monarch... 3. (1) localhost (2) melmac (3) trieste Select hosts to delete [] 2 3 You have selected the following hosts to delete: melmac,trieste, Please answer 'y' if you wish to delete the specified hosts, otherwise answer 'n' to exit. [y] y Deleting host: melmac Deleting host: trieste All selected/valid hosts have been deleted. Please answer 'y' if you wish to commit the Monarch configuration to Nagios, otherwise answer 'n' to exit. Make sure no one is working in the Configuration user interface before answering 'y'. [y] y Monarch configuration has been committed to Nagios.
You may also choose to supply the script with a list of hosts in a separate file:
[nagios@dabrhel4es tools]$ ./delete_hosts.pl -f /tmp/hostlist Deleting host: melmac Deleting host: trieste Deleting host: funnyhost (error) no valid host_id for host funnyhost found All selected/valid hosts have been deleted. Please answer 'y' if you wish to commit the Monarch configuration to Nagios, otherwise answer 'n' to exit. Make sure no one is working in the Configuration user interface before answering 'y'. [y] y Monarch configuration has been committed to Nagios.
In both cases you are prompted as to whether you wish to perform a commit operation. You will want to make sure no one is using the web Configuration tool before doing any commit. Prompting for a commit operation can be overridden by a command line option so that the commit is automatically done after host deletion:
[nagios@dabrhel4es tools]$ ./delete_hosts.pl -f /tmp/hostlist --commit
Deleting host: melmac
Deleting host: trieste
Deleting host: funnyhost
(error) no valid host_id for host funnyhost found
All selected/valid hosts have been deleted.
Monarch configuration has been committed to Nagios.