All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.emc.vipr.client.system.HealthMonitor Maven / Gradle / Ivy

There is a newer version: 3.5.0.0
Show newest version
/*
 * Copyright (c) 2015 EMC Corporation
 * All Rights Reserved
 */
package com.emc.vipr.client.system;

import static com.emc.vipr.client.system.impl.PathConstants.MONITOR_DIAGNOSTICS_URL;
import static com.emc.vipr.client.system.impl.PathConstants.MONITOR_HEALTH_URL;
import static com.emc.vipr.client.system.impl.PathConstants.MONITOR_STATS_URL;
import static com.emc.vipr.client.system.impl.PathConstants.MONITOR_STORAGE_URL;
import static com.emc.vipr.client.impl.jersey.ClientUtils.addQueryParam;

import java.util.List;

import javax.ws.rs.core.UriBuilder;

import com.emc.vipr.model.sys.healthmonitor.StorageStats;
import com.emc.vipr.model.sys.healthmonitor.DiagnosticsRestRep;
import com.emc.vipr.client.impl.RestClient;
import com.emc.vipr.model.sys.healthmonitor.HealthRestRep;
import com.emc.vipr.model.sys.healthmonitor.StatsRestRep;

public class HealthMonitor {

    private static final String NODE_ID_PARAM = "node_id";
    private static final String NODE_NAME_PARAM = "node_name";
    private static final String INTERVAL_PARAM = "interval";
    private static final String VERBOSE_PARAM = "verbose";
    private static final String VERBOSE = "1";

    private RestClient client;

    public HealthMonitor(RestClient client) {
        this.client = client;
    }

