Sha256: 477e8314e2c87da869fe1955fd9b01233c3616ab0c184a065d85f46ec731cda6

Contents?: true

Size: 1.02 KB

Versions: 5

Compression:

Stored size: 1.02 KB

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 init
    plugin.set_default(:filter, ['rx bytes', 'rx errs', 'rx drop', 'tx bytes', 'tx errs', 'tx drop'])
  end

  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

5 entries across 5 versions & 1 rubygems

Version Path
riemann-babbler-1.4.0 lib/riemann/babbler/plugins/net.rb
riemann-babbler-1.3.9.7 lib/riemann/babbler/plugins/net.rb
riemann-babbler-1.3.9.6 lib/riemann/babbler/plugins/net.rb
riemann-babbler-1.3.9.5 lib/riemann/babbler/plugins/net.rb
riemann-babbler-1.3.9.4 lib/riemann/babbler/plugins/net.rb