class Visage::Collectd::RRDs
Public Class Methods
hosts(opts={})
click to toggle source
Returns a list of hosts that match the supplied glob, or array of names.
# File lib/visage-app/collectd/rrds.rb, line 17 def hosts(opts={}) hosts = opts[:hosts] case hosts when String glob = "{#{hosts}}" when Array glob = "{#{opts[:hosts].join(',')}}" else glob = "*" end Dir.glob("#{rrddir}/#{glob}").map {|e| e.split('/').last }.sort.uniq end
metrics(opts={})
click to toggle source
# File lib/visage-app/collectd/rrds.rb, line 31 def metrics(opts={}) selected_hosts = hosts(opts) metrics = opts[:metrics] case metrics when String && /,/ metric_glob = "{#{metrics}}" when Array metric_glob = "{#{opts[:metrics].join(',')}}" else metric_glob = "*/*" end dametrics = selected_hosts.map { |host| Dir.glob("#{rrddir}/#{host}/#{metric_glob}.rrd").map {|filename| filename[/#{rrddir}\/#{host}\/(.*)\.rrd/, 1] } } if (dametrics.length) == 1 dametrics.first else dametrics.reduce(:&) end #else # Dir.glob("#{rrddir}/#{host_glob}/#{glob}.rrd").map {|e| e.split('/')[-2..-1].join('/').gsub(/\.rrd$/, '')}.sort.uniq #end end
rrddir()
click to toggle source
# File lib/visage-app/collectd/rrds.rb, line 12 def rrddir @rrddir ||= Visage::Config.rrddir end