Sha256: f2bb3009fe83fd6fb1a8780a5d4b91894e23594b290919d20e718ff4791416d5

Contents?: true

Size: 1.11 KB

Versions: 2

Compression:

Stored size: 1.11 KB

Contents

class ZabbixRubyClient
  module Plugins
    module Network
      extend self

      def collect(*args)
        host = args[0]
        interface = args[1]
        netinfo = `netstat -i | grep "^#{interface} "`
        if $?.to_i == 0
          _, mtu, rx_ok, rx_err, rx_drop, rx_over, tx_ok, tx_err, tx_drop, tx_over, flags  = netinfo.split(/\s+/)
        else
          logger.warn "Please install netstat."
          return []
        end
        back = []
        back << "#{host} net[#{interface},mtu] #{mtu}"
        back << "#{host} net[#{interface},rx_ok] #{rx_ok}"
        back << "#{host} net[#{interface},rx_err] #{rx_err}"
        back << "#{host} net[#{interface},rx_drop] #{rx_drop}"
        back << "#{host} net[#{interface},rx_over] #{rx_over}"
        back << "#{host} net[#{interface},tx_ok] #{tx_ok}"
        back << "#{host} net[#{interface},tx_err] #{tx_err}"
        back << "#{host} net[#{interface},tx_drop] #{tx_drop}"
        back << "#{host} net[#{interface},tx_over] #{tx_over}"
        return back

      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.5 lib/zabbix-ruby-client/plugins/network.rb
zabbix-ruby-client-0.0.4 lib/zabbix-ruby-client/plugins/network.rb