Goal
- ohaiで取得できるステータス一覧を確認する
- ステータスをitamaeで表示させてみる
Manual
gem which ohai
# ohaiのインストールパスを確認
grep -R "provides" -h <ohaiのインストールパス>/lib/ohai/plugins | sed 's/^[\s ]*//g' | sed "s/\\\"/\'/g" | sort | uniq | grep "^provides"
# ※CentOS6.5とMacOSXで動作確認
■ワンライナー
ワンライナーだとこうなる.
grep -R "provides" -h `gem which ohai | perl -e '@p=split(/\//,<STDIN>);pop(@p);print join("/",@p)."/ohai/plugins";'` | sed 's/^[\s ]*//g' | sed "s/\\\"/\'/g" | sort | uniq | grep "^provides"
# ※CentOS6.5とMacOSXで動作確認
provides 'azure'
provides 'block_device'
provides 'chef_packages/chef'
provides 'chef_packages/ohai'
provides 'cloud'
provides 'cloud_v2'
provides 'command'
provides 'command/ps'
provides 'counters/network', 'counters/network/interfaces'
provides 'cpu'
provides 'digital_ocean'
provides 'dmi'
provides 'domain', 'hostname', 'fqdn', 'machinename'
provides 'ec2'
provides 'etc', 'current_user'
provides 'eucalyptus'
provides 'filesystem'
provides 'gce'
provides 'idletime', 'idletime_seconds' # linux only
provides 'init_package'
provides 'ipaddress', 'ip6address', 'macaddress'
provides 'joyent'
provides 'kernel', 'kernel/modules'
provides 'keys'
provides 'keys/ssh'
provides 'languages'
provides 'languages/c'
provides 'languages/elixir'
provides 'languages/erlang'
provides 'languages/go'
provides 'languages/groovy'
provides 'languages/java'
provides 'languages/lua'
provides 'languages/mono'
provides 'languages/nodejs'
provides 'languages/perl'
provides 'languages/php'
provides 'languages/powershell'
provides 'languages/python'
provides 'languages/ruby'
provides 'languages/rust'
provides 'linode'
provides 'lsb'
provides 'mdadm'
provides 'memory'
provides 'memory', 'memory/swap'
provides 'network', 'counters/network'
provides 'network', 'network/interfaces'
provides 'network/interfaces/adapters/route'
provides 'network/listeners'
provides 'network_ip_scope', 'privateaddress'
provides 'ohai_time'
provides 'openstack'
provides 'os', 'os_version'
provides 'platform', 'platform_version', 'platform_build', 'platform_family'
provides 'platform', 'platform_version', 'platform_family'
provides 'rackspace'
provides 'root_group'
provides 'system_profile'
provides 'uptime', 'uptime_seconds'
provides 'virtualization'
provides 'virtualization/#{info}'
provides 'virtualization/guest_id'
provides 'zpools'
Check
itamaeを使って適当にいくつかのステータスをピックアップして表示させてみる.
recipe.rb
require 'pp'
p "------- platform ------- "
pp node[:platform]
p "------- ipaddress ------- "
pp node[:ipaddress]
p "------- command/ps ------- "
pp node[:command][:ps]
p "------- cpu ------- "
pp node[:cpu]
p "------- filesystem ------- "
pp node[:filesystem]
p "------- current_user ------- "
pp node[:current_user]
p "------- os -------"
pp node[:os]
p "------- uptime -------"
pp node[:uptime]
itamae local --ohai recipe.rb
"------- platform ------- "
"mac_os_x"
"------- ipaddress ------- "
"192.168.2.100"
"------- command/ps ------- "
"ps -ef"
"------- cpu ------- "
{"real"=>2,
"total"=>4,
"mhz"=>2500,
"vendor_id"=>"GenuineIntel",
"model_name"=>"Intel(R) Core(TM) i5-3210M CPU @ 2.50GHz",
"model"=>58,
"family"=>6,
"stepping"=>9,
"flags"=>
["fpu",
"vme",
"de",
"pse",
"tsc",
"msr",
"pae",
"mce",
"cx8",
"apic",
"sep",
"mtrr",
"pge",
"mca",
"cmov",
"pat",
"pse36",
"clfsh",
"ds",
"acpi",
"mmx",
"fxsr",
"sse",
"sse2",
"ss",
"htt",
"tm",
"pbe",
"sse3",
"pclmulqdq",
"dtes64",
"mon",
"dscpl",
"vmx",
"est",
"tm2",
"ssse3",
"cx16",
"tpr",
"pdcm",
"sse4.1",
"sse4.2",
"x2apic",
"popcnt",
"aes",
"pcid",
"xsave",
"osxsave",
"tsctmr",
"avx1.0",
"rdrand",
"f16c"]}
"------- filesystem ------- "
{"/dev/disk1"=>
{"block_size"=>512,
"kb_size"=>117286912,
"kb_used"=>111143428,
"kb_available"=>5887484,
"percent_used"=>"95%",
"mount"=>"/",
"fs_type"=>"hfs",
"mount_options"=>["NFS exported", "local", "journaled"]},
"devfs"=>
{"block_size"=>512,
"kb_size"=>333,
"kb_used"=>333,
"kb_available"=>0,
"percent_used"=>"100%",
"mount"=>"/dev",
"fs_type"=>"devfs",
"mount_options"=>["local", "nobrowse"]},
"map -hosts"=>
{"block_size"=>512,
"kb_size"=>0,
"kb_used"=>0,
"kb_available"=>0,
"percent_used"=>"100%",
"mount"=>"/net",
"fs_type"=>"autofs",
"mount_options"=>["nosuid", "automounted", "nobrowse"]},
"map auto_home"=>
{"block_size"=>512,
"kb_size"=>0,
"kb_used"=>0,
"kb_available"=>0,
"percent_used"=>"100%",
"mount"=>"/home",
"fs_type"=>"autofs",
"mount_options"=>["automounted", "nobrowse"]},
"/dev/disk2s3"=>
{"block_size"=>512,
"kb_size"=>390952852,
"kb_used"=>325596108,
"kb_available"=>65356744,
"percent_used"=>"84%",
"mount"=>"/Volumes/TimeMachine",
"fs_type"=>"hfs",
"mount_options"=>["local", "nodev", "nosuid", "journaled"]},
"/dev/disk2s5"=>
{"block_size"=>512,
"kb_size"=>97171548,
"kb_used"=>41044544,
"kb_available"=>56127004,
"percent_used"=>"43%",
"mount"=>"/Volumes/Dynamo",
"fs_type"=>"hfs",
"mount_options"=>["local", "nodev", "nosuid", "journaled", "noowners"]},
"localhost:/7Pu_uSHTbhGSOyLay6Vpzx"=>
{"block_size"=>512,
"kb_size"=>117286912,
"kb_used"=>117286912,
"kb_available"=>0,
"percent_used"=>"100%",
"mount"=>"/Volumes/MobileBackups",
"fs_type"=>"mtmfs",
"mount_options"=>["nosuid", "read-only", "nobrowse"]}}
"------- current_user ------- "
"metheglin"
"------- os -------"
"darwin"
"------- uptime -------"
"2 hours 36 minutes 03 seconds"