默认已安装Prometheus服务,服务地址:192.168.56.200

一、获取交换机snmp信息

snmp服务IP(交换机IP):172.20.2.83

snmp community:dfetest

二、部署 snmp_exporter

2.1 下载snmp_exporter

下载snmp_exporter安装包,下载地址:https://github.com/prometheus/snmp_exporter/releases

下载完成后,上传至机器的  /usr/local 目录下

解压安装包

#   tar -zvxf snmp_exporter-0.15..linux-arm64.tar.gz
# mv snmp_exporter-0.15..linux-arm64/ snmp_exporter

2.2 配置snmp_exporter

snmp_exporter的配置文件需要自己通过SNMP Exporter Config Generator 项目编译生成,

参考方法: https://github.com/prometheus/snmp_exporter/tree/master/generator#file-format

由于Prometheus使用go语言开发的,所以自己编译生成snmp_exporter的配置文件需要go环境,Linux中安装go环境可参考:https://www.cnblogs.com/guoxiangyue/p/11772717.html  中安装go环境章节

go环境安装以后,构建snmp exporter  config Generator,执行以下操作:

#  yum -y install git
# yum -y install gcc gcc-g++ make net-snmp net-snmp-utils net-snmp-libs net-snmp-devel
# go get github.com/prometheus/snmp_exporter/generator
# cd ${GOPATH-$HOME/go}/src/github.com/prometheus/snmp_exporter/generator
# go build
# make mibs

编译完成后,修改当前目录下的generator.yml 文件,generator.yml文件的配置可以参考 https://github.com/prometheus/snmp_exporter/tree/master/generator#file-format ,generator.yml文件中只需要注入snmp的community即可,下面仅修改了modules.if_mib.auth字段,其余与 File Format 中一致。

#  vim generator.yml

generator.yml 中module.if_mib.auth字段:

modules:
# Default IF-MIB interfaces table with ifIndex.
if_mib:
walk: [sysUpTime, interfaces, ifXTable]
version:
auth:
community: dfetest
lookups:
- source_indexes: [ifIndex]
lookup: ifAlias
- source_indexes: [ifIndex]
lookup: 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. # ifName
overrides:
ifAlias:
ignore: true # Lookup metric
ifDescr:
ignore: true # Lookup metric
ifName:
ignore: true # Lookup metric
ifType:
type: EnumAsInfo

修改完成后,保存退出,执行以下操作,生成新的 snmp.yml 文件

#   export MIBDIRS=mibs
# ./generator generate

将新生成的snmp.yml 替换掉原snmp_exporter中的snmp.yml

#   cp snmp.yml /usr/local/snmp_exporter

2.3 验证并设置snmp_exporter 服务开机启动

#   cd /usr/local/snmp_exporter
# ./snmp_exporter

开启服务端口在9116上,浏览器访问 http://192.168.56.200:9116 , 在 Target 输入框中填入交换机IP地址,点击 submit 按钮,出现数据,在snmp_exporter 配置成功。

2.4 设置snmp_exporter 以服务方式,开机启动

Ctrl+C 结束掉 snmp_exporter 进程,创建 snmp_exporter 服务,让 snmp_exporter 以服务的方式,开机自启。

添加系统服务

#   vim /etc/systemd/system/snmp_exporter.service

将以下内容写入文件中

[Unit]
Description=node_exporter
After=network.target [Service]
ExecStart=/usr/local/snmp_exporter/snmp_exporter
Restart=on-failure [Install]
WantedBy=multi-user.target

启动服务,设置开机自启

#  systemctl daemon-reload
# systemctl enable snmp_exporter
# systemctl start snmp_exporter

三、修改Prometheus 配置

进入Prometheus的安装文件夹,打开Prometheus配置文件

#  cd /usr/local/prometheus
# vim prometheus.yml

在scrape_configs标签下,添加以下内容,配置监控。params.module中可以配置需要抓取的模块,不配置表示全部抓取。

