6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
|
# File 'lib/cloudcost/commands/volume/volume_influxdb_output.rb', line 6
def totals_influx_line_protocol
lines = []
tag_set = [
"profile=#{@options[:profile] || "?"}",
"state=#{volumes_attached_state}"
]
metrics = calculate_totals
[
{ field: "ssd_gb", key: :size_ssd, unit: "i" },
{ field: "bulk_gb", key: :size_bulk, unit: "i" },
{ field: "chf_per_day", key: :size, unit: "" }
].each do |field|
lines << %(
cloudscaleVolumeCosts,#{tag_set.join(",")}
#{field[:field]}=#{metrics[field[:key]]}#{field[:unit]}
).gsub(/\s+/, " ").strip
end
lines.join("\n")
end
|