Monday, June 20, 2011

MRTG Make sure snmp server installed


MRTG Make sure snmp server installed
Step # 1 : Make sure snmp server installed
Please note that snmpd configuration does not require using mrtg with remote network devices such as Routers and switches. If you just want mrtg graphs for router or switch then please refer to step # 4 (as all these devices comes preconfigured with snmpd software).
Run rpm commands query option to find out snmp server installed or not:
# rpm -qa | grep snmp
snmp installed then please refer step # 2; otherwise snmp server and utils were not present and your need to install them using following steps (login as a root user):
(a) Visit rpmfind.net to get snmp server and utilities rpms. If you are fedora user then use yum command as follows to install it:
# yum install net-snmp-utils net-snmp
(b) If you are RHEL s ubscriber then use up2date command as follows to install:
#up2date -v -i net-snmp-utils net-snmp
Step # 2 : Determine if snmp server is running or not
Run ‘ps’ command to see if snmp server is running or not:
# ps -aux | grep snmp
Output:
root   5512  0.0  2.3  5872 3012 pts/0    S    22:04   0:00 /usr/sbin/snmpd
Alternatively, you can try any of the following two commands as well:
# lsof -i :199
Output:
COMMAND  PID USER   FD   TYPE DEVICE SIZE NODE NAME
snmpd   5512 root    4u  IPv4  34432       TCP *:smux (LISTEN)
OR try out netstat command:
# netstat -natv | grep ‘:199′
Output:
tcp        0      0 0.0.0.0:199             0.0.0.0:*        &nb sp;      LISTEN
If you found service is running or listing on port 199 then please see step #3; otherwise start service using following command:
# service snmpd start
Make sure snmpd service starts automatically, when linux comes us (add snmpd service):
# chkconfig –add snmpd
Step # 3 : Make sure snmp server configured properly
Run snmpwalk utility to request for tree of information about network entity. In simple words query snmp server for your IP address (assigned to eth0, eth1, lo etc):
# snmpwalk -v 1 -c public localhost IP-MIB::ipAdEntIfIndex
ip.ipAddrTable.ipAddrEntry.ipAdEntIfIndex.127.0.0.1 = 1
ip.ipAddrTable.ipAddrEntry.ipAdEntIfIndex.192.168.0.3 = 2
If you can see your IP address then please proceed to step 4; else it is a time to configure snmp server as follows (by default RHEL an d RH 8/9 are not configured for snmp server for security reason):
Configure SNMP
(1) Edit file /etc/snmp/snmpd.conf using text editor:
# vi /etc/snmp/snmpd.conf
Chan ge/Modify line(s) as follows:
Find following Line:
com2sec notConfigUser  default       public
Replace with (make sure you replace 192.168.0.0/24 replace with your network IPs) following lines:
com2sec local  &nb sp;  localhost           public
com2sec mynetwork 192.168.0.0/24      public
Scroll down bit and change:
Find Lines:
group   notConfigGroup v1    & nbsp;      notConfigUser
group   notConfigGroup v2c           notConfigUser
Replace with:
group MyRWGroup v1         local
group MyR WGroup v2c        local
group MyRWGroup usm        local
group MyROGroup v1         mynetwork
group MyROGroup v2c        mynetwork
group MyROGroup usm        mynetwork
Again scroll down bit and locate following line:
Find line:
view    systemview     included      system
Re place with:
view all    included  .1                               80
Again scroll down bit and change:
Find line:
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
Scroll down bit and change:
Find lines:
syslocation Unknown (edit /etc/snmp/snmpd.conf)
syscontact Root  (configure /etc/snmp/snmp.local.conf)
Replace with (make sure you supply appropriate values):
syslocation Linux (RH3_UP2), Home Linux Router.
syscontact Vivek G Gite <vivek@nixcraft.com>
For your convenient, here is my /etc/snmp/snmpd.conf file. Feel free to use this file. Make sure you make backup of your existing file if you use this file as it is.
Start your snmp server and test it:
(a) Make sure when linux comes up snmpd always starts:
# chkconfig snmpd on
(b) Make sure service start whenever Linux comes up (after reboot):
# service snmpd start
(c) Finally test your snmp server:
# snmpwalk -v 1 -c public localhost IP-MIB::ipAdEntIfIndex
Step # 4 : Install mrtg if not installed
Mrtg software may install during initial installation; you can verify if MRTG installed or not with following RPM command:
rpm -qa | grep mrtg
If mrtg already installed please see step # 5; else use rpmfind.net to find MRTG rpm or up2date command to install MRTG software:
# up2date -v - i mrtg
Fedora Linux user can use yum command as follows to install MRTG:
# yum install mrtg
cfgmaker -global ‘WorkDir: /var/www/html/mrtg’ -output /etc/mrtg/mrtg_local.cfg public@174.143.168.193
indexmaker –output=/var/www/html/mrtg/index.html  /etc/mrtg/mrtg_local.cfg
cp -av /var/www/mrtg/*.png /var/www/html/mrtg/
/usr/bin/mrtg      /etc/m rtg/mrtg_local.cfg
env LANG=C /usr/bin/mrtg /etc/mrtg/mrtg_local.cfg
Crontab
*/1 * * * *  env LANG=C /usr/bin/mrtg /etc/mrtg/mrtg_local.cfg