Install SNMP Service on RHEL or CentOS
In this article we are going to learn how to install and start SNMP service in RHEL/CentOS.We need to have net-snmp rpm package installed on the servers , generally it would come with repository.
1. Install net-snmp with yum:
#yum install net-snmp
[root@umserv]# yum install net-snmp
Loaded plugins: dellsysid, fastestmirror
Loading mirror speeds from cached hostfile
-----
-----
Dependencies Resolved
========================================================================================================================================================================
Package Arch Version Repository Size
========================================================================================================================================================================
Installing:
net-snmp x86_64 1:5.3.2.2-22.el5_10.1 updates 708 k
Installing for dependencies:
lm_sensors x86_64 2.10.7-9.el5 base 525 k
Updating for dependencies:
net-snmp-libs i386 1:5.3.2.2-22.el5_10.1 updates 1.3 M
net-snmp-libs x86_64 1:5.3.2.2-22.el5_10.1 updates 1.3 M
Transaction Summary
========================================================================================================================================================================
Install 2 Package(s)
Update 2 Package(s)
Remove 0 Package(s)
Total download size: 3.8 M
Is this ok [y/N]: y
Downloading Packages:
(1/4): lm_sensors-2.10.7-9.el5.x86_64.rpm | 525 kB 00:01
(2/4): net-snmp-5.3.2.2-22.el5_10.1.x86_64.rpm | 708 kB 00:02
(3/4): net-snmp-libs-5.3.2.2-22.el5_10.1.i386.rpm | 1.3 MB 00:04
(4/4): net-snmp-libs-5.3.2.2-22.el5_10.1.x86_64.rpm | 1.3 MB 00:03
------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Total 168 kB/s | 3.8 MB 00:23
Running rpm_check_debug
Running Transaction Test
Finished Transaction Test
Transaction Test Succeeded
Running Transaction
----
----
Installed:
net-snmp.x86_64 1:5.3.2.2-22.el5_10.1
Dependency Installed:
lm_sensors.x86_64 0:2.10.7-9.el5
Dependency Updated:
net-snmp-libs.i386 1:5.3.2.2-22.el5_10.1 net-snmp-libs.x86_64 1:5.3.2.2-22.el5_10.1
Complete!
[root@umserv]#
Loaded plugins: dellsysid, fastestmirror
Loading mirror speeds from cached hostfile
-----
-----
Dependencies Resolved
========================================================================================================================================================================
Package Arch Version Repository Size
========================================================================================================================================================================
Installing:
net-snmp x86_64 1:5.3.2.2-22.el5_10.1 updates 708 k
Installing for dependencies:
lm_sensors x86_64 2.10.7-9.el5 base 525 k
Updating for dependencies:
net-snmp-libs i386 1:5.3.2.2-22.el5_10.1 updates 1.3 M
net-snmp-libs x86_64 1:5.3.2.2-22.el5_10.1 updates 1.3 M
Transaction Summary
========================================================================================================================================================================
Install 2 Package(s)
Update 2 Package(s)
Remove 0 Package(s)
Total download size: 3.8 M
Is this ok [y/N]: y
Downloading Packages:
(1/4): lm_sensors-2.10.7-9.el5.x86_64.rpm | 525 kB 00:01
(2/4): net-snmp-5.3.2.2-22.el5_10.1.x86_64.rpm | 708 kB 00:02
(3/4): net-snmp-libs-5.3.2.2-22.el5_10.1.i386.rpm | 1.3 MB 00:04
(4/4): net-snmp-libs-5.3.2.2-22.el5_10.1.x86_64.rpm | 1.3 MB 00:03
------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Total 168 kB/s | 3.8 MB 00:23
Running rpm_check_debug
Running Transaction Test
Finished Transaction Test
Transaction Test Succeeded
Running Transaction
----
----
Installed:
net-snmp.x86_64 1:5.3.2.2-22.el5_10.1
Dependency Installed:
lm_sensors.x86_64 0:2.10.7-9.el5
Dependency Updated:
net-snmp-libs.i386 1:5.3.2.2-22.el5_10.1 net-snmp-libs.x86_64 1:5.3.2.2-22.el5_10.1
Complete!
[root@umserv]#
2. Simple SNMP configuration:
mv /etc/snmp/snmpd.conf /etc/snmp/snmpd.conf.old
Add below configuration to /etc/snmp/snmpd.conf
rocommunity public xxx.xxx.xxx.xxx
rocommunity public 127.0.0.1
syslocation "HYD, UM DataCenter"
syscontact surya@unixmantra.com
Replace xxx.xxx.xxx.xxx with the IP address of the server that you want to allow SNMP lookups from:
rocommunity public xxx.xxx.xxx.xxx
rocommunity public 127.0.0.1
syslocation "HYD, UM DataCenter"
syscontact surya@unixmantra.com
Replace xxx.xxx.xxx.xxx with the IP address of the server that you want to allow SNMP lookups from:
rocommunity public xxx.xxx.xxx.xxx
3. Start the SNMP service, and set it to auto-start on reboot:
/etc/init.d/snmpd start
chkconfig snmpd on
Note:If you have a firewall configured, ensure that you have UDP port 161 open to your SNMP lookup server.chkconfig snmpd on
4) Validation:
On your SNMP lookup server, you can do the following to perform a quick SNMP test to ensure that it’s working.
snmpwalk -v 2c -c public xxx.xxx.xxx.xxx or snmpwalk -v 1 -c public -O e 127.0.0.1
[root@umserv ~]# snmpwalk -v 1 -c public -O e 127.0.0.1
SNMPv2-MIB::sysDescr.0 = STRING: Linux umserv 2.6.18-92.1.17.el5 #1 SMP Mon Jul 14 06:07:13 IST 2014 i686
SNMPv2-MIB::sysObjectID.0 = OID: NET-SNMP-MIB::netSnmpAgentOIDs.10
DISMAN-EVENT-MIB::sysUpTimeInstance = Timeticks: (16748) 0:02:47.48
SNMPv2-MIB::sysContact.0 = STRING: surya@unixmantra.com
SNMPv2-MIB::sysName.0 = STRING: umserv
SNMPv2-MIB::sysLocation.0 = STRING: "HYD, UM DataCenter"
SNMPv2-MIB::sysORLastChange.0 = Timeticks: (1) 0:00:00.01
...
...
Yes, it is working[root@umserv ~]# snmpwalk -v 1 -c public -O e 127.0.0.1
SNMPv2-MIB::sysDescr.0 = STRING: Linux umserv 2.6.18-92.1.17.el5 #1 SMP Mon Jul 14 06:07:13 IST 2014 i686
SNMPv2-MIB::sysObjectID.0 = OID: NET-SNMP-MIB::netSnmpAgentOIDs.10
DISMAN-EVENT-MIB::sysUpTimeInstance = Timeticks: (16748) 0:02:47.48
SNMPv2-MIB::sysContact.0 = STRING: surya@unixmantra.com
SNMPv2-MIB::sysName.0 = STRING: umserv
SNMPv2-MIB::sysLocation.0 = STRING: "HYD, UM DataCenter"
SNMPv2-MIB::sysORLastChange.0 = Timeticks: (1) 0:00:00.01
...
...
Also need to ensure that iptables will permit udp 161 traffic.
ReplyDelete