From 4cf72d94c399914641fa019447c4efbc09b1c98f Mon Sep 17 00:00:00 2001 From: Ethan Edwards Date: Sat, 6 Jun 2020 22:41:30 -0400 Subject: [PATCH] I hope this works lol --- scripts/ram_info.sh | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/scripts/ram_info.sh b/scripts/ram_info.sh index 6fc4705..ff17c91 100755 --- a/scripts/ram_info.sh +++ b/scripts/ram_info.sh @@ -4,13 +4,23 @@ get_percent() { case $(uname -s) in Linux) - percent=$(free -m | awk 'NR==2{printf "%.1f%%\n", $3*100/$2}') - echo $percent + # percent=$(free -m | awk 'NR==2{printf "%.1f%%\n", $3*100/$2}') + used_mem=$(free -g | grep Mem: | awk '{mem += $3} END {print mem}') + total_mem=$(free -h | grep Mem: | awk '{mem += $2} END {print mem}') + if (( $used_mem == 0 )); then + memory_usage=$(free -m | grep Mem: | awk '{mem += $3} END {print mem}') + echo $memory_usage\M\B/$total_mem\G\B + else + memory_usage=$(free -g | grep Mem: | awk '{mem += $3} END {print mem}') + echo $memory_usage\G\B/$total_mem\G\B + fi ;; Darwin) - percent=$(ps -A -o %mem | awk '{mem += $1} END {print mem}') - echo $percent + # percent=$(ps -A -o %mem | awk '{mem += $1} END {print mem}') + used_mem=$(top -l 1 -s 0 | grep PhysMem | awk '{mem += $2} END {print mem}') + total_mem=$(hwprefs memory_size | sed 's/ //g; s/B//g;') + echo $used_mem/$total_mem ;; CYGWIN*|MINGW32*|MSYS*|MINGW*)