1、首先在CentOS上安裝SNMP及需要的組件
[root@aksnail axing]# yum install -y net-snmp lm_sensors net-snamp-utils
[root@aksnail axing]# service snmpd start
[root@aksnail axing]# systemctl enable snmpd.service
2、更改snmpd配置文件
vim /etc/snmp/snmpd.conf
主要以下幾點:
2.1 通訊字串(密碼)
com2sec notConfigUser default <你的密碼>
2.2 大約在55行左右,改成
# Make at least snmpwalk -v 1 localhost -c public system fast again.
# name incl/excl subtree mask(optional)
view systemview included .1
view systemview included .1.3.6.1.2.1
view systemview included .1.3.6.1.2.1.25.1.1
view systemview included .1.3.6.1.2.1.2
2.3 約84行左右,改成
## incl/excl subtree mask
view all included .1 80
## -or just the mib2 tree-
view mib2 included .iso.org.dod.internet.mgmt.mib-2 fc
2.4 約 152行,改成
152 access notConfigGroup "" any noauth exact all none none
2.5 約163行,改成主機地址和你的郵箱
syslocation <你的主機地址> (edit /etc/snmp/snmpd.conf)
syscontact Root [email protected] (configure /etc/snmp/snmp.local.conf)
2.6 重啓SNMP
systemctl restart snmpd
3、添加防火牆規則,默認防火牆是打開的,允許遠程snmp訪問端口161/udp
firewall-cmd --zone=public --add-port=161/udp --permanent
firewall-cmd --reload
4、在Cacti上添加主機
導航菜單Console -> Management -> Devices ,右上角添加主機。Hostname處填主機IP地址,或者域名(如果有翻譯),Device Template選Net-SNMP Device,其他就沒什麼了。
4.1 添加監控網卡流量
添加完成後,在主機界面可以看到SNMP查詢的一些信息,其他通用操作就不多寫了,想監控網卡流量的話,就在設備標籤頁點擊右上角Create Graph for this Device,選擇Graph Type爲 SNMP - Interface Statistics 即可。