8

I was wondering if I deploy a server at home, with apache2. I would like to know how much traffic is currently on my site, in real time.

Please and thank you.

:)

4
  • What kind of traffic? Number of page hits, or how much bandwidth is used/ number of bytes transferred via network interface?
    – txwikinger
    Oct 28, 2010 at 2:36
  • @txwikinger all the above! long time no see!
    – myusuf3
    Oct 28, 2010 at 2:58
  • Well.. have been busy with other Ubuntu stuff :D
    – txwikinger
    Oct 28, 2010 at 3:04
  • Use JetHTTP :) Seriously though, I am curious to know if there is a way to do this with Apache. Oct 28, 2010 at 6:00

6 Answers 6

6

You can install the package iptraf which gives you realtime monitoring of various tcp and udp information. Page hits are realtime logged in the apache log that you have configured. You can either scan that file for number of lines matching your time period, or you can use some like piwik for your apache server which gives you analysis similar to google analytics.

5

I frequently add the status module to my apache configuration so that I can examine the running state of Apache (this example restricts access to only localhost status requests).

This goes in the virtualhost configuration:

 # Server status
 <IfModule mod_status.c>
  <Location /server-status>
    SetHandler server-status
    Order deny,allow
    Deny from all
    Allow from localhost
  </Location>
 </IfModule>

This goes in the general server configuration (I used /etc/apache2/conf.d/10status.conf):

# Turn on extended status collection
<IfModule mod_status.c>
    ExtendedStatus On
</IfModule>

And then I make sure mod_status is enabled:

sudo a2enmod status

After that, I can just visit http://your-virtual-host.example.com/server-status and get all kinds of details, including the high-level summary, like this:

Server uptime: 7 days 22 hours 56 minutes 45 seconds
Total accesses: 292855 - Total Traffic: 5.6 GB
CPU Usage: u85.78 s8.21 cu1.49 cs0 - .0139% CPU load
.426 requests/sec - 8.5 kB/second - 19.9 kB/request
2 requests currently being processed, 8 idle workers
....
Srv PID Acc M   CPU     SS  Req Conn    Child   Slot    Client  VHost   Request
0-1 27078   0/9/21119   _   0.06    3   101 0.0 0.04    372.17  67.195.113.233  example.com GET /foo.php?state=ND&thing=Madison
1-1 -   0/0/21273   .   0.01    137 0   0.0 0.00    402.35  128.61.99.146   example.com GET /favicon.ico HTTP/1.1
....

I especially like the requests/sec, and the detailed report about what URLs are being (or were recently) served.

4

I would recommend using apachetop, unfortunately it seems the development stopped, but it works well.

This site is more recent.

2
  • 1
    apachetop is cool. able to view summary realtime accessed page.
    – apis17
    Mar 16, 2013 at 6:34
  • apachetop is more cool that iptraf as for me :) Dec 25, 2014 at 8:42
2

If every 5 minutes or so is realtime enough for you, take a look at Munin. It collects system information and displays them in nice graphs, see here for a live example-installation.

alt text

1

ssh root@HOST tcpdump -U -s0 -w - 'not port 22' | wireshark -k -i -

HOST = your webserver Chose Statistics fro Menu and Click IO Graphs

1

Try cacti.

aptitude install cacti

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .