In the OpsCode Wiki there is there following documentation:
require 'ohai'
# ...
# Profit! ;-)
How can I print the JSON data provided by the 'ohai' command but using IRB? I tried to see the code in application.rb but I get empty data.
require 'ohai/application'
ohai = Ohai::System.new
ohai.json_pretty_print
=> "{\n\n}"
I am not trying to do this within Chef (or Shef), I just want to use the ohai gem itself, in my own app.
Poking about in the
Ohai::Application
class (what you get when you runohai
),#run_application
instantiatesOhai::System
and, unless it was configured by a file, it callsall_plugins
to populate it with data.Presumably,
Ohai::System#all_plugins
delegates the data collection to thelib/ohai/plugins
directory.