Monitoring apache VirtualHosts activity
May 2022
Sun Mon Tue Wed Thu Fri Sat
1 2 3 4 5 6 7
8 9 10 11 12 13 14
15 16 17 18 19 20 21
22 23 24 25 26 27 28
29 30 31        
This site is an effort to share some of the base knowledge I have gathered through all this years working with Linux, FreeBSD, OpenBSD, Python or Zope, among others. So, take a look around and I hope you will find the contents useful.
Recent Entries
Recent Comments
Recent Trackbacks
OpenBSD (9 items)
BSD (0 items)
FreeBSD (19 items)
Linux (3 items)
Security (3 items)
Python (22 items)
Zope (13 items)
Daily (144 items)
e-shell (9 items)
Hacks (14 items)
PostgreSQL (3 items)
OSX (8 items)
Nintendo DS (0 items)
enlightenment (0 items)
Apache (3 items)
Nintendo Wii (1 items)
Django (24 items)
Music (12 items)
Plone (7 items)
Varnish (0 items)
Lugo (2 items)
Sendmail (0 items)
europython (7 items)
Cherokee (1 items)
self (1 items)
Nature (1 items)
Hiking (0 items)
uwsgi (0 items)
nginx (0 items)
cycling (10 items)
Networking (1 items)
DNS (0 items)

Syndicate this site (XML)

RSS/RDF 0.91

28 enero

Monitoring apache VirtualHosts activity

apache + top, soon on shells near you!

For the last few days I've been monitoring (using the classic top utility) the load of apache processes in one of my webservers. Everything went as expected but, from time to time, one of the apache processes went crazy, reaching 40-50% of CPU use. It is not so important, but I began to think about how usefult it would be to know which VirtualHost is accessed by the request managed by such apache process...

Being honest, my first thought was to code something to do it, but soon I realized it should exist already a tool to do it. A quick search through google and I found an option, apachetop (which is already in the FreeBSD ports). This tool simply does some parsing on apache access logs and show in real time the urls that are being accessed.

It is a useful tool, for sure, but it was not what I was searching for. So, I did some more research, just to find apache-top.

Apache-top is a small python script that will monitor an apache web server /server-status url (more info on the mod_status page from the apache project), displaying it's information in a top-like curses interface. This information includes the pid of each apache process, the VirtualHost ServerName for the request handled by such process and a lot more information.

In FreeBSD to get it working you only have to edit /usr/local/etc/apache22/httpd.conf (if you are using other version than apache 2.2, it could be apache2/ or apache/ instead of apache22/) and uncomment the line:

#Include etc/apache22/extra/httpd-info.conf

Then you will have to edit /usr/local/etc/apache22/extra/httpd-info.conf. There you have to locate the <Location /server-status> directive and change:

Allow from


Allow from

This way, you will allow only requests from localhost for the /server-status location (just as a security measure).

Next, uncomment the following line (to activate extended reports):

ExtendedStatus On

And comment the following ones (as they are not needed for apache-top:

<Location /server-info>
    SetHandler server-info
    Order deny,allow
    Deny from all
    Allow from

Then you will have to restart apache, to the changes to have effect:

sudo /usr/local/etc/rc.d/apache22 restart

Ok, almost done, now you will have to download ( and you can rename it to get rid of the .py extension:

cd ~/bin && wget && mv apache-top

Finally, you can call apache-top from a shell to get the information:

apache-top -u http://localhost/server-status

and you should get something like:

apache-top in my e17 desktop, eterm!

Nice, isn't it?

There you will see not only the apache process and the related vhost access, but the cpu load, the ip address from the request is coming and even the url accessed. That's pretty much the thing I was searching for :D

Posted by wu at 19:30 | Comments (0) | Trackbacks (0)
<< OpenBSD, PyCha and the Memory Error. | Main | Una vez más, la misma mierda periodística >>
There are no comments.
Please send trackback to:
There are no trackbacks.
Post a comment