#!/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 $? } 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 ) 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 ) printf " up:%s" $( shorttime $( cut -d" " -f1 /proc/uptime ) ) # exit okay true