use of com.emc.storageos.xtremio.restapi.model.response.XtremIOPerformanceResponse in project coprhd-controller by CoprHD.
the class XtremIOV2Client method getXtremIOObjectPerformance.
@Override
public XtremIOPerformanceResponse getXtremIOObjectPerformance(String clusterName, String entityName, String... parameters) throws Exception {
StringBuilder strBuilder = new StringBuilder(XtremIOConstants.XTREMIO_V2_PERFORMANCE_STR);
strBuilder.append(XtremIOConstants.getInputClusterString(clusterName));
strBuilder.append(XtremIOConstants.getInputAdditionalParamString(XtremIOConstants.ENTITY, entityName));
for (int i = 0; i < parameters.length; i = i + 2) {
String parameter = parameters[i];
String value = parameters[i + 1];
strBuilder.append(XtremIOConstants.getInputAdditionalParamString(parameter, value));
}
String uriString = strBuilder.toString();
ClientResponse response = get(URI.create(uriString));
XtremIOPerformanceResponse performanceResponse = getResponseObject(XtremIOPerformanceResponse.class, response);
log.info("Returned performance counters size : {}", performanceResponse.getCounters().length);
return performanceResponse;
}
use of com.emc.storageos.xtremio.restapi.model.response.XtremIOPerformanceResponse in project coprhd-controller by CoprHD.
the class XtremIOMetricsCollector method collectXEnvCPUUtilization.
/**
* Collect the CPU Utilization for all XEnv's in the cluster.
*
* @param system the system
* @param dbClient the db client
* @param xtremIOClient the xtremio client
* @param xioClusterName the xtremio cluster name
* @throws Exception
*/
private void collectXEnvCPUUtilization(StorageSystem system, DbClient dbClient, XtremIOClient xtremIOClient, String xtremIOClusterName) throws Exception {
// An XENV(XtremIO Environment) is composed of software defined modules responsible for internal data path on the array.
// There are two CPU sockets per Storage Controller (SC), and one distinct XENV runs on each socket.
/**
* Collect average CPU usage:
* - Get the last processing time for the system,
* - If previously not queried or if it was long back, collect data for last one day
*
* - Query the XEnv metrics for last one hour/day with granularity based on cycle time gap
* - 1. Group the XEnvs by SC,
* - 2. For each SC:
* - - - Take the average of 2 XEnv's CPU usages
* - - - Calculate exponential average by calling PortMetricsProcessor.processFEAdaptMetrics()
* - - - - (persists cpuPercentBusy, emaPercentBusy and avgCpuPercentBusy)
*
* - Average of all SC's avgCpuPercentBusy values is the average CPU usage for the system
*/
log.info("Collecting CPU usage for XtremIO system {}", system.getNativeGuid());
// Collect metrics for last one hour always. We are not using from-time to to-time because of machine time zone differences.
Long lastProcessedTime = system.getLastMeteringRunTime();
Long currentTime = System.currentTimeMillis();
Long oneDayTime = TimeUnit.DAYS.toMillis(1);
String timeFrame = XtremIOConstants.LAST_HOUR;
String granularity = XtremIOConstants.TEN_MINUTES;
if (lastProcessedTime < 0 || ((currentTime - lastProcessedTime) >= oneDayTime)) {
// last 1 day
timeFrame = XtremIOConstants.LAST_DAY;
granularity = XtremIOConstants.ONE_HOUR;
}
XtremIOPerformanceResponse response = xtremIOClient.getXtremIOObjectPerformance(xtremIOClusterName, XtremIOConstants.XTREMIO_ENTITY_TYPE.XEnv.name(), XtremIOConstants.TIME_FRAME, timeFrame, XtremIOConstants.GRANULARITY, granularity);
log.info("Response - Members: {}", Arrays.toString(response.getMembers()));
log.info("Response - Counters: {}", Arrays.deepToString(response.getCounters()));
// Segregate the responses by XEnv
ArrayListMultimap<String, Double> xEnvToCPUvalues = ArrayListMultimap.create();
int xEnvIndex = getIndexForAttribute(response.getMembers(), XtremIOConstants.NAME);
int cpuIndex = getIndexForAttribute(response.getMembers(), XtremIOConstants.AVG_CPU_USAGE);
String[][] counters = response.getCounters();
for (String[] counter : counters) {
log.debug(Arrays.toString(counter));
String xEnv = counter[xEnvIndex];
String cpuUtilization = counter[cpuIndex];
if (cpuUtilization != null) {
xEnvToCPUvalues.put(xEnv, Double.valueOf(cpuUtilization));
}
}
// calculate the average usage for each XEnv for the queried period of time
Map<String, Double> xEnvToAvgCPU = new HashMap<>();
for (String xEnv : xEnvToCPUvalues.keySet()) {
List<Double> cpuUsageList = xEnvToCPUvalues.get(xEnv);
Double avgCPU = cpuUsageList.stream().mapToDouble(Double::doubleValue).sum() / cpuUsageList.size();
log.info("XEnv: {}, collected CPU usage: {}, average: {}", xEnv, cpuUsageList.toString(), avgCPU);
xEnvToAvgCPU.put(xEnv, avgCPU);
}
// calculate the average usage for each Storage controller (from it's 2 XEnvs)
Map<URI, Double> scToAvgCPU = new HashMap<>();
for (String xEnv : xEnvToAvgCPU.keySet()) {
StorageHADomain sc = getStorageControllerForXEnv(xEnv, system, dbClient);
if (sc == null) {
log.debug("StorageHADomain not found for XEnv {}", xEnv);
continue;
}
Double scCPU = scToAvgCPU.get(sc.getId());
Double xEnvCPU = xEnvToAvgCPU.get(xEnv);
Double avgScCPU = (scCPU == null) ? xEnvCPU : ((xEnvCPU + scCPU) / 2.0);
scToAvgCPU.put(sc.getId(), avgScCPU);
}
// calculate exponential average for each Storage controller
double emaFactor = PortMetricsProcessor.getEmaFactor(DiscoveredDataObject.Type.valueOf(system.getSystemType()));
if (emaFactor > 1.0) {
// in case of invalid user input
emaFactor = 1.0;
}
for (URI scURI : scToAvgCPU.keySet()) {
Double avgScCPU = scToAvgCPU.get(scURI);
StorageHADomain sc = dbClient.queryObject(StorageHADomain.class, scURI);
log.info("StorageHADomain: {}, average CPU Usage: {}", sc.getAdapterName(), avgScCPU);
portMetricsProcessor.processFEAdaptMetrics(avgScCPU, 0l, sc, currentTime.toString(), false);
StringMap dbMetrics = sc.getMetrics();
Double scAvgBusy = MetricsKeys.getDouble(MetricsKeys.avgPercentBusy, dbMetrics);
Double scEmaBusy = MetricsKeys.getDouble(MetricsKeys.emaPercentBusy, dbMetrics);
Double scPercentBusy = (scAvgBusy * emaFactor) + ((1 - emaFactor) * scEmaBusy);
MetricsKeys.putDouble(MetricsKeys.avgCpuPercentBusy, scPercentBusy, dbMetrics);
MetricsKeys.putLong(MetricsKeys.lastProcessingTime, currentTime, dbMetrics);
sc.setMetrics(dbMetrics);
dbClient.updateObject(sc);
}
// calculate storage system's average CPU usage by combining all XEnvs
portMetricsProcessor.computeStorageSystemAvgPortMetrics(system.getId());
}
Aggregations