Web Hosting Talk







View Full Version : Calculate Bandwidth Using MRTG


Justin C
08-12-2002, 05:21 PM
I just created this script to calculate total bandwidth (GB) using MRTG. I haven't fully tested it and it comes with no guarantees. Your comments are appreciated

You need to edit the lines that start with $log_file and $tmp_file. The first one is the location of your MRTG log file for the interface you wish to use. The second one is just a location that the script can use for a temporary file.

Sample is here: http://216.138.206.6/test.php

Hopefully this helps someone... it should be especially useful to rackshack folks ;)

Starhost
08-12-2002, 06:04 PM
Such script already excisted..........

http://bjorn.swift.st/

UmBillyCord
08-12-2002, 06:36 PM
I am sure someone will appriciate the free script you have put together.

goodness0001
08-12-2002, 07:00 PM
Yes thank you for your time, why is everyone so quick to down someone?

Justin C
08-12-2002, 07:25 PM
I didn't know that existed ;)

I needed this for myself and some others are always asking about something like this so I thought I would post it.

Deahost
08-12-2002, 07:28 PM
Great script, thanks M8 for taking the time to write this. Its most helpfull.

Thanks,

Brian

hostchamp
08-13-2002, 11:58 AM
Hi,

What is MRTG?

I want to monitor bandwidth consumption by each website hosted on our server, there are hindreds of domains. We do not offer individual IPs and offer name based hosting.

Can this script achieve what i want? i.e. calculate data transfer by each website i host? I have seen many control panels offer this solution but i do not run any cp like CPANEl/Hspehere etc. but how can i still acieve this?

Thanks,
Viv

Starhost
08-13-2002, 01:07 PM
You could use mod_watch and with that you can make mrtg graphs. Then you can make bandwidth calculations a virtualhost.

hostchamp
08-13-2002, 01:39 PM
what is mod_watch, i understand it is an apache module, what exactly does it do? Do i need to use it in conjuctosync with MRTG?
os this can simply calculate the bandwidth usage by domain? pls let me know.

Thanks,
Vivek

Starhost
08-13-2002, 03:04 PM
mod_watch keeps track of the bandwidth transferred a virtualhost. But it keeps logging, so it just doesn't make sense for you.

for mod_watch their is a special script that makes mrtg graphs of those transfers. And of those graphs you can calculate bandwisth as done above. Ofcourse you could also use ftp,

hostchamp
08-14-2002, 04:20 AM
Yes, can you post the location to the script which read mod_watch log and make mrtg graphs? I want to try this.

Starhost
08-14-2002, 04:36 AM
http://www.snert.com/Software/mod_watch/apache2mrtg.html

All scripts nesecary can be found on:
http://www.snert.com/Software/mod_watch/

prashant1979
06-28-2010, 02:48 AM
I just created this script to calculate total bandwidth (GB) using MRTG. I haven't fully tested it and it comes with no guarantees. Your comments are appreciated

You need to edit the lines that start with $log_file and $tmp_file. The first one is the location of your MRTG log file for the interface you wish to use. The second one is just a location that the script can use for a temporary file.

Sample is here: http://216.138.206.6/test.php

Hopefully this helps someone... it should be especially useful to rackshack folks ;)

I know this is a very old post and there might be some changes in the script thereafter. I just found this one today and I thought I would give it a try. I uploaded the script in my monitoring server and entered the path of the mrtg file for a host in the script and gave the path of the /tmp directory in the script. When I ran the script, it copied the mrtg log file in the /tmp directory, but all I get is 0 MB for all the months in the script. Is there anything wrong with the permissions or I should wait for sometime till the data transfer is displayed.

prashant1979
06-28-2010, 04:22 AM
Got it. I was checking the wrong log file.