MRTG with RRDtool and Routers2 – Installation from Scratch

I always wanted to monitor my private network with an open source tool. Since I knew some nice statistics, e.g. from the DE-CIX (printed with RRDtool) or from the Uni-Gießen (generated with MRTG), I had the idea of installing such a system by myself. Luckily I found a book from Steve Shipway, called “Using MRTG with RRDtool and Routers2“, which actually disappointed me because it did not offer a complete installation guide but mainly further information about fine-tuning the appropriate tools.

Therefore, I want to show a complete step-by-step installation of all the needed tools in order to monitor a network with MRTG, RRDtool and Routers2.  “From scratch” means that there are no prerequisite to this installation guide except a plain Linux server (in my case a Ubuntu Linux) such as presented here. Okay, let’s go:

Please note: Though I am still using this setup in 2019, it is not state of the art anymore when it comes to network and system monitoring. Please consider using a more modern solution such as Zabbix or Icinga, whatever fits your needs.


In order to use all features that I explain in the next sections, the following tools must be installed on the system. Of course, all these packages can be installed step-by-step, but I think it is easier to install them at once. Here is the list:

The installation requires round about 60 packages. Attention: The installation process from MRTG asks a single question, whether or not the root user should be the only one who can read the default configuration file from MRTG (/etc/mrtg.cfg). In our scenario, this can be answered with “Yes”, which is also the default option in this question.

Webserver: Apache

We just installed the apache web server. ;) It is already running in the background and can be tested with a browser that accesses the IP address/domain name of the server. If you see the standard “It works!” page you are right. (The following paragraph is only for further investigations on it.)

  • You can see whether the apache server is running via ps -A | grep apache which should show a few apache2 processes. Furthermore, the command netstat -l should show at least one tcp process that LISTENs on port 80 (http). If you have IPv6 enabled, another tcp6 process also LISTENs on port 80.
  • The configuration can be edited with sudo nano /etc/apache2/apache2.conf (since I am using Ubuntu. Other Linux distributions are using httpd.conf).
  • If you get an error message in your logs similar to this: “apache2: Could not reliably determine the server’s fully qualified domain name, using for ServerName”, you can add a line in the apache2.conf file which starts with ServerName, e.g., “ServerName”.
  • We also already installed the CGI support. In the following file an alias specifies in which directory the CGI scripts must be stored:  cat /etc/apache2/sites-available/default. It is under “/usr/lib/cgi-bin/”.

MRTG and RRDtool

There is not much to say about the blank MRTG installation on a Ubuntu server since it already comes with a pre-configured configuration file (/etc/mrtg.cfg) and also an installed cron job which runs MRTG every five minutes. You can verify that there is a cron job installed as you should have a file called “mrtg” in the “/etc/cron.d/” directory. You can display it via cat /etc/cron.d/mrtg. If you look at your syslog messages with tail /var/log/syslog you should see a few lines similar to the following:

Similarly, the MRTG log is under /var/log/mrtg/mrtg.log .

We must create some folders in order to store our configuration and rrd files. I decided to store the configs under the /etc folder while the rrd files under the /var folder:

Note that RRDtool itself needs no further configuration since it is always used from Routers2 directly and thus needs no specific configuration.


At first, the routers2.cgi package must be downloaded from here. Extract it, cd into the folder and start the installation:

During the installation, several questions are asked and can be answered as follows. (Note that these are only my suggestions! Answer the questions to your needs. The following text only shows the relevant lines):

After this installation process, the configuration file for routers2.cgi can be modified with sudo nano /var/mrtg/routers2.conf. I suggest the following changes in the file: (Refer to the excellent notes in the file itself to fully understand all these settings.)

Modifying the Default mrtg.cfg

Open the file with sudo nano /etc/mrtg.cfg and delete (or #comment) ALL lines. Then add the following lines which are needed for the following reasons:

First Test (Yet Without Any Devices)

With a web browser, access the following page/file: http://<ip-address>/cgi-bin/routers2.cgi.
Since there are no monitored devices (called “targets”) yet, this blank page should look like this:

If so, you are almost done with the base installation of MRTG, RRDtool and Routers2!!! Congratulations! ;)
You can also view the configuration verification of Routers2 when you access the following URL (of course without any targets, too): http://<ip-address>/cgi-bin/routers2.cgi?page=verify.

Forwarding to Routers2.cgi