    /**
     * Convenience method to get stats of all nodes.
     * 

* Get statistics of virtual machine and its active services Virtual machine stats include memory usage, I/O for each device, load * average numbers Service stats include service memory usage, command that invoked it, file descriptors count and other stats (uptime, * start time, thread count). *

* If interval value is passed it will return differential disk stats: difference between first report (contains stats for the time * since system startup) and second report (stats collected during the interval since the first report). *

* API Call: GET /monitor/stats * * @return The stats response */ public StatsRestRep getStats() { return getStats(null, null); } /** * Get statistics of virtual machine and its active services Virtual machine * stats include memory usage, I/O for each device, load average numbers Service * stats include service memory usage, command that invoked it, file descriptors * count and other stats (uptime, start time, thread count). *

* If interval value is passed it will return differential disk stats: difference between first report (contains stats for the time * since system startup) and second report (stats collected during the interval since the first report). *

* API Call: GET /monitor/stats * * @return The stats response */ public StatsRestRep getStats(List nodeIds, Integer interval) { UriBuilder builder = client.uriBuilder(MONITOR_STATS_URL); addQueryParam(builder, NODE_ID_PARAM, nodeIds); addQueryParam(builder, INTERVAL_PARAM, interval); return client.getURI(StatsRestRep.class, builder.build()); } /** * Get statistics of virtual machine and its active services Virtual machine * stats include memory usage, I/O for each device, load average numbers Service * stats include service memory usage, command that invoked it, file descriptors * count and other stats (uptime, start time, thread count). *

* If interval value is passed it will return differential disk stats: difference between first report (contains stats for the time * since system startup) and second report (stats collected during the interval since the first report). *

* API Call: GET /monitor/stats * * @return The stats response */ public StatsRestRep getStatsByNodeName(List nodeNames, Integer interval) { UriBuilder builder = client.uriBuilder(MONITOR_STATS_URL); addQueryParam(builder, NODE_NAME_PARAM, nodeNames); addQueryParam(builder, INTERVAL_PARAM, interval); return client.getURI(StatsRestRep.class, builder.build()); } /** * Gets health of node and its services. Convenience method to get health on all nodes. *

* Node health status: Good - when node is reachable and all its services are GOOD Unavailable - when node is not reachable Degraded - * when node is reachable and any of its service is Unavailable/Degraded Node/syssvc Unavailable - when node is down or syssvc is not * Unavailable on the node *

* Service health status: Good - when a service is up and running Unavailable - when a service is not running but is registered in * coordinator Restarted - when service is restarting *

* API Call: GET /monitor/health * * @return The health response */ public HealthRestRep getHealth() { return getHealth(null); } /** * Gets health of node and its services. *

* Node health status: Good - when node is reachable and all its services are GOOD Unavailable - when node is not reachable Degraded - * when node is reachable and any of its service is Unavailable/Degraded Node/syssvc Unavailable - when node is down or syssvc is not * Unavailable on the node *

* Service health status: Good - when a service is up and running Unavailable - when a service is not running but is registered in * coordinator Restarted - when service is restarting *

* API Call: GET /monitor/health * * @param nodeIds Node ids for which health stats are collected. * @return The health response */ public HealthRestRep getHealth(List nodeIds) { UriBuilder builder = client.uriBuilder(MONITOR_HEALTH_URL); addQueryParam(builder, NODE_ID_PARAM, nodeIds); return client.getURI(HealthRestRep.class, builder.build()); } /** * Gets health of node and its services by node name. *

* Node health status: Good - when node is reachable and all its services are GOOD Unavailable - when node is not reachable Degraded - * when node is reachable and any of its service is Unavailable/Degraded Node/syssvc Unavailable - when node is down or syssvc is not * Unavailable on the node *

* Service health status: Good - when a service is up and running Unavailable - when a service is not running but is registered in * coordinator Restarted - when service is restarting *

* API Call: GET /monitor/health * * @param nodeNames Node names for which health stats are collected. * @return The health response */ public HealthRestRep getHealthByNodeName(List nodeNames) { UriBuilder builder = client.uriBuilder(MONITOR_HEALTH_URL); addQueryParam(builder, NODE_NAME_PARAM, nodeNames); return client.getURI(HealthRestRep.class, builder.build()); } /** * Gets the diagnostic results for all virtual machines in a ViPR * controller appliance. Also gives test details when verbose option is set. *

* API Call: GET /monitor/diagnostics * * @param nodeIds Node ids for which diagnostic results are collected. * @param verbose If true, will run command with -v option. * @return The diagnostic test results */ public DiagnosticsRestRep getDiagnostics(List nodeIds, boolean verbose) { UriBuilder builder = client.uriBuilder(MONITOR_DIAGNOSTICS_URL); addQueryParam(builder, NODE_ID_PARAM, nodeIds); if (verbose) { addQueryParam(builder, VERBOSE_PARAM, VERBOSE); } return client.getURI(DiagnosticsRestRep.class, builder.build()); } /** * Gets the diagnostic results for all virtual machines in a ViPR * controller appliance. Also gives test details when verbose option is set. *

* API Call: GET /monitor/diagnostics * * @param nodeNames Node names for which diagnostic results are collected. * @param verbose If true, will run command with -v option. * @return The diagnostic test results */ public DiagnosticsRestRep getDiagnosticsByNodeName(List nodeNames, boolean verbose) { UriBuilder builder = client.uriBuilder(MONITOR_DIAGNOSTICS_URL); addQueryParam(builder, NODE_NAME_PARAM, nodeNames); if (verbose) { addQueryParam(builder, VERBOSE_PARAM, VERBOSE); } return client.getURI(DiagnosticsRestRep.class, builder.build()); } /** * Gets the diagnostic results for all virtual machines in a ViPR * controller appliance. Non-verbose. * * @param nodeIds Node ids for which diagnostic results are collected. * @return */ public DiagnosticsRestRep getDiagnostics(List nodeIds) { return getDiagnostics(nodeIds, false); } /** * Get the current capacity for object, file and block storage. *

* API Call: GET /monitor/storage * * @return Storage stats for controller (file , block) and object. */ public StorageStats getStorageStats() { return client.get(StorageStats.class, MONITOR_STORAGE_URL); } }





© 2015 - 2025 Weber Informatics LLC | Privacy Policy