the luxury of invaluable experience.
7 Mar
Today I have finished install mrtg for my idaemon server and here are the perfect setup instruction for who run centos 5.1 in the box.
check this instruction you will not regret, after I have try from many source and googled all day this is the way out!
Part I : SNMP Server
we need to install snmp service to make mrtg graph work.
#yum install net-snmp-utils net-snmp
after it installed make this service that run automaticaly.
#chkconfig --level 345 snmpd
run it.
#service snmpd start
check service that run properly.
#netstat -natv | grep ':199'
look into the line that should be.
tcp 0 0 127.0.0.1:199 0.0.0.0:* LISTEN
now we must check this service.
#snmpwalk -v 1 -c public localhost IP-MIB::ipAdEntIfIndex
the output should be like this. note that 192.168.0.3 is your network ip or internet ip.
ip.ipAddrTable.ipAddrEntry.ipAdEntIfIndex.127.0.0.1 = 1
ip.ipAddrTable.ipAddrEntry.ipAdEntIfIndex.192.168.0.3 = 2
if it not show any line in output you should make a configuration. before that better to make copy of cfg file.
#cp /etc/snmp/snmpd.conf /etc/snmp/snmpd.conf.original
then it’s time to config.
#vi /etc/snmp/snmpd.conf
looking for
com2sec notConfigUser default public
comment it and replace with note that 192.0.0.0 that your ip class.
com2sec local localhost public
com2sec mynetwork 192.0.0.0/8 public
then looking for these line.
com2sec local localhost public
com2sec mynetwork 10.0.0.0/8 public
comment them and replace with.
group MyRWGroup v1 local
group MyRWGroup v2c local
group MyRWGroup usm local
group MyROGroup v1 mynetwork
group MyROGroup v2c mynetwork
group MyROGroup usm mynetwork
looking for
view systemview included .1.3.6.1.2.1.1
view systemview included .1.3.6.1.2.1.25.1.1
same process comment it and add with this
view all included .1 80
and find this
access notConfigGroup "?" any noauth exact systemview none none
replace with
access MyROGroup "?" any noauth exact all none none
access MyRWGroup "?" any noauth exact all all none
the last one change your information if you wish. from this
syslocation Unknown (edit /etc/snmp/snmpd.conf)
syscontact Root (configure /etc/snmp/snmp.local.conf)
with your information
syslocation Linux, Centos 5.1
syscontact Root root@localhost
save it. and now we need to restart snmp server
#service snmpd restart
test it with snmpwalk
#snmpwalk -v 1 -c public localhost IP-MIB::ipAdEntIfIndex
now we will meet output like this
IP-MIB::ipAdEntIfIndex.192.168.2.105 = INTEGER: 2
IP-MIB::ipAdEntIfIndex.127.0.0.1 = INTEGER: 1
Part I : MRTG
install it
#yum install mrtg
create a directoty we want a index page
#mkdir /var/www/html/mrtg/
make a configuration file
#cfgmaker --global "workdir: /var/www/mrtg" -ifref=ip --output /etc/mrtg/mrtg.cfg --global 'options[_]: growright,bits’ root@localhost
create a index file
#indexmaker --output=/var/www/html/mrtg/index.html /etc/mrtg/mrtg.cfg
next, we need to config apache alias edit in /etc/httpd/conf.d/mrtg.conf
Alias /mrtg /var/www/mrtg
Order allow,deny
Allow from all
Now we need to check
#mrtg /etc/mrtg/mrtg.cfg
they may be show
ERROR: Mrtg will most likely not work properly when the environment
variable LANG is set to UTF-8. Please run mrtg in an environment
where this is not the case. Try the following command to start:
#env LANG=C /usr/bin/mrtg /etc/mrtg/mrtg.cfg
fix it with this
#env LANG=C /usr/bin/mrtg /etc/mrtg/mrtg.cfg
they will show some error again don’t worry
#env LANG=C /usr/bin/mrtg /etc/mrtg/mrtg.cfg
now we will promt to # again so we can view mrtg now!
http://www.yoursite.com/mrtg
congrat!
Leave a reply