Added conditional for linux boxes with < 1 GB Ram
This commit is contained in:
parent
cac4731e56
commit
b2d99517d0
1 changed files with 15 additions and 10 deletions
|
@ -16,16 +16,21 @@ 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}')
|
||||||
used_mem=$(free -g | awk '/^Mem/ {print $3}')
|
total_mem_gb=$(free -g | awk '/^Mem/ {print $2}')
|
||||||
total_mem=$(free -h | awk '/^Mem/ {print $2}')
|
used_mem=$(free -g | awk '/^Mem/ {print $3}')
|
||||||
if (( $used_mem == 0 )); then
|
total_mem=$(free -h | awk '/^Mem/ {print $2}')
|
||||||
memory_usage=$(free -m | awk '/^Mem/ {print $3}')
|
if (( $total_mem_gb == 0)); then
|
||||||
echo $memory_usage\M\B/$total_mem\G\B
|
memory_usage=$(free -m | awk '/^Mem/ {print $3}')
|
||||||
else
|
total_mem_mb=$(free -m | awk '/^Mem/ {print $2}')
|
||||||
memory_usage=$(free -g | awk '/^Mem/ {print $3}')
|
echo $memory_usage\M\B/$total_mem_mb\M\B
|
||||||
echo $memory_usage\G\B/$total_mem\G\B
|
elif (( $used_mem == 0 )); then
|
||||||
fi
|
memory_usage=$(free -m | awk '/^Mem/ {print $3}')
|
||||||
|
echo $memory_usage\M\B/$total_mem\G\B
|
||||||
|
else
|
||||||
|
memory_usage=$(free -g | awk '/^Mem/ {print $3}')
|
||||||
|
echo $memory_usage\G\B/$total_mem\G\B
|
||||||
|
fi
|
||||||
;;
|
;;
|
||||||
|
|
||||||
Darwin)
|
Darwin)
|
||||||
|
|
Loading…
Reference in a new issue