Identify hosts monitored by a collector cluster
There are three different methods to identify all the hosts monitored by a particular collector cluster:
API query Copied
Learn to use Opsview’s API
For more information about using Opsview’s REST API, refer to the Opsview API documentation.
You can query the monitoringcluster endpoint to see a list of hosts assigned to a given collector cluster. This method returns both the monitored host’s name and configuration endpoint in the API, e.g.
{
"name": "de-db-1000",
"ref": "/rest/config/host/9"
}
Prerequisites Copied
jqis installed
Process Copied
Run the following API query and pipe its output to jq:
GET 'config/monitoringcluster?s.name=<cluster_name>' | jq '.list[].monitors[]'
Replace <cluster_name> with the name of the collector cluster.
E.g. On your orchestrator:
/opt/opsview/coreutils/bin/opsview_rest --username=admin --password=initial GET 'config/monitoringcluster?s.name=<cluster_name>' | jq '.list[].monitors[]'
Replace <cluster_name> with the name of the collector cluster.
orchestratorclusterhosts script
Copied
The orchestratorclusterhosts script lists monitored hosts by the collectors and clusters that monitor them. If you want to only see hosts monitored by a specific cluster, you will need to filter the script’s output.
Prerequisites Copied
- None
Process Copied
- Log in to your orchestrator as
root. - Run the
orchestratorclusterhostsscript
/opt/opsview/orchestrator/bin/orchestratorclusterhosts
Database query Copied
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 Copied
- None
Process Copied
- Access the opsview database with the MySQL console.
- Run the following query to see all hosts and the clusters that monitor them:
SELECT hosts.name AS 'Name', hosts.ip AS 'Address', monitoringclusters.name AS 'Monitored by' FROM hosts LEFT JOIN monitoringclusters ON hosts.monitored_by = monitoringclusters.id;
You could extend this query to see only hosts monitored by a given cluster like this:
SELECT hosts.name AS 'Name', hosts.ip AS 'Address', monitoringclusters.name AS 'Monitored by' FROM hosts LEFT JOIN monitoringclusters ON hosts.monitored_by = monitoringclusters.id WHERE monitoringclusters.name = "<cluster_name>";
Replace <cluster_name> with the name of the collector cluster.