Skip to content

Commit

Permalink
Add total memory
Browse files Browse the repository at this point in the history
  • Loading branch information
MishkaMN committed Nov 20, 2024
1 parent b951e55 commit 28edba6
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion engineering_tools/monitor-ros-cpu.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ def main():
"Memory (%)",
"Command Line",
"Total CPU (%)",
"Total Memory (%)",
]
)

Expand All @@ -121,12 +122,14 @@ def main():
while True:
timestamp = datetime.now().strftime("%Y-%m-%d %H:%M:%S.%f")[:-3]
total_cpu_percent = psutil.cpu_percent(interval=None)
total_memory_percent = (
psutil.virtual_memory().percent
) # Get total memory usage

for proc in psutil.process_iter(
["pid", "name", "cpu_percent", "memory_percent", "cmdline"]
):
try:
# Fix for the join() error - handle None case
cmdline = (
" ".join(proc.info["cmdline"]) if proc.info["cmdline"] else ""
)
Expand All @@ -146,6 +149,7 @@ def main():
memory_percent,
cmdline,
total_cpu_percent,
total_memory_percent, # Added total memory usage
]
)

Expand Down

0 comments on commit 28edba6

Please sign in to comment.