标签:gets mib mct 重启 int rom ip地址 试验 config
各中间件安装部署请查看第一篇采用的是if_mib模块。所以需要修改if_mib模块的配置文件,添加交换机snmp验证的关键字(默认是public),默认没有监控CPU和内存的OID内容,需要手动添加。
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
····
https://www.cisco.com/c/en/us/support/web/tools-catalog.html
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.html
https://blog.csdn.net/weixin_34088838/article/details/92604104
(二) Prometheus 监控思科交换机---snmp_exporter配置文件修改
标签:gets mib mct 重启 int rom ip地址 试验 config
原文地址:https://blog.51cto.com/liujingyu/2541727