This article explains how to move all the hosts monitored by a collector cluster to another collector cluster.
You may want to do this when removing a collector cluster.
API query
Learn to use Opsview's API
For more information about using Opsview's REST API, refer to the Opsview API documentation.
Prerequisites
- Another suitable collector cluster exists
-
jq
is installed
Process
- Log in to the orchestrator as
root
. - Use
opsview_rest
to move all the hosts monitored by the original cluster to another cluster:
/opt/opsview/coreutils/bin/opsview_rest --username=<admin> --password=<password> --pretty --data-format=json get 'config/monitoringcluster?s.name=<original_cluster>' | jq '.list[].monitors[].ref' | xargs -I REF opsview_rest --username=<admin> --password=<password> put REF --content-file=<( echo "{ monitored_by => {name => '<new_cluster>'} }")
Replace the variables in angle brackets (<>
) according to the following table:
Variable | Value |
---|---|
<admin> |
Username of an administrator user |
<password> |
Administrator user’s password |
<original_cluster> |
Name of the original collector cluster |
<new_cluster> |
Name of the new collector cluster |
This query works by getting the host configuration endpoints of all the hosts monitored by <original_cluster>
and then updating them to be monitored by <new_cluster>
.
Database
Proceed with caution
We do not recommend making any direct changes to the Opsview databases. Wherever possible, you should use the API instead.
Changes to the Opsview databases can irreparably damage your Opsview installation.
Always take appropriate backup precautions before making any direct changes to the Opsview databases.
Prerequisites
- Another suitable collector cluster exists
Process
- Access the
opsview
database using the MySQL console. - Identify the
id
of the cluster currently monitoring the hosts:
SELECT * FROM monitoringclusters where name = '<original_cluster_name>\G
Replace <original_cluster_name>
with the name of the cluster currently monitoring the hosts.
- Identify the
id
of the cluster you want to move the hosts to:
SELECT * FROM monitoringclusters where name = '<new_cluster_name>\G
Replace <new_cluster_name>
with the name of the cluster you want to monitor the hosts.
- Update the
monitored_by
field of the hosts so they are monitored by the new cluster:
UPDATE hosts SET monitored_by = <new_cluster_id> where monitored_by = <original_cluster_id>;
Replace <new_cluster_id>
with the id
of the new cluster. Replace <original_cluster_id>
with the id
of the original cluster.
-
Apply Changes.
You must Apply Changes even if you do not see a prompt to do so in the UI.
Comments
0 comments
Please sign in to leave a comment.