diff options
author | Saumit Dinesan <justsaumit@protonmail.com> | 2023-06-11 13:36:31 +0530 |
---|---|---|
committer | Saumit Dinesan <justsaumit@protonmail.com> | 2023-06-11 13:36:31 +0530 |
commit | 35387a2d4f0277823a04ed2c9a5a6e56de10eba4 (patch) | |
tree | 2659ff95860ff8c29697bf7163b52e9b361bcc43 /.scripts | |
parent | 813776dc0d56a65ed7133eba238253d2797fa34a (diff) |
.scripts: updating hardcoded memory script
Diffstat (limited to '.scripts')
-rwxr-xr-x | .scripts/memory | 15 |
1 files changed, 14 insertions, 1 deletions
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))}' |