AMP AMP

How to install and Configure SNMP on CentOS 8.3

To Install and Configure SNMP on CentOS 8.1

Introduction:

SNMP, or Simple Network Management Protocol, is widely used to communicate with and monitor network devices, dedicated servers, and more, all via IP. In this case, we’ll be installing an SNMP agent on a CentOS VPS server, which will allow for collection of data from our server, and make the information available to a remote SNMP manager. This tutorial will cover the installation of SNMP on CentOS 8.1

Installation procedure

Check the installed version of OS

[root@linuxhelp ~]# cat /etc/centos-release
CentOS Linux release 8.3.2011
 [root@linuxhelp ~]# yum -y install net-snmp net-snmp-utils
Last metadata expiration check: 3:27:53 ago on Tuesday 22 December 2020 03:37:38 PM IST.
Installing:
 net-snmp                 x86_64      1:5.8-17.el8                          appstream      354 k
 net-snmp-utils           x86_64      1:5.8-17.el8                          appstream      238 k
total download size: 1.4 M
Installed size: 3.6 M
Downloading Packages:
(1/4): net-snmp-utils-5.8-17.el8.x86_64.rpm                      300 kB/s | 238 kB     00:00    
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
  Preparing        :                                                                         1/1 
  Installing       : lm_sensors-libs-3.4.0-21.20180522git70f7e08.el8.x86_64                  1/4 
  Running scriptlet: lm_sensors-libs-3.4.0-21.20180522git70f7e08.el8.x86_64                  1/4 
  Installing       : net-snmp-agent-libs-1:5.8-17.el8.x86_64                                 2/4 
  Installing       : net-snmp-1:5.8-17.el8.x86_64                                            3/4 
Installed products updated.
Installed:
  lm_sensors-libs-3.4.0-21.20180522git70f7e08.el8.x86_64    net-snmp-1:5.8-17.el8.x86_64         
  net-snmp-agent-libs-1:5.8-17.el8.x86_64                   net-snmp-utils-1:5.8-17.el8.x86_64   
Complete!

Take a backup of the configuration file

[root@linuxhelp ~]# mv /etc/snmp/snmpd.conf /etc/snmp/snmpd.conf.orig

And now we'll create a new

[root@linuxhelp ~]# vim /etc/snmp/snmpd.conf

Restart the service

[root@linuxhelp ~]# service snmpd restart

Redirecting to /bin/systemctl restart snmpd.service Configure SNMP to start when the server boots:

[root@linuxhelp ~]# chkconfig snmpd on
Note: Forwarding request to 'systemctl enable snmpd.service'.
Created symlink /etc/systemd/system/multi-user.target.wants/snmpd.service → /usr/lib/systemd/system/snmpd.service.
Test the SNMP Configuration

Now let's test the SNMP configuration... try running the following two commands:

[root@linuxhelp ~]# snmpwalk -v 2c -c idv90we3rnov90wer -O e 127.0.0.1
SNMPv2-MIB::sysDescr.0 = STRING: Linux linuxhelp 4.18.0-147.el8.x86_64 #1 SMP Wed Dec 4 21:51:45 UTC 2019 x86_64
SNMPv2-MIB::sysObjectID.0 = OID: NET-SNMP-MIB::netSnmpAgentOIDs.10
DISMAN-EVENT-MIB::sysUpTimeInstance = Timeticks: (7296) 0:01:12.96
SNMPv2-MIB::sysContact.0 = STRING: root@localhost
SNMPv2-MIB::sysName.0 = STRING: linuxhelp
SNMPv2-MIB::sysLocation.0 = STRING: Unknown
SNMPv2-MIB::sysORLastChange.0 = Timeticks: (108) 0:00:01.08
SNMPv2-MIB::sysORID.1 = OID: SNMP-FRAMEWORK-MIB::snmpFrameworkMIBCompliance
SNMPv2-MIB::sysORID.2 = OID: SNMP-MPD-MIB::snmpMPDCompliance
SNMPv2-MIB::sysORID.3 = OID: SNMP-USER-BASED-SM-MIB::usmMIBCompliance
SNMPv2-MIB::sysORID.4 = OID: SNMPv2-MIB::snmpMIB
SNMPv2-MIB::sysORID.5 = OID: SNMP-VIEW-BASED-ACM-MIB::vacmBasicGroup
SNMPv2-MIB::sysORID.6 = OID: TCP-MIB::tcpMIB
SNMPv2-MIB::sysORID.7 = OID: IP-MIB::ip
SNMPv2-MIB::sysORID.8 = OID: UDP-MIB::udpMIB
SNMPv2-MIB::sysORID.9 = OID: SNMP-NOTIFICATION-MIB::snmpNotifyFullCompliance
SNMPv2-MIB::sysORID.10 = OID: NOTIFICATION-LOG-MIB::notificationLogMIB
SNMPv2-MIB::sysORDescr.1 = STRING: The SNMP Management Architecture MIB.
SNMPv2-MIB::sysORDescr.2 = STRING: The MIB for Message Processing and Dispatching.
SNMPv2-MIB::sysORDescr.3 = STRING: The management information definitions for the SNMP User-based Security Model.
SNMPv2-MIB::sysORDescr.4 = STRING: The MIB module for SNMPv2 entities
SNMPv2-MIB::sysORDescr.5 = STRING: View-based Access Control Model for SNMP.
SNMPv2-MIB::sysORDescr.6 = STRING: The MIB module for managing TCP implementations
SNMPv2-MIB::sysORDescr.7 = STRING: The MIB module for managing IP and ICMP implementations
SNMPv2-MIB::sysORDescr.8 = STRING: The MIB module for managing UDP implementations
SNMPv2-MIB::sysORDescr.9 = STRING: The MIB modules for managing SNMP Notification, plus filtering.
SNMPv2-MIB::sysORDescr.10 = STRING: The MIB module for logging SNMP Notifications.
SNMPv2-MIB::sysORUpTime.1 = Timeticks: (100) 0:00:01.00
SNMPv2-MIB::sysORUpTime.2 = Timeticks: (100) 0:00:01.00
SNMPv2-MIB::sysORUpTime.3 = Timeticks: (100) 0:00:01.00
SNMPv2-MIB::sysORUpTime.4 = Timeticks: (102) 0:00:01.02
SNMPv2-MIB::sysORUpTime.5 = Timeticks: (102) 0:00:01.02
SNMPv2-MIB::sysORUpTime.6 = Timeticks: (103) 0:00:01.03
SNMPv2-MIB::sysORUpTime.7 = Timeticks: (103) 0:00:01.03
SNMPv2-MIB::sysORUpTime.8 = Timeticks: (103) 0:00:01.03
SNMPv2-MIB::sysORUpTime.9 = Timeticks: (108) 0:00:01.08
SNMPv2-MIB::sysORUpTime.10 = Timeticks: (108) 0:00:01.08
HOST-RESOURCES-MIB::hrSystemUptime.0 = Timeticks: (4562201) 12:40:22.01
HOST-RESOURCES-MIB::hrSystemUptime.0 = No more variables left in this MIB View (It is past the end of the MIB tree)

