Module: ZabbixRubyClient::Plugins::Network

Extended by:
ZabbixRubyClient::PluginBase, Network
Included in:
Network
Defined in:
lib/zabbix-ruby-client/plugins/network.rb

Instance Method Summary collapse

Methods included from ZabbixRubyClient::PluginBase

getline, getlines, httprequest, perform

Instance Method Details

#collect(*args) ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/zabbix-ruby-client/plugins/network.rb', line 10

def collect(*args)
  host = args[0]
  interface = args[1]
  info = get_info(interface)
  if info
    time = Time.now.to_i
    back = []
    back << "#{host} net.rx_ok[#{interface}] #{time} #{info[1]}"
    back << "#{host} net.rx_packets[#{interface}] #{time} #{info[2]}"
    back << "#{host} net.rx_err[#{interface}] #{time} #{info[3]}"
    back << "#{host} net.rx_drop[#{interface}] #{time} #{info[4]}"
    back << "#{host} net.tx_ok[#{interface}] #{time} #{info[9]}"
    back << "#{host} net.tx_packets[#{interface}] #{time} #{info[10]}"
    back << "#{host} net.tx_err[#{interface}] #{time} #{info[11]}"
    back << "#{host} net.tx_drop[#{interface}] #{time} #{info[12]}"
    return back
  else
    return []
  end
end

#discover(*args) ⇒ Object



31
32
33
34
# File 'lib/zabbix-ruby-client/plugins/network.rb', line 31

def discover(*args)
  interface = args[0]
  [ "net.if.discovery", "{\"{#NET_IF}\": \"#{interface}\"}" ]
end