每台服务器的带宽摘要

编程入门 行业动态 更新时间:2024-10-27 14:19:58
本文介绍了每台服务器的带宽摘要的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我正在尝试获取我帐户下所有软层服务器的带宽数据.

I am trying to get the bandwidth data for all the softlayer servers under my account.

由于account_servers.rb,我能够获取所有服务器的服务器ID.现在,我想获取服务器在特定时间范围内使用的带宽.我感兴趣的数据是

Thanks to account_servers.rb I am able to get the server id for all the servers. Now I would like to get the Bandwidth used by the servers for a particular time frame. The data that I am interested is

sldn.softlayer/reference/datatypes/SoftLayer_Metric_Tracking_Object_Bandwidth_Summary

我尝试使用softlayer_client.service_named("Metric_Tracking_Object_Bandwidth_Summary")获取信息.不幸的是,我无法获得详细信息.

I tried to get information using softlayer_client.service_named("Metric_Tracking_Object_Bandwidth_Summary"). Unfortunately I am not able to get the details.

我确实找到了Java代码,但是我对ruby代码感兴趣.有人可以指导我获取服务器摘要摘要吗?

I did find a java code, but I am interested in ruby code. Can someone please guide me to get the server bandwith summary?

在SL中获取带宽数据

推荐答案

请尝试以下Ruby示例:

require 'rubygems' require 'softlayer_api' server_id = 11498369 # Your SoftLayer API username. SL_API_USERNAME = 'set me' # Your SoftLayer API key. SL_API_KEY = 'set me' softlayer_client = SoftLayer::Client.new(:username => SL_API_USERNAME, :api_key => SL_API_KEY) vsi_service = softlayer_client.service_named('SoftLayer_Virtual_Guest') metric_tracking_object_id = vsi_service.object_with_id(server_id).getMetricTrackingObjectId metric_service = softlayer_client.service_named('SoftLayer_Metric_Tracking_Object') service_ref = metric_service.object_with_id(metric_tracking_object_id) begin object_template = [{ 'keyName' => 'PUBLICOUT', 'summaryType' => 'sum' }] result = service_ref.getSummaryData('2016-03-29T00:00:00','2016-03-30T00:00:00',object_template,600) puts result.inspect rescue => e puts 'Error when executing the script...' $stdout.print(e.inspect) end

参考:

SoftLayer_Metric_Tracking_Object :: getSummaryData

SoftLayer_Virtual_Guest :: getMetricTrackingObjectId

使用SoftLayer_Virtual_Gues::getBandwidthDataByDate的第二个示例:

require 'rubygems' require 'softlayer_api' require 'pp' require 'date' # Set the server id that you wish to get Bandwidth information. server_id = 11498369 softlayer_client = SoftLayer::Client.new(:username => 'set me', :api_key => 'set me') server = SoftLayer::VirtualServer.server_with_id(server_id, :client => softlayer_client) get_bandwidth_data_by_date = server.service.getBandwidthDataByDate('2016-03-29T00:00:00','2016-03-30T00:00:00','public') pp('getBandwidthDataByDate: ', get_bandwidth_data_by_date)

参考:

SoftLayer_Virtual_Guest :: getBandwidthDataByDate

更多推荐

每台服务器的带宽摘要

本文发布于:2023-11-24 08:42:48,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1624511.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:每台   带宽   摘要   服务器

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!