- job_name: 'snmp'
scrape_interval: 10s
static_configs:
- targets:
- 172.20.2.83 # 交换机IP地址
metrics_path: /snmp
# params:
# module: [if_mib]
relabel_configs:
- source_labels: [__address__]
target_label: __param_target
- source_labels: [__param_target]
target_label: instance
- target_label: __address__
replacement: 192.168.56.200: # snmp_exporter 服务IP地址

以下是Prometheus.yml 文件全部内容

# my global config
global:
scrape_interval: 15s # Set the scrape interval to every seconds. Default is every minute.
evaluation_interval: 15s # Evaluate rules every seconds. The default is every minute.
# scrape_timeout is set to the global default (10s). # Alertmanager configuration
alerting:
alertmanagers:
- static_configs:
- targets:
# - alertmanager: # Load rules once and periodically evaluate them according to the global 'evaluation_interval'.
rule_files:
# - "first_rules.yml"
# - "second_rules.yml" # A scrape configuration containing exactly one endpoint to scrape:
# Here it's Prometheus itself.
scrape_configs:
# The job name is added as a label `job=<job_name>` to any timeseries scraped from this config.
- job_name: 'prometheus' # metrics_path defaults to '/metrics'
# scheme defaults to 'http'. static_configs:
- targets: ['localhost:9090'] - job_name: 'Linux'
static_configs:
- targets: ['192.168.56.201:9100']
labels:
instance: Linux - job_name: 'Windows'
static_configs:
- targets: ['192.168.56.1:9182']
labels:
instance: Windows - job_name: 'snmp'
scrape_interval: 10s
static_configs:
- targets:
- 172.20.2.83 # 交换机IP地址
metrics_path: /snmp
# params:
# module: [if_mib]
relabel_configs:
- source_labels: [__address__]
target_label: __param_target
- source_labels: [__param_target]
target_label: instance
- target_label: __address__
replacement: 192.168.56.200: # snmp_exporter 服务IP地址

保存退出,重启Prometheus服务

#  systemctl restart prometheus

浏览器访问 http://192.168.56.200:9090/targets  查看监控信息

可以看到,snmp已经加入进来。

四、配置Grafana

添加dashboard

Grafana官方为我们提供了很多dashboard页面,可直接下载使用。浏览器访问 https://grafana.com/grafana/dashboards 下载所需要的dashboard页面

此处我们使用  snmp 的监控dashboard,dashboard Id为:10523

然后打开我们的Grafana监控页面,打开dashboard的管理页面

点击【import】按钮

然后将我们刚才的dashboard Id (10523) 复制进去

Grafana会自动识别dashboard Id 。

然后点击【change】按钮,生成一个随机的UID,然后点击下方输入框,选择我们之前创建的数据源Prometheus,最后点击【Import】按钮,即可完成导入。

导入成功后,会自动打开该Dashboard,即可看到我们刚才设置好的snmp监控

至此Prometheus监控交换机,配置完成。

