Cleaned up the Memory scripts by removing undeeded greps and using awk
This will speed up execution because bash only needs to call the awk binary and not grep along with it.
This commit is contained in:
parent
fbc02ca665
commit
cac4731e56
1 changed files with 4 additions and 4 deletions
|
@ -17,13 +17,13 @@ get_percent()
|
|||
case $(uname -s) in
|
||||
Linux)
|
||||
# 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}')
|
||||
used_mem=$(free -g | awk '/^Mem/ {print $3}')
|
||||
total_mem=$(free -h | awk '/^Mem/ {print $2}')
|
||||
if (( $used_mem == 0 )); then
|
||||
memory_usage=$(free -m | grep Mem: | awk '{mem += $3} END {print mem}')
|
||||
memory_usage=$(free -m | awk '/^Mem/ {print $3}')
|
||||
echo $memory_usage\M\B/$total_mem\G\B
|
||||
else
|
||||
memory_usage=$(free -g | grep Mem: | awk '{mem += $3} END {print mem}')
|
||||
memory_usage=$(free -g | awk '/^Mem/ {print $3}')
|
||||
echo $memory_usage\G\B/$total_mem\G\B
|
||||
fi
|
||||
;;
|
||||
|
|
Loading…
Reference in a new issue