MRTG HowTO (Centos 5.5 64bit)
What is MRTG ?
"The Multi Router Traffic Grapher (MRTG) is a tool to monitor the traffic load on network-links. MRTG generates HTML pages containing GIF images which provide a LIVE visual representation of this traffic."
# Required RPMs
* mrtg
* snmp
* snmp-utils
# Make sure snmp server installed
rpm -qa | grep snmp
if not then install this packages
yum install net-snmp-utils.x86_64 net-snmp.x86_64
# Determine if snmp server is running or not
ps -aux | grep snmp
# Start service & then check again
service snmpd start
# check if started on port 199
netstat -natv | grep ':199'
tcp 0 0 127.0.0.1:199 0.0.0.0:* LISTEN
or
lsof -i :199
COMMAND PID USER FD TYPE DEVICE SIZE NODE NAME
snmpd 29793 root 8u IPv4 89533572 TCP localhost:smux (LISTEN)
# add it permanent to boot at startup
chkconfig --add snmpd
# Make sure snmp server configured properly
snmpwalk -v 1 -c public localhost IP-MIB::ipAdEntIfIndex
no output then follow steps below (if ur configuring first time then this steps are necessary)
vi /etc/snmp/snmpd.conf ( Modified as per my need please config as per your need)
com2sec local localhost public
com2sec mynetwork 10.0.0.0/16 public
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 all included .1 80
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
chkconfig snmpd on
/etc/init.d/snmpd restart
snmpwalk -v 1 -c public localhost IP-MIB::ipAdEntIfIndex
# Install mrtg if not installed
rpm -qa | grep mrtg
yum install mrtg
# Commands to Configure mrtg
mkdir -p /var/www/html/mymrtg/
# cfgmaker command to create mrtg configuration file
cfgmaker --global 'WorkDir: /var/www/html/mymrtg' --output /etc/mrtg/mymrtg.cfg public@localhost
OR
cfgmaker --global 'WorkDir: /var/www/html/mymrtg' --output /etc/mrtg/mymrtg1.cfg public@rh9.test.com (need FQDN & should resolve)
# Create default index page for your MRTG configuration
indexmaker --output=/var/www/html/mymrtg/index.html /etc/mrtg/mymrtg.cfg
# Copy all tiny png files to your mrtg path
cp -av /var/www/mrtg/*.png /var/www/html/openx/mymrtg/
# Run below command
env LANG=C /usr/bin/mrtg /etc/mrtg/mymrtg.cfg
mrtg /etc/mrtg/mymrtg.cfg
# Make a Shell Script of above command & add in crontab
vi /root/mrtg.sh
env LANG=C /usr/bin/mrtg /etc/mrtg/mymrtg.cfg
mrtg /etc/mrtg/mymrtg.cfg
crontab -e
*/5 * * * * sh /root/mrtg.sh
# Protect your MRTG graphs/html pages with password protected directory
Create .htaccess file
vi /var/www/html/mymrtg/.htaccess
AuthName "MRTG Graphs/Html restricted access"
AuthType Basic
AuthUserFile /var/www/html/mymrtg/.htpasswd
require user mrtgadmin
Create a user and password name (-c assumes first time you are using .htpasswd file):
htpasswd -c /var/www/html/mymrtg/.htpasswd mrtgadmin
DONE.......
Just Browse your page http://
U can do change in index.html as per your need
No comments:
Post a Comment