前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >Prometheus实现对IDRAC的SNMP监控

Prometheus实现对IDRAC的SNMP监控

作者头像
用户8851537
修改2021-09-01 14:37:26
1.8K0
修改2021-09-01 14:37:26
举报

SNMP是管理进程(NMS)和代理进程(Agent)之间的通信协议。它规定了在网络环境中对设备进行监视和管理的标准化管理框架、通信的公共语言、相应的安全和访问控制机制。网络管理员使用SNMP功能可以查询设备信息、修改设备的参数值、监控设备状态、自动发现网络故障、生成报告等。

snmp_exporter 安装

下载你需要的版本,解压并运行 https://github.com/prometheus/snmp_exporter/releases

nohup /root/snmp_exporter/snmp_exporter --web.listen-address=0.0.0.0:9116 --config.file=/root/snmp_exporter/snmp.yml > /root/logs/snmp_exporter.log 2>&1 &

mibs下载

# Dell iDRAC-SMIv2.mib 下载地址
wget https://dl.dell.com/FOLDER06571535M/1/Dell-OM-MIBS-950_A00.zip
# 解压文件 (记住你的解压路径,后面需要用到)
unzip Dell-OM-MIBS-950_A00.zip
# 目录结构
support/
└── station
    └── mibs
        ├── *.mib

或者可以在下面的git地址找到你所需要的mibs https://github.com/librenms/librenms/tree/master/mibs

# 执行此命令可查看OID对应的名字,我们使用 internet 来采集所有指标,记下这个OID
snmptranslate -Tz -m /root/support/station/mibs/iDRAC-SMIv2.mib

通过mibs生成snmp.yml

参考链接https://github.com/prometheus/snmp_exporter/tree/main/generator#file-format

# 基于 RHEL 的发行版
sudo yum install gcc gcc-g++ make net-snmp net-snmp-utils net-snmp-libs net-snmp-devel
# 安装 golang 与 git
yum install golang git -y
# 配置 go 代理
export GO111MODULE=on
export GOPROXY=https://mirrors.aliyun.com/goproxy/
# 获取 pgk
go get github.com/prometheus/snmp_exporter/generator
# 进入到 pgk 目录
cd ${GOPATH-$HOME/go}/src/github.com/prometheus/snmp_exporter/generator
# 编译 generator
go build

cd ${GOPATH-$HOME/go}/src/github.com/prometheus/snmp_exporter/generator 在该目录目录创建generator.yml,并编辑如下内容

modules:
  idrac:
    walk:
      - 1.3.6.1
    version: 2
    timeout: 30s
    auth:
      community: public
# MIBDIRS替换为你自己的解压路径
export MIBDIRS=/root/support/station/mibs
# 此步骤必须执行,否则将会生成失败,并得到如下失败信息
# level=error ts=2021-07-29T02:44:56.144Z caller=main.go:130 msg="Error generating config netsnmp" err="cannot find oid '1.3.6.1' to walk"
cp /usr/share/snmp/mibs/SNMPv2-SMI.txt /root/support/station/mibs/
# 生成监控指标
./generator generate
# 将 snmp.yml 复制到 snmp_exporter 目录下
cp ./snmp.yml ~/root/snmp_exporter/

如果一切顺利,你将看到如下输出内容 并生成snmp.yml文件,生成路径见最后一行的file字段

[root@prometheus generator]# ./generator generate
level=info ts=2021-07-29T02:46:37.096Z caller=net_snmp.go:144 msg="Loading MIBs" from=/root/support/station/mibs
level=warn ts=2021-07-29T02:46:37.165Z caller=main.go:120 msg="NetSNMP reported parse error(s)" errors=1
level=info ts=2021-07-29T02:46:37.210Z caller=main.go:52 msg="Generating config for module" module=idrac
level=info ts=2021-07-29T02:46:37.246Z caller=main.go:67 msg="Generated metrics" module=idrac metrics=2418
level=info ts=2021-07-29T02:46:37.797Z caller=main.go:92 msg="Config written" file=/root/go/src/github.com/prometheus/snmp_exporter/generator/snmp.yml

测试指标抓取是否正常

prometheus配置

编辑prometheus.yml文件,添加如下job

  - job_name: 'idrac_snmp'
    scrape_interval: 60s
    scrape_timeout: 60s
    static_configs:
    - targets:
      - 192.168.10.201  # SNMP device.
    metrics_path: /snmp
    params:
      module: [idrac]
    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.

测试 promethues 指标查询

指标返回值的具体含义可查看snmp.yml文件内对应的enum_values

本文系转载,前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文系转载前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
目录
  • snmp_exporter 安装
  • mibs下载
  • 通过mibs生成snmp.yml
  • 测试指标抓取是否正常
  • prometheus配置
  • 测试 promethues 指标查询
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档