我正在使用Softlayer API開發帶寬和使用率(參考附件)的圖形。 是否可以使用會話ID &通過直接鏈接圖表顯示在我們的門戶網站?Softlayer中的直接鏈接圖
回答
是SL API可以讓你獲得圖形的方法是使用一些方法:
例如:
http://sldn.softlayer.com/reference/services/SoftLayer_Metric_Tracking_Object/getBandwidthGraph http://sldn.softlayer.com/reference/services/SoftLayer_Virtual_Guest/getCustomBandwidthDataByDate http://sldn.softlayer.com/reference/services/SoftLayer_Hardware_Server/getCustomBandwidthDataByDate
你可以看到你需要你選擇一些必需的標題和參數。
這是Python的例子來獲取硬件帶寬圖:
"""
Retrieve a bandwidth graph for a single server.
Retrieve a bandwidth graph for a single server for an arbitrary start and
end date, specifying graph size and other graphing options. We can do this
with two calls to the SoftLayer API.
Counter data such as bandwidth counters and VSI resource use are stored in
a server's metric tracking object. Our first call retrieves that server's
tracking object record. The second call is to the tracking object service
which will generate a PNG image of our bandwidth graph.
Important manual pages:
http://sldn.softlayer.com/reference/services/SoftLayer_Hardware_Server/getObject
http://sldn.softlayer.com/reference/services/SoftLayer_Metric_Tracking_Object/getBandwidthGraph
http://sldn.softlayer.com/reference/datatypes/SoftLayer_Container_Bandwidth_GraphOutputs
License: http://sldn.softlayer.com/article/License
Author: SoftLayer Technologies, Inc. <[email protected]>
"""
import SoftLayer.API
# Your SoftLayer API username and key.
USERNAME = 'set me'
API_KEY = 'set me'
"""
The id number of the server whose graph you wish to retrieve. Call the
getHardware() method in the SoftLayer_Account API service to retrieve a list
of the servers on your account.
"""
serverID = 87165
# The date at which you wish to start graphing bandwidth.
startDate = '2015-3-1'
# The date at which you wish to end graphing bandwidth.
endDate = '2015-4-11'
# Whether to get a graph for 'public' or 'private' bandwidth usage.
graphType = 'public'
# The height of the text in the bandwidth graph in pixels.
fontSize = 8
# The width of the graph to retrieve in pixels.
graphWidth = 827
graphHeight = 273
hideTimeZone = True
# Declaring the API client
client = SoftLayer.Client(username=USERNAME, api_key=API_KEY)
hardawareService = client['SoftLayer_Hardware_Server']
metricTrackingObject = client['SoftLayer_Metric_Tracking_Object']
try:
trackingObject = hardawareService.getMetricTrackingObject(id=serverID)
except SoftLayer.SoftLayerAPIError as e:
print("Unable to retrieve the metric tracking object:"
% (e.faultCode, e.faultString))
try:
"""
getBandwidthGraph() returns a SoftLayer_Container_Bandwidth_GraphOutputs
object. The contents of the bandwidth image is in $image->graphImage.
From here you can write it to the file system, display it to a web
browser, or run other functions on it.
"""
image = metricTrackingObject.getBandwidthGraph(startDate, endDate, graphType, fontSize, graphWidth, graphHeight, hideTimeZone, id=trackingObject['id'])
print("Image retrieved!")
except SoftLayer.SoftLayerAPIError as e:
print("Unable to retrieve bandwidth image"
% (e.faultCode, e.faultString))
一些參考:
http://sldn.softlayer.com/reference/services/SoftLayer_Hardware_Server/getCustomBandwidthDataByDate http://sldn.softlayer.com/reference/datatypes/SoftLayer_Container_Graph http://sldn.softlayer.com/reference/services/SoftLayer_Hardware_Server/getBandwidthForDateRange
http://sldn.softlayer.com/reference/services/SoftLayer_Hardware_Server/getObject http://sldn.softlayer.com/reference/services/SoftLayer_Metric_Tracking_Object/getBandwidthGraph http://sldn.softlayer.com/reference/datatypes/SoftLayer_Container_Bandwidth_GraphOutputs
- 1. api的Mediafire圖像直接鏈接(convkey)
- 2. Google Picker的圖片直接鏈接
- 3. 非直接鏈接
- 4. 區分圖像的鏈接和直接鏈接
- 5. 直接圖像鏈接從http://postimage.org/
- 6. 直接從鏈接下載圖片
- 7. 直接鏈接的帖子
- 8. 添加直接鏈接鏈接
- 9. 直接在Web視圖中直接進入Android電子市場的鏈接
- 10. 直接鏈接到OpenCart中的語言
- 11. 垂直中心鏈接圖像div
- 12. 直接從鏈接登錄
- 13. JMapViewer.jar直接下載鏈接?
- 14. 直接鏈接到GSP
- 15. 直接鏈接facebook視頻
- 16. 直接鏈接到活動
- 17. 直接鏈接到SonarQube Widget
- 18. GitHub發佈:直接鏈接
- 19. Commission Junction直接鏈接
- 20. AJAX或直接鏈接
- 21. 直接鏈接到asp.net中的數據庫圖像
- 22. webview中的直接圖像鏈接顯示全部尺寸
- 23. 從C#中的直接身份驗證鏈接下載圖像
- 24. Python3.2垂直鏈接
- 25. 如何從Twitter的短鏈接直接鏈接
- 26. 直接鏈接到iPad上的App Store?
- 27. 獲取與視頻的直接鏈接
- 28. 直接鏈接到iPhone的Vimeo視頻
- 29. 的urllib:直接下載鏈接
- 30. GWT直接鏈接的應用