One of our servers has had much higher than average load today, consistently running higher than normal. Our server admins are making sure all is running okay but this has got me wondering if maybe the server is just very busy today. This in turn has made me think, is there any way to get a reasonably accurate report on how many active website visitors there are across all sites on the whole server?
All sites are PHP/MySQL running on apache 2 on Centos 4.8 - obviously we do have things like google analytics / awstats / webaliser for each site but i just wondered if theres a command that can be run that will give us an active users on server stat? maybe analyse all session files for sessions active in last x minutes?
If you enable mod_status in apache, you can get access to a page which will give you statistics on the number of active processes, the number of idle processes, what they are processing, how many accesses per second, and volume.
http://httpd.apache.org/docs/2.0/mod/mod_status.html
If you use a monitoring framework such as munin (http://munin.projects.linpro.no/), you can query the page over time and store the results. This will give you a graphical display over what the load looks like over time to see if any pikes correlate to the higher load on the box.
Another alternative would be to use apachetop. This is an utility like top, which displays Apache information, including requests per second, bytes per second, most popular URLs, etc.