Networking How to Install and Configure MRTG on Ubuntu Server

79 Comments

(2.28.10) – This post was amended to include minor editorial corrections — iceflatline)

This post will describe how to install and configure Tobi Oetiker’s MRTG (Multi Router Traffic Grapher) on your Ubuntu home server. Once configured, you’ll be able to use it to monitor the traffic in and out of your home network using the SNMP capability in your network’s gateway/router. MRTG generates static HTML pages containing PNG images which provide a visual representation of this traffic. MRTG typically produces daily, weekly, monthly, and yearly graphs. MRTG is written in perl and works on Unix/Linux as well as Windows. MRTG is free software licensed under the GNU GPL.

Software versions used in this post were as follows:

  • Ubuntu Server v10.04 LTS (x64)
  • mrtg_2.16.2-5ubuntu2_i386.deb
  • So, let’s get started.

    Download and Install

    First, download and install MRTG:

    sudo apt-get install mrtg
    

    If this is the first time installing MRTG on your server you’ll likely be presented with the following message. Answering “Yes” means that the default configuration file will be installed with permissions set at 640. Answering “No” means that the permissions are set at 644. In this example we’re going to accept the default Yes. No worries though, if you select No the steps in this tutorial will still work.

    MRTG Message Concerning File Permissions

    MRTG installs a sample configuration file /etc/mrtg.cfg. This file will eventually hold the information obtained from your gateway\router. For a full listing of what MRTG installs and where, run the locate command:

    sudo updatedb && locate mrtg
    

    Technically speaking, mrtg.cfg could remain in /etc, but just to keep things tidy and to help facilitate the startup script that will be discussed later, let’s create a directory for it and move it into that directory:

    sudo mkdir /etc/mrtg && sudo mv /etc/mrtg.cfg /etc/mrtg
    

    That’s it for installing MRTG. Now let’s move on and configure it.

    Configure

    MRTG includes a script called cfgmaker that will help us populate mrtg.cfg with the information obtained from your gateway/router. But before you run cfgmaker, you should setup the SNMP community. This usually involves logging into your gateway/router and enabling SNMP. The default community will typically be “public.” If you change the default community to another name though, make note of it. Now, run the following command, substituting the SNMP community name, if you’ve changed it, and adding the IP address of your gateway/router:

    sudo cfgmaker --output=/etc/mrtg/mrtg.cfg public@your-router's-IP-address
    

    Next, open mrtg.cfg in a text editor and make sure under Global Configiration Options that the line “WorkDir: /var/www/mrtg” (under Debian) is uncommented, and under Global Defaults the line “Options[_]: growright, bits” is uncommented. Finally, add the following lines under the Global Defaults section:

    RunAsDaemon: Yes
    Interval: 5
    Logdir: /var/log/
    EnableIPv6: no
    

    What does all this do? RunAsDaemon will enable MRTG to…um… run as a daemon. This is beneficial because MRTG is launched only once, thus the parsing of mrtg.cfg file is done only once, not repeatedly as would be the case if one were to run MRTG as a cron task – another acceptable method for running MRTG. Also, when running as a daemon, MRTG itself is responsible for timing the measurement intervals; therefore, we need to add the Interval option and assign it a value – in this case 5 (minutes). This means that every five minutes MRTG will update its graphs. We’ve given MRTG a directory to place its log file, and finally, because many routers do not currently support SNMP over IPv6, we’ve shut that off.

    Speaking of graphs, by default MRTG graphs grow to the left, so by adding the option “growright” the direction of the traffic visible in MRTG’s graphs flips causing the current time to be at the right edge of the graph and the history values to the left. We’ve also chosen the “bits” option, which means that the monitored traffic values obtained from your gateway/router are multiplied by 8 and displayed bits per second instead of bytes per second.

    Okay, now it’s time to create the web pages which display the MRTG graphs. Run the following commands:

    sudo mkdir /var/www/mrtg
    sudo indexmaker --output=/var/www/mrtg/index.html /etc/mrtg/mrtg.cfg
    

    MRTG has been configured. Let’s start it up and see what it displays.

    Start

    There’s something important to keep in mind when starting MRTG, and that is that MRTG requires the environmental variable “LANG” to be C in order to run properly. Since most Linux systems these days, including Ubuntu server, use UTF-8 (run echo $LANG to see what your system uses), let’s change LANG to C and start MRTG using the following command:

    sudo env LANG=C /usr/bin/mrtg /etc/mrtg/mrtg.cfg
    

    When you run MRTG for the first time you may see a lot of complaints about missing log files. No worries, this is normal for the first 2-3 times you start MRTG this way. If, however, it continues to complain you may want to look into the source of the problem.

    Well, that’s it. Now point your browser to http://your-server-address/mrtg and you should see a page that resembles the following. You may have more or less graphs depending on the number interfaces reported by your gateway/router.

    Screenshot of default MRTG index page

    Because of the aforementioned options added to mrtg.cfg, you’ll see the graph starting “grow” to the right as the traffic is monitored over time, and the Y axis displayed as bits per second. If you click on any one of these graphs you’ll be taken to another page showing individual graphs for daily, weekly, monthly, and yearly traffic averages, along with the maximum, average, and current bit rate in and out of that particular interface. Only interested in displaying one particular interface? Don’t like the look of the page? No worries, just edit /etc/mrtg/mrtg.cfg and/or /var/www/mrtg/index.html until you get it looking the way you want.

    Okay, so now that we have MRTG installed, configured and running let’s move on and discuss how to keep it running.

    Operate

    Starting MRTG by hand is not ideal in the long run. So perhaps after you’ve done some tweaking on MRTG and are satisfied with the results, you can automate the process of running MRTG by using a startup script in your system startup sequence. Here’s the script that I use:

    #! /bin/sh
    ### BEGIN INIT INFO
    # Provides:          mrtg
    # Required-Start:
    # Required-Stop:
    # Default-Start:     2 3 4 5
    # Default-Stop:      0 1 6
    # Short-Description: mrtg init script
    # Description:       This file is used to start, stop, restart,
    #					 and determined status of the mrtg daemon.
    # Author: 			 iceflatline <iceflatline@gmail.com>
    ### END INIT INFO
    
    ### START OF SCRIPT
    set -e
    # PATH should only include /usr/* if it runs after the mountnfs.sh script
    PATH=/sbin:/usr/sbin:/bin:/usr/bin
    DESC="mrtg"
    NAME=mrtg
    DAEMON=/usr/bin/$NAME
    DAEMON_ARGS="/etc/mrtg/mrtg.cfg"
    PIDFILE=/etc/mrtg/$NAME.pid
    SCRIPTNAME=/etc/init.d/$NAME
    
    # Exit if the mrtg package is not installed
    [ -x "$DAEMON" ] || exit 0
    
    # Load the VERBOSE setting and other rcS variables
    . /lib/init/vars.sh
    
    # Define LSB log_* functions.
    # Depend on lsb-base (>= 3.0-6) to ensure that this file is present.
    . /lib/lsb/init-functions
    
    # Function that starts the mrtg daemon
    start()
    {
    	env LANG=C start-stop-daemon --start --quiet \
    	--exec $DAEMON -- $DAEMON_ARGS
    }
    
    # Function that stops the mrtg daemon
    stop()
    {
    	start-stop-daemon --stop --quiet --retry=TERM/30/KILL/5 \
    	--pidfile $PIDFILE
    }
    
    case "$1" in
      start)
    	log_daemon_msg "Starting $DESC"
    	start
    	case "$?" in
    		0) log_end_msg 0 ;;
    		1) log_end_msg 1 ;;
    	esac
    	;;
      stop)
    	log_daemon_msg "Stopping $DESC"
    	stop
    	case "$?" in
    		0) log_end_msg 0 ;;
    		1) log_end_msg 1 ;;
    	esac
    	;;
      restart|force-reload)
    	log_daemon_msg "Restarting $DESC"
    	stop
    	case "$?" in
    	  0|1)
    		start
    		case "$?" in
    			0) log_end_msg 0 ;;
    			1) log_end_msg 1 ;;
    		esac
    		;;
    	esac
    	;;
    	status)
        status_of_proc "$DAEMON" "$NAME"
        ;;
      *)
    	echo "Usage: $SCRIPTNAME {start|stop|status|restart|force-reload}"
    	;;
    esac
    exit 0
    ### END OF SCRIPT
    

    To use the script, save it to your home directory as mrtg and make it executable. Then move or copy it to /etc/init.d:

    cd ~
    chmod +x mrtg
    sudo mv mrtg /etc/init.d/
    

    Now, link the mrtg script to all of Ubuntu server’s multi-user run levels (2-5):

    sudo update-rc.d mrtg defaults
    

    Now, let’s start MRTG using our script. If it’s currently running then substitute restart for start in the following command:

    sudo /etc/init.d/mrtg start
    

    That’s it. Now if for some reason your server is rebooted, MRTG should fire up automatically (to remove the link from the server’s multi-user run levels, use the command sudo update-rc.d -f mrtg remove).

    Conclusion

    This concludes the post on how to install and configure MRTG on Ubuntu server. As you can see, MRTG isn’t terribly complicated and proves to be a really nice open source package for monitoring and displaying traffic in and out your home network from virtually anywhere you have a web browser. For a full list of all the configuration options and other information I encourage you to visit the MRTG web site.

    References

    http://oss.oetiker.ch/mrtg/doc/index.en.html

    Tags: , ,

    79 Responses to “How to Install and Configure MRTG on Ubuntu Server”

    1. Tim Says:

      Thanks for this great write-up! I am using your startup script, and I think it’s great. I did have some trouble finding the RDDs.pm tool, but a quick “apt-get install librrds-perl” fixed everything!

    2. iceflatline Says:

      Thanks for your kind words Tim, glad you enjoyed the post.

    3. Hamish Says:

      Fantastic. THanks very much :)
      combing Google for hours looking for a good tutorial. As a new linux user I’ve found this was the only one that could lead me to get it working :)

      And that script is fantastic, before that I wasn’t sure how to stop and start it!!!
      Cheers.

    4. iceflatline Says:

      Hamish, you’re very welcome.

    5. ask123 Says:

      HI, thats great , but I’ve problem with this startup script, after Ubuntu bootup it’s telling me: /etc/rc2.d/S99mrtg: 49: –daemon: not found
      And it’s not starup with Ununtu, only manual starup

    6. iceflatline Says:

      ask123, there are a couple of things you might check:

      Make sure that the mrtg.cfg file contains the “RunAsDaemon: yes” line under Global Defaults section;

      make sure the script reflects accurately the locations of the directories and files where you’ve set up MRTG;

      make sure the symbolic links to the script from /etc/rc2.d are correct (you might also make sure the server is starting up in run level 2);

      make sure the mrtg script under /etc/init.d is set is set to be executable by owner, group and other; and finally,

      make sure that mrtg.pid file is being written to /var/run.

      If for some reason these steps don’t get you running, then you might trying running MRTG under cron.

    7. pym93 Says:

      Big props on the great how-to! Very nice, worked like a charm.

    8. iceflatline Says:

      pym93, thanks! Glad you enjoyed it.

    9. hopeful Says:

      thank you iceflatline for sharing this guide..very useful very convenient very useful

    10. Darwis Suryantoro Says:

      Hi, i’m Indonesian. Many thanks for your great tutorial Bro!

    11. iceflatline Says:

      You’re very welcome! Thanks for the comment.

    12. Sontaya Says:

      Thank you for sharing this guide.

      #For openSUSE 11.2, SLES

      $ ln -s /etc/init.d/mrtg /etc/rc2.d/S99mrtg
      $ ln -s /etc/init.d/mrtg /etc/rc2.d/K99mrtg

      Change to:

      $ ln -s /etc/init.d/mrtg /etc/init.d/rc2.d/S99mrtg
      $ ln -s /etc/init.d/mrtg /etc/init.d/rc2.d/K99mrtg

      Regards,
      http://www.susethailand.com/suseforum/

    13. iceflatline Says:

      Thanks Sontaya!

    14. noobie Says:

      Hi,

      Thanks for the great post?
      Any plans for adding password protection to this :>

    15. iceflatline Says:

      noobie, thanks for your comment. I assume you mean password protection for MRTG? I have no plans but perhaps the developer does. You may want to post your question to them directly. However, if all you’re interested in is protecting access to the MRTG page(s) themselves you might consider using a simple approach like an .htaccess file in the MRTG folder root.

    16. Manuel Says:

      @noobie
      You could use an .htaccess in your /var/www/mrtg and setup user/password with the Apache’s “htpasswd” utility, that’s how i password protected mrtg stats on my dedicated server.

    17. sil nic Says:

      Great tutorial!
      Many thanks from Romania :)!

    18. iceflatline Says:

      sil nic, you’re welcome. How’s things in Romania?

    19. Roy Berry Says:

      Just wanted to let you know, your guide is great. Wish some of the others put this very simple procedure so simply. Short, sweet and to the point.

      Thanks from Albany, NY

    20. iceflatline Says:

      Roy, thanks for your kind comments!

    21. Ammar Says:

      Many thanks iceflatline. It’s very helpful for me. I am from IRAQ BAGHDAD. I think nobody like me. But still I like my country, any way I need to ask you, how can I add more than 2 routers. I have 2 dedicated comtech VSAT modems and I need to check there traffic from my end.

      Regards

      Ammar

    22. iceflatline Says:

      Ammar, no worries my friend, not all Americans are the same. You are certainly welcome here. Thanks for taking the time to post, and for your question.

      It’s quite easy to add other SNMP devices. Simply append the additional URL to the cfgmaker command described above, like this:

      sudo cfgmaker --output /etc/mrtg/mrtg.cfg public@your-router's-IP-address public@your-router's-IP-address
      

      See http://oss.oetiker.ch/mrtg/doc/cfgmaker.en.html

    23. Ammar Says:

      IceFaltline ,

      Really I am very grateful to you for your cooperation with me.

      Do you have any idea about how to configure the mrtg on windows?

      Regards
      Ammar

    24. iceflatline Says:

      Ammar, no problem.

      Purportedly Windows is supported, although I have not tried to install it myself. See this article at the MRTG web site.

    25. Ammar Says:

      iceflatline,

      I installed it on windows but the problem when I try to access it http://ipaddress/mrtg .. nothing appears to me.

      Regards

    26. iceflatline Says:

      Ammar, it works a little differently under Windows. First make sure you have followed all the steps called for in the MRTG documentation. Then, run perl mrtg .cfg from your ~:\mrtg\bin directory. Let it run for 5-10 minutes to collect data, then run the command again. Navigate to the WorkDir you created when using cfgmaker and you should find a html file there with the results.

      This other guide may be helpful for you too.

      Good luck!

    27. Iqbal Says:

      First thanks for this nice tutorial!

      I was trying to create mrtg for localhost machine, but having following error. Need some suggestion.

      cfgmaker –output /etc/mrtg/mrtg.cfg public@localhost

      indexmaker –output=/var/www/mrtg/index.html /etc/mrtg/mrtg.cfg
      Use of uninitialized value $first in hash element at /usr/bin/indexmaker line 353

    28. iceflatline Says:

      Iqbal, I’ve not encountered that error before. The fact that you’re using “localhost” as the address suggests that you’re attempting to gather information from the same host you’re installing MRTG on? Perhaps the SNMP daemon in that host is mis-configured? Anyway, a bit of googling on the error suggests this guide may help: http://www.my-guides.net/en/content/view/23/26/.

      Good luck and please post again when you’ve resolved it so others may benefit.

    29. Jargalan Says:

      thats very coooool :)

      thanks a lot from Mongolia UB

    30. luckysanj Says:

      That’s great job…Thanks alot from luckysanj…very very nice hints & nice tutorial..

    31. supernoob Says:

      Hi, thank you very much for sharing this information, I’m having problems at the point to see the page, I’m pointing my browser to http://my-ip-address/mrtg but I get a problem loading page, can you please tell me what I’m doing wrong?

    32. iceflatline Says:

      supernoob, thanks for posting your question. In that step I did not intend for you to literally use the URL “http://your-server-address/mrtg”. My intent there was for you to fill in the actual IP address of your server. So, you should be using something like http://192.168.1.2/mrtg or whatever your IP address happens to be for your Apache web server.

      My apologies for the confusion.

    33. supernoob Says:

      Thank you very much for your reply and support, I did point it to the IP address of the host where I installed the software, I followed all the steps and I see data already pulled from the device if I edit the mrtg.cfg file, however when I tried to load the page I get the error, I was planning to try today maybe I haven’t enable apache on my ubuntu box, I’m completely new to Ubuntu also. Do you think that can be the case?

    34. supernoob Says:

      iceflatline I really appreciate the work you have done here, I got it to work. I was missing the apache installation and after that it worked perfectly!! Thank you.

    35. iceflatline Says:

      supernoob, yup, that would certainly be a problem! I’m glad you got it running. Thanks for posting back.

    36. Thom Says:

      Thx for this very detailed tutorial… I’m also stuck on the error :

      “Use of uninitialized value $first in hash element at /usr/bin/indexmaker line 353.”

      The link that you have provided above doesn’t give me hint for a possible solution. What do you mean with : “perhaps the SNMP server in the host is mis-configured?”

    37. vaibhav Says:

      Thanks for the totorial…….but i encountered a following error……..

      I am trying to install mrtg….i am in the last step in completing the process but when i entered the command..
      indexmaker –output=/var/www/mrtg/index.html /etc/mrtg/mrtg.cfg
      it gives the following error.
      Use of uninitialized value $first in hash element at /usr/bin/indexmaker line 353.

      I searched it on google but i don’t get the proper answer..plz help me out..

    38. iceflatline Says:

      I have not encountered this error before. I’ll see if I can duplicate it.

    39. iceflatline Says:

      I have run through the steps discussed in the post, installing MRTG on Ubuntu Server v10.04 LTS (x64), and polling a gateway at 192.168.10.1 with a SNMP community string of “public.” This setup worked fine and I encountered no errors when configuring MRTG. I would suggest making sure that SNMP daemon in the device your trying to poll is setup correctly and that you are using the correct URL and SNMP community string (typically “public”).

    40. Leif Madsen Says:

      Worked great first try! The init.d script was especially helpful. Great job!

    41. iceflatline Says:

      My pleasure Leif, thanks for your comments.

    42. Niclas Says:

      Terrific! Epic guide.

    43. iceflatline Says:

      My pleasure Niclas, thanks for the kind words.

    44. Tharaka Says:

      Wow, Thanks a lot coz I was struggled with this for few days with windows and now its working nicely. Thanks again.. ;)

    45. iceflatline Says:

      Tharaka, excellent; glad it helped.

    46. cyberfido Says:

      thank you very much for the guide.
      I was breaking my head yesterday both from the Tobi Oetiker’s and others to understand how to install mrtg.
      This morning I’ve found your site and the solution to my problems.
      I’ve successfully installed, configured and started mrtg.
      Really thanks!
      Greetings from Italy! :)

    47. iceflatline Says:

      Ciao cyberfido. You’re welcome, I’m glad the post was of help to you.

    48. katsumoto Says:

      thank you so much for the easy to follow guide. i encountered a problem though. i followed the procedure carefully but the graph failed to start. here what shows up after i put “http://ipa.ddr.ess/mrtg/” in the browser:

      Not Found

      The requested URL /mrtg/ was not found on this server.
      Apache/2.2.14 (Ubuntu) Server at ipa.ddr.ess Port 80

      Below what happens in the cli when I execute “mrtg”:

      katsumoto@ubentoboxx:~$ mrtg
      ———————————————————————–
      ERROR: Mrtg will most likely not work properly when the environment
      variable LANG is set to UTF-8. Please run mrtg in an environment
      where this is not the case. Try the following command to start:

      env LANG=C /usr/bin/mrtg
      ———————————————————————–
      katsumoto@ubentoboxx:~$
      katsumoto@ubentoboxx:~$

      I did try to execute “sudo env LANG=C /usr/bin/mrtg /etc/mrtg/mrtg.cfg” a couple of times though hoping to clear the error. Any help is appreciated.

    49. iceflatline Says:

      katsumoto, sorry you’re encountered difficulties. It appears MRTG isn’t starting for you. You can use ps -e | grep mrtg to confirm. What version of Ubuntu server did you use? Is it possible that MRTG did not get installed at /usr/bin/ or its config file at /etc/mrtg/mrtg.cfg?

    50. katsumoto Says:

      this is my Ubuntu server version:

      Linux 2.6.32-33-generic-pae #70-Ubuntu SMP i686 GNU/Linux
      Ubuntu 10.04.2 LTS

      the daemon is running and MRTG is properly installed at /usr/bin/ and config file looks good a /etc/mrtg/mrtg.cfg though

    51. iceflatline Says:

      katsumoto, thanks. I am running 10.04.3 and it seems to work fine for me as of a few minutes ago. Are you sure that mrtg is running? If so, it’s unclear to me why you would be getting that error.

    52. MrtgProblem Says:

      ERROR: Creating templock /var/lock/mrtg/_etc_mrtg_mrtg.cfg_l_1688: No such file or directory at /usr/bin/mrtg line 1833.

      I installed after your steps first mrtg working good but after use your script is not working where is the problem. I dont have installed mrtg in /var/lock/mrtg ????

    53. iceflatline Says:

      MrtgProblem, when MRTG starts it creates two files: /etc/mrtg/mrtg.pid and /var/lock/mrtg/_etc_mrtg_mrtg.cfg_l. Remove these two files and/or any other *.pid or *.cfg files that may be contained within these those two directories, then start MRTG manually using

      sudo env LANG=C /usr/bin/mrtg /etc/mrtg/mrtg.cfg 

      and verify it works. If it does, then run

       sudo killall mrtg

      to stop it and then start it again using the script

      sudo /etc/init.d/mrtg start
    54. MrtgProblem Says:

      i dont have this files in /etc/mrtg only mrtg.cfg but still not working

    55. iceflatline Says:

      MrtgProblem, sorry you’re having problems. I have not encountered that error before and I verified today that the steps as written do work on both Ubuntu Server v10.04.3 x64 and v11.04 x64.

      Which version of Ubuntu Server are you using? Are you saying that MRTG will start if you use the command sudo env LANG=C /usr/bin/mrtg /etc/mrtg/mrtg.cfg, but not if you use the script?

    56. MrtgProblem Says:

      if i want start mrtg
      sudo env LANG=C /usr/bin/mrtg /etc/mrtg/mrtg.cfg
      [sudo] password for black:
      2011-08-04 09:40:23: ERROR: Creating templock /var/lock/mrtg/_etc_mrtg_mrtg.cfg_l_5603: No such file or directory at /usr/bin/mrtg line 1833.

      it not working mrtg stop working after use your script and reboot machine
      use UBUNTU 10.04.3

    57. iceflatline Says:

      MrtgProblem, my inelegant advice at this point would be to completely uninstall MRTG from your system and start over. Make sure to use the search tool of your choice to find and delete any leftovers (e.g. /var/log/mrtg and /var/www/mrtg). Another thing to keep in mind when/if reinstalling is there is no requirement to run the script. You could simply start MRTG manually or run it under cron. Good luck and I hope you get it running.

    58. MrtgProblem Says:

      if i reinstall mrtg ist working but after install your script its down, i must try with cron ;) ok thx

    59. luckysanj Says:

      Wow. really a very appreciated work man…
      Now i want to one things more…i got mrtg graph of my router Fast ethernet port 1 to 4 but Can u suggest me how can i fetch the particular IP’s usage used on ether3 interface which are on vlan.

    60. iceflatline Says:

      luckysanj, having not done that before I’m unsure; however, you might try looking at the Interface by IP section of the MRTG configuration reference to see if that will meet your needs.

    61. ern@krypton Says:

      Hi Iceflatline, thank you very. This is the best MRTG reference I’ve seen on the net. It works like a charm on a single router. Now, I have a quick question. How would I setup a MRTG to monitor about 80 routers? I have seen your suggestion using the script below for 2 routers but I don’t think it is the best solution for my scenario.

      sudo cfgmaker –output /etc/mrtg/mrtg.cfg public@your-router’s-IP-address public@your-router’s-IP-address

      Any suggestion is highly appreciated.

      Thanks again.

    62. iceflatline Says:

      ern, thanks for your kind words.

      ~80! That’s quite a few, and I’m afraid beyond my practical experiences so far with MRTG. Doing a quick Google search on mrtg+support+multiple+routers, however, suggests there are at least a few threads out there with people discussing how they have approached this level of scaling.

      Good luck and please post back when/if you discover an approach that works for you. I would be interested in knowing.

    63. Has9 Says:

      Thanks for this helpful post,

      i successfully installed and am running MRTG as of right now, i am a beginner at this and still cannot integrate other devices in it, i tried the (sudo cfgmaker –output /etc/mrtg/mrtg.cfg public@your-router’s-IP-address public@your-router’s-IP-address) command but for some reason i cannot add, can you please show how to refresh the page automatically

      thanks

    64. iceflatline Says:

      Has9, my apologies for the delay in responding. The command should work, but make sure the IP addresses are unique. This article and the MRTG page on cfgmaker both have some examples that may be of help.

      Once MRTG is started the page should refresh automatically every five minutes; however, this can be modified by changing the value assigned to the global configuration option Interval from 5 to some other value.

    65. wale89 Says:

      Hi iceflatline..

      Thanks for this helpful article..i really admired your hard work in writing it..

      I have some basic questions to ask..do we have to install first the SNMP & HTTP before proceed with this MRTG tutorial? Do you have any good links to work it on?..since i already stumble upon different version of configuration on the internet but does know which one to choose..

      Thanks in advance =)

    66. iceflatline Says:

      wale89, thank you. You do need to have the SNMP process already up and running in your router, or whatever device you happen to be interested in acquire data from, else the cfgmaker command will return an error. You should also have an http server installed before running the indexmaker command.

      I’m not aware of any links you could simply point your MRTG implementation to.

    67. Mikko Says:

      Greetings from Finland and thank you for great HOWTO. Helped me and a few friends a lot. :)

    68. Suhail Says:

      Thanks guys, for the simple how to guide!!

    69. iceflatline Says:

      Mikko, Suhail, thank you kindly for your comments.

    70. rashmani Says:

      Hey iceflatline,

      just performed a test (ubuntu) and a production (debian) install following your tutorial: everything went veeery smooth.
      Supercool, thanks a ton!
      I’ve only added a very simple timer contdown (abt. 5 lines) to the page, which I believe would be a useful feature for indexmaker to have.

      Cheers,
      rash*

    71. iceflatline Says:

      rashmani, awesome. Glad it worked well for you. The countdown timer does sound useful. Would you mind posting the code when time permits? Thanks!

    72. bhargavi Says:

      Dear iceflatline,

      i installed and configure as it is in tutorial but my graph was not updating showing 17mbps and was not updatingg,,, any sugetions

    73. iceflatline Says:

      bhargavi, I’m not sure. Assuming you’ve followed the instructions correctly, it should update every 5 minutes. I would suggest going back over the instructions making sure each step is followed. I’ve installed MRTG many times as described and it has not failed to work.

    74. Andrew Says:

      Hello. Thanks for the excellent guide. When using your startup script I get the following:

      root@apollo:/etc/init.d# update-rc.d mrtg defaults
      update-rc.d: warning: /etc/init.d/mrtg missing LSB keyword ‘required-start’

      update-rc.d: warning: /etc/init.d/mrtg missing LSB keyword ‘required-stop’

      update-rc.d: warning: /etc/init.d/mrtg missing LSB keyword ‘default-start’

      update-rc.d: warning: /etc/init.d/mrtg missing LSB keyword ‘default-stop’

      Adding system startup for /etc/init.d/mrtg …
      /etc/rc0.d/K20mrtg -> ../init.d/mrtg
      /etc/rc1.d/K20mrtg -> ../init.d/mrtg
      /etc/rc6.d/K20mrtg -> ../init.d/mrtg
      /etc/rc2.d/S20mrtg -> ../init.d/mrtg
      /etc/rc3.d/S20mrtg -> ../init.d/mrtg
      /etc/rc4.d/S20mrtg -> ../init.d/mrtg
      /etc/rc5.d/S20mrtg -> ../init.d/mrtg
      root@apollo:/etc/init.d# /etc/init.d/mrtg status
      /etc/init.d/mrtg: 73: Syntax error: word unexpected

      Any thoughts? (Ubuntu 10.04.3 LTS )

    75. iceflatline Says:

      Andrew: It appears you’ve got something wrong with the script you’re using to start/stop/restart MRTG. If you’re using the one provided in the post it should work as is – I’ve used it many times. If you’ve modified it or are using something else, I would suggest going back over it to make sure it’s coded correctly.

    76. Andrew Says:

      Ice – I found the problem… a few lines concatenated at the end instead of needed line breaks. However, once that’s fixed, trying to start mrtg via the script gives me a permission denied. The script is owned by root, executable, and the mrtg binary is owned by root. I can start it just fine without the script with “env LANG=C /usr/bin/mrtg /etc/mrtg/mrtg.cfg –logging /var/log/mrtg.log”.

    77. Andrew Says:

      I’ll do more checking, I have a feeling there be other problems in copying the file… thanks again for the article.

    78. Andrew Says:

      Success. Your script is fine, but need to be careful that it is copied correctly.

    79. iceflatline Says:

      Andrew: Thanks for your kind comments and taking the time to post. I’m glad it’s working for you.

    Leave a Reply