一、SNMP介绍
简单网络管理协议(SNMP) 是专门设计用于在 IP 网络管理网络节点(服务器、工作站、路由器、交换机及HUBS等)的一种标准协议,它是一种应用层协议。
二、服务端安装snmp监控工具
[root@IT-01 ~]# yum -y install net-snmp net-snmp-utils.x86_64
Last metadata expiration check: 8:51:16 ago on Thu 03 Jun 2021 02:07:15 AM CST.
Dependencies resolved.
===============================================================================================================================================
Package Architecture Version Repository Size
===============================================================================================================================================
Installing:
net-snmp x86_64 1:5.8-18.el8_3.1 AppStream 354 k
net-snmp-utils x86_64 1:5.8-18.el8_3.1 AppStream 239 k
Upgrading:
net-snmp-libs x86_64 1:5.8-18.el8_3.1 BaseOS 824 k
Installing dependencies:
lm_sensors-libs x86_64 3.4.0-21.20180522git70f7e08.el8 BaseOS 59 k
net-snmp-agent-libs x86_64 1:5.8-18.el8_3.1 AppStream 747 k
Transaction Summary
===============================================================================================================================================
Install 4 Packages
Upgrade 1 Package
Total download size: 2.2 M
Downloading Packages:
(1/5): net-snmp-agent-libs-5.8-18.el8_3.1.x86_64.rpm 2.5 MB/s | 747 kB 00:00
(2/5): net-snmp-5.8-18.el8_3.1.x86_64.rpm 1.1 MB/s | 354 kB 00:00
(3/5): lm_sensors-libs-3.4.0-21.20180522git70f7e08.el8.x86_64.rpm 801 kB/s | 59 kB 00:00
(4/5): net-snmp-utils-5.8-18.el8_3.1.x86_64.rpm 584 kB/s | 239 kB 00:00
(5/5): net-snmp-libs-5.8-18.el8_3.1.x86_64.rpm 5.2 MB/s | 824 kB 00:00
-----------------------------------------------------------------------------------------------------------------------------------------------
Total 4.7 MB/s | 2.2 MB 00:00
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
Preparing : 1/1
Upgrading : net-snmp-libs-1:5.8-18.el8_3.1.x86_64 1/6
Installing : lm_sensors-libs-3.4.0-21.20180522git70f7e08.el8.x86_64 2/6
Running scriptlet: lm_sensors-libs-3.4.0-21.20180522git70f7e08.el8.x86_64 2/6
Installing : net-snmp-agent-libs-1:5.8-18.el8_3.1.x86_64 3/6
Installing : net-snmp-1:5.8-18.el8_3.1.x86_64 4/6
Running scriptlet: net-snmp-1:5.8-18.el8_3.1.x86_64 4/6
Installing : net-snmp-utils-1:5.8-18.el8_3.1.x86_64 5/6
Cleanup : net-snmp-libs-1:5.8-14.el8.x86_64 6/6
Running scriptlet: net-snmp-libs-1:5.8-14.el8.x86_64 6/6
Verifying : net-snmp-1:5.8-18.el8_3.1.x86_64 1/6
Verifying : net-snmp-agent-libs-1:5.8-18.el8_3.1.x86_64 2/6
Verifying : net-snmp-utils-1:5.8-18.el8_3.1.x86_64 3/6
Verifying : lm_sensors-libs-3.4.0-21.20180522git70f7e08.el8.x86_64 4/6
Verifying : net-snmp-libs-1:5.8-18.el8_3.1.x86_64 5/6
Verifying : net-snmp-libs-1:5.8-14.el8.x86_64 6/6
Installed products updated.
Upgraded:
net-snmp-libs-1:5.8-18.el8_3.1.x86_64
Installed:
lm_sensors-libs-3.4.0-21.20180522git70f7e08.el8.x86_64 net-snmp-1:5.8-18.el8_3.1.x86_64 net-snmp-agent-libs-1:5.8-18.el8_3.1.x86_64
net-snmp-utils-1:5.8-18.el8_3.1.x86_64
Complete!
三、修改SNMP相关配置文件
[root@IT-01 ~]# grep -Ev '^#|^$' /etc/snmp/snmpd.conf
com2sec notConfigUser default public
group notConfigGroup v1 notConfigUser
group notConfigGroup v2c notConfigUser
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
access notConfigGroup "" any noauth exact systemview none none
syslocation Unknown (edit /etc/snmp/snmpd.conf)
syscontact Root <root@localhost> (configure /etc/snmp/snmp.local.conf)
dontLogTCPWrappersConnects yes
四、重启snmp服务
[root@IT-01 ~]# systemctl start snmpd
五、测试收集信息
[root@IT-01 ~]# snmpwalk -v 2c -c public 127.0.0.1 sysname
SNMPv2-MIB::sysName.0 = STRING: IT-01