Requirements:
Operating System: Linux
Packages: mrtg, snmp, snmp-utils
SNMP – Simple Network Management Protocol is used to manage IP network devices such as routers, switches etc.
Make sure snmp is installed.
# rpm –qa | grep snmp
If installed, avoid next step. Otherwise install it using the command given below.
Install SNMP
# yum install net-snmp-utils net-snmp
Start the snmp service
# service snmpd start
Make the service run in startup
# chkconfig snmpd on
Now use the snmpwalk utility for getting the details about your network.
# snmpwalk -v 1 -c public localhost IP-MIB::ipAdEntIfIndex
You will get an output something similar as given below.
ip.ipAddrTable.ipAddrEntry.ipAdEntIfIndex.127.0.0.1 = 1
ip.ipAddrTable.ipAddrEntry.ipAdEntIfIndex.192.168.1.5 = 2
If you can see your IP address, you can avoid next steps or configure snmp as given below.
Configure SNMP
# vi /etc/snmp/snmpd.conf
Change/Modify line(s) as follows:
Find following Blue Lines and replace with the next Green Lines:
com2sec notConfigUser default public
com2sec local localhost public
com2sec mynetwork 192.168.1.0/24 public
(Make sure you give your IP range in the above line.)
group notConfigGroup v1 notConfigUser
group notConfigGroup v2c notConfigUser
group MyRWGroup v1 local
group MyRWGroup v2c local
group MyRWGroup usm local
group MyROGroup v1 mynetwork
group MyROGroup v2c mynetwork
group MyROGroup usm mynetwork
view systemview included system
view all included .1 80
access notConfigGroup "" any noauth exact systemview none none
access MyROGroup "" any noauth exact all none none
access MyRWGroup "" any noauth exact all all none
syslocation Unknown (edit /etc/snmp/snmpd.conf)
syscontact Root (configure /etc/snmp/snmp.local.conf)
syslocation Linux (RH3_UP2), Home Linux Router.
syscontact Name <name@domain.com>
Start your snmp server and test it:
# service snmpd start
Now test your snmp server:
# snmpwalk -v 1 -c public localhost IP-MIB::ipAdEntIfIndex
Install MRTG
Check whether it’s already installed.
# rpm –qa | grep mrtg
If not done, run the below command.
# yum install mrtg
Configuring MRTG
Create document root to store mrtg graphs/html pages:
# mkdir -p /var/www/html/mrtg/
Create mrtg configuration file using cfgmaker command.
# cfgmaker --global 'WorkDir: /var/www/html/mrtg' --output /etc/mrtg/mrtg.cfg public@localhost
Create default index page for the MRTG configuration:
# indexmaker --output=/var/www/html/mrtg/index.html /etc/mrtg/mrtg.cfg
Copy all png files to the mrtg path:
# cp -av /var/www/html/mrtg/*.png /var/www/html/mrtg/
Run mrtg command from command line with your configuration file:
# mrtg /etc/mrtg/mymrtg.cfg
(You may get few warning message for first time; ignore them.)
Open a web browser and type url http://www.your-server-name/mrtg/ or http://your-ip/mrtg/
You can see the mrtg graphs of your network.
You can generate the graph in each 5 (for example) minutes using a cron job.
Login as a root and configure the cron job:
# crontab -e
Append following line to the crontab file:
* 5 * * * * /usr/bin/mrtg /etc/mrtg/mymrtg.cfg --logging /var/log/mrtg.log
Save and exit
For detailed document, please check out the link (MRTG).
Stories on Linux