IBM VPN : How to check the status under Ubuntu ?

Here my script (CheckVPN.sh) to check the status of VPN with logs in syslog :

# cat ./CheckVPN.sh 

grep "naclient_poll" /var/log/syslog* | sed 's/:/ /1' | awk '{print $2 " " $3 " " $4 " " $10}' | sort > /tmp/naclient_poll.txt

filename='/tmp/naclient_poll.txt'
n=1
m=0
previous_state=0
while read line; do
	state=`echo $line | awk '{print $4}'`  
	if [ $previous_state = $state ] 
		then
			#echo "Line No. $n $state : $line"
			m=$((m+1))
		else
	        	echo "Line No. $n $state (new state) $m : $line"
			if [ $previous_state = 1 ]
				then
					echo " Network is down"
			fi
			if [ $state = 1 ]
                                then
                                        echo " Network is up"
                        fi
			previous_state=${state}
			m=0
	fi
	n=$((n+1))
done < $filename