Sha256: 19fdab1399f1e8635b576781a8ba9b8dca01a11930d64d4f70e35f2bf30bbed9
Contents?: true
Size: 1.17 KB
Versions: 1
Compression:
Stored size: 1.17 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 plugin options.plugins.net end def init @old_status = Hash.new end def net f = File.read('/proc/net/dev') status = Hash.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.merge!({service => value}) end end status end def tick status = net status.each_key do |service| #next if status[service] == 0 report({ :service => service, :metric => status[service], :is_diff => true }) end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
riemann-babbler-0.3.3 | lib/riemann/babbler/plugins/net.rb |