概要
Ohaiでサーバー情報の収集
詳細
Ohaiでサーバー情報の収集をする。
OhaiはChefのnode情報収集用に作成されたgemですが、単独で利用可能です。
・Chef内ではデータ収集を行い、nodeに情報を格納している。
node[:platform]等で取得して、レシピ内で利用可能
・Chefインストール時に一緒にインストールされるため、該当環境でohaiコマンドを利用出来る
・requireしてサーバーの設定、メンテナンス系のプログラムなどで利用出来る
ohaiコマンド試用
$ ohai | head
{
"languages": {
"ruby": {
"platform": "x86_64-linux",
"version": "1.8.7",
"release_date": "2012-02-08",
"target": "x86_64-unknown-linux-gnu",
"target_cpu": "x86_64",
"target_vendor": "unknown",
"target_os": "linux",
$ ohai languages/perl
{
"version": "5.14.2",
"archname": "x86_64-linux-gnu-thread-multi"
}
$ ohai os
[
"linux"
]
ohai require sample
require "ohai" oh = Ohai::System.new oh.require_plugin("os") p oh[:languages][:ruby][:version] p oh[:languages][:ruby][:bin_dir]
出力(Windows環境で試行)
"1.9.3" "C:/Ruby193/bin"