I use the following script probably with basic ideas I'd borrowed from elsewhere. It uses curl statistics:
estadistica () {
local site=$1
echo $site
echo ${site} | sed -n 's/./-/gp'
curl -w '
Lookup time:\t%{time_namelookup} s
Connect time:\t%{time_connect} s
Pretransfer time:\t%{time_pretransfer} s
Starttransfer time:\t%{time_starttransfer} s
Size download:\t%{size_download} bytes
Speed download:\t%{speed_download} bytes/s
Total time:\t%{time_total} s
' -o /dev/null -s $site
echo
}
for i in ${@}; do
estadistica $i
done
Lets say it's named webstats; this is how it works:
~/src$ bash webstats http://serverfault.com/questions/295194/simple-program-or-script-to-check-load-time-of-web-page http://www.google.com
http://serverfault.com/questions/295194/simple-program-or-script-to-check-load-time-of-web-page
-----------------------------------------------------------------------------------------------
Lookup time: 0,009 s
Connect time: 0,139 s
Pretransfer time: 0,139 s
Starttransfer time: 0,284 s
Size download: 37298 bytes
Speed download: 57153,000 bytes/s
Total time: 0,653 s
http://www.google.com
---------------------
Lookup time: 0,084 s
Connect time: 0,147 s
Pretransfer time: 0,147 s
Starttransfer time: 0,218 s
Size download: 218 bytes
Speed download: 1000,000 bytes/s
Total time: 0,218 s
If something goes wrong you can know it (and hence tell zabbix) because the resulting data is not logical:
~/src$ bash webstats http://thisdoesntexist
http://thisdoesntexist
----------------------
Lookup time: 0,000 s
Connect time: 0,000 s
Pretransfer time: 0,000 s
Starttransfer time: 0,000 s
Size download: 0 bytes
Speed download: 0,000 bytes/s
Total time: 0,000 s
EDITED: curl's timeout option:
Just to answer your comment, curl has a timeout option; from it's man page:
--connect-timeout <seconds>
Maximum time in seconds that you allow the connection to the
server to take. This only limits the connection phase, once
curl has connected this option is of no more use. See also the
-m/--max-time option.