From 35387a2d4f0277823a04ed2c9a5a6e56de10eba4 Mon Sep 17 00:00:00 2001 From: Saumit Dinesan Date: Sun, 11 Jun 2023 13:36:31 +0530 Subject: .scripts: updating hardcoded memory script --- .scripts/memory | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) (limited to '.scripts') diff --git a/.scripts/memory b/.scripts/memory index 9848458..05c6364 100755 --- a/.scripts/memory +++ b/.scripts/memory @@ -1,3 +1,16 @@ #!/bin/sh -free --mebi | sed -n '2{p;q}' | awk '{printf ("%2.1fGB/16GB\n", ( $3 / 1024))}' +# Get the total memory in human readable format +total_memory_gb=$(free -h | awk '/^Mem:/{print $2}') + +# Check the total memory and set the relative value +if [[ $total_memory_gb == "7Gi" ]]; then + total_mem=8 +elif [[ $total_memory_gb == "15Gi" ]]; then + total_mem=16 +else + totalmem=$(echo $total_memory_gb | sed 's/Gi//') +fi + +# Display the used memory as a percentage of the total memory +free --mebi | sed -n '2{p;q}' | awk '{printf ("%2.1fGB/'$total_mem'GB\n", ( $3 / 1024))}' -- cgit v1.2.3