# bytes packets errs drop fifo frame compressed multicast|bytes packets errs drop fifo colls carrier compressed Struct.new("NetworkStat", :dev, :rbytes, :rpackets, :rerrs, :rdrop, :rfifo, :rframe, :rcompressed, :rmulticast, :wbytes, :wpackets, :werrs, :wdrop, :wfifo, :wcolls, :wcarrier, :wcompressed) module Ganymed class Collector class Network < Base def collect! 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!(/:$/, '') @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) @sampler.emit(:derive, "os.net.#{ns.dev}.werrs", ns.werrs) end end end def interval @config.interval.tap{} or 0.1 end end end end