How to check if a web page loads?

Simple program or script to check load time of web page

  • I'm looking for a simple program or script, you give it a URL and it does the following: checks whether it can open a connection to that URL and reports how long the response time is checks how long it takes to the load the page and reports this number reports some error code or other number when a site is unresponsive exits after it either: fails to connect, loads the page successfully, or after a predetermined number of seconds specified by the user My purpose is to integrate this functionality as an external program to Zabbix. I did a google search but was unable to locate one.

  • Answer:

    You can do what you want with a combination of the http://linux.die.net/man/1/time and wget commands - e.g.: time wget -q http://www.google.com/ time will print the time (in seconds/fractions of a second) that it took to complete the wget command, and the return code of the whole mess will be whatever wget's return code would have been (0=success, non-zero indicating various failures). This can be further wrapped in an appropriate script to determine if the page was successfully retrieved and produce output suitable for Zabbix to pick up and use.

80skeys at Server Fault Visit the source

Was this solution helpful to you?

Other answers

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.

hmontoliu

This: http://tools.pingdom.com/ Alternatively, it would be really easy to code a simple script to do this yourself and output in a specific format.

yrosen

I think the firefox firebug network option and pagespeed is a good option

bulleric

Related Q & A:

Just Added Q & A:

Find solution

For every problem there is a solution! Proved by Solucija.

  • Got an issue and looking for advice?

  • Ask Solucija to search every corner of the Web for help.

  • Get workable solutions and helpful tips in a moment.

Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.