Apache

View Realtime Requests Per Second From Log

Added by on January 28th, 2009, filed under Apache, PHP

so you want to view the number of requests to your webserver per second. here’s a quick and easy php script that you can run from command line.

1
2
3
4
while(true){
    echo exec('cat /var/log/httpd/access_log | wc -l') . "n";
    sleep(1);
  }

it isn’t perfect, but it will work for doing some basic troubleshooting. just hit ctrl+c to terminate.

and if you want to simulate a bunch of request so you can watch the num go up and down, here’s a script to help:

1
2
3
4
while(true) {
  exec('wget yourdomain.com');
  unlink('index.html');
}

Enjoy this Post?

Spread the word by promoting this post on FaceBook and Twitter.

What do you think?