#!/bin/bash DATE=`date "+Date courante: %Y-%m-%d%nHeure: %H:%M:%S"` LOG=/var/log/whoami-check.log TAIL='tail -1 $LOG' RESULT=/var/log/whoami-result.log source /etc/verimag/functions type=$1 if [ x$type = x ] ; then printf "usage debian-whoami-check sarge|servers\n" exit 0 fi case "$1" in sarge) hlist="`hosts debian-linux-3.1`" ;; servers) hlist="`hosts debian server`" ;; esac clear; echo -en "~~~~~~~~~~~~~~~~~~~~\n" echo $DATE echo -en "~~~~~~~~~~~~~~~~~~~~\n" echo -en " \n" sleep 1; for h in ${hlist} ; do ssh $h w | grep -v root | grep -v USER | grep -v ^" " |awk '{printf $1;printf " : ";print $8}' > $LOG 2>&1 if [ ! $? = 0 ] ; then echo ${h} ": WARNING host may be down" ; else sleep 1; echo -en " \n";echo -en ${h} && tail -1 $LOG ;echo -en "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" ;echo -en " "; fi done