默认已安装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. 【PL/SQL 卡】

    DBA给解决好了,但我不在场,要问一下

  2. async-profiler 容器使用常见问题

    Failed to inject profiler log Failed to inject profiler into 1830 linux-vdso.so.1 => (0x00007ffdf ...

  3. 在程序中修改IP win7 winXP(参考1)

    https://blog.csdn.net/bbdxf/article/details/7548443 Windows下程序修改IP的三种方法 以下讨论的平台依据是Window XP + SP1, 不 ...

  4. CF1149D Abandoning Roads(图论,最短路,状态压缩,最小生成树)

    题目大意:$n$ 个点,$m$ 条边的无向图,边权只有两种,小的为 $a$,大的为 $b$. 对于每个点 $p$,询问在这张图所有的最小生成树上,$1$ 到 $p$ 的最短距离的最小值. $2\le ...

  5. [LeetCode] 333. Largest BST Subtree 最大的二分搜索子树

    Given a binary tree, find the largest subtree which is a Binary Search Tree (BST), where largest mea ...

  6. .NET Core创建Worker Services

    .NET CORE 3.0新增了Worker Services的新项目模板,可以编写长时间运行的后台服务,并且能轻松的部署成windows服务或linux守护程序.如果安装的vs2019是中文版本,W ...

  7. FontForge:免费字库设计软件 附使用教程

    引用:http://www.sucaijishi.com/2018/articles_0817/259.html 如何设计一套自己的字库?今天分享一个开源的字库设计软件FontForge, 官方下载: ...

  8. zipfile

    zipfile是一个用于处理zip压缩格式的文件的模块, 主要会用到它的ZipFile类 import zipfile zipfile.is_zipfile('myzip.zip')) # 判断一个文 ...

  9. TINYMCE使用手册

    TINYMCE使用手册 这方面的教程会陆续加进来. tinymce.get('f1').getContent();

  10. Linux内核中的并发与竞态概述

    1.前言 众所周知,Linux系统是一个多任务的操作系统,当多个任务同时访问同一片内存区域的时候,这些任务可能会相互覆盖内存中数据,从而造成内存中的数据混乱,问题严重的话,还可能会导致系统崩溃. 2. ...