All pastes #457649 Raw Edit

Stuff

public text v1 · immutable
#457649 ·published 2007-04-25 14:43 UTC
rendered paste body
#!/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 -h | grep -v root |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} ;printf " : "; tail -1 $LOG ;
                 echo -en "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" ;echo -en "  ";
        fi
done