Sign up ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

I have apache running on a virtual server, which in periods gives very bad performance - even when retrieving static JPG or PNG files. This only happens once in a while, so it's hard for me to document it to the hosting company.

Is there a good tool out there, which can easily store a "loading time in milliseconds" of a file on a webserver every minute? Maybe even a shell script one-liner, I can run in a "screen" session?

share|improve this question

2 Answers 2

up vote 2 down vote accepted

You can modify the apache logging format (if it's not already there), to make it record the time it took to process a request:

LogFormat "%h %D %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined

It's the %D that adds the time, measured in microseconds.

To make it even easier to debug page load times you can add HTTP headers which include this information (so you don't even have to read the log file):

Header set X-Request-Received: %t
Header set X-Request-Processing-Time: %D

Remember to enable mod_headers first by executing enabling the headers module

Now you should see these headers in the response:

X-Request-Received  t=1286995673038485
X-Request-Processing-Time   D=251

(jogged my memory by reading this page

share|improve this answer
Btw: Can anyone explain why there seems to be a difference between the number logged in /var/log/apache2/access.log and the number sent through the header? I used exactly the code above (with header defined in .htaccess) but get "245598" in the log and "529" in the header for the same request. In general there seems to be orders of magnitude in difference between the numbers. – Søren Haagerup Aug 18 '11 at 7:47

I personally like Coops' answer, but if you want an independent check of load time (ie, how long did it take me to get all the page data from the server, rather than how long did the server think it took to serve all the page data) this answer may be helpful.

If you're already running NAGIOS or ICINGA, the check_http plugin can evaluate loading times and go WARNING or CRITICAL if they exceed certain thresholds. I'm not sure I'd put either of them in just for that, but if you're already using one, the plugin's ideally suited to qualitative monitoring (how often did this page take too long to load?).

If you'd prefer quantitative data (how long does this page take to load?) and are running munin, the check_http_requisites plugin will track that.

Many other monitoring systems will no doubt have similar functionality; what are you doing your internal monitoring with at the moment?

And if the answer above is "nothing", I beg your forgiveness if I go all soapbox for a moment: now is the time to put a proper monitoring solution in. I know it's tempting to pop in just-another-one-line-script, but they rapidly grow to be unmaintainable. Whereas once you're put in a good, free, plugin-based monitoring solution you suddenly discover all sorts of other things it would be really useful to monitor, and you don't have to reinvent the data-gathering, data-collating, data-display, and error-notification infrastructures each time.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.