I did some searches before typing this so please don't throw too many cans at me if I didn't get the search done correctly :)

I have a VPS serverwith a tiny slew of drupal instances. Something like 25/30 that have accumulated over time. I was wondering if there is some kind of program that is pretty elegant at tracking statistics of all enabled apache hosts or something like that, without having to install something huge like awstats that also requires a manual entry for each virtual host.

Sometimes my IO rate goes crazy on the server and I cant quite figure out who is doing it, if that sheds any light on the nature of my need.

Thanks so much in advance.

  • What do you mean by "tracking statistics of all enabled Apache hosts"? Web/visitor statistics or server performance broken down by vhost?
    – Mxx
    Commented Jan 10, 2013 at 16:49
  • server performance broken down by vhost Commented Jan 12, 2013 at 3:06

7 Answers 7


25/30 drupal and i/o problems :-)

Drupal 7 makes some really intensive usage of a bad file_scan_directory function.

Check this drupal bug for example or this and that.

The problem for you is 25/30 websites but all of them are managed by the same apache processes. So it is quite hard to isolate the real problematic drupal instance from the system monitoring tools.

With advanced mode for apache status you could check which Virtualhost is currently running on which apache process (if the long request is long enough for you to catch it). You could also use various calls to lsof command to identify which of the apache children is parsing the disk, and what directories are implied (that would give you the drupal instance). Of course it will be easier with one virtualhost for each Drupal (no multisite drupal deployment).

Now you should at least track the response time of each website, using nagios with check_http, or munin, or one of all the various monitoring tools and web services available. Note that for most of these http monitoring tools the most important parameter is to indicate the server IP and DNS, so that the 25 or 30 different websites are really checked, and not only the first one (default virtualhost). If they all respond in the same time chances are that you forgot to tell the monitor tool the right DNS to use on that http request.

Having the response time for all the websites you will see after any upgrades if one of the drupal instance as lost 1s in the average response time (for example) and this one will be the right target for a deeper analysis.


I assume that from the statistics point of view Awstats would do the job. Also I assume that your point here is to prepare for possible new Virtual Hosts, and because of that, automate the generation of statistics for new sites.

Well, here's a try.

  1. Use Awstats and install it normally.
  2. Make sure your virtual hosts are configured in a standard way so that reading their configuration can be automated. Since you use Apache, you may grep for ServerName directive from inside the sites-enabled -directory.
  3. Create a template config file /etc/awstats/template/awstats.template.conf containing $SITE in both LogFile and SiteDomain directives to enable the customization later on.
  4. Now, create a wrapper to look for sites that do not have awstats configured and run the actual update. It could be something like this:


    # Searching for new sites
    grep -i ServerName $HTTPDIR/*|grep -v "\#"|awk '{print $3}'|while read SITE
        if [ ! -f $AWSTATSDIR/awstats.${SITE}.conf ]; then
            # Here creating the custom config based on the $SITE variable placed into template
            sed -e "s/\\\$SITE/$SITE/g" $AWSTATSDIR/template/awstats.template.conf > $AWSTATSDIR/$awstats.$SITE.conf"

    # Ships with the package, runs updates all /etc/awstats/awstats.*.conf configs.
  1. And in the cron, simply:
    */10 * * * /path/to/above/script.sh

Try monitoring your server usage using tools like NewRelic, Amon (a NewRelic-like but self-hosted) or Munin.


Let's look at this from a slightly different angle. You've got 30 sites on your VPS. Presumably, you do not actively maintain all of them. I'd also image that you do not want one compromise to compromise the rest of your sites.

In my opinion, the only way to run large numbers of PHP sites on the same machine is to make sure that all their code executes as different users. The easiest way to do that is to install and configure suPHP. This also helps you with your actual problem, as once each website is running as it's own user, you can easily determine which ones are using up all of your resources.

It's going to be fairly tricky for you to track down which website is causing the load if everything is running as the same user.


You will probably use some log analysis tool like awstats (that you mentioned). You can also use one of the open source 'google analytics' competitors like Open Web Analytics.


There is a good utility to detect who's read\writes to disk: iotop

  • 1
    Not when those apache processes are servicing multiple virtualhosts and you need to isolate which one of them is the troublemaker.
    – Andrew B
    Commented Jan 10, 2013 at 4:20
  • 1
    U could use /server-status or log analisys tools
    – dr-evil
    Commented Jan 10, 2013 at 7:15
  • you can use Piwik - you can install it and monitor even from a remote server

  • or can install awstats on a local web server in your LAN and via cron jobs download and process daily web server's log files you are monitoring

You must log in to answer this question.

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