How to Install MRTG on Ubuntu 11.10 / Debian Squeeze

Share

The assumption here is that apache web server already installed in system. Below is guide on how to install MRTG and SNMP packages.

1. Install MRTG and SNMP

$ sudo apt-get install mrtg snmpd

2. Configure SNMP

Backup configuration file:

$ sudo mv /etc/snmp/snmpd.conf /etc/snmp/snmpd.conf.bak

Create new configuration file:

$ sudo nano /etc/snmp/snmpd.conf

And replace the current content with these lines:

rocommunity  public
syslocation  "ColekColek"
syscontact  xxxxxx@yahoo.com
com2sec public localhost public
group public v1 public
group public v2c public
group public usm public
view all included .1
access public "" any noauth exact all none none

Edit /etc/default/snmpd

$ sudo nano /etc/default/snmpd

And make sure the file contains these lines:

SNMPDRUN=yes
SNMPDOPTS='-Lsd -Lf /dev/null -u snmp -g snmp -I -smux -p /var/run/snmpd.pid -c /etc/snmp/snmpd.conf'
TRAPDRUN=yes
SNMPDCOMPAT=yes 

Restart snmpd:

$ sudo /etc/init.d/snmpd restart

3. Configure MRTG

Create mrtg folder:

$ sudo mkdir /var/www/mrtg
$ sudo chmod o+w /var/www/mrtg

Create configuration file:

$ sudo cfgmaker --global 'WorkDir:/var/www/mrtg' --ifref=name --ifdesc=eth --global 'Options[_]: bits' --output /etc/mrtg.cfg   public@localhost

Create index file:

$ sudo indexmaker /etc/mrtg.cfg > /var/www/mrtg/index.html

Run MRTG:

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

First execution will produce error message, this is normal. You can execute again few times. After more than 3 times of execution, the error message will be gone.

4. Create scheduled job:

$ sudo crontab -e

And add in this line:

*/5 * * * * env LANG=C /usr/bin/mrtg /etc/mrtg.cfg

5. Done. You can check MRTG graph on http://localhost/mrtg/ or http://your_ip/mrtg/

14 Comments

  1. Are you sure and executed it successfully.

    1. Which SNMP version will be running ?
    2. The snmpd.conf will be edited or purely new snmpd.conf will be created.
    3. snmpwalk command will not to used?
    4. Our tutorial will be executed on Ubuntu 11.04 also?

    Thanks and regards

    • Hi, Sidharatha

      I wrote the article after tried successfully, also it is for my bookmark if someday I need it again.

      1. SNMP version is using latest version installed by apt-get.
      2. I edited snmpd.conf
      3. snmpwalk command is only be used to test if your snmp not working properly.
      4. It should be working on Ubuntu 11.04

      Best Regards.

  2. Hello, I can’t make it work on my server, I Want to monitor it with my cacti server but it does not work at all..I already tried several configuration scenarios and with snmpwalk no response from localhost… can we please discuss?I really need help with this one, you already have my email

  3. Thanks for the tip. I guess the “>” character in indexmaker command line was messed up by your website.

    Best regards.
    Brazil

  4. Isaac Granados GOmez on

    i need help!!!! that is part of mi job, but i cant configure snmpd or mrtg in a server, i need that someone explain me step by step, i dont undertand where i must install mrtg or snmpd, i dont know if i can configure mrtg in the same server that i want to see the information or i must install it in other server or pc, i need help!!! please

  5. $ sudo indexmaker /etc/mrtg.cfg > /var/www/mrtg/index.html
    bash: /var/www/mrtg/index.html: Permission denied

    how to fix somebody help meeee plzzz

    • Please execute:

      $ sudo chmod o+w /var/www/mrtg

      Make sure you already create /var/www/mrtg folder beforehand:

      $ sudo mkdir /var/www/mrtg

  6. Quite strange, after running the command:
    indexmaker /etc/mrtg.cfg > /var/www/mrtg/index.html

    It throws me back a message: Use of uninitialized value $first in hash element at /usr/bin/indexmaker line 353.

    I’ve tried nearly anything to solve this issue, but couldn’t succeed.

    Also, I get no graphs at all, just the MRTG banner and MRTG Index Page.

    What else should I do? It seems like all of the articles are outdated, and none of them seems to be working.

Reply To suwapit Cancel Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.