It is desirable to have a forwarding to the routers2.cgi if only the IP address or domain name of the server is entered. That is, even though only is entered in the browser, the routers2.cgi page should appear. This can be done by adding a few lines to the index.html under /var/www/index.html : Between the  <html>  and the  <body>  tag, the following lines should be inserted, of course with the correct domain name:

From now on, the web page automatically redirects to the routers2.cgi page after a few milliseconds.

Adding Devices/Targets

Since we now have a complete MRTG with RRDtool and Routers2 installation, we can add several devices to monitor, e.g., network routers and switches, firewalls, servers, and/or even other interesting values to monitor, such as ping-times to a remote server, temperature values, firewall statistics, etc. I will explain the adding procedure for various targets into MRTG in later posts. However, here comes a rough overview:

Querying SNMP values

The first step is always to activate SNMP on the appropriate device. I recommend to use different community strings (i.e., passwords) for every single device! After that, the querying of SNMP can be tested from the Linux server with the tools from snmp, e.g., snmpwalk. Here is an example with the first few lines from requesting a Juniper SSG firewall:

For gathering information about the MIBs that the device supports, the brilliant MIB Browser from iReasoning can be used. It is free for personal use an can be downloaded here. It uses a GUI, can load several MIBs and is able to request the whole SNMP tree via “Get Subtree”. Really good! Here is a screenshot with the output of the NetscreenVpnMonitor MIB:

iReasoning MIB Browser

With these information, precise SNMP OIDs can be queried with MRTG, etc.

Building the MRTG/Routers2 Configuration

Finally, the *.cfg files for MRTG/Routers2 must be created. The tool cfgmaker which ships directly with MRTG can be used for the basic gathering of interfaces of routers and switches, such as:

Note that you can use host templates and interface templates with cfgmaker. [Comment by Steve added here:] “These are scripts that add additional Targets either on a per-device or per-interface basis. For example, the correct host template will add Targets to monitor CPU, Memory, disk space, and so on at the same time as creating all the Interface targets. You can download some templates that work with most hosts and devices from”

Also note that I wrote several posts about adding other devices to MRTG/routers2. Use this category to search for them on my blog.

MRTG on the Raspberry Pi?

Since the RPi is quite popular these days, it would be a good use case to run MRTG and the other programs on it. I tried it (Model B) and my short summary is: Everything runs without problems – but it is really slow. I have monitored a few switches with 24 ports each, and the RPi took a few seconds for every refresh of the summary page. This is because the Routers2.cgi generates all RRD images on the fly which consumes lots of CPU power. That is: I stopped running MRTG on the RPi because it was simply to slow.

Okay, finished for today! ;)

[Update] 1 Minute Interval

Just a quick update for running MRTG on a 1 minute interval rather than on 5 minutes:

Run the cron job every minute, change the first number from 5 to 1:

Set the MRTG option to 1:

Set routers2 to display the 6 hour graphs:

And delete all already existing rrd files in order to have them created with the 1 minute interval (make a backup before you are deleting them!):

Featured image: “control centre” by pristyles is licensed under CC BY-NC 2.0.

