MRTG (Multi Router Traffic Grapher) – a tool for displaying various data in graphs.
The installation command in Ubuntu/Debian:
1 | sudo apt-get install mrtg snmp snmpd |
In CentOS:
1 | yum install mrtg net-snmp net-snmp-utils |
The command below can tell you which additional modules are in the repository:
1 | apt-cache search mrtg |
Open the configuration file /etc/snmp/snmpd.conf
1 | sudo nano /etc/snmp/snmpd.conf |
Comment on the line:
1 | com2sec paranoid default public |
And uncomment the line:
1 | com2sec readonly default public |
Restart snmpd so that changes to the configuration file take effect:
1 | sudo /etc/init.d/snmpd restart |
You can check snmp by commands:
1 2 | netstat -nlp | grep snmpd snmpwalk -v2с -c public localhost |
Beginners can generate a simple configuration file with the command:
1 | sudo cfgmaker public@localhost >> /etc/mrtg.cfg |
where public is the name of the community (the password is in other words), and localhost is the host address or ip.
Example of starting the configuration file /etc/mrtg.cfg:
1 2 3 4 5 6 7 8 9 10 | WorkDir: /var/www/mrtg Options[_]: growright, bits, nobanner Background[_]: #B0C4DE EnableIPv6: no Language: russian EnableSnmpV3: no Interval: 10 Refresh: 600 Include: /etc/mrtg/server1.cfg Include: /etc/mrtg/server2.cfg |
Create the working directory:
1 | sudo mkdir /var/www/mrtg |
Then you must write or generate the index.html file with the command:
1 | sudo indexmaker /etc/mrtg.cfg > /var/www/mrtg/index.html |
We look at the log /var/log/mrtg.log so that there are no errors.
Here is an example of setting up SNMP on D-Link switches:
1 2 | private CommunityView Read Write public CommunityView Read Only |
Example of a manual start script (mrtg.sh):
1 2 3 4 5 | #!/bin/bash #run mrtg LANG=C export $LANG /usr/bin/mrtg /etc/mrtg.cfg --logging /var/log/mrtg.log |