The result for your first command should be about 33 lines, and contain some basic system information. The result for the second command should contain a lot more information about your system, and will likely be thousands of lines.

[root@linuxhelp ~]# snmpwalk -v 2c -c 209ijvfwer0df92jd -O e 127.0.0.1
SNMPv2-MIB::sysDescr.0 = STRING: Linux linuxhelp 4.18.0-147.el8.x86_64 #1 SMP Wed Dec 4 21:51:45 UTC 2019 x86_64
SNMPv2-MIB::sysObjectID.0 = OID: NET-SNMP-MIB::netSnmpAgentOIDs.10
DISMAN-EVENT-MIB::sysUpTimeInstance = Timeticks: (10816) 0:01:48.16
SNMPv2-MIB::sysContact.0 = STRING: root@localhost
SNMPv2-MIB::sysName.0 = STRING: linuxhelp
SNMPv2-MIB::sysLocation.0 = STRING: Unknown
SNMPv2-MIB::sysORLastChange.0 = Timeticks: (108) 0:00:01.08
SNMPv2-MIB::sysORID.1 = OID: SNMP-FRAMEWORK-MIB::snmpFrameworkMIBCompliance
SNMPv2-MIB::sysORID.2 = OID: SNMP-MPD-MIB::snmpMPDCompliance
SNMPv2-MIB::sysORID.3 = OID: SNMP-USER-BASED-SM-MIB::usmMIBCompliance
SNMPv2-MIB::sysORID.4 = OID: SNMPv2-MIB::snmpMIB
SNMPv2-MIB::sysORID.5 = OID: SNMP-VIEW-BASED-ACM-MIB::vacmBasicGroup
SNMPv2-MIB::sysORID.6 = OID: TCP-MIB::tcpMIB
SNMPv2-MIB::sysORID.7 = OID: IP-MIB::ip
SNMPv2-MIB::sysORID.8 = OID: UDP-MIB::udpMIB
SNMPv2-MIB::sysORID.9 = OID: SNMP-NOTIFICATION-MIB::snmpNotifyFullCompliance
SNMPv2-MIB::sysORID.10 = OID: NOTIFICATION-LOG-

HOST-RESOURCES-MIB::hrSWRunPerfMem.98700 = INTEGER: 0 KBytes
HOST-RESOURCES-MIB::hrSWRunPerfMem.98759 = INTEGER: 0 KBytes
HOST-RESOURCES-MIB::hrSWRunPerfMem.98832 = INTEGER: 0 KBytes
HOST-RESOURCES-MIB::hrSWRunPerfMem.98845 = INTEGER: 14940 KBytes
HOST-RESOURCES-MIB::hrSWRunPerfMem.98985 = INTEGER: 816 KBytes
HOST-RESOURCES-MIB::hrSWRunPerfMem.98986 = INTEGER: 6800 KBytes
Timeout: No Response from 127.0.0.1

With this the installation of SNMP comes to end on CentOS 8.1.

Tag : SNMP CentOS
FAQ
Q
How to restart the SNMP service?
A
once can start the SNMP service using service snmpd restart
Q
What does the MIB do?
A
management information is viewed as a collection of managed objects information store in a base is called MIB
Q
What are different versions for SNMP?
A
There are three versions for SNMP
SNMP V1, SNMP V2c, SNMP V3.
Q
Which port does NMP uses?
A
SNMP uses the UDP port 161 for sending and receiving requests, and port 162 for receiving traps.
Q
What is SNMP(Simple network management protocol )?
A
SNMP is a simple network management protocol is used to communicate with network devices.