well many time ago
i was rouding with this idea in my head..
measure how many time took a host on reboot process , the following script is the most accurate way ,that i could craft, to perform that task…
this script was maded to test Rhel hosts but should work against almost any linux flavor’s , check the reboot command , if you plan to test it in other
plattaform.
beware of ssk unknown hosts and/or duplicate keys…. before to launch this script test if you could connect using ssh to the the root account…
#!/bin/bash
slp=”/bin/sleep”
expr=”/usr/bin/expr”
ssh=”/usr/bin/ssh”
rb=”/sbin/reboot”
oneMinuteInSeconds=”60″
oneHourInSeconds=”3600″
dateStart=”`date +%s`”
remoteUser=”root”
remoteHost=”someHost.Somedomain.tld” # should be know first the launch this script
$ssh $remoteUser@$remoteHost “$rb”
sleep 30
while true;
do
sleep 1
$ssh -q $remoteUser@$remoteHost “$slp 1 2>&1 > /dev/null” 2>&1 > /dev/null
if [ $? -eq 0 ];then
echo “host up”
break
fi
done
dateEnd=”`date +%s`”
totalTime=”`$expr $dateEnd – $dateStart`”
if [ "$totalTime" -eq 0 ];then
echo “the process probably doesn’t run or took less than one second”
elif [ "$totalTime" -gt 0 ] && [ "$totalTime" -lt "$oneMinuteInSeconds" ];then
echo “total time was $totalTime”
elif [ "$totalTime" -gt "$oneMinuteInSeconds" ] && [ "$totalTime" -lt "$oneHourInSeconds" ] ;then
howManyMins=”`$expr $totalTime \/ $oneMinuteInSeconds`”
howManyMinsInSecs=”`$expr $howManyMins \* $oneMinuteInSeconds`”
howManySecsOverMins=”`$expr $totalTime – $howManyMinsInSecs`”
echo “total was $howManyMins min(s), $howManySecsOverMins seconds”
else
echo “the process probably it’s stucked or never run”
fi
