How to delete hosts
About Removing Hosts
In GroundWork Monitor you may need to delete a host or multiple host configurations, delete Cloud Hub associated hosts, or other types of monitored hosts. This page describes how to remove hosts based on the monitoring method used.
Deleting Hosts using Scripts
Sometimes you are adding hosts from sources you can't directly control, or misconfigure and end up with hosts in the database that should not be there. While it's possible to delete these with database queries, the use of foreign keys makes this process risky unless you are an expert. It's much safer to use the API. These scripts allow you to delete hosts by name or regex pattern, or by agentID (a database field that identifies the owner process). They require a login with an admin role user.
Note about Event History
Deleting hosts removes their event history, so don't do this unless you no longer need this data. Note, it will be archived after 1 day so you can still report on them up to the date before you delete them. If your source for monitoring data for these hosts is still active, they will reappear on the next synchronization cycle, minus their event history.
Using the delete-groundwork-hosts script
This script removes hosts you specify. The services associated with the host will also be removed in a cascade delete. You can run it on a GroundWork server, or on your workstation. It uses HTTPS to connect to the GroundWork API.
- Download the script: delete-groundwork-hosts.sh
- Copy it to your workstation.
Set the file as executable:
chmod +x delete-groundwork-hosts.sh
CODERun the script and answer the prompts.
./delete-groundwork-hosts.sh
CODE
Using the delete_by_agentid script
This script will remove all the hosts, services and hostgroups and servicegroups associated with a particular agentID, which is a database field that identifies the "Owner" of a host, or the source of monitoring data for a service. You can find the agentID for TCG sources by looking in the Status tab of the connector under Configuration > Connectors. If the source is another application you created, or the agentID is orphaned by errors or configuration changes, you can find it in the database with a query like this:
docker-compose exec pg psql -c "select hostname, agentID from host;"
Once you know the agentID you want to remove, you can use this script to remove it.
- Download the script: delete_by_agentid.sh
- Copy it to your workstation.
Set the file as executable:
chmod +x delete_by_agentid.sh
CODERun the script and answer the prompts.
./delete_by_agentid.sh
CODE
Deleting Nagios Configured Hosts
Like all Nagios configuration changes, you will need to perform a Commit operation, (Configuration > Nagios Monitoring > Control > Pre flight test > Commit), to complete the task of removing a host or hosts.
Delete one host
- Go to Configuration > Nagios Monitoring > Hosts > Hosts.
- Locate the host you want to delete and select Detail.
- Scroll down to the bottom of the Manage Host screen and click Delete.
Delete multiple hosts
There is an easy way to delete one, many, or all hosts. The Delete hosts tool completely removes a host, its associated services, and any reference such a a membership in host groups, service groups, groups, and profiles.
- Go to Configuration > Nagios Monitoring > Hosts.
- Select Delete hosts.
- Next, in the Delete Hosts screen, using the drop-down box, select from the list of abbreviated host names and host addresses.
- For example, selecting " * " lists all hosts, and " 1* " will list all hosts with an IP address that starts with the number 1.
- Once a host abbreviation is chosen the matching hosts will be listed. Select the check box next to each host to be removed.
Select Delete.
If you select the " * " filter to list all hosts and select Check All to remove all hosts, the system will consider this action as an invalid configuration with no hosts and services. This should be avoided.
Deleting Cloud Hub Hosts
Cloud Hub instances are the hosts that have been setup using the GroundWork Cloud Hub monitoring subsystem. Cloud Hub configuration, using hypervisors and or virtualization manager(s), performs various functions including auto discovery, creating of hosts and host groups, and applying of profiles. Completely removing previously set environments in Cloud Hub includes a command line entry, which is outlined below.
Over license limit
It is recommended to check your license limit prior to configuring Cloud Hub connections. If you need to delete Cloud Hub connectors and can't log in to GroundWork Monitor to do so because the addition of connectors created enough hosts to exceed your license hard limit, please see Cloud Hub Troubleshooting.
Stop monitoring and keep configuration
If you decide you do not want to monitor a particular region but you want to keep the configuration, simply:
- Navigate to Configuration > Cloud Hub.
- Select STOP for the corresponding connection. The connection, as previously configured, can be started again by selecting START.
Completely delete a configuration
To completely DELETE a specific region's monitored hosts follow the steps below. All of the created host groups and the discovered and monitored instances for that region will be deleted from the Foundation database within a few minutes and monitoring access to the region endpoint will cease.
- As an Administrator, go to Configuration > Cloud Hub.
- Select STOP and DELETE for each connection to be deleted.
Deleting GDMA Hosts
To remove GDMA hosts from being monitored in GroundWork Monitor you need to uninstall the agent on the client server.
Like all Nagios configuration changes, you will need to perform a Commit operation, (Configuration > Nagios Monitoring > Control > Pre flight test > Commit), to complete the task of removing a host or hosts.
Uninstall GDMA for Linux
- Access a command line interface for the Linux GDMA client server.
- Backup any custom plugins in the /usr/local/groundwork directory structure. You will need to move these to the new location.
Next, as root user, run the following script to uninstall the agent:
/usr/local/groundwork/uninstall
CODEYou will be prompted with the question Do you want to uninstall GroundWork Distributed Monitoring Agent and all of its modules?, confirm the uninstall.
Remove the groundwork sub-directory and all sub-directories:
rm -rf /usr/local/groundwork
CODEOn the GroundWork server delete the GDMA client host within the Auto Registration host group, (Configuration > Nagios Monitoring > Hosts > Hosts > Auto-Registration > <hostname> > Detail > delete).
Uninstall GDMA for Windows
- Access the File Manager for the Windows GDMA client server.
- Backup any custom plugins in the C:\Program Files (x86)\groundwork directory structure. You will need to move these to the new location.
- Next, from the C:\Program Files (x86)\groundwork directory, select and run the uninstall.exe file. You will be prompted with the question Do you want to uninstall GroundWork Distributed Monitoring Agent and all of its modules?, answer Yes to uninstall and proceed.
- Using the File Manager remove the groundwork directory all all sub-directories.
- On the GroundWork server delete the GDMA client host within the Auto Registration host group.
Deleting WMI NRPE_NT Hosts
- On the Windows WMI client server, launch the Command Prompt and check if the NRPE_NT directory exists in the C: directory.
If the directory exists stop the service:
net stop nrpe_nt
CODEThen uninstall the service:
\nrpe_nt\bin\nrpe_nt.exe -u
CODENext, navigate to Computer > Local Disk (C\:) > and delete the NRPE_NT directory.
Related Resources
-
Page:
-
Page: