#!/usr/bin/perl #Kamin Whitehouse Oct 17 2004 #this script shows the status of all network connections. For wireless connections, it shows the #link quality as a bar. For all connections, it shows ping time to your favorite server, #or the first argument if there is one. #it requires the xosd library to be installed. I have it hot-keyed to Ctrl-Alt-Shift-N if (length $ARGV[0] ==0){ $remoteMachine="www.google.com"; } else{ $remoteMachine=$ARGV[0]; } $_=`/sbin/ifconfig`; @interfaces = /(\w+)\s+Link/g; $ifnum=0; $wifnum=0; foreach $if (@interfaces){ if("lo" ne $if){ #fist, get ping statistics about all interfaces besides 'lo'. #we might need to use async in the future, if this is too slow with multiple interfaces $ifname[$ifnum]=$if; $ping=`ping $remoteMachine -i 0.2 -c 5 -I $if`; $ping=~/(\d+)% packet loss/; $packetLoss[$ifnum]=$1; $ping=~/min\/avg\/max\/mdev = (\d*.\d*)\/(\d*.\d*)\/(\d*.\d*)\/(\d*.\d*) ms/; $rtt[$ifnum]=sprintf("%3.1f",$2); $ifnum+=1; #then, get connectivity statistics about the wireless interfaces #we might want to do this multiple times for more reliability $wlan=`/sbin/iwconfig $if`; if($wlan =~ /(\w+)\s+IEEE/){ $wlan=~ /^(\w*).*ESSID:"(.*?)"(.*?|\n)*Link Quality:(\d+)\/(\d+)/; $essid[$wifnum]=$2; $percentage[$wifnum]=$4/$5*100; $spercentage[$wifnum]=sprintf("%3.0f",$percentage[$wifnum]); $wifnum+=1; } } } $printTime=3*$ifnum; #seconds #then print them all to the screen at the same time $offset=0; $ifnum=0; foreach $id (@essid){ system "osd_cat -b percentage -P $percentage[$ifnum] -d $printTime -c yellow -f -adobe-utopia-bold-r-*-*-19-*-*-*-*-*-iso8859-* -O 6 -T ' Essid: $essid[$ifnum]; Quality $spercentage[$ifnum]%' &"; $offset+=60; $ifnum+=1; } $ifnum=0; foreach $id (@ifname){ $offset+=20; system "echo $ifname[$ifnum]: | osd_cat -d $printTime -c yellow -f -adobe-utopia-bold-r-*-*-19-*-*-*-*-*-iso8859-* -o $offset -O 6 &"; $offset+=20; system "echo \" $packetLoss[$ifnum]% packet loss\" | osd_cat -d $printTime -c yellow -f -adobe-utopia-bold-r-*-*-19-*-*-*-*-*-iso8859-* -o $offset -O 6 &"; $offset+=20; system "echo \" $rtt[$ifnum] ms rtt\" | osd_cat -d $printTime -c yellow -f -adobe-utopia-bold-r-*-*-19-*-*-*-*-*-iso8859-* -o $offset -O 6 &"; $offset+=20; $ifnum+=1; }