Use kstat for Solaris CPU info

This commit is contained in:
Chris Gardner 2013-05-28 22:36:09 +01:00 committed by Chris Gardner
parent 4a215203ed
commit 50c3cf302c

View file

@ -655,13 +655,20 @@ class SunOSHardware(Hardware):
return self.facts return self.facts
def get_cpu_facts(self): def get_cpu_facts(self):
rc, out, err = module.run_command("/usr/sbin/psrinfo -v") rc, out, err = module.run_command("/usr/sbin/kstat cpu_info")
self.facts['processor'] = [] self.facts['processor'] = []
for line in out.split('\n'): for line in out.split('\n'):
if 'processor operates' in line: if len(line) < 1:
continue
data = line.split(None, 1)
key = data[0].strip()
# key "brand" works on Solaris 10
if key == 'brand':
if 'processor' not in self.facts: if 'processor' not in self.facts:
self.facts['processor'] = [] self.facts['processor'] = []
self.facts['processor'].append(line.strip()) self.facts['processor'].append(data[1].strip())
# Counting cores on Solaris can be complicated. Leave as-is for now.
# https://blogs.oracle.com/mandalika/entry/solaris_show_me_the_cpu
self.facts['processor_cores'] = 'NA' self.facts['processor_cores'] = 'NA'
self.facts['processor_count'] = len(self.facts['processor']) self.facts['processor_count'] = len(self.facts['processor'])