lib/ganymed/collector/network.rb in ganymed-0.1.0 vs lib/ganymed/collector/network.rb in ganymed-0.1.1

- old
+ new

@@ -5,14 +5,20 @@ module Ganymed class Collector class Network < Base def collect! + return if not File.readable?('/proc/net/dev') + File.open('/proc/net/dev') do |f| f.each do |line| next unless line =~ /:/ + ns = Struct::NetworkStat.new(*line.strip.split(/\s+/)) ns.dev.sub!(/:$/, '') + + next if @config.exclude.map {|e| Regexp.new(e).match(ns.dev)}.any? + @sampler.emit(:derive, "os.net.#{ns.dev}.rbytes", ns.rbytes) @sampler.emit(:derive, "os.net.#{ns.dev}.wbytes", ns.wbytes) @sampler.emit(:derive, "os.net.#{ns.dev}.rpackets", ns.rpackets) @sampler.emit(:derive, "os.net.#{ns.dev}.wpackets", ns.wpackets) @sampler.emit(:derive, "os.net.#{ns.dev}.rerrs", ns.rerrs)