I hope this works lol

This commit is contained in:
Ethan Edwards 2020-06-06 22:41:30 -04:00
parent 3ec3f2f08b
commit 4cf72d94c3

View file

@ -4,13 +4,23 @@ get_percent()
{ {
case $(uname -s) in case $(uname -s) in
Linux) Linux)
percent=$(free -m | awk 'NR==2{printf "%.1f%%\n", $3*100/$2}') # percent=$(free -m | awk 'NR==2{printf "%.1f%%\n", $3*100/$2}')
echo $percent 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) Darwin)
percent=$(ps -A -o %mem | awk '{mem += $1} END {print mem}') # percent=$(ps -A -o %mem | awk '{mem += $1} END {print mem}')
echo $percent 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*) CYGWIN*|MINGW32*|MSYS*|MINGW*)