Using apachetop with a Community Server

Having just installed apachetop on a community server to get an overview of what sites are busy on the server, I needed to create a single log file to read. Adding a line into each Apache stanza was simple but tiresome, I simply added this line:

        CustomLog /data/logs/all.log combined

This gave me a central log file which has all of the sites in it, then I can call the apachetop program with he following format:

apachetop -f /data/logs/all.log

This worked really well with one problem. Th server has a lot of sites running WordPress and the like and apachetop was not differentiating in its output. The solution was to use Apache and create a new logging format. I wanted to shim the ‘ServerName’ into the request so I could see which site’s wp-login.php (for example) page it actually was showing. My new format is:

    LogFormat "%h %l %u %t \"%m %v%U%q %H\" %>s %B" central

Its called ‘central’ so I needed to update the apache config accordingly which sed took care of it quickly and painlessly. Now I get output like:

 REQS REQ/S    KB KB/S URL
  304 10.13 879.0 29.3*www.qqqqqqqq.co.uk/wp-content/themes/qqqqqqqq/images/atdefault.jpg
   22  0.81   0.0  0.0 www.bbbbbbbb.com/new/wp-content/themes/MagMan/timthumb.php
    4  0.13 222.5  7.4 www.bbbbbbbb.co.uk/wp-content/uploads/nivoslider4wp_files/19_s.jpeg
    3  0.12  15.5  0.6 www.aaaaaaaa.com/index.html
    2  0.07 112.9  3.8 www.bbbbbbbb.com/index.php
    1  0.03   0.7  0.0 www.bbbbbbbb.com/new/xmlrpc.php
This entry was posted in Apache and tagged , . Bookmark the permalink.

Leave a Reply