Skip to main content

ohai (executable)

ohai is the command-line interface for Ohai, a tool that is used to detect attributes on a node, and then provide these attributes to Chef Infra Client at the start of every Chef Infra Client run.


This command has the following syntax:


This tool has the following options:


Use to have Ohai show only output for named attributes. To address attributes deeper in the tree, use a / delimiter between each level. For example: memory/free.

-c CONFIG, --config CONFIG

The path to a configuration file to use. For example: /etc/ohai/config.rb.


The directory in which additional Ohai plugins are located. For example: /my/extra/plugins.

-h, --help

Show help for the command.

-l LEVEL, --log_level LEVEL

The level of logging to be stored in a log file.


The location of the log file.

-v, --version

The version of Ohai.


The following examples show how to use the Ohai command-line tool:

Query for a specific attribute

Pass an attribute as an argument to ohai to get the value of that attribute. For example:

ohai os

This fetches the value of Chef Infra’s node data at node['os'] and returns something like:


To query for an attribute deeper in the tree, use a forward slash (/) as a delimiter. For example, to query for free memory, run:

ohai memory/free

Run a plugin independently of a Chef Infra Client run

An Ohai plugin can be run independently of a Chef Infra Client run. First, ensure that the plugin is located in the /plugins directory and then use the -f option when running Ohai from the command line. For example, a plugin named sl_installed may look like the following:

Ohai.plugin(:Sl) do
  provides "sl"

  collect_data(:default) do

    if ::File.exist?("/usr/games/sl")
      sl[:installed] = true
      sl[:installed] = false

    # sl[:installed] = ::File.exist?("/usr/games/sl")


To run that plugin from the command line, use the following command:

ohai --directory /path/to/directory sl

The command will return something similar to:

  "sl": {
    "installed": true
Edit this page on GitHub

Thank you for your feedback!


Search Results