From 8c35b82069d4651661a31f119f19e58ec13d4a16 Mon Sep 17 00:00:00 2001 From: Brian Read Date: Tue, 10 Dec 2024 16:55:46 +0000 Subject: [PATCH] Correct awk call in get_total_memory free -m gives: ``` total used free shared buff/cache available Mem: 31966 10870 9147 1572 14146 21095 Swap: 2047 137 1910 ``` --- lxc_autoscale/lxc_utils.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lxc_autoscale/lxc_utils.py b/lxc_autoscale/lxc_utils.py index 2e4592e..8a1ef77 100644 --- a/lxc_autoscale/lxc_utils.py +++ b/lxc_autoscale/lxc_utils.py @@ -152,7 +152,7 @@ def get_total_cores(): def get_total_memory(): """Calculate available memory after reserving fixed amount.""" try: - command_output = run_command("free -m | awk '/^MemTotal:/ {print $2}'") + command_output = run_command("free -m | awk '/^Mem:/ {print $2}'") total_memory = int(command_output.strip()) if command_output else 0 except (ValueError, subprocess.CalledProcessError) as e: logging.error("Failed to get total memory: %s", str(e))