gouf
2/16/2014 - 11:16 PM

Ohai を単体で使ってみる。 Ref: https://wiki.opscode.com/display/chef/Ohai+Installation+and+Use

Ohai を単体で使ってみる。 Ref: https://wiki.opscode.com/display/chef/Ohai+Installation+and+Use

require 'ohai'
require 'pp'

pp ohai = Ohai::System.new
pp ohai.all_plugins
pp ohai.seen_plugins
pp kernel = ohai.kernel
pp kernel.keys
pp kernel[:name]
pp kernel[:release]
pp kernel[:version]
#pp kernel[:modules]
pp kernel[:machine]
pp kernel[:os]

=begin
#<Ohai::System:0x007f06879412b0
 @data={},
 @hints={},
 @plugin_path="",
 @providers={},
 @seen_plugins={}>
true
{"os"=>true,
 "kernel"=>true,
 "ruby"=>true,
 "languages"=>true,
 "java"=>true,
 "ssh_host_key"=>true,
 "keys"=>true,
 "cloud"=>true,
 "ec2"=>true,
 "hostname"=>true,
 "linux::hostname"=>true,
 "network"=>true,
 "linux::network"=>true,
 "gce"=>true,
 "rackspace"=>true,
 "eucalyptus"=>true,
 "linode"=>true,
 "openstack"=>true,
 "azure"=>true,
 "dmi_common"=>true,
 "root_group"=>true,
 "c"=>true,
 "php"=>true,
 "network_listeners"=>true,
 "chef"=>true,
 "erlang"=>true,
 "ohai_time"=>true,
 "virtualization"=>true,
 "linux::virtualization"=>true,
 "nodejs"=>true,
 "ip_scopes"=>true,
 "lua"=>true,
 "dmi"=>true,
 "passwd"=>true,
 "platform"=>true,
 "linux::platform"=>true,
 "linux::lsb"=>true,
 "groovy"=>true,
 "mono"=>true,
 "python"=>true,
 "ohai"=>true,
 "command"=>true,
 "uptime"=>true,
 "perl"=>true,
 "linux::filesystem"=>true,
 "linux::memory"=>true,
 "linux::kernel"=>true,
 "linux::block_device"=>true,
 "linux::ps"=>true,
 "linux::cpu"=>true,
 "linux::uptime"=>true}
{"name"=>"Linux",
 "release"=>"3.11.0-15-generic",
 "version"=>"#25-Ubuntu SMP Thu Jan 30 17:22:01 UTC 2014",
 "machine"=>"x86_64",
 "modules"=>
  {"pci_stub"=>{"size"=>"12622", "refcount"=>"1"},
   ......
   "libahci"=>{"size"=>"31928", "refcount"=>"1"}},
 "os"=>"GNU/Linux"}
["name", "release", "version", "machine", "modules", "os"]
"Linux"
"3.11.0-15-generic"
"#25-Ubuntu SMP Thu Jan 30 17:22:01 UTC 2014"
"x86_64"
"GNU/Linux"
=end