Fix RAM display for versions of free lacking the cache/buffer-adjusted row

This commit is contained in:
Mattia Basaglia 2016-03-22 18:08:07 +00:00
parent a592ea89d7
commit 7b4325a89b

View file

@ -38,12 +38,12 @@ function pccolor()
function ponyget_RAM() function ponyget_RAM()
{ {
local ramtable=$(free -h) local ramtable=$(free -h | head -n -1)
local used=$(echo "$ramtable" | sed -n 3p | sed -r "s/ +/\t/g" | cut -f 3) local used=$(echo "$ramtable" | tail -n 1 | sed -r "s/ +/\t/g" | cut -f 3)
local total=$(echo "$ramtable" | sed -n 2p | sed -r "s/ +/\t/g" | cut -f 2) local total=$(echo "$ramtable" | sed -n 2p | sed -r "s/ +/\t/g" | cut -f 2)
ramtable=$(free -m) ramtable=$(free -m | head -n -1)
local used_M=$(echo "$ramtable" | sed -n 3p | sed -r "s/ +/\t/g" | cut -f 3) local used_M=$(echo "$ramtable" | tail -n 1 | sed -r "s/ +/\t/g" | cut -f 3)
local total_M=$(echo "$ramtable" | sed -n 2p | sed -r "s/ +/\t/g" | cut -f 2) local total_M=$(echo "$ramtable" | sed -n 2p | sed -r "s/ +/\t/g" | cut -f 2)
let percent="$used_M * 100 / $total_M" let percent="$used_M * 100 / $total_M"