use of iControl.LocalLBVirtualServerVirtualServerStatistics in project cloudstack by apache.
the class F5BigIpResource method getIpBytesSentAndReceived.
// Stats methods
private ExternalNetworkResourceUsageAnswer getIpBytesSentAndReceived(ExternalNetworkResourceUsageCommand cmd) throws ExecutionException {
ExternalNetworkResourceUsageAnswer answer = new ExternalNetworkResourceUsageAnswer(cmd);
try {
LocalLBVirtualServerVirtualServerStatistics stats = _virtualServerApi.get_all_statistics();
for (LocalLBVirtualServerVirtualServerStatisticEntry entry : stats.getStatistics()) {
String virtualServerIp = entry.getVirtual_server().getAddress();
virtualServerIp = stripRouteDomainFromAddress(virtualServerIp);
long[] bytesSentAndReceived = answer.ipBytes.get(virtualServerIp);
if (bytesSentAndReceived == null) {
bytesSentAndReceived = new long[] { 0, 0 };
}
for (CommonStatistic stat : entry.getStatistics()) {
int index;
if (stat.getType().equals(CommonStatisticType.STATISTIC_CLIENT_SIDE_BYTES_OUT)) {
// Add to the outgoing bytes
index = 0;
} else if (stat.getType().equals(CommonStatisticType.STATISTIC_CLIENT_SIDE_BYTES_IN)) {
// Add to the incoming bytes
index = 1;
} else {
continue;
}
long high = stat.getValue().getHigh();
long low = stat.getValue().getLow();
long full = getFullUsage(high, low);
bytesSentAndReceived[index] += full;
}
if (bytesSentAndReceived[0] >= 0 && bytesSentAndReceived[1] >= 0) {
answer.ipBytes.put(virtualServerIp, bytesSentAndReceived);
}
}
} catch (Exception e) {
s_logger.error(e);
throw new ExecutionException(e.getMessage());
}
return answer;
}
Aggregations