Projected Data for Bandwidth in Softlayer

2019-09-10 05:55发布

问题:

I am developing a projected value for bandwidth, but I can't find a projected value for private network. This is my code getting public projected data, but it returns defferent value compared to "Control.softlayer.com".

This is a summary of my questions. 1. How to get a projected data for Private Network. 2. API getting a projected value for Throughput and Usage. 3. How to set a date to get a projected value for a specific period.

private void getVMProjectedData(){
    Guest.Service vsiService = Guest.service(client, 22075687l);
    vsiService.withMask().id().projectedPublicBandwidthUsage();
    Guest guest = vsiService.getObject();

    double usage = guest.getProjectedPublicBandwidthUsage().doubleValue();

    System.out.println("VM public Projected Usage : " + usage);

}

private void getBMProjectedData(){
    Server.Service bmService = Server.service(client, 168805l);
    bmService.withMask().projectedPublicBandwidthUsage();
    Server hd = bmService.getObjectForServer();

    System.out.println("BM public Projected Usage : " + hd.getProjectedPublicBandwidthUsage().doubleValue());

}

回答1:

There’s no an API method that retrieves the Projected value, neither one that generates it based on a specific period of time.

The Projected value is calculated by taking the current usage, dividing it by the current elapsed time (as determined by the most recent data point, not the current time) since the start of the billing period, and multiplying it by the time of the complete billing period.

In order to retrieve the data used for this process/calculations, you could use the next mask:

https://$username:$apiKey@api.softlayer.com/rest/v3.1/SoftLayer_Hardware_Server/$HardwareServerId/getObject.json?objectMask=mask[id,bandwidthAllocation,averageDailyBandwidthUsage,averageDailyPrivateBandwidthUsage,averageDailyPublicBandwidthUsage,bandwidthAllotmentDetail,billingCycleBandwidthUsage[trackingObject],billingCycleBandwidthUsageCount,billingCyclePrivateBandwidthUsage,billingCyclePublicBandwidthUsage,currentBandwidthSummary,currentBillableBandwidthUsage,projectedOverBandwidthAllocationFlag,projectedPublicBandwidthUsage,outboundBandwidthUsage,outboundPrivateBandwidthUsage,outboundPublicBandwidthUsage,inboundBandwidthUsage]

I hope this information could help you.