SNMP, or Simple Network Management Protocol, is widely used to communicate with and monitor network devices, servers, and more, all via IP. In this case, we’ll be installing an SNMP agent on a CentOS 6.5 server, which will allow for collection of data from our server, and make the information available to a remote SNMP manager.
1. Make sure net-snmp utilitas package on centos7
# yum install net-snmp net-snmp-libs net-snmp-utils net-snmp-perl net-snmp-python
# rpm -q net-snmp net-snmp-libs net-snmp-utils net-snmp-perl net-snmp-python
# yum install net-snmp net-snmp-libs net-snmp-utils net-snmp-perl net-snmp-python
# rpm -q net-snmp net-snmp-libs net-snmp-utils net-snmp-perl net-snmp-python
2. configuration snmp on /etc/snmp/snmpd.conf example snmp (teguht)
# Setting Community
com2sec notConfigUser default teguht
# Enable access OID/MIB
view systemview included .1
# Enable Syslocation
syslocation Teguh Triharto Tower
# Enable Syscontact
syscontact teguh.triharto@microsoft.com
sample log
[root@trial /]# cat /etc/snmp/snmpd.conf | grep com2sec
com2sec notConfigUser default teguht
#com2sec local localhost COMMUNITY
#com2sec mynetwork NETWORK/24 COMMUNITY
#com2sec notConfigUser default public
[root@trial /]#
[root@trial /]# cat /etc/snmp/snmpd.conf | grep syslocation
# Also remember to comment the syslocation and syscontact parameters later as
syslocation Teguh Triharto Tower
[root@trial /]# cat /etc/snmp/snmpd.conf | grep syscontact
# Also remember to comment the syslocation and syscontact parameters later as
syscontact teguh.triharto@microsoft.com
[root@trial /]#
[root@trial ~]# cat /etc/snmp/snmpd.conf | grep systemview
view systemview included .1.3.6.1.2.1.1
view systemview included .1.3.6.1.2.1.25.1.1
view systemview included .1
# Finally, grant the group read-only access to the systemview view.
access notConfigGroup "" any noauth exact systemview none none
# Finally, grant the group read-only access to the systemview view.
[root@trial ~]#
3. enable snmp service
centos6
# /etc/init.d/snmpd start
# service snmpd start
centos7
# systemctl start snmpd.service
4. check status snmp service
centos6
# /etc/init.d/snmpd status
# service snmpd status
centos7
# systemctl status snmpd.service
5. enable Configure SNMP to start when the server boots:
centos6
# chkconfig snmpd on
centos7
# systemctl enable snmpd.service
6. Test snmpwakl localhost
# snmpwalk -v2c -c public 127.0.0.1
# snmpwalk -v2c -c public 127.0.0.1 sysDescr
# snmpwalk -v2c -c public 127.0.0.1 1.3.6.1.2.1.1
# snmpwalk -v2c -c teguht 10.10.10.10 sysDescr
# snmpwalk -v2c -c teguht 10.10.10.10 1.3.6.1.2.1.1
[root@TeguhLab data]# snmpwalk -v2c -c teguht 10.10.10.10 sysDescr
SNMPv2-MIB::sysDescr.0 = STRING: TiMOS-C-14.0.R7 cpm/hops64 Nokia 7750 SR Copyright (c) 2000-2017 Nokia.
All rights reserved. All use subject to applicable license agreements.
Built on Thu Jan 12 12:38:16 PST 2017 by builder in /rel14.0/b1/R7/panos/main
[root@TeguhLab data]# snmpwalk -v2c -c teguht 10.10.10.10 1.3.6.1.2.1.1
SNMPv2-MIB::sysDescr.0 = STRING: Linux trial 2.6.32-642.el6.x86_64 #1 SMP Wed Apr 13 00:51:26 EDT 2016 x86_64SNMPv2-MIB::sysObjectID.0 = OID: NET-SNMP-MIB::netSnmpAgentOIDs.10
DISMAN-EVENT-MIB::sysUpTimeInstance = Timeticks: (74904) 0:12:29.04
SNMPv2-MIB::sysContact.0 = STRING: teguh.triharto@microsoft.com
SNMPv2-MIB::sysName.0 = STRING: trial
SNMPv2-MIB::sysLocation.0 = STRING: Teguh Triharto Tower
SNMPv2-MIB::sysORLastChange.0 = Timeticks: (3) 0:00:00.03
SNMPv2-MIB::sysORID.1 = OID: SNMP-MPD-MIB::snmpMPDMIBObjects.3.1.1
SNMPv2-MIB::sysORID.2 = OID: SNMP-USER-BASED-SM-MIB::usmMIBCompliance
SNMPv2-MIB::sysORID.3 = OID: SNMP-FRAMEWORK-MIB::snmpFrameworkMIBCompliance
SNMPv2-MIB::sysORID.4 = OID: SNMPv2-MIB::snmpMIB
SNMPv2-MIB::sysORID.5 = OID: TCP-MIB::tcpMIB
SNMPv2-MIB::sysORID.6 = OID: IP-MIB::ip
SNMPv2-MIB::sysORID.7 = OID: UDP-MIB::udpMIB
SNMPv2-MIB::sysORID.8 = OID: SNMP-VIEW-BASED-ACM-MIB::vacmBasicGroup
SNMPv2-MIB::sysORDescr.1 = STRING: The MIB for Message Processing and Dispatching.
SNMPv2-MIB::sysORDescr.2 = STRING: The MIB for Message Processing and Dispatching.
SNMPv2-MIB::sysORDescr.3 = STRING: The SNMP Management Architecture MIB.
SNMPv2-MIB::sysORDescr.4 = STRING: The MIB module for SNMPv2 entities
SNMPv2-MIB::sysORDescr.5 = STRING: The MIB module for managing TCP implementations
SNMPv2-MIB::sysORDescr.6 = STRING: The MIB module for managing IP and ICMP implementations
SNMPv2-MIB::sysORDescr.7 = STRING: The MIB module for managing UDP implementations
SNMPv2-MIB::sysORDescr.8 = STRING: View-based Access Control Model for SNMP.
SNMPv2-MIB::sysORUpTime.1 = Timeticks: (3) 0:00:00.03
SNMPv2-MIB::sysORUpTime.2 = Timeticks: (3) 0:00:00.03
SNMPv2-MIB::sysORUpTime.3 = Timeticks: (3) 0:00:00.03
SNMPv2-MIB::sysORUpTime.4 = Timeticks: (3) 0:00:00.03
SNMPv2-MIB::sysORUpTime.5 = Timeticks: (3) 0:00:00.03
SNMPv2-MIB::sysORUpTime.6 = Timeticks: (3) 0:00:00.03
SNMPv2-MIB::sysORUpTime.7 = Timeticks: (3) 0:00:00.03
SNMPv2-MIB::sysORUpTime.8 = Timeticks: (3) 0:00:00.03
[root@TeguhLab data]#
No comments:
Post a Comment