Results 1 to 14 of 14
  1. #1
    Join Date
    May 2002
    Location
    Ontario, Canada
    Posts
    11

    Smile Calculate Bandwidth Using MRTG

    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
    Attached Files Attached Files

  2. #2
    Such script already excisted..........

    http://bjorn.swift.st/

  3. #3
    Join Date
    Nov 2000
    Location
    San Diego
    Posts
    3,407
    I am sure someone will appriciate the free script you have put together.

  4. #4
    Join Date
    Nov 2001
    Posts
    852
    Yes thank you for your time, why is everyone so quick to down someone?

  5. #5
    Join Date
    May 2002
    Location
    Ontario, Canada
    Posts
    11
    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.

  6. #6
    Great script, thanks M8 for taking the time to write this. Its most helpfull.

    Thanks,

    Brian

  7. #7
    Join Date
    Aug 2002
    Posts
    655
    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

  8. #8
    You could use mod_watch and with that you can make mrtg graphs. Then you can make bandwidth calculations a virtualhost.

  9. #9
    Join Date
    Aug 2002
    Posts
    655
    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

  10. #10
    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,

  11. #11
    Join Date
    Aug 2002
    Posts
    655
    Yes, can you post the location to the script which read mod_watch log and make mrtg graphs? I want to try this.

  12. #12

  13. #13
    Join Date
    Jul 2007
    Posts
    2,051
    Quote Originally Posted by Justin C View Post
    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.
    Prashant T.

    Don't run after Success. Run after Excellence and Success will soon follow.

  14. #14
    Join Date
    Jul 2007
    Posts
    2,051
    Got it. I was checking the wrong log file.
    Prashant T.

    Don't run after Success. Run after Excellence and Success will soon follow.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •