SoftLayer中的资源数据 [英] Resource Data In SoftLayer

查看:31
本文介绍了SoftLayer中的资源数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用SL Java客户端在详细的设备中开发资源图,例如带宽,使用率,内存和cpu.从api检索的数据与控制门户上的图不同.

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.

这些是来自control.softlayer.com上图形的数据

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

这些是来自SL API的数据. getCount()是CPU值. getType():cpu0

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
****************************************

我已经使用此API来获取CPU数据. 列出dataList = Guest.service(client,deviceID).getCpuMetricDataByDate(startDate,endDate,null);

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

内存数据API 列出dataList = Guest.service(client,deviceID).getMemoryMetricDataByDate(startDate,endDate);

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

带宽数据API 列出dataList = Guest.service(client,deviceID).getBandwidthDataByDate(startDate,endDate,"public");

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.

谢谢

推荐答案

我建议您使用

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"
}
]

示例:

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()

这篇关于SoftLayer中的资源数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