67 thoughts on “MRTG with RRDtool and Routers2 – Installation from Scratch

  1. Sorry you were a little disappointed due to the lack of detailed installation instructions in the book.
    The problem I had was that there are simply way too many different platforms under which the software can be installed, plus several different ways that it can be installed and managed on a given system, and I could not give detailed instructions for all of them. Your instructions above are great, and very detailed; but are specifically for one way of installing under Debian. I would have also needed to cover Redhat, Solaris, AIX, and of course Windows…
    As I result I went lighter on the ‘how to install’ (since the individual packages come with their own instructions) and heavier on the ‘how to use it and make the most of it’. Hopefully, you found the book much more useful in this area.

    1. Hey Steve. I appreciate it to see your comment here.
      Yes, I am still using your book. It was a good starting point to see, what routers2 can do at all. And it is still a reference for all the options. ;)

  2. Hi Johonnes,

    Any idea why I get this error:

    Error reading RRD database /var/mrtg/
    opening ‘/var/mrtg/’: No such file or directory
    Check that MRTG has run successfully on this device, and has created the RRD file.

    I followed your guide step by step..

    Also, when I try to manually run MRTG.. i get an error saying that /var/mrtg is not created.. when it is created…


    1. Hi Carlos,

      this might have something to do with the permission of that /var/mrtg/ directory. Maybe mrtg is not able to create the rrd file. Have you created it as sudo? If you do a “ls -ahl /var/” on your machine, what are the permission on the mrtg folder? Something like this?:
      drwxr-xr-x 2 root root 20K Aug 13 08:51 mrtg

      1. Hi Johonnes

        Thanks for a great write-up, I’m still facing the issue that is on the subject. I have the same permission you indicate but no luck. Any other options


    2. This really looks like permissions on the /var/mrtg directory are wrong. Make sure the directory has write permission to (or is owned by) the MRTG process.

    1. Hm, I am sorry, but I don’t know any further hints right now.
      I hope that you have correctly used a Target[], Title[], MaxBytes[] triple to have an rrd file created without any other errors. But if it is still not created, I do not know. Maybe you can post your issue on the forum from Steve Shipway (

    2. Either you have wrong permissions on /var/mrtg — no write permission to the MRTG process, or /var is full, or you have not set ‘WorkDir:/var/mrtg’ in your cfg files (so they are being created elsewhere), or you have string SELinux operating which is denying write permission to /var/mrtg, or MRTG is not running (try running it interactively to test)

  3. The “Error reading RRD” message appears when the RRD file cannot be read, either because of file or directory access permission, or because the RRD file mentioned does not exist. The usual reason is that it does not exist; the RRD file is created by the first *successful* run of MRTG against the Target.

    Possible causes for this would be —
    0. File permissions. The file exists but is owned by the wrong user – maybe you ran an initial test as the ‘root’ user then run subsequent updates as ‘mrtg’, but the file does not have read permission for the web process.
    1. directory permissions. The MRTG process does not have write permission to the directory to create the file
    2. file system full or quota restrictions
    3. The MRTG process cannot retrieve the data. Possibly the SNMP community or ACL for the device are wrong, so it cannot collect the data. The RRD file will not be created if it does not have data.
    4. The cfg file is incorrectly set to ‘native’ mode — IE, it does not have LogFormat:rrdtool defined. In this case it will write a .log file, not a .rrd file
    5. The MRTG process has not run. Maybe your MRTG daemon has died, or you have a scheduler that is not running? Maybe you have not scheduled a run against this cfg file?
    6. The MRTG daemon has not updated. Maybe you’re using a single daemon with a master.cfg inclusion configuration, but you have not restarted it to cause it to re-read the configuration, and a new cfg file has not been picked up (MRTG 2.17.4 checks file update time to try and re-read where necessary)

    To test this, try switching to the user that MRTG is supposed to run as, and run MRTG interactively against your cfg file. You’ll see any error messages which should help to clear things up — either SNMP errors, or file permission errors. If an interactive run works fine, the issue is likely with your scheduler.

    Hope this helps

  4. Gentlemen,
    This is the error that appeared on my mrtg.log
    ERROR: CFG Error in “logformat”, file /etc/mrtg.cfg line 3: Invalid Logformat ‘rrdtool #Tells MRTG to use RRD instead of its own log format’

    Advise Pls

    1. You are not allowed to do follow-on comment style in MRTG — IE, this is NOT allowed:

      LogFormat: rrdtool # comment here

      You can only do comment lines prepended with whitespace and a #, like this:

      # comment here
      LogFormat: rrdtool

  5. I am getting an error early where I can’t access the http://IPADDRESS/cgi-bin/routers2.cgi, the part that begins First Test (Yet Without Any Devices).

    initially, I got a 404 error “Does not exist”.
    I created a ScriptAlias for usr/lib/cgi-bin
    with the directory.
    THEN I got a second error:
    You don’t have permission to access /cgi-bin/routers2.cgi on this server.

    So, when I thought this was going to be a short and sweet config up to this point, I seem to be going down different rabbit holes. somehow the guide must be assuming that I know more about this than I do, because I think there are steps missing. Or did I miss something?


  6. I thought I had left a comment. I am having issues from the get go on this config. Could be that I’m no expert with either apache or cgi. In any case,when I go to http://ip-address/cgi-bin/routers2.cgi, I get a text file of the routers2.cgi file displayed, OR, if I delete the settings I made, then I get an error that it doesn’t exist.

    So I know I’m not correctly allowing the cgi to be properly displayed. Just don’t know where that is. I don’t see any guides that integrate things like this one, so any help, thanks in advance.

    1. Hi Ryan,

      hm, I am sorry, but I do not know where your problem is. I have done MRTG/routers2 installation with this guide a few times now. Every single step I did is documented here. So maybe you just have skipped a few lines here? (Have you done the fourth point from “Webserver: Apache”?)

    2. If you’re seeing the contents of the CGI file itself, then this means you have an Apache configuration issue – the script is not being run, which means that either you dont have the Apache CGI module installed, or you have not set up ScriptAlias for the directory correctly, or you don’t have the ExecCGI option set (see ). If you are using mod_perl, you may want to use AddHandler and ExecCGI (see the previous link for details)

      Make sure the routers2.cgi has read and execute permission on it, as do the containing directories, and (unless you are using mod_perl) verify the initial #! line correctly gives the path to the perl executable.

      “You dont have permission” errors will mean that you need to check the directory permissions; also and authentication rules you have configured in apache, including any .htaccess directives. Something in Apache is denying you access to the URL.

      Hope this helps…

    3. There is one thing to note that 14.04 uses Doc root is actually /var/www/html this could fix your issue.

  7. Something you may wish to add to your section about using cfgmaker to create MRTG configuratiobs, is that cfgmaker allows you to specify ‘host templates’ and ‘interface templates’. These are scripts that add additional Targets either on a per-device or per-interface basis. For example, the correct host template will add Targets to monitor CPU, Memory, disk space, and so on at the same time as creating all the Interface targets.

    You can download some templates that work with most hosts and devices from

  8. I followed these directions step for step on Ubuntu Server 14 with Apache 2.4. There are 2 steps that helped me get this working.

    1st.) sudo a2enmod cgi
    2nd.) sudo gedit /etc/apache2/sites-available/000-default.conf
    Change /var/www/html to /var/www *basically remote the /html
    3rd.)sudo service apache2 restart

    These steps got it working for me!

  9. just do not forge to change default cfmaker WorkDir to appropriate option…

    cfgmaker –global ‘WorkDir: /var/mrtg’ –output ….

    i made that mistake

    great tutorial…

  10. Is there any step by step to install MRTG With RRDTOOL and routers2 on Windows platform?

    1. The Open Innovations Bundle for Windows can install everything in one go, and they have instructions on their website.

      Unfortunately, they have fairly old versions of Routers2, RRDTool and MRTG, but these can be separately upgraded afterwards using the instructions with the individual applications. Routers2, for example, can be upgraded simply by unpacking the ‘tar’ package and running the ‘’ script, which then identifies the existing installation and upgrades it.

  11. Great job of documenting! I loved to follow your instructions.
    But there are a few things I had to adjust:

    1. Font-Size of the table next to the graph
    It was just too small for me so I adjusted line 84 in
    /var/www/rrdicons/routers2.css (side text on summary page: changed from “smaller” to “small”

    2. Increased height of top frame for larger logo
    I changed line 4933 the parameter “rows” from 50 to whatever fits your logo in

    It would be cool to adjust these things from within /var/mrtg/routers2.conf

    Hope this helps if someone else needs such an adjustment!

  12. Hi Johannes,

    thanks for the documentation, but I have one problem!

    When I go to http://localhost/cgi-bin/routers2.cgi the MRTG Network Monitor ist opening, but there no icons shown.
    And I think the paths are correct!

    Here is the Actice Configuration Settings:
    routers.cgi-actuals = “yes”
    routers.cgi-archive-mode = “hash”
    routers.cgi-bgcolour = “#ffffff”
    routers.cgi-cfgfiles = “*.cfg”
    routers.cgi-compact = “no”
    routers.cgi-confpath = “/etc/mrtg”
    routers.cgi-dayend = “18”
    routers.cgi-daystart = “8”
    routers.cgi-dbpath = “/var/mrtg”
    routers.cgi-defaultinterface = “_summary_”
    routers.cgi-defaulttarget = “summary”
    routers.cgi-extendedtime = “yes”
    routers.cgi-graphpath = “/graphs”
    routers.cgi-graphstyle = “x3”
    routers.cgi-graphtype = “w”
    routers.cgi-graphurl = “/graphs”
    routers.cgi-iconurl = “/rrdicons/”
    routers.cgi-legendunits = “yes”
    routers.cgi-percentile = “yes”
    routers.cgi-showfindbox = “no”
    routers.cgi-showtotal = “yes”
    routers.cgi-slope = “yes”
    routers.cgi-smalliconurl = “/rrdicons/”
    routers.cgi-sorder = “l2 l2D x3 x3D”
    routers.cgi-stylesheet = “/rrdicons/routers2.css”
    routers.cgi-twinmenu = “yes”
    routers.cgi-unscaled = “no”
    routers.cgi-usebigk = “no”
    routers.cgi-windowtitle = “RasPi MRTG Network Monitor”
    routers.cgi-withdate = “yes”
    targetnames-ifdefault = “ai”
    targetnames-routerdefault = “filename”
    web-backurl = “/”
    web-charset = “utf-8”
    web-png = “1”

    Thanks for your help!


    1. You might like to try visiting page http://localhost/cgi-bin/routers2.cgi?page=verify which will test your configuration. If the small target icons are invisible, then this indicates that the smalliconurl does not point to the correct location. If the larger heading icons are invisible, then they may be missing, or you may have installed a language pack incorrectly and ${iconurl}/${language} does not contain the replacement icons.

    2. Hi Carsten,

      I just installed another MRTG with Routers2 and got the same error. After 1-2 hours I found a difference in the apache2 configuration: they changes the DocumentRoot from /var/www to /var/www/html
      I solved it by:
      “sudo nano /etc/apache2/sites-available/000-default.conf”
      and change the edited the following line into:
      “DocumentRoot /var/www”
      Then “sudo service apache2 restart” and it worked.


  13. Hello Steve,
    all icons are invisible….
    How can I install the missing icons and reinstall the language pack?

    1. Check that your iconurl and smalliconurl are correct. Do the paths exist, and they are accessible to the web server? Look in the corresponding directory for the icon files. If they are there then your web server config is wrong. If they are not there, then re-run the script from the routers2 package.

      Looking at your config, it also seems that graphpath and graphurl are incorrect. Make sure that graphpath is the PATH corresponding to the graphurl URL.

  14. Hie Johannes,

    Thanks for a good article, l have been tasked with implementing a monitoring solution for billing purposes…The key deliverable is to store historical data for longer periods of time ,. l want to store daily 5 minute data for 30 days , weekly 10 minute data for 30 days ,monthly 30 minute data for 90 days and yearly 1 day data for 5 years….l am not sure what metrics l should use in creating metrics for these graphs…

    1. Hi Jikamsila,

      as far as I know it is not that simple to further extend the storing of historical data. Routers2.cgi as well as MRTG use almost always these default values. Please refer to the MRTG or Routers2 documentation. I cannot help you with this, sorry.

    2. If you have the latest version of Routers2, then it supports extended RRD files. There are detailed instructions in the installation docs with the package. Basically, you need to have some MRTG directives in your default MRTG cfg file (so that RRD files are created with the new default larger size) and existing RRD files can be extended using ‘rrdtool tune’. Routers2 will automatically detect these extended RRD files (you need to enable this in the routers2,.conf though).

      The default 5min data is kept for 2 days, but you can extend that as far as you want – note that the disk space requirements will increase proportionally, though. When using ‘rrdtool tune’, RRA number 0 and 1 are the 5min (daily), 2 and 3 are the 30min (weekly), 4 and 5 are the 2h (monthly) and 6 and 7 are the 1day (yearly).

  15. I’m trying to get this running on Ubuntu 16.04.1 Server without any success (as yet). I note (first) that there’s an inconsistency I’ve seen in your documentation where the routers2.cgi setup is being configured. You give the following:
    Configuration file [/var/mrtg/routers2.conf]?

    whereas the configuration default is actually:
    Configuration file [/etc/mrtg/routers2.conf]?

    And along with this, you then have the following line:
    After this installation process, the configuration file for routers2.cgi can be modified with sudo nano /var/mrtg/routers2.conf.

    Should this actually be:
    sudo nano /etc/mrtg/routers2.conf

    The next step (First Test without any devices) is where I come unstuck – I get the following error message:

    500 Internal Server Error

    Internal Server Error

    The server encountered an internal error or misconfiguration and was unable to complete your request.

    Please contact the server administrator at webmaster@localhost to inform them of the time this error occurred, and the actions you performed just before this error.

    More information about this error may be available in the server error log.

    Apache/2.4.18 (Ubuntu) Server at Port 80

    1. Check your apache error log; the most likely cause of this is that you have some perl modules missing on your system, or even perl has not been installed correctly. The error log should give you proper information. Another possibliity is incorrect file permissions, though the script will usually catch these.

      Also, you can run the routers2.cgi script direct from the commandline (don’t do this as root) which should give you relevant error messages.

      The installation process does a bit of intelligent system checking, and so will give a different default location in some cases, if it discovers that you have installed your web server in a different way, or if certain things are already installed. This is likely why you have a different default to the one in the original example.

      1. running /usr/lib/cgi-bin/routers2.cgi gives the following error message:
        Can’t locate in @INC (you may need to install the CGI module) (@INC contains: /etc/perl /usr/local/lib/x86_64-linux-gnu/perl/5.22.1 /usr/local/share/perl/5.22.1 /usr/lib/x86_64-linux-gnu/perl5/5.22 /usr/share/perl5 /usr/lib/x86_64-linux-gnu/perl/5.22 /usr/share/perl/5.22 /usr/local/lib/site_perl /usr/lib/x86_64-linux-gnu/perl-base .) at /usr/lib/cgi-bin/routers2.cgi line 29.
        BEGIN failed–compilation aborted at /usr/lib/cgi-bin/routers2.cgi line 29.

        When I check using “a2enmod cgi”, as JKroll mentioned above, I had to run this to enable CGI before, it reports:
        Your MPM seems to be threaded. Selecting cgid instead of cgi.
        Module cgid already enabled

        The error in the apache error.log is the same as the router2.cgi output.

        Aside from running on Ubuntu Server 16.04.1 (not 13.04 which looks like the last LTS version as of the original date of this post), I’ve done everything else as per the blog post – including the additional steps as detailed by Johannes in response to Carsten in the comments (which I think Johannes actually meant:
        “and change the edited the following line into:
        “DocumentRoot /var/www/html”

        Still looks like the cgi-bin stuff is faulting here and I’m not sure why. Again, using Ubuntu Server 16.04.1 with everything else as per this blog.

        1. The Routers2 script requires the Perl CGI module to run; without this installed, it fails, as you see. The a2enmod command only enables the embedded Perl CGI support in Apache; you need to install the CGI Perl module.

          Try installing libcgi-pm-perl and see if this fixes things; otherwise, it may be overkill, but under Ubuntu, try installing libcgi-application-basic-plugin-bundle-perl which should pull in the CGI module (and a fair bit more besides)

  16. Hy guys, ty for this tutorial i need a large help because im big newbie on linux

    i have a problem on step: First Test (Yet Without Any Devices)

    i just cant get that to work, just getting error 404 not found response…

    so things i got: ubuntu server properly working and updated
    installed all programs and apache2 is up and running, same with mrtg

    so only problem i think is routers… do i need to turn it on somehow? do i need to make changes to apache cfg or what do i need to do that isnt explained in tutorial to get that test monitor page?

    sry for this kind of questions…

    1. sry guys, dont bother previous comments solved my issue

      resolved with: sudo a2enmod cgi
      service apache2 restart

  17. Guten Abend,

    vor ein paar Tagen hatte ich eine Frage zum Thema MRTG bereits per Mail gestellt. Natürlich macht es mehr Sinn dies entsprechend direkt unter diesen Blog hier zu setzen um eventuell anderen damit gleich mit zu helfen.

    Seit längerer Zeit besitze ich zwei Raspberry Pi an zwei verschiedenen Standorten um mehrere Geräte zu überwachen und FritzDect Cometen sowie Fritz DECT Geräte zu monitoren. Nun bin ich vor längerer Zeit über den Fakt gestolpert welcher mir zwar bewusst war aber in dem Zusammenhang nie in den Kopf gekommen ist: SD Karten mögen es ja eigentlich nicht häufig beschrieben zu werden und sterben eher früher als später. Nun stellt sich mir die Frage was kann man unternehmen um diesen Prozess zu verlangsamen? Was ich ändern könnte wäre das Auslagern der RRD Dateien da diese teilweise sogar im Minuten Takt geändert werden. Nur wo wird angegeben wo die RRD Dateien sind beziehungsweise was muss alles geändert werden wenn man in einem laufenden System den Speicherort der RRDs verändert?
    Ich würde diese nämlich gern auf meine NAS auslagern. Den dabei aussetzenden Standby nehme ich dabei in Kauf da a) eh WD Red verbaut sind und b) demnächst Dienste (IP-Cams) auf dem NAS laufen werden wo die Platten eh nicht mehr schlafen gehen.

    Auf eine Antwort zu diesem Thema würde ich mich sehr freuen.

    Mit freundlichen Grüßen


    1. Hallo Marcus,

      meine persönliche Erfahrung mit den SD-Karten ist außerordentlich gut! Ich verwende bei meinem Stromzähler-Projekt ebenfalls eine herkömmliche SD-Karte, welche teilweise mehrmals pro Minute (!!!) einen Zählerstand auf der SD-Karte erhöht. Aber bereits seit mehreren Jahren läuft dieser Raspberry Pi ohne Probleme! (Ein anderer Leser hatte gleiches Bedenken ebenfalls geäußert: )

      Obwohl es also *theoretisch* möglich wäre, die RRD Dateien auf ein NAS auszulagern, würde ich sehr davon abraten, weil der MRTG Prozess dann immer erst auf das NAS zugreifen muss, was es verlangsamen würde. Änderungen im Minutentakt auf der SD-Karte sind meiner Meinung nach unkritisch. (Mir hat mal ein IT-Fachmann gesagt, dass die Chips auf den SD-Karten selber sehr gut die Speicherzugriffe verwalten und eine automatische Streuung einbauen. Evtl. gibt es deswegen wenig Probleme bei mir?)

      PS: Mein Problem mit MRTG auf dem Raspberry Pi war eher die generelle Langsamkeit des Pis beim Erstellen der Graphen. Öffnete man eine Seite im Monitoring Server, welche mehrere Graphen erstellen musste, musste man mitunter ein paar Sekunden warten. Dieses Problem würde man mit einem Auslagern der RRD Files ebenfalls nicht lösen können.

      Ok, ich hoffe ich konnte dir trotzdem irgendwie helfen. ;)

      1. Vielen Dank für die Antwort. Das beruhigt mich dann doch etwas. Sicherlich wäre der Weg über das NAS eine Krücke aber wenn die Karten dann doch so viel aushalten passt es. Regelmäßige Backups werde ich aber anlegen für den Fall der Fälle.
        Sobald es jetzt wieder kälter wird werde ich mich nochmal wegen einem anderen Problem melden.

        Vielen dank und liebe Grüße

  18. Hy,

    ich hab mal wieder ein Problem.
    Ich hatte es nun gewagt mein Raspbian Jessie auf Stretch zu upgraden. Lief auch alles relativ gut bis auf Routers2.
    Beim Aufruf bekam ich immer nur einen Error 500 Internal Server Error.
    Ich habe daraufhin PHP und den Lighttp Webserver deinstalliert und wieder installiert und konfiguriert ohne erfolg. Auch ein Upgrade auf PHP7.0 brachte keinen erfolg. Neu setzen der Berechtigungen erfolglos. Ich habe nun ein Backup wieder auf die SD Karte gezogen und frage mich nun ob jemand MRTG mit routers2 nach einem Upgrade oder einer clean install von Raspbian Stretch zum laufen bekommen hat.

    Liebe grüße

    1. Hallo Marcus.

      Wir sagen auf der Arbeit immer spaßeshalber: “Lernen durch Schmerz”. ;) In Update von einem Raspbian geht meiner Erfahrung nach meistens schief. Don’t touch a running system. Solange du nicht *wirklich* neue Features brauchst oder das Teil im Internet erreichbar ist und du somit auf Security-Updates angewiesen bist, würde ich es NICHT auf eine neue Major-Version bringen, sondern lediglich kleine Updates installieren.

      In der Tat hatte auch ich vor einiger Zeit mal große Probleme, meine MRTG Installation von einem (mittlerweile nicht mehr supporteten) Ubuntu 12.04 LTS auf ein Ubuntu 14.04 LTS zu heben. Nach ca. 2 Stunden habe ich es aufgegeben und habe mein zum Glück vorhandenes Backup zurückgespielt. Seitdem läuft mein MRTG komplett abgeschottet vom Internet fröhlich auf dieser alten Version. Schließlich geht ja alles.

      PS: Stand heute ist MRTG sowieso nicht mehr das Produkt der Wahl wenn es um Monitoring geht. Man nimmt eher sowas wie Cacti oder Zabbix. Auch ich bin gerade am Wechseln. Schau dich doch mal um, was es für schönere und flexiblere Möglichkeiten gibt.


    1. Hey Saiful,

      I am sorry, but I cannot really help you. I know that there are some differences for newer Ubuntu releases and so on. (I think I used Ubuntu 12.04 LTS back then…)

      Also note that I would not recommend the usage of MRTG anymore. It is way too old. Maybe you can try Zabbix or other solutions.


    2. Try checking your web server error log; or else run the routers2.cgi script from the commandline. This should reveal what the actual error is. Likely you have a required module missing, or have the wrong permissions on a directory somewhere

  19. Hi Johannes ,
    Is there any option to alert a condition and notification to user say it reached the threshold in your template or anywhere in routers.cgi?

    1. Hey CY,
      I don’t know, to be honest. If so, I would assume that an alerting function is within MRTG rather than routers2.cgi, since MRTG is the one on which all those SNMP Targets are configured.
      Have you already asked Google?

      1. MRTG stopped working after adding the following, all charts went blank, I’ve defined a ThreshDir that is writeable by the MRTG (chmod 777)
        ThreshDir: /var/run/mrtg
        ThreshProgI[_]: /usr/local/sbin/notify
        ThreshProgOKI[_]: /usr/local/sbin/notify
        ThreshMinI[]: 1000

      2. Hi Steve,
        Per your recommendation I’ve added the following in /etc/mrtg.cfg, all charts MRTG stopped working all charts went blank!


        ThreshDir: /var/run/mrtg
        ThreshProgI[_]: /usr/local/sbin/notify
        ThreshProgOKI[_]: /usr/local/sbin/notify
        ThreshMinI[]: 1000


        1. You will need to make sure your version of MRTG is recent enough to support Thresholds. Run MRTG from the command line and get the error messages which may help. Make sure you have the ThreshMinI line AFTER the respective Target line.

  20. Hi Steve/Johannes,
    I got it works but still see a minor issue where if the threshold set to min say 100, will trigger email notification which is good but it keeps sending notification even numbers above 100.

    Also, wondering if release image can be added into each chart!
    Thank you in advance..

  21. Hi Steve/Johannes,
    i am using Ubuntu 16.04.5 LTS and i am following all steps but First Test (Yet Without Any Devices) http://MYIP/cgi-bin/routers2.cgi but didn’t open page

    This site can’t be reached refused to connect.

    what is the problem and what is the salutation for this issued

    1. There are many things which could be the issue. Try checking these –
      * Make sure your web server service is actually running… start it if necessary
      * Maybe you have SELinux incorrectly configured/enabled?
      * Check your firewall to make sure it isn’t blocked
      * Are you sure you have the web server configured to the right port?
      * Are you sure you have the correct IP and it is reachable (its a private IP so check routing)
      * Try accessing a normal page. If you can’t the problem is with your web server, not Routers2
      * Make sure you have Perl support configured correctly – e.g. mod_perl installed and configured with Apache, etc

      1. I am seeing the same problem.

        When I visit the landing page I see:

        refused to connect in every FRAME.

        When I view page source and click on the FRAME urls they open up fine in a different window.

  22. === how to add new device in mrtg ===
    The configuration I did worked fine but now I don’t know how to add the ip of the new router and how to put the title name in it like I had to add
    == centos 7 ==

    #com2sec notConfigUser default public
    com2sec local localhost public
    com2sec mynetwork public
    group MyRWGroup v2c local
    group MyROGroup v2c mynetwork
    view all included .1 80

    mv /etc/snmp/snmpd.conf /etc/snmp/snmpd.conf_original

    cd /etc/snmp/
    snmpwalk -v2c -c public localhost system
    cfgmaker –snmp-options=:::::2 –ifref=descr –ifdesc=descr –global ‘WorkDir: /var/www/html/mymrtg’ public@ > /etc/mrtg/mrtg.cfg

    cd /var/www/html/
    mkdir mymrtg
    indexmaker –columns=1 /etc/mrtg/mrtg.cfg > /var/www/html/mymrtg/index.html

    vi /etc/cron.d/mrtg
    */5 * * * * root LANG=C LC_ALL=C /usr/bin/mrtg /etc/mrtg/mrtg.cfg –lock-file /var/lock/mrtg/mrtg_l –confcache-file /var/lib/mrtg/mrtg.ok
    vi /etc/httpd/conf.d/mrtg.conf
    Alias /mrtg /var/www/html/mymrtg

    Require local
    # Require ip
    allowoverride all
    # Require host

  23. So I have a broken graph image. I see the red square it there in the folder but on the system monitor it is broken as well as my graphs. they are pointed to the right folder but dont show on the site. Why?

    1. This means a configuration issue in your routers2.conf or possibly your .htaccess
      If you have made the changes to htaccess, check you don’t have a typo and so its not that blocking the clients from reading the image files.
      Verify that your graphurl (the url path) matches your graphpath (the filesystem location); if these are wrong, then the graphs get created in graphpath but graphurl is not pointing to the same directory.

Leave a Reply to Marcus Cancel reply

Your email address will not be published. Required fields are marked *