Files
nando/nando-stats
Ville Rantanen 8aeb5d67fd posix
2015-07-13 14:56:08 +03:00

32 lines
999 B
Bash
Executable File

#!/bin/bash
function filesize {
awk 'BEGIN{ x = '$1'
split("K M G T P",type)
for(i=5;y < 0.1;i--)
y = x / (2^(10*i))
str=int(y*10)/10 type[i+2]
if (x==0) { str = "0" }
print str
}' || return $?
}
cores=$( grep -c processor /proc/cpuinfo )
load=$( cat /proc/loadavg | cut -d" " -f3 | tr -d [:cntrl:] )
echo -n "L:$load/$cores M:"
# used + cached = total - free
free=$( grep ^MemFree /proc/meminfo | tr -d -c [:digit:] )
cache=$( grep ^Cached /proc/meminfo | tr -d -c [:digit:] )
total=$( grep ^MemTotal /proc/meminfo | tr -d -c [:digit:] )
used=$( echo $total $free $cache | awk '{ print $1 -$2 -$3 }' )
used=$( filesize $used )
cache=$( filesize $cache )
total=$( filesize $total )
echo -n "$used+$cache/$total U:"
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 )
# exit okay
true