Prometheus(三):Prometheus监控交换机(snmp)的更多相关文章

  1. kubernetes之监控Prometheus实战--prometheus介绍--获取监控(一)

    Prometheus介绍 Prometheus是一个最初在SoundCloud上构建的开源监控系统 .它现在是一个独立的开源项目,为了强调这一点,并说明项目的治理结构,Prometheus 于2016 ...

  2. Grafana+Prometheus通过node_exporter监控Linux服务器信息

    Grafana+Prometheus通过node_exporter监控Linux服务器信息 一.Grafana+Prometheus通过node_exporter监控Linux服务器信息 1.1nod ...

  3. Docker系列——Grafana+Prometheus+Node-exporter服务器监控平台(一)

    在最近的博文中,都是介绍监控平台的搭建,其实并不难,主要是需要自己动手操作,实践一番就会了. 有天在想,云上的服务器,是不是也可以搭建一个监控平台,所以就捣鼓了一下,不过遗憾的是,使用阿里云开源的插件 ...

  4. 基于Centos7.4搭建prometheus+grafana+altertManger监控Spring Boot微服务(docker版)

    目的:给我们项目的微服务应用都加上监控告警.在这之前你需要将 Spring Boot Actuator引入 本章主要介绍 如何集成监控告警系统Prometheus 和图形化界面Grafana 如何自定 ...

  5. Prometheus+Grafana企业监控系统

    Prometheus+Grafana企业监控系统 作者 刘畅 实验配置: 主机名称 Ip地址 controlnode 172.16.1.70/24 slavenode1 172.16.1.71/24 ...

  6. Prometheus神器之监控K8s集群

    Prometheus 简介 Prometheus是SoundCloud开源的一款开源软件.它的实现参考了Google内部的监控实现,与源自Google的Kubernetes结合起来非常合适.另外相比i ...

  7. Prometheus 运维监控

    Prometheus 运维监控 1.Prometheus 介绍详解 2.Prometheus 安装部署 3.Prometheus 配置文件详解 4.Prometheus PromSQL 常用资源 5. ...

  8. prometheus+alertmanager+granafa监控总结,安装基于docker-compose(长期更新)

    最近自己个人尝试在使用prometheus+grafana监控工作业务上的指标, 但是报警功能还没有实际用上,但是感觉是很好用,写下一些啃prometheus官网文档并且自己用到的一些配置的总结,后续 ...

  9. 基于grafana+prometheus构建Flink监控

    先上一个架构图 Flink App : 通过report 将数据发出去 Pushgateway :  Prometheus 生态中一个重要工具 Prometheus :  一套开源的系统监控报警框架 ...

随机推荐

  1. Excel-查找函数

    1.VLOOKUP函数 该函数的语法规则如下: VLOOKUP(lookup_value,table_array,col_index_num,range_lookup) 多表关联查询---vlooku ...

  2. Oracle工具PLSQL

    2018版的PLSQL美化工具在Tools中的PL/SQL Beautifier中 如下:

  3. python的可变类型和不可变类型

    Python有六种数据类型:数字类型.字符串类型.列表类型.元组类型.字典类型和集合类型 其中不可变类型包括三种:数字类型.字符串类型和元组类型 剩余三种为可变类型:列表类型.字典类型和集合类型 可变 ...

  4. 动态规划 | DAG最长路

    1.矩形嵌套 查了很久的错,最后发现是ans在每次测试样例输入的时候没有初始化为0 . AC代码: #include <stdio.h> #include <memory.h> ...

  5. Linux性能优化实战学习笔记:第三讲

    一.关于上下文切换的几个为什么 1. 上下文切换是什么? 上下文切换是对任务当前运行状态的暂存和恢复 2. CPU为什么要进行上下文切换? 当多个进程竞争CPU的时候,CPU为了保证每个进程能公平被调 ...

  6. [LeetCode] 505. The Maze II 迷宫之二

    There is a ball in a maze with empty spaces and walls. The ball can go through empty spaces by rolli ...

  7. 说清楚,5G SA和NSA到底有啥区别?

    原文: https://tech.sina.com.cn/5g/i/2019-06-25/doc-ihytcitk7540907.shtml 与4G不同,5G时代有了NSA和SA两个组网选项,这让整个 ...

  8. asp.net mvc移除X-AspNet-Version、X-AspNetMvc-Version、Server

    asp.net mvc程序部署到IIS,,返回的HTTP头中包含Server, X-Powered-By, 和 X-AspNet-Version.X-AspNet-Version信息. 这些信息有时给 ...

  9. Visual Studio 调试系列6 监视变量(使用监视窗口和快速监视窗口)

    系列目录     [已更新最新开发文章,点击查看详细] 当你进行调试时,可以使用 监视窗口 和 快速监视窗口 来监视变量和表达式. 仅在调试会话期间,这两个窗口才可用. 监视窗口可以在调试时一次显示多 ...

  10. .NetCore 入门篇:理解

    (良心转载)原文地址:https://ken.io/note/dotnet-core-qucikstart-preface 一..NET Core的诞生 聊 .NET Core,就不得不说他的爸爸 . ...