44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
|
# File 'lib/focuslight/rrd.rb', line 44
def path(graph, target=:normal)
dst = (graph.mode == 'derive' ? 'DERIVE' : 'GAUGE')
filepath = nil
rrdoptions = nil
if target == :short
filepath = File.join(@datadir, graph.md5 + '_s.rrd')
rrdoptions = rrd_create_options_short(dst)
else filepath = File.join(@datadir, graph.md5 + '.rrd')
rrdoptions = rrd_create_options_long(dst)
end
unless File.exists?(filepath)
ret = RRD::Wrapper.create(filepath, *rrdoptions.map(&:to_s))
unless ret
raise "RRDtool returns error to create #{filepath}, error: #{RRD::Wrapper.error}"
end
end
filepath
end
|