small patch to fact gathering for when no dmesg.boot exists on freebsd, mainly happens in jails
Signed-off-by: Brian Coca <briancoca+ansible@gmail.com>
This commit is contained in:
parent
291648ccd9
commit
6886683e16
1 changed files with 10 additions and 1 deletions
|
@ -438,13 +438,22 @@ class FreeBSDHardware(Hardware):
|
||||||
stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
||||||
out, err = cmd.communicate()
|
out, err = cmd.communicate()
|
||||||
self.facts['processor_count'] = out.strip()
|
self.facts['processor_count'] = out.strip()
|
||||||
for line in open(FreeBSDHardware.DMESG_BOOT).readlines():
|
|
||||||
|
try:
|
||||||
|
dmesg_boot = open(FreeBSDHardware.DMESG_BOOT)
|
||||||
|
except IOError:
|
||||||
|
dmesg_cmd = subprocess.Popen("/sbin/dmesg", shell=True,
|
||||||
|
stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
||||||
|
dmesg_boot,dmesg_err = dmesg_cmd.communicate()
|
||||||
|
|
||||||
|
for line in dmesg_boot.readlines():
|
||||||
if 'CPU:' in line:
|
if 'CPU:' in line:
|
||||||
cpu = re.sub(r'CPU:\s+', r"", line)
|
cpu = re.sub(r'CPU:\s+', r"", line)
|
||||||
self.facts['processor'].append(cpu.strip())
|
self.facts['processor'].append(cpu.strip())
|
||||||
if 'Logical CPUs per core' in line:
|
if 'Logical CPUs per core' in line:
|
||||||
self.facts['processor_cores'] = line.split()[4]
|
self.facts['processor_cores'] = line.split()[4]
|
||||||
|
|
||||||
|
|
||||||
def get_memory_facts(self):
|
def get_memory_facts(self):
|
||||||
cmd = subprocess.Popen("/sbin/sysctl vm.stats", shell=True,
|
cmd = subprocess.Popen("/sbin/sysctl vm.stats", shell=True,
|
||||||
stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
||||||
|
|
Loading…
Reference in a new issue