function idl () { if [ "${1:0:2}" == "-h" ]||[ "${1:0:2}" == "-?" ] then echo -e "\033[0;32mReinis ${FUNCNAME[0]} V1.0\033[0m" echo "Reinis .bashrc Tools" echo "" echo -e "\033[1;30;47m${FUNCNAME[0]} IP-Adresse CPU_NR\033[0m" echo "Zeigt IDLE-Zeit von CPU_NR der IP-Adresse" echo "" echo "IP-Adresse default ist localhost" echo "" echo "CPU_NR default ist Durchschnitt aller CPUs" return fi if echo $1 |egrep '.*\..*\..*\..*' >/dev/null 2>&1 then remote=$(echo "ssh $1") cpunr=$(echo "$2") else remote=$(echo "") cpunr=$(echo "$1") fi if [ "$cpunr" == "" ] then cpunr=$(echo "1") else ((cpunr=cpunr+1)) fi rstat=$($remote head -n$cpunr /proc/stat|tail -n1|awk '{$1=""; print $0}') b=0 for a in $rstat do ((b=b+$a)) done c=$(echo "$rstat"|awk '{print $4}') iowait=$(echo|mawk '{OFMT="%.2f";print '$c'*100/'$b'}') if [ "$remote" == "" ] then remote=$(echo "localhost") fi if [ "$cpunr" == "1" ] then cpun=$(echo "Last-Durchschnitt") else ((cpunr=cpunr-1)) cpun=$(echo "CPU_NR $cpunr") fi echo "IDLE-Time $cpun von $remote = $iowait" }