Computing > 8 - LoadBalancers Management > Get LoadBalancer Statistics

8.07 Get LoadBalancer Statistics

By the Aruba WsEndUser method GetLoadBalancerRuleStatistics you can retrieve the list of statistics for the load balancer.

Parameters
loadBalancerRuleID
Type: int
Load balancer Rule identification number

startTime
Type: DateTime
Start time of statistics interval

endTime
Type: DateTime
End time of statistics interval


/// IWsEndUser.GetLoadBalancerRuleStatistics Method (c# .NET)
public static string GetLoadBalancerRuleStatistics(WsEndUserClient client,
        int loadBalancerRuleID, DateTime startTime, DateTime endTime)
{
    //specify the account login details 
    client.ClientCredentials.UserName.UserName = "ARU-0000";
    client.ClientCredentials.UserName.Password = "0123456789";

    StringBuilder stringBuilder = new StringBuilder();

    try
    {
        // create the request object
        LoadBalancerRuleStatisticsRequest request = 
             new LoadBalancerRuleStatisticsRequest();
        request.LoadBalancerRuleID = loadBalancerRuleID;
        request.StartTime = startTime;
        request.EndTime = endTime;

        // call method GetLoadBalancerRuleStatistics 
        // obtaining a WsResultOfLoadBalancerRuleStatistics item
        WsResultOfLoadBalancerRuleStatistics result = 
            client.GetLoadBalancerRuleStatistics(request);

        //if the call is Success print values
        if (result.Success)
        {
            stringBuilder.Append(" Operation ends successfully.");

            LoadBalancerRuleStatistics item = result.Value;

            stringBuilder.Append("\n CompanyID: ");
            stringBuilder.Append(item.CompanyID);
            stringBuilder.Append("\n DataCenterID: ");
            stringBuilder.Append(item.DataCenterID);
            stringBuilder.Append("\n Name: ");
            stringBuilder.Append(item.Name);
            stringBuilder.Append("\n LoadBalancerID: ");
            stringBuilder.Append(item.LoadBalancerID);

            if (item.Statistics != null)
            {
                foreach (Statistics entity in item.Statistics)
                {
                    stringBuilder.Append("\nActiveSession: ");
                    stringBuilder.Append(entity.ActiveSession);
                    stringBuilder.Append("\nEventTime: ");
                    stringBuilder.Append(entity.EventTime);
                    stringBuilder.Append("\nKbpsIn: ");
                    stringBuilder.Append(entity.KbpsIn);
                    stringBuilder.Append("\nKbpsOut: ");
                    stringBuilder.Append(entity.KbpsOut);
                    stringBuilder.Append("\nRateSession: ");
                    stringBuilder.Append(entity.RateSession);
                }
            }
        }
        else
        {
            throw new ApplicationException(result.ResultMessage);
        }
    }
    catch (Exception ex)
    {
        // re-run the error
        throw new ApplicationException(ex.Message);
    }

    return stringBuilder.ToString();
}
/// IWsEndUser.GetLoadBalancerRuleStatistics Method (JAVA)
public static String GetLoadBalancerRuleStatistics(IWsEndUser client,
     int loadBalancerRuleID, XMLGregorianCalendar startTime, 
     XMLGregorianCalendar endTime)
{
    //specify the account login details 
    ((BindingProvider) client).getRequestContext()
            .put(BindingProvider.USERNAME_PROPERTY, "ARU-0000");
    ((BindingProvider) client).getRequestContext()
            .put(BindingProvider.PASSWORD_PROPERTY, "0123456789");

    StringBuilder StringBuilder = new StringBuilder();

    try
    {
        // create the request object
        LoadBalancerRuleStatisticsRequest request = 
            new LoadBalancerRuleStatisticsRequest();
        request.setLoadBalancerRuleID(loadBalancerRuleID);
        request.setStartTime(startTime);
        request.setEndTime(endTime);

        // call method GetLoadBalancerRuleStatistics 
        // obtaining a WsResultOfLoadBalancerRuleStatistics item
        WsResultOfLoadBalancerRuleStatistics result =
            client.getLoadBalancerRuleStatistics(request);

        //if the call is Success print values
        if (result.isSuccess())
        {
            StringBuilder.append(" Operation ends successfully.");

            LoadBalancerRuleStatistics item = result.getValue();

            StringBuilder.append("\n CompanyID: ");
            StringBuilder.append(item.getCompanyID());
            StringBuilder.append("\n DataCenterID: ");
            StringBuilder.append(item.getDataCenterID());
            StringBuilder.append("\n Name: ");
            StringBuilder.append(item.getName());
            StringBuilder.append("\n LoadBalancerID: ");
            StringBuilder.append(item.getLoadBalancerID());

            ArrayOfStatistics arrayOfStatistics = item.getStatistics();
            List<Statistics> statisticsList = arrayOfStatistics.getStatistics();
            
            for (Iterator<Statistics> it = statisticsList.iterator();
                it.hasNext();)
            {
                Statistics entity = it.next();
                StringBuilder.append("\nActiveSession: ");
                StringBuilder.append(entity.getActiveSession());
                StringBuilder.append("\nEventTime: ");
                StringBuilder.append(entity.getEventTime());
                StringBuilder.append("\nKbpsIn: ");
                StringBuilder.append(entity.getKbpsIn());
                StringBuilder.append("\nKbpsOut: ");
                StringBuilder.append(entity.getKbpsOut());
                StringBuilder.append("\nRateSession: ");
                StringBuilder.append(entity.getRateSession());
            }

        }
        else
        {
            throw new Exception(result.getResultMessage());
        }
    }
    catch (Exception ex)
    {
        //show error
        System.out.println(ex);
    }

    return StringBuilder.toString();
}
Version
API: v2.8 URL:https://api.dc1.computing.cloud.it/WsEndUser/v2.8/WsEndUser.svc?wsdl