我正在尝试调用RRD.create
Ruby。我的 RRD 变量存储在哈希中,我需要构造一个RRD.create
调用。这是我的代码:
pool_map = {
"cleanup" => "Cleaning up",
"leased" => "Leased",
"ready" => "Ready"
}
start = Time.now.to_i
ti = 60 # time interval, in seconds
RRD.create(
rrdfile,
"--start", "#{start - 1}",
"--step", ti, # seconds
pool_map.keys.map{|val| "DS:#{val}:GAUGE:#{ti * 2}:0:U" }.collect,
"RRA:LAST:0.5:1:#{86400 / ti}", # detailed values for last 24 hours
"RRA:AVERAGE:0.5:#{5*60 / ti}:#{7*24*60}", # 5 min averages for 7 days
"RRA:MAX:0.5:#{5*60 / ti}:#{7*24*60}", # 5 min maximums for 7 days
"RRA:AVERAGE:0.5:#{60*60 / ti}:#{183*24}", # 1 hour averages for a half of the year
"RRA:MAX:0.5:#{60*60 / ti}:#{183*24}" # 1 hour maximums for a half of the year
)
但是,我从 Ruby 收到以下错误:
in `create': invalid argument - Array, expected T_STRING or T_FIXNUM on index 5 (TypeError)
我需要指定几个字符串RRD.create
而不是传递数组。我怎样才能在 Ruby 中做到这一点?