Page 1 of 2

How to add another switch/router with MRTG

Posted: Tue Jun 16, 2015 12:00 pm
by Jessuzz94
i have followed these steps to monior bandwidth of interfaces of one cisco switch and it works fine:

Code: Select all

mkdir /etc/mrtg

mv /etc/mrtg.cfg /etc/mrtg/

Now we run the cfgmaker command to get things up and running:

cfgmaker --global 'WorkDir:/var/www/mrtg' --global 'Options[_]: bits,growright' --output /etc/mrtg/mrtg.cfg public@<yourrouterip>

We need to make sure the following lines are correct in /etc/mrtg/mrtg.cfg If they are not there, add them.

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

Now run:

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

Which will build the index so you can view the output.

Then I run this command to set an environmental variable

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

and open http://localhost/mrtg/index.html
but, iif i want now to add one router how can i do?, i tried to use the same steps but to the router ip and doesnt work

Re: How to add another switch/router with MRTG

Posted: Tue Jun 16, 2015 1:18 pm
by tgriep
Do you have SNMP enabled and configured on the router?
Can you run the following from your Nagios system to see if the router has the SNMP port open? Replace xxx with the routers IP address.

Code: Select all

nmap xxx.xxx.xxx.xxx -sU -p 161
When you ran cfgmaker, did you receive any errors?
Can you post the errors?

Re: How to add another switch/router with MRTG

Posted: Tue Jun 16, 2015 1:38 pm
by Jessuzz94
Sorry now i can do, it just to change to other directory, example mrtg/router, and i put localhost/mrtg/router/index.html and shows the interface, but, very thanks!

Re: How to add another switch/router with MRTG

Posted: Tue Jun 16, 2015 3:48 pm
by tgriep
Is the problem solved now by going to the new link?

Re: How to add another switch/router with MRTG

Posted: Wed Jun 17, 2015 2:28 pm
by Jessuzz94
Yeah the problem is solved, just one question, for each device that i want to monitor (switch or router) , is the same mrtg.cfg?, for every devices that i want to add with the cfgmaker i put mrtg.cfg always?, or mrtg1.cfg, mrtg2.cfg, mrtg3.cfg,?

Re: How to add another switch/router with MRTG

Posted: Wed Jun 17, 2015 4:37 pm
by tgriep
Depending on the settings in the /etc/mrtg/mrtg.cfg file, you shouldn't have to add it to the cfgmaker command at all.
Can you post your mrtg.cfg file?

Re: How to add another switch/router with MRTG

Posted: Thu Jun 18, 2015 3:03 pm
by Jessuzz94
Ok, but i need to connect remotely to copy the the text

Re: How to add another switch/router with MRTG

Posted: Thu Jun 18, 2015 3:46 pm
by tgriep
I found that you could just generate a different .cfg file with cfgmaker and append it to main config file or create a different cfg file and add that to your crontab file.

Re: How to add another switch/router with MRTG

Posted: Mon Jun 22, 2015 11:24 am
by Jessuzz94
How add to my contab file?, you say the command line to start the mrtg daemon every 5 minutes?

Re: How to add another switch/router with MRTG

Posted: Mon Jun 22, 2015 12:12 pm
by tgriep
Without knowing how your system is setup, I cannot give you any details, but the crontab file that currently runs the mrtg command every 5 minutes needs to be edited and just duplicate the current command and change the name of the cfg file to the new on that you created.
Then restart the cron daemon and it should start collecting the data.