Ubuntu – Cacti measuring Apache bandwidth

apache-2.2cactiUbuntu

I've set up Cacti on my web server and it gives me graphs for Load Average and Memory Usage and such but I'd also like to monitor how much bandwidth my site is using.

I've been reading some of the Cacti documentation and I tried searching with Google but I can't seem to find anything that explains to me how to do this.

UPDATE:

Could it be that I shouldn't be looking at Apache for bandwidth measurement but at a lower level device? I'm currently running my LAMP stack on a EC2 instance if that makes a difference.

UPDATE 2:

Since asking this question I've actually switched from Cacti to Munin. Not that one is better than the other but simply because Munin suited more with my needs since out of the box it showed me everything I needed to know. I might still use Cacti in the future though.

Best Answer

Assuming you're running Cacti on the same machine, not querying over SNMP, you would have to:

1) Add response size logging to Apache

2) Write a script that parses your Apache log, sums up all request/response sizes for the past 5 minutes (Cacti's polling interval) and prints the result in a format Cacti understands:

sent:321 received:123 other_field:other_value ...

3) Create a new Data Input Method in Cacti's web interface:

  • name = Apache traffic
  • type = script/command
  • output fields = list all the sent/received/other_field fields you could come up with above

4) Create a Data Source which uses your new Apache Traffic input method

5) Create a graph which graphs your new Data Source

You'll have to check Cacti's documentation for more details on steps 3 and 4. I'm leaving this as a community wiki if someone else wants to chime in.

Related Topic