Sha256: f2e05c24e80896304f78cf0f2c362ae446de61bb33dac468ebdb6ded7d63faf9
Contents?: true
Size: 1.31 KB
Versions: 5
Compression:
Stored size: 1.31 KB
Contents
#!/usr/bin/env ruby $: << File.expand_path(File.join(File.dirname(__FILE__), '..', '..', '..')) require 'lib/visage/patches' module Visage module Collectd class RRDs class << self def rrddir @rrddir = "/var/lib/collectd/rrd" end def hosts(opts={}) case when opts[:hosts].blank? glob = "*" when opts[:hosts] =~ /,/ glob = "{#{opts[:hosts].strip.gsub(/\s*/, '').gsub(/,$/, '')}}" else glob = opts[:hosts] end Dir.glob("#{rrddir}/#{glob}").map {|e| e.split('/').last }.sort.uniq end def metrics(opts={}) case when opts[:metrics].blank? glob = "*/*" when opts[:metrics] =~ /,/ puts "\n" * 4 glob = "{" + opts[:metrics].split(/\s*,\s*/).map { |m| m =~ /\// ? m : ["*/#{m}", "#{m}/*"] }.join(',').gsub(/,$/, '') + "}" when opts[:metrics] !~ /\// glob = "#{opts[:metrics]}/#{opts[:metrics]}" else glob = opts[:metrics] end host_glob = (opts[:host] || "*") Dir.glob("#{rrddir}/#{host_glob}/#{glob}.rrd").map {|e| e.split('/')[-2..-1].join('/').gsub(/\.rrd$/, '')}.sort.uniq end end end end end
Version data entries
5 entries across 5 versions & 1 rubygems