#!/bin/sh
NUM_FAILED=0
while true
	do
		ping -w 2 -c 1 10.2.0.2 > /dev/null
		if [ $? -eq 0 ]
			then
				#if ping ok
				NUM_FAILED=0
				mca-dump | curl http://10.2.0.2/report.php -X POST --data-binary @-
			else
				#if ping failed
				NUM_FAILED=`expr $NUM_FAILED + 1`
		fi
		if [ $NUM_FAILED -gt 20 ]
			then
				reboot
		fi
sleep 30
done

