Resource Data In SoftLayer

后端 未结 1 957
庸人自扰
庸人自扰 2021-01-23 11:11

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

相关标签:
1条回答
  • 2021-01-23 12:12

    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()
    
    0 讨论(0)
提交回复
热议问题