Skip to content

Instantly share code, notes, and snippets.

@gouf
Created February 16, 2014 23:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gouf/9042037 to your computer and use it in GitHub Desktop.
Save gouf/9042037 to your computer and use it in GitHub Desktop.
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment