Prometheus监控系统:监控交换机流量、状态等(snmp_exporter)

本文介绍了如何配置snmp_exporter监控交换机流量和状态,包括下载交换机MIB文件、配置snmp_exporter、修改Prometheus配置文件以及在Grafana中实现可视化。
摘要由CSDN通过智能技术生成

默认已安装Prometheus服务
Prometheus服务地址:192.168.0.254:9090
交换机ip地址:192.168.0.67

一、准备

1.1 下载相应交换机厂家提供的交换机mib文件

如我的交换机是华为S5700交换机,我需要到华为官网上找到S5700型号的mib文件并下载。
在这里插入图片描述

1.2 环境安装

由于Prometheus使用go语言开发的,所以自己编译生成snmp_exporter的配置文件需要go环境。

yum install  go -y

安装依赖模块

yum install -y epel-release
yum  install git -y
yum group install -y "Development Tools"
yum install -y wget net-snmp net-snmp-utils net-snmp-libs net-snmp-devel golang p7zip*

二、配置snmp_exporter

2.1 测试SNMP

(pubilc0001是团体名,.1表示查看所有信息)

snmpwalk -v 2c -c public0001 192.168.0.67 .1

在这里插入图片描述

2.2 git snmp_exporter

cd /
git clone https://github.com/prometheus/snmp_exporter.git

2.3 go国内代理

export GO111MODULE=on
export GOPROXY=https://goproxy.cn,direct

2.4 build generator


                
要使用Prometheus监控华为交换机,需要安装和配置node_exporter,node_exporter是一个Prometheusexporter,可以在Linux或Windows上运行,收集与操作系统相关的指标,并将其公开为Prometheus可以使用的指标。 以下是在Linux上配置node_exporterPrometheus监控华为交换机的步骤: 1. 安装和配置node_exporter 下载并解压node_exporter: ``` wget https://github.com/prometheus/node_exporter/releases/download/v1.0.1/node_exporter-1.0.1.linux-amd64.tar.gz tar xvfz node_exporter-1.0.1.linux-amd64.tar.gz cd node_exporter-1.0.1.linux-amd64/ ``` 运行node_exporter: ``` ./node_exporter ``` 2. 配置华为交换机华为交换机上启用SNMP,并配置读取SNMP信息的Community String。 3. 配置PrometheusPrometheus的配置文件中添加以下内容: ``` scrape_configs: - job_name: 'node_exporter' scrape_interval: 5s static_configs: - targets: ['localhost:9100'] - job_name: 'huawei_switch' scrape_interval: 5s static_configs: - targets: ['<华为交换机IP>:<SNMP端口>'] labels: instance: '<华为交换机IP>' metrics_path: /snmp params: module: [if_mib] static_configs: - targets: ['<SNMP Community String>@<华为交换机IP>'] ``` 其中,将`<华为交换机IP>`和`<SNMP端口>`替换为实际的IP地址和SNMP端口,将`<SNMP Community String>`替换为实际的SNMP Community String。 4. 重启Prometheus 重启Prometheus以使配置文件生效。 5. 查看指标 在Prometheus的Web界面中,可以查看华为交换机收集到的指标。例如,可以查看接口的流量、错误率和丢包率等指标。
评论 13
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值