Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
533 views
in Technique[技术] by (71.8m points)

ibm cloud infrastructure - Resource Data In SoftLayer

I'm developing resource graph such as Bandwidth, usage, memory, and cpu in detailed device using SL java client. Data retrieved from api are different from the graph on control portal.

These are data from graph on control.softlayer.com

Date                        CPU Value
2016-03-03T10:00:00-06:00   0.67
2016-03-03T10:30:00-06:00   0.86
2016-03-03T11:00:00-06:00   0.84
2016-03-03T11:30:00-06:00    1
2016-03-03T12:00:00-06:00   0.82

These are data from SL API. getCount() is CPU value. getType() : cpu0

getCounter() : 0.26266666666667
getDateTime() : 03 03 2016 10:00:00-0600
dt.hashCode() : 1396398841
****************************************
getType() : cpu0
getCounter() : 0.42433333333333
getDateTime() : 03 03 2016 10:30:00-0600
dt.hashCode() : 1574026271
****************************************
getType() : cpu0
getCounter() : 0.591
getDateTime() : 03 03 2016 11:00:00-0600
dt.hashCode() : 1955972951
****************************************
getType() : cpu0
getCounter() : 0.57966666666667
getDateTime() : 03 03 2016 11:30:00-0600
dt.hashCode() : 357719181
****************************************
getType() : cpu0
getCounter() : 0.55033333333333
getDateTime() : 03 03 2016 12:00:00-0600
dt.hashCode() : 1379547114
****************************************

I've used this api to get CPU data. List dataList = Guest.service(client, deviceID).getCpuMetricDataByDate(startDate, endDate, null);

Memory data API List dataList = Guest.service(client, deviceID).getMemoryMetricDataByDate(startDate, endDate);

Bandwidth data API List dataList = Guest.service(client, deviceID).getBandwidthDataByDate(startDate, endDate, "public");

These data are not matched to the data on graph either. pls give me your comments how i can get precise data.

Thanks

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

I recommed you to use the http://sldn.softlayer.com/reference/services/SoftLayer_Metric_Tracking_Object/getSummaryData method, see below an example using the Softlayer Python client to get the bandwidth. In order to get the CPU replace the types variable with this value.

[
{
"keyName": "CPU0",
"summaryType": "max"
}
]

The example:

import SoftLayer
import pprint


def main():
    hardware_id = 120065

    start_date = "2015-10-03"
    end_date = "2015-10-12"

    # []SoftLayer_Container_Metric_Data_Type
    types = [
        {
            "keyName": "PUBLICIN",
            "name": "publicIn",
            "summaryType": "sum"
        },
        {
            "keyName": "PUBLICOUT",
            "name": "publicOut",
            "summaryType": "sum"
        }
    ]

    client = SoftLayer.create_client_from_env()
    hw_object = client.call('SoftLayer_Hardware_Server',
                            'getObject',
                            mask="mask[metricTrackingObjectId]",
                            id=hardware_id)
    result = client.call('SoftLayer_Metric_Tracking_Object',
                         'getSummaryData',
                         start_date,
                         end_date,
                         types,
                         3600,
                         id=hw_object['metricTrackingObjectId'])
    pprint.pprint(result)


if __name__ == '__main__':
    main()

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...