Please find below some commands and utilities which can help you working and monitoring Apache server. More stuff will be added once I discover it.
Monitor your website in real time with apachetop:
This tool is very interesting, it lets you view exactly what is happening, displaying data like requests per second or total bytes. It is parsing the apache logfiles and displaying meaningful output to the screen.
How to use it? Simple:
jupiter:~# apachetop -r 1 -f /var/log/apache2/sites/docs.gz.ro.log
The display will look similar to this one:
last hit: 19:29:06 atop runtime: 0 days, 00:01:25 19:29:15
All: 36 reqs ( 0.6/sec) 1198.1K ( 19.0K/sec) 33.3K/req
2xx: 36 ( 100%) 3xx: 0 ( 0.0%) 4xx: 0 ( 0.0%) 5xx: 0 ( 0.0%)
R ( 30s): 19 reqs ( 0.6/sec) 548.8K ( 18.3K/sec) 28.9K/req
2xx: 19 ( 100%) 3xx: 0 ( 0.0%) 4xx: 0 ( 0.0%) 5xx: 0 ( 0.0%)
REQS REQ/S KB KB/S URL
8 0.80 259.1 25.9*/node/29
2 0.07 60.4 2.2 /osx
2 0.08 72.3 3.0 /node/60
2 0.11 59.9 3.2 /node/70
1 0.05 48.0 2.2 /osx-lion-diskutil-encrypt-decrypt-hfs.html
1 0.08 39.9 3.1 /tips-and-tricksYou can find more tricks about this tool, here: http://www.howtogeek.com/howto/ubuntu/monitor-your-website-in-real-time-with-apachetop/
Using ab benchmark tool.
This tool is very interesting, you can test your web server's settings. There are various options and you can find them by reading the command's manual but I will show you now just two:
-n 100: ab will send 100 number of requests to server http://docs.gz.ro/;
-c 2: 22 is concurrency number, meaning it will send 2 requests in the same time to the target.
[/code]
Example:
core:html# ab -n 100 -c 2 http://docs.gz.ro/
This is ApacheBench, Version 2.3 <$Revision: 655654 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/
Benchmarking docs.gz.ro (be patient).....done
Server Software: Apache/2.2.16
Server Hostname: docs.gz.ro
Server Port: 80
Document Path: /
Document Length: 27703 bytes
Concurrency Level: 2
Time taken for tests: 21.685 seconds
Complete requests: 100
Failed requests: 0
Write errors: 0
Total transferred: 2819800 bytes
HTML transferred: 2770300 bytes
Requests per second: 4.61 [#/sec] (mean)
Time per request: 433.694 [ms] (mean)
Time per request: 216.847 [ms] (mean, across all concurrent requests)
Transfer rate: 126.99 [Kbytes/sec] received
Connection Times (ms)
min mean[+/-sd] median max
Connect: 0 0 0.2 0 1
Processing: 333 433 56.6 426 641
Waiting: 306 406 53.9 399 617
Total: 333 433 56.7 426 642
Percentage of the requests served within a certain time (ms)
50% 426
66% 450
75% 464
80% 473
90% 494
95% 545
98% 641
99% 642
100% 642 (longest request)
How to check which pages are hot-linking your images from the apache log? Below, with awk we use " as separator, search for image extensions and exclude our url. Finally we sort the output and count the duplicates:
jupiter:~# awk -F\" '($2 ~ /\.(jpg|gif|png)/ && $4 !~ /mediashow\.ro/){print $4}' /var/log/apache2/sites/mediashow.ro.log | sort | uniq -c | sort -nHow to dynamically display only hot-linked images, excluding your domain and empty referrers:
jupiter:~# tail -f /var/log/apache2/sites/mediashow.ro.log | awk -F\" '($2 ~ /\.(jpg|gif|png)/ && $4 !~ /(mediashow\.ro|-)/){print}'