graphing http traffic

I decided to plot my http server’s hits and errors in my mrtg graphing pages.

Hitrate

Given the trivial traffic I do (2500 – 4000 hits a day, even excluding all css files, images, and various MSFT exploit attempts), it’s not too difficult. It was simple enough for me to refactor it so I could track error rates as well. All I do is grab the 100 most recent lines of log file, pull out the date of the first and last, work out the seconds between, and calculate how many hits per minute that represents. Pulling the date from the logfile lines took more time than anything, but I am a bear of very little brain when it comes to regular expressions.

I’m sure some smarter person can come up with a Better Way . . . I’ll look for it in the comments.

If that’s too hard to read, you can get a copy here.

and the mrtg config looks like this:

Target[red-httpd]: `/usr/home/paul/bin/hitrate.pl`
MaxBytes[red-httpd]: 1000
AbsMax[red-httpd]: 1000000
Title[red-httpd]: httpd hits and errors
PageTop[red-httpd]: <h1>httpd hits and errors</h1>

Unscaled[red-httpd]: ymw
ShortLegend[red-httpd]: hits/minute
#kMG[red-httpd]:k
YLegend[red-httpd]: hits and errors
Legend1[red-httpd]: hits
Legend2[red-httpd]: errors
Legend3[red-httpd]: hits
Legend4[red-httpd]: errors
LegendI[red-httpd]: hits
LegendO[red-httpd]: errors
Options[red-httpd]: growright,gauge,nopercent

Leave a Reply

Your email address will not be published. Required fields are marked *