[X4U] Testing conection

Charles Howse chowse at charter.net
Wed Jul 12 13:06:16 PDT 2006


On Jul 12, 2006, at 6:54 AM, Jan Melichar wrote:

> I'm living with a long term problem with the internet connection at  
> my office - connection keeps dropping. I have have had a lot of  
> visits from telephone engineers who tell me that I have a very good  
> quality line but the line keeps dropping. :Last week I was told  
> that a circuit at the exchange has been changed and I have to say  
> the connection seems to be better but my 'ultimate' test is  
> streaming radio which keeps loosing connection with monotonous  
> frequency (this very rarely happens to me at home with the same  
> ISP, router and similar Mac setup and same radio station- yes I  
> have tried different pouters and the problem is the same)
>
> I realise the problem could be with the BBC servers or the radio  
> stations connected via iTunes and any number of other things (even  
> though I do not get the same problem at home) so what I would like  
> to be able to do is have some means whereby I can monitor more  
> effectively whether I have a connection or not and that this can be  
> documented.Anyone with any suggestions on how this might be done.

Would this work for you?

#!/bin/sh
host=24.159.76.1
logfile=Documents/ping_results.txt
stats=`curl -s http://192.168.100.1/signaldata.html | grep dB | tr -d  
\<TD\> | tr -d /`
test=`ping -c 3 $host 2>&1 | grep packets`
look=`tail -1 Documents/ping_results.txt`

if [ "$test" == "$look" ] ; then
        :
else
       	echo >> $logfile
       	date >> $logfile
	echo "$stats" >> $logfile
        	echo "$test" >> $logfile
fi

exit 0


Line-by-line:
line 1. sha-bang
line 2. one of my isp's gateway servers
line 3. file to save results into
line 4. use curl to get the current power levels and s/n ratio from  
my cable modem
line 5. ping the gateway server 3 times only and grep the results for  
the line containing "packets"
line 6. look at the last line of the results file
If: the last line of the results file is exactly the same as the  
result of the ping, then do nothing, otherwise write the results to  
the file.

Sample output with explanations in brackets:
Wed Jul 12 04:25:04 CDT 2006
37 dB
-6 dBmV
52 dBmV
3 packets transmitted, 2 packets received, 33% packet loss
[online and all readings in the normal range]

Wed Jul 12 04:30:03 CDT 2006
37 dB
-6 dBmV
52 dBmV
3 packets transmitted, 3 packets received, 0% packet loss
[online and all readings in the normal range]

Wed Jul 12 14:21:28 CDT 2006

3 packets transmitted, 0 packets received, 100% packet loss
[The modem is apparently offline, since it's readings are not  
displayed, and we are offline here at the Mac]

Wed Jul 12 14:30:02 CDT 2006
36 dB
-9 dBmV
53 dBmV
3 packets transmitted, 3 packets received, 0% packet loss
[9 minutes later, back online...go figure]

Comments and improvements welcomed.

--
Webmaster's Computer Page -
http://bubbabbq.homeunix.net/webmaster.html




More information about the X4U mailing list