[SNMP] 安裝與設定 for Centos

紀錄要如何在Centos安裝與設定SNMP 服務,以便於監控軟體後續的設定
安裝 snmp套件
1
yum -y install net-snmp net-snmp-utils

編輯snmp設定檔

1
vi /etc/snmp/snmpd.conf

修改config

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
####
# First, map the community name "public" into a "security name"

# sec.name source community
com2sec notConfigUser default public //通關密碼

####
# Second, map the security name into a group name:

# groupName securityModel securityName
group notConfigGroup v1 notConfigUser
group notConfigGroup v2c notConfigUser

####
# Third, create a view for us to let the group have rights to:

# Make at least snmpwalk -v 1 localhost -c public system fast again.
# name incl/excl subtree mask(optional)
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.

# group context sec.model sec.level prefix read write notif
access notConfigGroup "" any noauth exact systemview none none

# -----------------------------------------------------------------------------

啟動snmp+預設開機啟動

1
2
systemctl enable snmpd.service
systemctl restart snmpd.service

防火牆放行udp161允許snmpd服務存取

1
2
firewall-cmd --add-port=161/udp --permanent
firewall-cmd --reload