snmp_exporter监控华为网络设备

1、安装环境依赖、测试SNMP联通
//安装依赖
yum install gcc make net-snmp net-snmp-utils net-snmp-libs net-snmp-devel
snmpwalk -v 2c -c public_read 10.0.0.1 //交换机地址
2、拉取Git snmp_exporter
cd /usr/local/
git clone https://github.com/prometheus/snmp_exporter
3、修改go环境变量国内代理地址
go env -w GO111MODULE=on
go env -w GOPROXY=https://goproxy.cn,direct
4、编译snmp_export
cd /usr.local/snmp_exporter/
go build
5、编译“generator”配置生成器
cd /usr.local/snmp_exporter/generator/
go build
6、使用./generator生成snmp.yml
//暂时不用make mibs,这里下载华为mib包,解压的mib文件夹复制到generator目录
cp -r  /home/Huawei_MIB/mib/ /***/generator/
//设置环境变量$MIBDIRS=存放mib文件的目录
export MIBDIRS=mib 
//生成snmp.yml
./generator generate

generator.yml配置文件参考:
walk下面是你查询信息对应的模块名或oid,community这个写snmp协议设置的团体名,huawei_mib使用snmp查的时候、prometheus配置文件的时候写对应的名称。

modules:
  # Default IF-MIB interfaces table with ifIndex.
  huawei_mib:
    walk: 
      - sysUpTime
      - interfaces
      - ifXTable
      - sysDescr
      - sysName
      - 1.3.6.1.2.1.31.1.1.1.1
                  ***
    version: 2
    auth:
      community: public_read
    lookups:
      - source_indexes: [ifIndex]
        lookup: ifAlias
      - source_indexes: [ifIndex]
        # Uis OID to avoid conflict with PaloAlto PAN-COMMON-MIB.
        lookup: 1.3.6.1.2.1.2.2.1.2 # ifDescr
      - source_indexes: [ifIndex]
        # Use OID to avoid conflict with Netscaler NS-ROOT-MIB.
        lookup: 1.3.6.1.2.1.31.1.1.1.1 # ifName
    overrides:
      ifAlias:
        ignore: true # Lookup metric
      ifDescr:
        ignore: true # Lookup metric
      ifName:
        ignore: true # Lookup metric
      ifType:
        type: EnumAsInfo
6、启动验证snmp_exporter 服务

先复制生成的snmp.yml覆盖原配置文件后启动,服务端口在9116,浏览器访问 在 Target 中填入交换机IP地址出现数据,配置成功。

cp snmp.yml /usr/local/snmp_exporter
cd /usr/local/snmp_exporter
./snmp_exporter
7、在Prometheus配置文件中添加数据节点
- job_name: 'snmp'
    scrape_interval: 10s #刷新间隔默认10s
    scrape_timeout: 1m  #超时时间,snmp_exporter刷数据慢修改大一点
    static_configs:
     - targets:
       - 10.1.0.1  #交换机IP地址
    metrics_path: /snmp
    params:
     module: [huawei_mib]  #generator.yml自定义文件的模块名
    relabel_configs:
      - source_labels: [__address__]
        target_label: __param_target
      - source_labels: [__param_target]
        target_label: instance
      - target_label: __address__
        replacement: 192.168.2.207:9116 # snmp_exporter 服务IP地址
8、Grafana添加dashboard
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • Prometheus SNMP Exporter 项目地址 SNMP Exporter 从 SNMP 服务中采集信...
    科举阅读 7,440评论 0 3
  • 将这篇文档命名为exporters,是因为其内容主要对github.com上的常用”***_exporters“做...
    aneirin阅读 1,264评论 0 0
  • 1 网络指标监控 网络设备(交换机、路由器、防火墙)本身并没有太多的监控方式,常规的是使用snmp,通过oid...
    luofengmacheng阅读 13,663评论 0 1
  • SNMP Exporter generator 项目地址 此配置生成器使用 NetSNMP 解析 MIB,并使用它...
    科举阅读 9,207评论 0 1
  • 我是黑夜里大雨纷飞的人啊 1 “又到一年六月,有人笑有人哭,有人欢乐有人忧愁,有人惊喜有人失落,有的觉得收获满满有...
    陌忘宇阅读 8,587评论 28 53