Search in sources :

Example 1 with CommonStatistic

use of iControl.CommonStatistic 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;
}
Also used : ExternalNetworkResourceUsageAnswer(com.cloud.agent.api.ExternalNetworkResourceUsageAnswer) CommonStatistic(iControl.CommonStatistic) ExecutionException(com.cloud.utils.exception.ExecutionException) LocalLBVirtualServerVirtualServerStatistics(iControl.LocalLBVirtualServerVirtualServerStatistics) ExecutionException(com.cloud.utils.exception.ExecutionException) RemoteException(java.rmi.RemoteException) ConfigurationException(javax.naming.ConfigurationException) LocalLBVirtualServerVirtualServerStatisticEntry(iControl.LocalLBVirtualServerVirtualServerStatisticEntry)

Aggregations

ExternalNetworkResourceUsageAnswer (com.cloud.agent.api.ExternalNetworkResourceUsageAnswer)1 ExecutionException (com.cloud.utils.exception.ExecutionException)1 CommonStatistic (iControl.CommonStatistic)1 LocalLBVirtualServerVirtualServerStatisticEntry (iControl.LocalLBVirtualServerVirtualServerStatisticEntry)1 LocalLBVirtualServerVirtualServerStatistics (iControl.LocalLBVirtualServerVirtualServerStatistics)1 RemoteException (java.rmi.RemoteException)1 ConfigurationException (javax.naming.ConfigurationException)1