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.
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:
3) Create a new
Data Input Method
in Cacti's web interface:sent/received/other_field
fields you could come up with above4) Create a
Data Source
which uses your newApache Traffic
input method5) 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.
I'm not familar with Cacti, but Apache should be able to log the "Response Size", which should give you, in bytes, the size of the returned document, which should give you pretty accurate bandwidth usage statistics.
Looking at lower-level devices, like the NIC or the router are usually much more difficult and expensive to monitor if you're on a mixed network (e.g. the one connection shared for mutliple web servers, or perhaps a VPN or something), as you have to filter our only the traffic destined to/from the web server.