Sha256: a7dd30a7132e3b80caa203f8bfacbe2906969389c0c7ed2975c170ec7ddca837
Contents?: true
Size: 1.34 KB
Versions: 2
Compression:
Stored size: 1.34 KB
Contents
require "zabbix-ruby-client/logger" module ZabbixRubyClient module Plugins module Network extend self def collect(*args) host = args[0] interface = args[1] netinfo = `grep "#{interface}: " /proc/net/dev` if $?.to_i == 0 _, _, rx_ok, rx_packets, rx_err, rx_drop, _, _, _, _, tx_ok, tx_packets, tx_err, tx_drop, _, _, _, _ = netinfo.split(/\s+/) else Log.warn "proc not found." return [] end time = Time.now.to_i back = [] back << "#{host} net.rx_ok[#{interface}] #{time} #{rx_ok}" back << "#{host} net.rx_packets[#{interface}] #{time} #{rx_packets}" back << "#{host} net.rx_err[#{interface}] #{time} #{rx_err}" back << "#{host} net.rx_drop[#{interface}] #{time} #{rx_drop}" back << "#{host} net.tx_ok[#{interface}] #{time} #{tx_ok}" back << "#{host} net.tx_packets[#{interface}] #{time} #{tx_packets}" back << "#{host} net.tx_err[#{interface}] #{time} #{tx_err}" back << "#{host} net.tx_drop[#{interface}] #{time} #{tx_drop}" return back end def discover(*args) interface = args[0] [ "net.if.discovery", "{\"{#NET_IF}\": \"#{interface}\"}" ] end end end end ZabbixRubyClient::Plugins.register('network', ZabbixRubyClient::Plugins::Network)
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
zabbix-ruby-client-0.0.17 | lib/zabbix-ruby-client/plugins/network.rb |
zabbix-ruby-client-0.0.16 | lib/zabbix-ruby-client/plugins/network.rb |