print uptime

This commit is contained in:
Ville Rantanen
2015-07-20 09:19:08 +03:00
parent a6e051bab3
commit 5aaac569df

View File

@@ -11,6 +11,19 @@ function filesize {
}' || return $? }' || return $?
} }
function shorttime {
awk 'BEGIN{ x = '$1'
split("s m h d",type)
split("1 60 3600 86400",divisor)
for(i=4;y < 1;i--)
y = x / (divisor[i])
str=int(y) type[i+1]
if (x==0) { str = "0" }
print str
}' || return $?
}
cores=$( grep -c processor /proc/cpuinfo ) cores=$( grep -c processor /proc/cpuinfo )
load=$( cat /proc/loadavg | cut -d" " -f3 | tr -d [:cntrl:] ) load=$( cat /proc/loadavg | cut -d" " -f3 | tr -d [:cntrl:] )
echo -n "L:$load/$cores M:" echo -n "L:$load/$cores M:"
@@ -27,5 +40,7 @@ echo -n "$used+$cache/$total U:"
ps a --format user| grep -v -e root -e USER | sort -u | wc -l | tr -c -d [:digit:] ps a --format user| grep -v -e root -e USER | sort -u | wc -l | tr -c -d [:digit:]
printf " R/H:%s/%s" $( df / | awk '{print $5}' | tail -n +2 ) $( df /home | awk '{print $5}' | tail -n +2 ) printf " R/H:%s/%s" $( df / | awk '{print $5}' | tail -n +2 ) $( df /home | awk '{print $5}' | tail -n +2 )
printf " up:%s" $( shorttime $( cut -d" " -f1 /proc/uptime ) )
# exit okay # exit okay
true true