diff options
author | Chris Chambers <ccgithub@chrischambers.net> | 2015-08-20 10:45:30 -0500 |
---|---|---|
committer | Chris Chambers <ccgithub@chrischambers.net> | 2015-08-20 10:45:30 -0500 |
commit | 282ebe3a65d70311b1683137f2f9ddfcb4180fe9 (patch) | |
tree | e131a0f54d64ee43338a57eee36bca0b44398dd4 | |
parent | c415be5e046674c3eb8b51dfdf937bf3bab745ce (diff) | |
download | ohai-282ebe3a65d70311b1683137f2f9ddfcb4180fe9.tar.gz |
Update to include CPU state counts for on-line,off-line,spare,noint
-rw-r--r-- | lib/ohai/plugins/solaris2/cpu.rb | 51 |
1 files changed, 25 insertions, 26 deletions
diff --git a/lib/ohai/plugins/solaris2/cpu.rb b/lib/ohai/plugins/solaris2/cpu.rb index cc9c7130..e53d05b1 100644 --- a/lib/ohai/plugins/solaris2/cpu.rb +++ b/lib/ohai/plugins/solaris2/cpu.rb @@ -21,51 +21,50 @@ Ohai.plugin(:CPU) do cpu Mash.new # This does assume that /usr/bin/kstat is in the path processor_info = shell_out("kstat -p cpu_info").stdout.lines - cpu["total"]=0 - cpu["sockets"]=0 - cpu["cores"]=0 - cpu["corethreads"]=0 - cpu["total_online"]=0 - cpu["total_offline"]=0 + cpu["total"] = 0 + cpu["sockets"] = 0 + cpu["cores"] = 0 + cpu["corethreads"] = 0 + cpu["cpustates"] = Mash.new - currentcpu=0 - cpucores=Array.new - cpusockets=Array.new + currentcpu = 0 + cpucores = Array.new + cpusockets = Array.new processor_info.each_with_index do |processor, i| desc,instance,record,keyvalue = processor.split(":") cpu[instance] = Mash.new if cpu[instance].nil? - if ( currentcpu != instance ) - cpu["total"]+=1 + if (currentcpu != instance) + cpu["total"] += 1 currentcpu = instance end - kv=keyvalue.gsub(/\s+/,"=").split(/=/) - key=kv.shift - value=kv.join(" ").chomp + kv = keyvalue.gsub(/\s+/,"=").split(/=/) + key = kv.shift + value = kv.join(" ").chomp case key when /chip_id/ cpu[instance]["socket"] = value cpusockets.push(value) if cpusockets.index(value).nil? when /cpu_type/ - cpu[instance]["arch"]=value + cpu[instance]["arch"] = value when /clock_MHz/ - cpu[instance]["mhz"]=value + cpu[instance]["mhz"] = value when /brand/ - cpu[instance]["model_name"]=value.sub(/\s+/," ") + cpu[instance]["model_name"] = value.sub(/\s+/," ") when /state$/ - cpu[instance]["state"]=value - cpu["total_offline"]+=1 if ( value.include? "off-line" ) - cpu["total_online"]+=1 if ( value.include? "on-line" ) + cpu[instance]["state"] = value + cpu["cpustates"][value] = 0 if cpu["cpustates"][value].nil? + cpu["cpustates"][value] += 1 when /core_id/ - cpu[instance]["core_id"]=value + cpu[instance]["core_id"] = value # Detect hyperthreading/multithreading cpucores.push(value) if cpucores.index(value).nil? when /family|fpu_type|model|stepping|vendor_id/ - cpu[instance][key]=value + cpu[instance][key] = value end end - cpu["cores"]=cpucores.size - cpu["corethreads"]=(cpu["total"]/cpucores.size) - cpu["sockets"]=cpusockets.size - cpu["real"]=cpusockets.size + cpu["cores"] = cpucores.size + cpu["corethreads"] = (cpu["total"] / cpucores.size) + cpu["sockets"] = cpusockets.size + cpu["real"] = cpusockets.size end end |