#!/bin/sh
#
# Run net_test to find data throughput through network
# Originally written by Ray Pasetes
# Modified by Troy Dawson on June 29, 2000
# Modifed S. Timm, 2002, 2003 for new burnin control files
if [ ! -e /etc/burnin_on ] 
then
    exit
fi
RUN_NETTEST="NO"
if [ -x /etc/burnin.conf ] 
then
	. /etc/burnin.conf
fi
if [ "$RUN_NETTEST" == "NO" ]
then
	exit
fi
#
# CONFIG VARIABLES
#
MAIL=/usr/bin/Mail
SOURCEDIR=.
BINDIR=/root/bin
NODEFILE=/root/test/nettest/nodelist
MAILFILE=/tmp/nettest_failures

##################################################
##################################################
if [ -f $MAILFILE ]
then
	rm $MAILFILE
fi

if [ -f $NODEFILE ] ; then
	cat $NODEFILE | {
		while read line
		do
			$BINDIR/net-test-single $line > /dev/null 2>&1
		done
	}


	if [ -f $MAILFILE ]; then
		echo "" >> $MAILFILE
		echo "Tests completed `date`" >> $MAILFILE
		echo "A negative network number means the machine was unreachable, or not running nettestd" >> $MAILFILE
		$MAIL -s "Test Net: failed nodes" $MAILLIST < $MAILFILE
		rm $MAILFILE
	fi

else
	echo "$NODEFILE is missing"
	exit 1
fi
