Sha256: 94fe310e3469d0e360a7edc63523e2c5d9379c89d5ead58df64c78afbf778f44

Contents?: true

Size: 923 Bytes

Versions: 78

Compression:

Stored size: 923 Bytes

Contents

class Riemann::Babbler::Net < Riemann::Babbler

  WORDS = ['rx bytes',
           'rx packets',
           'rx errs',
           'rx drop',
           'rx fifo',
           'rx frame',
           'rx compressed',
           'rx multicast',
           'tx bytes',
           'tx packets',
           'tx drops',
           'tx fifo',
           'tx colls',
           'tx carrier',
           'tx compressed']

  def collect
    f = File.read('/proc/net/dev')
    status = Array.new
    f.split("\n").each do |line|
      iface = line.split(':')[0].strip
      iface.gsub!(/\./, '_')
      next unless line =~ /(\w*)\:\s*([\s\d]+)\s*/
      WORDS.map do |service|
        "#{plugin.service} #{iface} #{service}"
      end.zip(
        $2.split(/\s+/).map { |str| str.to_i }
      ).each do |service, value|
        status << { :service => service, :metric => value, :as_diff => true}
      end
    end
    status
  end

end

Version data entries

78 entries across 78 versions & 1 rubygems

Version Path
riemann-babbler-0.9.9.7 lib/riemann/babbler/plugins/net.rb
riemann-babbler-0.9.9.6 lib/riemann/babbler/plugins/net.rb
riemann-babbler-0.9.9.5 lib/riemann/babbler/plugins/net.rb
riemann-babbler-0.9.9.4 lib/riemann/babbler/plugins/net.rb
riemann-babbler-0.9.9.3 lib/riemann/babbler/plugins/net.rb
riemann-babbler-0.9.9.2 lib/riemann/babbler/plugins/net.rb
riemann-babbler-0.9.9.1 lib/riemann/babbler/plugins/net.rb
riemann-babbler-0.9.9 lib/riemann/babbler/plugins/net.rb
riemann-babbler-0.9.8 lib/riemann/babbler/plugins/net.rb
riemann-babbler-0.9.7 lib/riemann/babbler/plugins/net.rb
riemann-babbler-0.9.6 lib/riemann/babbler/plugins/net.rb
riemann-babbler-0.9.5 lib/riemann/babbler/plugins/net.rb
riemann-babbler-0.9.4 lib/riemann/babbler/plugins/net.rb
riemann-babbler-0.9.3 lib/riemann/babbler/plugins/net.rb
riemann-babbler-0.9.2 lib/riemann/babbler/plugins/net.rb
riemann-babbler-0.9.1 lib/riemann/babbler/plugins/net.rb
riemann-babbler-0.9.0 lib/riemann/babbler/plugins/net.rb
riemann-babbler-0.8.9 lib/riemann/babbler/plugins/net.rb