Skip to content

Commit 9e8cc2a

Browse files
keithcampbelljrKeith Campbell
andauthored
feat(Firewall): New fields for show_system_resources (#544)
* linter passed, tests passed for enhancement * Update firewall.py fixing format issue --------- Co-authored-by: Keith Campbell <[email protected]>
1 parent 7e87952 commit 9e8cc2a

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

panos/firewall.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -426,24 +426,27 @@ def show_system_resources(self):
426426
result = self.xapi.xml_root()
427427
if self._version_info >= (9, 0, 0):
428428
regex = re.compile(
429-
r"load average: ([\d\.]+).*? ([\d\.]+) id,.*KiB Mem :\s+(\d+) total,.*? (\d+) free",
429+
r"load average: ([\d\.]+).*? ([\d\.]+) id,.*KiB Mem :"
430+
r"\s+(\d+) total,.*? (\d+) free.*? (\d+) used,"
431+
r".*? (\d+) buff/cache",
430432
re.DOTALL,
431433
)
432434
else:
433435
regex = re.compile(
434-
r"load average: ([\d.]+).* ([\d.]+)%id.*Mem:.*?([\d.]+)k total.*?([\d]+)k free",
436+
r"load average: ([\d.]+).* ([\d.]+)%id.*"
437+
r"Mem:.*?([\d.]+)k total.*?"
438+
r"([\d]+)k free.*?([\d]+)k used.*?([\d]+)k buff/cache",
435439
re.DOTALL,
436440
)
437441
match = regex.search(result)
438442
if match:
439-
"""
440-
return cpu, mem_free, load
441-
"""
442443
return {
443444
"load": Decimal(match.group(1)),
444445
"cpu": 100 - Decimal(match.group(2)),
445446
"mem_total": int(match.group(3)),
446447
"mem_free": int(match.group(4)),
448+
"mem_used": int(match.group(5)),
449+
"mem_buffer": int(match.group(6)),
447450
}
448451
else:
449452
raise err.PanDeviceError(

0 commit comments

Comments
 (0)