Resource Data In SoftLayer

ぐ巨炮叔叔 提交于 2019-12-02 05:48:57

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()
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!