[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Script to help migration from BB to Hobbit



Hi all

here's a quick & very dirty script which eases BB to Hobbit migration, by re-disable in Hobbit all the tests which were disabled in BB.
It requires GNU date and GNU ls.


You just have to change the following inside the script :

OLD_DISABLED=/home/bbuser/bbvar/disabled
BB=/home/hobbituser/server/bin/bb
BBDISP=10.20.30.40
TESTMODE=N

By default "test mode" is on, so no disable is actually un.

Here's the output :

$ ./redo_disable.sh
Disable hades.disk for 9 minutes (until 2005-11-15 18:26:00)

Hope it will help someone...

Regards,

--

Frédéric Mangeant

Steria EDC Sophia-Antipolis


#!/bin/sh

# ------------------------------------
# Script to re-disable tests in Hobbit
#
# Requires GNU date & GNU ls
# ------------------------------------

LANG=C

# ------------------------------------
# Change this !
# ------------------------------------

BB=/BB/hobbit/server/bin/bb
OLD_DISABLED=/BB/bbvar/disabled
BBDISP=10.50.8.10
TESTMODE=Y

# ------------------------------------
# Main loop
# ------------------------------------

for i in $OLD_DISABLED/*; do
	# ------------------------------------
	# Get machine & column names
	# ------------------------------------

	FILENAME=`basename $i`
	MACHINE=`echo $FILENAME | cut -f 1 -d '.'`
	COLUMN=`echo $FILENAME | cut -f 2 -d '.'`

	# ------------------------------------
	# We don't want to disable 'info' colums
	# ------------------------------------

	if [ "$COLUMN" = "info" ]; then
		continue
	fi

	# ------------------------------------
	# Get the files's full time & date
	# ------------------------------------

	FULLDATE=`ls --full-time $i | awk '{ print $6 }'`
	FULLTIME=`ls --full-time $i | awk '{ print $7 }' | cut -c 1-8`

	# ------------------------------------
	# Get the "end" date
	# ------------------------------------

	DATE=`date +%s --date="$FULLTIME $FULLDATE"`

	# ------------------------------------
	# Difference between now and the "end" date
	# ------------------------------------

	NOW=`date +%s`
	DIFFERENCE=`expr $DATE - $NOW`

	# ------------------------------------
	# Convert it in minutes
	# ------------------------------------

	MINUTES=`expr $DIFFERENCE / 60`
	
	# ------------------------------------
	# Do it for real ?
	# ------------------------------------

	if [ "$TESTMODE" = "Y" ]; then
		echo "Test mode - Disable $MACHINE.$COLUMN for $MINUTES minutes (until $FULLDATE $FULLTIME)"
	else
		echo "Disable $MACHINE.$COLUMN for $MINUTES minutes (until $FULLDATE $FULLTIME)"
		echo $BB $BBDISP "disable $MACHINE.$COLUMN $MINUTES"
	fi
done

exit 0