各中間件安裝部署請查看第一篇html
採用的是if_mib模塊。因此須要修改if_mib模塊的配置文件,添加交換機snmp驗證的關鍵字(默認是public),默認沒有監控CPU和內存的OID內容,須要手動添加。web
BJ-BG-Center-S3750-A# show running-config | include snmp ··· snmp-server community ABCDEFG RW ···
yum -y install net-snmp-utils # 查看交換機接口詳細信息,若是能夠正常返回接口信息則說明關鍵字正確 [root@localhost ~]# snmpwalk -v 2c -c ABCDEFG IP_ADDRESS 1.3.6.1.2.1.2 IF-MIB::ifNumber.0 = INTEGER: 146 IF-MIB::ifIndex.1 = INTEGER: 1 IF-MIB::ifIndex.4 = INTEGER: 4 IF-MIB::ifIndex.5 = INTEGER: 5 ····
http://oid-info.com/docker
https://www.cisco.com/c/en/us/support/web/tools-catalog.htmlvim
vim /opt/snmp_exporter/snmp.yml ···· if_mib: auth: community: ABCDEFG walk: - 1.3.6.1.2.1.2 - 1.3.6.1.2.1.31.1.1 - 1.3.6.1.4.1.9.2.1 # 交換機cpu的相關信息 - 1.3.6.1.4.1.9.9.48 # 交換機內存的相關信息 get: - 1.3.6.1.2.1.1.3.0 metrics: - name: busyPer oid: 1.3.6.1.4.1.9.2.1.56.0 type: gauge help: CPU utilization - name: avgBusy1 oid: 1.3.6.1.4.1.9.2.1.57.0 type: gauge help: CPU utilization in the past 1 minute - name: avgBusy2 oid: 1.3.6.1.4.1.9.2.1.58.0 type: gauge help: CPU utilization in the past 5 minute - name: MemoryPoolFree oid: 1.3.6.1.4.1.9.9.48.1.1.1.6.1 type: gauge help: ciscoMemoryPoolFree - name: MemoryPoolUsed oid: 1.3.6.1.4.1.9.9.48.1.1.1.5.1 type: gauge help: ciscoMemoryPoolUsed ···
[root@localhost ~]# systemctl restart snmp_exporter [root@localhost ~]# netstat -tnlp Active Internet connections (only servers) Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 20451/sshd tcp 0 0 127.0.0.1:25 0.0.0.0:* LISTEN 20561/master tcp6 0 0 :::22 :::* LISTEN 20451/sshd tcp6 0 0 ::1:25 :::* LISTEN 20561/master tcp6 0 0 :::9116 :::* LISTEN 27273/snmp_exporter
vim /opt/prometheus/prometheus.yml #添加以下內容 ··· - job_name: 'BJ-BG-Center-3750-A' # 交換機的名稱表示採用Job作區分,而後多個交換機寫多個Job對應便可 static_configs: - targets: ['192.168.4.1'] # 交換機的IP地址 metrics_path: /snmp params: module: [if_mib] # 若是是其餘設備,能夠採用其餘模塊,好比cisco_wlc AP設備, ddwrt 軟路由等等 relabel_configs: - source_labels: [__address__] target_label: __param_target - source_labels: [__param_target] target_label: instance - target_label: __address__ replacement: 192.168.202.239:9116 # The SNMP exporter's real hostname:port. ··· # 個人 prometheus 部署到 docker 容器中,部署到宿主機便可 [root@e36188d4c068 /]# cd /opt/prometheus/ [root@e36188d4c068 prometheus]# ./promtool check config prometheus.yml
能正常顯示 交換機CPU 使用率,則說明 prometheus 監控正常瀏覽器
參考:服務器
https://www.cnblogs.com/leoshi/p/12856713.htmlssh
https://blog.csdn.net/weixin_34088838/article/details/92604104tcp