Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I'm getting a lot of traffic that is crushing my tiny server. Is there something I can install that will allow me to examine my Apache traffic real-time? Ideally a web interface. I'd like to see what the requests are for and which ones are taking the most resources.

enter image description here

share|improve this question

4 Answers 4

Apache's mod_status can help you. For more complex troubleshooting, you might need to customize format of your logs (e.g. include %D to it) and write some kind of parser.

share|improve this answer

Have you tried using Apache's extended status?

share|improve this answer

well you need to parse the apache logs, there are many tools to do that. I myself wrote a few awk scripts.

echo  "Hits by source IP:"
echo "======================================================================"

awk '{print $2}' "$1" | grep -ivE "(127.0.0.1|192.168.100.)" | sort | uniq -c | sort -   rn | head -25


echo "The 25 most popular pages:"
echo "======================================================================"

awk '{print $6}' "$1" | grep -ivE '(mod_status|favico|crossdomain|alive.txt)' | grep  -ivE '(.gif|.jpg|.png)' | sed 's/\/$//g' | sort | uniq -c | sort -rn | head -25

echo

echo "The 25 most popular pages (no js or css):"
echo "======================================================================"

awk '{print $6}' "$1" | grep -ivE '(mod_status|favico|crossdomain|alive.txt)' | grep -ivE '(.gif|.jpg|.png|.js|.css)' | sed 's/\/$//g' | sort | uniq -c | sort -rn | head -25


echo "The 25 most common referrer URLs:"
echo "======================================================================"

awk '{print $11}' "$1" | \
grep -vE "(^"-"$|/www.$host|/$host)" | \
sort | uniq -c | sort -rn | head -25



echo "Longest running requests"
echo "======================================================================"

awk  '{print $10,$6}' "$1" | grep -ivE '(.gif|.jpg|.png|.css|.js)'  | awk '{secs=0.000001*$1;req=$2;printf("%.2f minutes req time for %s\n", secs / 60,req )}' | sort -rn | head -50

exit 0

Just put in a file named: "apache_stats" and run it like: "./apache_stats ".

share|improve this answer

Check out http://mmonit.com/

M/Monit is paid, and offers a lot more features (and a more expansive GUI). Monit is free and allows you to monitor. You can get email alerts when your server load passes a certain threshold. I use this myself to monitor server load and respond accordingly.

share|improve this answer

Your Answer

 
discard

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.