Skip to content

Commit

Permalink
feat(Firewall): New fields for show_system_resources (#544)
Browse files Browse the repository at this point in the history
* linter passed, tests passed for enhancement

* Update firewall.py

fixing format issue

---------

Co-authored-by: Keith Campbell <keith@keiths-mbp.mynetworksettings.com>
  • Loading branch information
keithcampbelljr and Keith Campbell committed Feb 8, 2024
1 parent 7e87952 commit 9e8cc2a
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions panos/firewall.py
Original file line number Diff line number Diff line change
Expand Up @@ -426,24 +426,27 @@ def show_system_resources(self):
result = self.xapi.xml_root()
if self._version_info >= (9, 0, 0):
regex = re.compile(
r"load average: ([\d\.]+).*? ([\d\.]+) id,.*KiB Mem :\s+(\d+) total,.*? (\d+) free",
r"load average: ([\d\.]+).*? ([\d\.]+) id,.*KiB Mem :"
r"\s+(\d+) total,.*? (\d+) free.*? (\d+) used,"
r".*? (\d+) buff/cache",
re.DOTALL,
)
else:
regex = re.compile(
r"load average: ([\d.]+).* ([\d.]+)%id.*Mem:.*?([\d.]+)k total.*?([\d]+)k free",
r"load average: ([\d.]+).* ([\d.]+)%id.*"
r"Mem:.*?([\d.]+)k total.*?"
r"([\d]+)k free.*?([\d]+)k used.*?([\d]+)k buff/cache",
re.DOTALL,
)
match = regex.search(result)
if match:
"""
return cpu, mem_free, load
"""
return {
"load": Decimal(match.group(1)),
"cpu": 100 - Decimal(match.group(2)),
"mem_total": int(match.group(3)),
"mem_free": int(match.group(4)),
"mem_used": int(match.group(5)),
"mem_buffer": int(match.group(6)),
}
else:
raise err.PanDeviceError(
Expand Down

0 comments on commit 9e8cc2a

Please sign in to comment.