各中间件安装部署请查看第一篇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