mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
Fix memory ios facts (#21696)
In order to populate the total and free mem of an IOS device, we run the 'show memory statistics' command. The output shows something similar to: Head Total(b) Used(b) Free(b) Lowest(b) Largest(b) Processor BEAE880 335215488 64044364 271171124 268918092 268463852 I/O 8DAE880 51380224 41880736 9499488 9461552 9352252 We need to just parse the line containing 'Processor' and get the first and third number for total and free mem, instaed for first and second as the code wrongly does.
This commit is contained in:
parent
46fee994d1
commit
6622b05326
1 changed files with 4 additions and 2 deletions
|
@ -222,10 +222,12 @@ class Hardware(FactsBase):
|
|||
|
||||
data = self.responses[1]
|
||||
if data:
|
||||
match = re.findall(r'\s(\d+)\s', data)
|
||||
processor_line = [l for l in data.splitlines()
|
||||
if 'Processor' in l].pop()
|
||||
match = re.findall(r'\s(\d+)\s', processor_line)
|
||||
if match:
|
||||
self.facts['memtotal_mb'] = int(match[0]) / 1024
|
||||
self.facts['memfree_mb'] = int(match[1]) / 1024
|
||||
self.facts['memfree_mb'] = int(match[3]) / 1024
|
||||
|
||||
def parse_filesystems(self, data):
|
||||
return re.findall(r'^Directory of (\S+)/', data, re.M)
|
||||
|
|
Loading…
Reference in a new issue