生成snmp.yml文件

  1. 下载并编译generator
go install github.com/prometheus/snmp_exporter/generator@latest
cd ${GOPATH-$HOME/go}/src/github.com/prometheus/snmp_exporter/generator
# ${GOPATH}/pkg/mod/github.com/prometheus/snmp_exporter@v0.20.0/generator
go build
  1. 创建mibs目录,用于存放mib文本文件
mkdir /home/wt/project/mibs_207

将mibs文件全放到这个目录

  1. 将mib目录指定到环境变量
    export MIBDIRS=/home/wangteng/project/mibs_207

  2. 编辑\({GOPATH-\)HOME/go}/src/github.com/prometheus/snmp_exporter/generator.yml

modules:
  module_name:  # The module name. You can have as many modules as you want.
    walk:       # List of OIDs to walk. Can also be SNMP object names or specific instances.
      - 1.3.6.1.2.1.2              # Same as "interfaces"获取接口信息,不用变,通用oid,也可以用snmp通用的文字字符串
      - sysUpTime                  # Same as "1.3.6.1.2.1.1.3"获取系统启动时间,不用变,通用的snmp通用的文字字符串,也可以使用通用的oid
      - 1.3.6.1.4.1.3375  # Instance of "ifHCInOctets" with index "40" 指定设备的父oid
      # 还可以添加其他的,具体可查询http://oidref.com/

    version: 2  # SNMP version to use. Defaults to 2.
                # 1 will use GETNEXT, 2 and 3 use GETBULK.
    max_repetitions: 25  # How many objects to request with GET/GETBULK, defaults to 25.
                          # May need to be reduced for buggy devices.
    retries: 3   # How many times to retry a failed request, defaults to 3.
    timeout: 10s # Timeout for each walk, defaults to 10s.

    auth:
      community: public123     # 指定snmp community


  1. 生成snmp.yml文件
    ./generator generate
posted @ 2022-07-14 09:46  明天OoO你好  阅读(1270)  评论(0编辑  收藏  举报