prometheus监控华为交换机
来源:原创
时间:2024-05-29
作者:脚本小站
分类:网络
交换机上开启snmp:
[S1]snmp-agent community read switch_core # switch_core这个名称是自己起的 [S1]snmp-agent sys-info version all [S1]snmp-agent trap enable
或者在web页面配置:
测试:能获取到数据说明配置正常
snmpwalk -v2c -c switch_core 192.168.101.1 1.3.6.1.2.1.2
安装snmp_exporter:
下载地址:
github.com/prometheus/snmp_exporter
修改 snmp_exporter 包中附带的 snmp.yml:
auths: public_v1: community: public security_level: noAuthNoPriv auth_protocol: MD5 priv_protocol: DES version: 1 public_v2: community: switch_core # 这里的名称就是上面自定义的名称 security_level: noAuthNoPriv auth_protocol: MD5 priv_protocol: DES version: 2
测试:
http://192.168.199.18:9116/
点击提交后如果可以获取数据则说明正常。
prometheus中的配置:
- job_name: 'snmp' scrape_interval: 60s static_configs: - targets: - 192.168.101.1 # 配置上交换机的地址 #- switch.local # SNMP device. #- tcp://192.168.1.3:1161 # SNMP device using TCP transport and custom port. metrics_path: /snmp params: auth: [public_v2] module: [if_mib] relabel_configs: - source_labels: [__address__] target_label: __param_target - source_labels: [__param_target] target_label: instance - target_label: __address__ replacement: 127.0.0.1:9116 # The SNMP exporter's real hostname:port. # Global exporter-level metrics - job_name: 'snmp_exporter' static_configs: - targets: ['localhost:9116']
grafana面板id:
11169 1124