ãµã¼ãã®æ§ææ
å ±ã®åéã«ã¯dmidecodeãunameã/proc/*ãªã©ãªã©ãããããé§ä½¿ãã¦ãã¨æãã®ã§ãã
è¦ããã®å¤§å¤ã»ã»ã»åºåã®ãã¼ã¹ããã©ãããã»ã»ã»è¤æ°OS使ã£ã¦ãå ´åã¯ç¹ã«ã»ã»ã»
ã¨ããããã§ããæãã«ãµã¼ãã®æ§ææ å ±ãåºåãã¦ããããã¼ã«ãohaiãç´¹ä»
ï¼å®ã¯Chefã£ã¦ããæ§æ管çãã¼ã«ã§å
é¨çã«ä½¿ãããã®ãã®ãªã®ã§ããåä½ã§ãå©ç¨å¯è½ã§ãï¼
http://wiki.opscode.com/display/chef/Ohai
ã¤ã³ã¹ãã¼ã«
Rubyã§æ¸ããããã¼ã«ãªã®ã§gemã§
[root@test01 ohai]# gem install ohai
â»ãã¾ãã¤ã³ã¹ãã¼ã«ã§ããªãå ´åã¯gemãã¢ãããã¼ããã¦ãã ãããruby-develãå¿
è¦
å®è¡ä¾ï¼ã³ãã³ãï¼
ohaiã³ãã³ããå®è¡ããã¨JSONå½¢å¼ã§ãµã¼ãã®æ å ±ãåºåããã¾ã
HPãµã¼ãä¸ã®CentOS
[root@test01 ohai]# ohai { "dmi": { "system": { "manufacturer": "HP", "product_name": "ProLiant DL360 G5", "serial_number": "CN77XXXXXX " ... "kernel": { "machine": "x86_64", "name": "Linux", "os": "GNU/Linux", "version": "#1 SMP Wed Jun 23 18:42:01 JST 2010", "release": "2.6.18.8" ... "platform_version": "5.2", "platform": "centos", ... "cpu": { "real": 2, "total": 4, "0": { ... "model_name": "Intel(R) Xeon(R) CPU 5140 @ 2.33GHz", ... "memory": { ... "total": "4046944kB", "free": "40408kB", ... "swap": { "total": "2031608kB", "free": "1921044kB", "cached": "58584kB" }, ... "filesystem": { "/dev/cciss/c0d0p1": { "kb_available": "71394", "mount": "/boot", "percent_used": "26%", "kb_used": "24473", "kb_size": "101086" }, ... "languages": { "perl": { "archname": "x86_64-linux-thread-multi", "version": "5.8.8" }, ...
HWãOSãè¨èªãªã©ãªã©
VMWare Playerä¸ã®Debian
ä»®æ³åé¢é£ã®æ å ±ãåå¾ã§ãã¾ã
root@debian6:~# ohai ... "vendor": "Phoenix Technologies LTD", ... "manufacturer": "VMware, Inc.", "wake_up_type": "Power Switch", "product_name": "VMware Virtual Platform" ... "virtualization": { "role": "guest", "system": "vmware" }, ... "platform": "debian" "platform_version": "6.0.2", ...
KVMã²ã¹ãã ã¨ãããªæã
[root@vm01 ~]# ohai ... "vendor": "QEMU", ... "manufacturer": "Red Hat", "product_name": "KVM", "serial_number": "Not Specified" ... "virtualization": { "role": "guest", "system": "kvm" }, ...
å®è¡ä¾ï¼ããã°ã©ã ï¼
JSONããã¼ã¹ãã¦ãããã®ã§ããï¼ohaiå
¥ããã¨Rubyã®Yajlã£ã¦ã©ã¤ãã©ãªãã¤ãã¦ãã¾ãï¼
rubyã§ã©ã¤ãã©ãªã¨ãã¦æ±ããã¨ãã§ãã¾ãã
â»HPãµã¼ãã ã£ããhpacucliãæ´æ°ããä¾
#!/usr/bin/ruby require 'rubygems' require 'ohai' ohai = Ohai::System.new ohai.all_plugins if ohai[:dmi][:system][:manufacturer] == 'HP' puts "HP!!!" system("yum -y update hpacucli") end
ãã°
Ruby1.8.7ã¨ç¾ç¶gemã§ã¤ã³ã¹ãã¼ã«ãããohai0.6.4ã§dmiãã«ã¼ãã«çãããããæ
å ±æããããã¾ããã
ãããã°ãªãã·ã§ã³ãã¤ããã¨ãããªã¨ã©ã¼ã
[root@test01 lib]# ohai -l debug ... [Sat, 17 Sep 2011 19:03:58 +0900] DEBUG: Plugin kernel threw exception #<NameError: uninitialized constant Ohai::Mixin::Command::StringIO> /usr/lib/ruby/gems/1.8/gems/ohai-0.6.4/lib/ohai/mixin/command.rb:249:in `popen4' ...
ãã°ã£ã½ãã§ãã
https://tickets.opscode.com/browse/OHAI-291
0.6.6ã§è§£æ±ºæ¸ã¿ã¨ã®ãã¨ã§æ©ãã¢ãããã¼ããã¦ãããããã¨ããã§ããã
ã¨ããããohai.rbã«require 'stringio'ã追å ããã°æ£å¸¸ã«åãã¾ã
ï¼/usr/lib/ruby/gems/1.8/gems/ohai-0.6.4/libãããã«ããã¾ãï¼
require 'ohai/version' require 'ohai/config' require 'ohai/system' #追å require 'stringio'
ã¨ãããã
ãã©ã°ã¤ã³ã§æ©è½è¿½å ãã§ãããã
ãªããªã便å©ãããªãã¼ã«ãªã®ã§Chefå°å
¥ã¸ã®å¸ç³ãå
¼ãã¦ã¡ãã£ã¨ä½¿ã£ã¦ã¿ããã¨æãã¾ãã