Page 1 of 2 12 LastLast
Results 1 to 15 of 22

Thread: How-To MRTG bandwidth monitoring utility

  1. #1
    Join Date
    Dec 2007
    Location
    The Netherlands - Eindhoven
    Posts
    1,767

    How-To MRTG bandwidth monitoring utility

    Do you want to measure what's going in and what's going out your router? I always did, and after some searching I found a tool to do this and plot it in a graph


    I found MRTG which is the predecessor of RRDtool, used by the largest internet exchange in the world: Amsterdam Internet Exchange
    Now, RRDtool is nice, but it will be too advanced for what we want to do, so in this how-to we'll stick to MRTG which does the job just as well
    The good thing about this monitor is that it only polls once every 5 minutes, so it uses hardly any CPU and will allow the harddrive to spin down now and then.


    Before you begin
    You need a proper IPKG setup (e.g. from wengi's how-to).
    Also you need to activate the SNMP server in the webadmin interface:

    Set it up like in this screenshot
    Furthermore, you need some way to access the generated graphs, this can be done via a samba share or a webserver.


    Installing
    It's as easy as executing:
    ipkg install mrtg
    Creating config files
    The IPKG package doesn't come with configuration files since they're different for every system!
    Before you can generate a config file you NEED to make sure the SNMP server is up and running.
    Adjust the workdir to your needs, this workdir should be accessible via samba or a webserver. Also don't forget to create the folder before you assign it.
    /opt/bin/cfgmaker --global 'WorkDir: /tmp/mnt/share/mrtg' --global 'RunAsDaemon: Yes' --global 'Options[_]: bits,growright' --output /opt/etc/mrtg.cfg public@localhost
    now wait a few seconds while the configuration is being made.

    Making a startupscript
    vi /opt/etc/init.d/S99mrtg
    and paste the code:
    #!/bin/sh
    if [ -n "`pidof mrtg`" ]; then
    killall mrtg 2>/dev/null
    fi
    /opt/bin/mrtg /opt/etc/mrtg.cfg
    save it and make it executable:
    chmod +x /opt/etc/init.d/S99mrtg

    Starting and monitoring
    Just execute
    /opt/etc/init.d/S99mrtg
    and it should start monitoring.
    Now just browse to the folder you put as workdir (either via samba or webserver).
    You'll see a few html pages called "localhost_x.html" (where x is a number).
    Just open up one of those files and the browser should open a page about a single network interface containing daily, weekly, monthly and yearly graphs.
    Usually "eth1" is the WAN port (where the internet goes in) so there you can see all the results for internet usage.

    Note that the speeds are displayed in bits per second meaning you have to devide the numbers by 8 to get the bytes per second.

    the end
    I hope you'll have fun monitoring.


    some extra: http://wl500g.info/showpost.php?p=205121&postcount=18
    kolaCZek made a nice post about some other scripts to monitor cpu load, memory usage and ping
    Just put the mrtg settings in the mrtg.cfg config file and the bash scripts in /opt/etc/mrtg (like described in the target information)
    don't forget to chmod +x /some/file the bash scripts to make them executable
    Last edited by wpte; 30-07-2010 at 03:15.

  2. #2
    Hi,
    Thanks for the info, looks like an interesting and fun addition to my router setup, however a couple of errors must be present (at least, according to me...):
    RunAsDeamon: Yes is misspelled, and should be (obviously)

    RunAsDaemon: Yes

    That is the easy one.

    I also get an error when running configmaker at the command "public@localhost". I guess a command is missing.

    I also cannot make sense of the final part of your tutorial, where you put some code for speed correction. I can see no obvious location to put in the code; if I paste the code in the mrtg.cfg an error occurs.

    I hope you understand the problems I encounter, and give a corrected code!
    Thanks in advance
    Ecori

  3. #3
    Join Date
    Dec 2007
    Location
    The Netherlands - Eindhoven
    Posts
    1,767
    Quote Originally Posted by ecori View Post
    Hi,
    Thanks for the info, looks like an interesting and fun addition to my router setup, however a couple of errors must be present (at least, according to me...):
    RunAsDeamon: Yes is misspelled, and should be (obviously)

    RunAsDaemon: Yes

    That is the easy one.

    I also get an error when running configmaker at the command "public@localhost". I guess a command is missing.

    I also cannot make sense of the final part of your tutorial, where you put some code for speed correction. I can see no obvious location to put in the code; if I paste the code in the mrtg.cfg an error occurs.

    I hope you understand the problems I encounter, and give a corrected code!
    Thanks in advance
    Ecori
    Yes sorry, fixed that typo!

    I made the how-to a bit easier now, there is no more editing of the config file, just the command to create it.
    The command should just work fine, be sure you didn't remove any quotation marks while editing the workdir.
    Also you MUST enable the SNMP server (that's the public@localhost part), since this program uses it to gather data

  4. #4
    Thanks,
    much easier now, but still contains the typo en deamon - daemon. Indeed SNMP was activated, but the router was not rebooted.
    Install worked fine now, waiting for the results. Process is running as indicated by ps axf.
    Regards,
    Ecori

  5. #5
    Join Date
    Dec 2007
    Location
    The Netherlands - Eindhoven
    Posts
    1,767
    Quote Originally Posted by ecori View Post
    Thanks,
    much easier now, but still contains the typo en deamon - daemon. Indeed SNMP was activated, but the router was not rebooted.
    Install worked fine now, waiting for the results. Process is running as indicated by ps axf.
    Regards,
    Ecori
    good good
    My graphs usually only show spikes, because they are a lot bigger than the usual internet usage.
    But the weekly and monthly graphs look quite nice

  6. #6
    Well, everything seems to be working great. Nice graphs, good overview. What I miss though is the total amount of traffic, what is the amount uploaded and downloaded in a day, week or month. Would be interested to see the total amount of traffic. Since this tool records the traffic activity during the day, can't we use it also for that purpose?
    Regards,
    Ecori

  7. #7
    Join Date
    Dec 2007
    Location
    The Netherlands - Eindhoven
    Posts
    1,767
    Quote Originally Posted by ecori View Post
    Well, everything seems to be working great. Nice graphs, good overview. What I miss though is the total amount of traffic, what is the amount uploaded and downloaded in a day, week or month. Would be interested to see the total amount of traffic. Since this tool records the traffic activity during the day, can't we use it also for that purpose?
    Regards,
    Ecori
    Yes, that's one of the downsides I guess.
    I found this very short article on the MRTG documentation: http://oss.oetiker.ch/mrtg/doc/mrtg-traffic-sum.en.html
    it should make a summary for 1 month... so I guess that might contain the total amount of bandwidth used

  8. #8
    Join Date
    Jul 2008
    Location
    Groningen, Netherlands
    Posts
    12
    Thanks!

    Once, I gave it a try to do it myself, but didn't work.

    This works like a dream!
    Asus WL-500g.Premium with Oleg firmware version 1.9.2.7-10. dropbear - samba - lighttp - php - mysql - ftp - nzbget - transmission - mediatomb - syslog-ng

  9. #9
    How can I use vlan1?

  10. #10
    Join Date
    Dec 2007
    Location
    The Netherlands - Eindhoven
    Posts
    1,767
    Quote Originally Posted by bebef_1987 View Post
    How can I use vlan1?
    if it doesn't appear in the HTML files you need to uncomment it.
    mrtg automatically filters out interfaces that do not return any speed. This is a problem of the build-in SNMP server and a bit thanks to the kernel as well. The problem is partially fixed thanks to lly: http://code.google.com/p/wl500g/issu...mmary%20Opened

    BUT you can comment out an interface in the config yourself, not sure if everything will go allright that way
    vi /opt/etc/mrtg.cfg
    a bit after where it says "System", "Description", "Contact" and "Location" you'll see all the network interfaces listed by the automatic configuration tool.

    you just need to scroll down and find your vlan
    it probably says:
    ### The following interface is commented out because:
    ### * has a speed of 0 which makes no sense
    Just remove all the # from where it says "Target" to the very last "</div>" belonging to that interface.
    Save it and restart mrtg:
    /opt/etc/init.d/S99mrtg
    I hope that works

  11. #11
    i'v uncomented the interface last night and it worked but on my router (wl500gp-v2) the WAN interface is Vlan1 as i see it. At least this is the interface with the extranet ip. so i shoud use this interface or one of the other ones...

    P.S. sry for my english it is a little rusty

  12. #12
    Join Date
    Dec 2007
    Location
    The Netherlands - Eindhoven
    Posts
    1,767
    Quote Originally Posted by bebef_1987 View Post
    i'v uncomented the interface last night and it worked but on my router (wl500gp-v2) the WAN interface is Vlan1 as i see it. At least this is the interface with the extranet ip. so i shoud use this interface or one of the other ones...

    P.S. sry for my english it is a little rusty
    yeh, vlan1 should be ok when you don't use auto dhcp or static ip for the WAN side

  13. #13
    and if i use static witch interface shoud i use?

  14. #14
    Join Date
    Dec 2007
    Location
    The Netherlands - Eindhoven
    Posts
    1,767
    Quote Originally Posted by bebef_1987 View Post
    and if i use static witch interface shoud i use?
    then eth1 should be the one as far as I know
    it has the WAN ip over here, so I guess that's the right one

  15. #15
    Quote Originally Posted by wpte View Post
    and it should start monitoring.
    Now just browse to the folder you put as workdir (either via samba or webserver).
    You'll see a few html pages called "localhost_x.html" (where x is a number).
    Can't find .html files. In the specified directory appeared three files:

    mrtg-l.png
    mrtg-m.png
    mrtg-r.png

    and no one .html

    In /opt/etc/mrtg.cfg (which was left 'as-is' after creation) have two uncommented interfaces - eth0, eth1

    Processes snmpd and mrtg are running.

    Any sudgessions how to check what's wrong?

    May be I've not installed some additional libraryes? Can you paste here output of 'ipkg list_installed' from your router?
    Last edited by andrewak; 05-03-2010 at 15:20.

Page 1 of 2 12 LastLast

Similar Threads

  1. Bandwidth Management, static leases not working
    By AugustsZ in forum WL-500w Q&A
    Replies: 1
    Last Post: 12-01-2011, 05:26
  2. Bandwidth management
    By smarttowers in forum WL-500gP Q&A
    Replies: 0
    Last Post: 07-12-2008, 09:13

Tags for this Thread

Posting Permissions

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