#!/bin/sh PATH=$PATH:/bin:/usr/bin export PATH # HTTP proxy to use HTTP_PROXY=http://proxy.wleiden.net:3128 # Test page to query PROXY_TEST=http://proxy-test.wirelessleiden.nl/ # Make variable global, so fetch can use it export HTTP_PROXY # Query the webpage SPEEDOUT=`fetch -o /dev/null ${PROXY_TEST} 2>&1` # What is the Exit code of fetch? SPEEDEXIT=$? # The speed by which the webpages was retrieved" SPEED=`echo ${SPEEDOUT} | awk '{ print $4 " " $5 }'` # What was the format of speed (Bps) TYPE=`echo ${SPEEDOUT} | awk '{ print $5 }'` # Dit the fetcommand exit happy, and was the format as we expected if [ ${SPEEDEXIT} -eq 0 -a "$TYPE" = "Bps" ]; then # Let's celebrate, it was successfull echo "INET OK: $SPEED" exit 0 else # Oh no, time to get drunk, retrieval was unsuccessfull echo "INET CRITICAL: $SPEEDOUT\n" exit 2 fi