Module: ZabbixRubyClient::Plugins::Sysinfo

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

Instance Method Summary collapse

Methods included from ZabbixRubyClient::PluginBase

getline, getlines, httprequest, os, perform, time

Instance Method Details

#collect(*args) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/zabbix-ruby-client/plugins/sysinfo.rb', line 9

def collect(*args)
  host = args.delete_at(0)
  uname = `uname -a`
  case os
  when :linux
    arch, hostname, kernel, kernel_version, machine, os_debian,
    _, platform_debian, _, _, _, _, _, platform, os = uname.split(/\s+/)
  when :unix
    os, hostname, _, platform, kernel, machine, kernel_version,
    _, _, _, _, _, _, _, arch = uname.split(/\s+/)
  else
    return []
  end
  back = []
  back << "#{host} sysinfo[name] #{time} #{host}"
  back << "#{host} sysinfo[arch] #{time} #{arch}"
  back << "#{host} sysinfo[hostname] #{time} #{hostname}"
  back << "#{host} sysinfo[kernel] #{time} #{kernel}"
  back << "#{host} sysinfo[kernel_version] #{time} #{kernel_version}"
  back << "#{host} sysinfo[machine] #{time} #{machine}"
  back << "#{host} sysinfo[platform] #{time} #{platform || platform_debian}"
  back << "#{host} sysinfo[os] #{time} #{os || os_debian}"
  Hash[*args].each do |k,v|
    back << "#{host} sysinfo[#{k}] #{time} #{v}"
  end
  return back
end