Categraf+VictoriaMetrics+Grafana网络设备监控方案

背景

应公司网工邀请,一起研究架设一套系统,对公司网络设备进行监控和预警。

基础

什么是SNMP

简单网络管理协议SNMP(Simple Network Management Protocol)用于网络设备的管理。
网络设备多种多样,不同设备不同厂家管理接口各不相同,于是snmp应运而生,SNMP作为广泛应用于TCP/IP网络的网络管理标准协议,提供了统一的接口,从而实现了不同种类和厂商的网络设备之间的统一管理。
SNMP系统由网络管理系统NMS(Network Management System)、SNMP Agent、被管对象Management object和管理信息库MIB(Management Information Base)四部分组成。NMS作为整个网络的网管中心,对设备进行管理。每个被管理设备中都包含驻留在设备上的SNMP Agent进程、MIB和多个被管对象。NMS通过与运行在被管理设备上的SNMP Agent交互,由SNMP Agent通过对设备端的MIB进行操作,完成NMS的指令。
详见:https://support.huawei.com/enterprise/zh/doc/EDOC1100087025

什么是MIB


linux命令行获取方式:

#工具安装命令(centos7)
yum install -y net-snmp-utils
snmpwalk -v 2c -c public xxx.xxx.xxx.xxx(ip) 1.3.6.1.2.1.1

选型学习

通常想到的开源架构就是snmp_exporter+prometheus+grafana,公司项目最常用,也最熟悉。通过各种各样的exporter组件,采集数据并汇聚至prometheus,再通过grafana进行数据处理和图表的展示。
而后来在逛bilibili,解锁了一个交换机监控新姿势。(https://www.bilibili.com/read/cv33912961/)
文中详细说明了架构组件替换的原因。
snmp_exporter ---> Categraf
prometheus ---> VictoriaMetrics

Categraf介绍

https://github.com/flashcatcloud/categraf
Categraf 是一款 All-in-One 的开源的 telemetry 数据采集器,支持指标、日志采集;支持 Tracing 数据的收集;支持物理机、虚拟机、交换机、容器、K8s、多种中间件/数据库的数据采集,支持混合云架构、云原生架构、多云架构。汇聚领域最佳实践,开箱即用。

VictoriaMetrics介绍

https://github.com/VictoriaMetrics/VictoriaMetrics
VictoriaMetrics是一款高性能的时序数据库,用于存储和查询时间序列数据。
详见docs地址:https://docs.victoriametrics.com

选型Categraf的原因

1.支持 remote_write 写入协议,可以直接将数据写入Prometheus,VictoriaMetrics,InfluxDB等等
2.snmp_exporter要手写snmp.yml,对我们来说非常不友好。因此便有了一套配置生成工具。配置的难度就是在于处理配置生成工具和协调mib库上。(具体如何部署,如何使用,后续出一期snmp_exporter+prometheus+grafana再展开来说),而Categraf的snmp插件的运行和采集是结合配置文件+mib文件+mib解析处理工具来得到指标数据。从配置文件的编写方面就更加简单,可以节省很多调试的时间。
3.Categraf支持虚拟表和数据筛选。可以将不同索引的表合并,并且将标签插到采集的指标数据里。

选型VictoriaMetrics的原因

1.支持remote_write 写入协议.(prometheus remote_write API)
2.性能和扩展性上做了很多优化。据说在样本数一直的情况下,磁盘空间使用可以比prometheus少7倍。(有待验证)

安装部署

安装包准备

#到对应的github下下载
#Categraf安装包
categraf-v0.3.76-linux-amd64.tar.gz
#VictoriaMetrics安装包
victoria-metrics-linux-amd64-v1.102.1.tar.gz
#MIB库文件
#根据自己的交换机操作系统到官方下载对应的MIB,这里演示(H3C ComwareV7)
Comware_MIB-20240814.zip
https://www.h3c.com/cn/d_201806/1089291_473262_0.htm
#Grafana安装包(直接安装,开箱即食,自己编译太浪费时间,有做了一键编译部署安装包,但版本比较老,直接用最新的)
sudo yum install -y https://dl.grafana.com/enterprise/release/grafana-enterprise-11.2.0-1.x86_64.rpm
https://grafana.com/grafana/download?pg=get&plcmt=selfmanaged-box1-cta1
#grafana启停/状态/加入开机启动
systemctl start grafana-server.service
systemctl stop grafana-server.service
systemctl status grafana-server.service
systemctl enable grafana-server.service

安装victoria-metrics

mkdir /app/victoria-metrics -p
tar -zxf victoria-metrics-linux-amd64-v1.102.1.tar.gz -C /app/victoria-metrics
#加入systemctl
vim /etc/systemd/system/victoria-metrics.service
[Unit]
Description=victoria-metrics
[Service]
Type=simple
ExecStart=/app/victoria-metrics/victoria-metrics-prod -retentionPeriod=30d -storageDataPath=data -selfScrapeInterval=10s -httpListenAddr=0.0.0.0:8428
WorkingDirectory=/app/victoria-metrics
Restart=always
[Install]
WantedBy=mutil-user.target
#配置生效
systemctl daemon-reload
#启停命令
systemctl start victoria-metrics
systemctl stop victoria-metrics
systemctl status victoria-metrics

安装Categraf

tar -zxf categraf-v0.3.76-linux-amd64.tar.gz -C /app/
#加入systemctl
vim /etc/systemd/system/categraf.service
[Unit]
Description="Categraf"
After=network.target
[Service]
Type=simple
ExecStart=/app/categraf-v0.3.76-linux-amd64/categraf
WorkingDirectory=/app/categraf-v0.3.76-linux-amd64
Restart=on-failure
SuccessExitStatus=0
LimitNOFILE=65536
StandardOutput=syslog
StandardError=syslog
SyslogIdentifier=categraf
[Install]
WantedBy=multi-user.target
#配置生效
systemctl daemon-reload
#启停命令
systemctl start categraf
systemctl stop  categraf
systemctl status categraf

配置Categraf

配置数据库

(在全局配置文件config.toml里面加入要写入的数据库victoria-metrics)

[[writers]]
url = "http://<victoria-metrics-ip>:8428/api/v1/write"

导入MIB文件

mkdir /app/categraf-v0.3.76-linux-amd64/mibs -p
unzip Comware_MIB-20240814.zip -d /app/categraf-v0.3.76-linux-amd64/mibs

cd /app/categraf-v0.3.76-linux-amd64/mibs
mv H3C\ New\ Style\ Private\ MIB/    private
mv H3C\ Public\ MIB/ public

配置input.snmp配置文件

vim /app/categraf-v0.3.76-linux-amd64/conf/input.snmp/snmp.toml

# Retrieves SNMP values from remote agents
[[instances]]
## Agent addresses to retrieve values from.
##   format:  agents = ["<scheme://><hostname>:<port>"]
##   scheme:  optional, either udp, udp4, udp6, tcp, tcp4, tcp6.
##            default is udp
##   port:    optional
##   example: agents = ["udp://127.0.0.1:161"]
##            agents = ["tcp://127.0.0.1:161"]
##            agents = ["udp4://v4only-snmp-agent"]
#agents = ["udp://127.0.0.1:161"]
agents = [
    "udp://192.168.1.3",
    "udp://192.168.1.4",
    "udp://192.168.1.5"
    #
]

## Timeout for each request.
timeout = "5s"

## SNMP version; can be 1, 2, or 3.
version = 2

## Unconnected UDP socket
## When true, SNMP reponses are accepted from any address not just
## the requested address. This can be useful when gathering from
## redundant/failover systems.
# unconnected_udp_socket = false

## Path to mib files
## Used by the gosmi translator.
## To add paths when translating with netsnmp, use the MIBDIRS environment variable
 path = ["/app/categraf-v0.3.76-linux-amd64/mibs"]
 translator = "gosmi"

## SNMP community string.
community = "public"

## Agent host tag
agent_host_tag = "agent_host"
#agent_host_tag = "ident"

## Number of retries to attempt.
retries = 3

## The GETBULK max-repetitions parameter.
max_repetitions = 50


# 系统启动时间
[[instances.field]]
oid = "1.3.6.1.2.1.1.3.0"
name = "uptime"

# 系统名称
[[instances.field]]
oid = "1.3.6.1.2.1.1.5.0"
name = "deviceName"
is_tag = true


# 接口表信息
[[instances.table]]
oid = "IF-MIB::ifTable"
name = "interface"
inherit_tags = ["deviceName"]

# 接口表信息中的某个字段
[[instances.table.field]]
oid = "IF-MIB::ifDescr"
name = "ifDescr"
is_tag = true

[[instances.table.field]]
oid = "IF-MIB::ifSpeed"
name = "ifSpeed"
is_tag = true

[[instances.table.field]]
oid = "IF-MIB::ifType"
name = "ifType"
is_tag = true

[[instances.table.field]]
oid = "IF-MIB::ifMtu"
name = "ifMtu"
is_tag = true

[[instances.table.field]]
oid = "IF-MIB::ifAlias"
name = "ifAlias"
is_tag = true

# 入方向报文统计(64位) ifHCInOctets
[[instances.table.field]]
oid = "1.3.6.1.2.1.31.1.1.1.6"
name = "ifHCInOctets"

# 入方向单播报文统计(64位) ifHCInUcastPkts
[[instances.table.field]]
oid = "1.3.6.1.2.1.31.1.1.1.7"
name = "ifHCInUcastPkts"

# 入方向多播报文统计(64位) ifHCInMulticastPkts
[[instances.table.field]]
oid = "1.3.6.1.2.1.31.1.1.1.8"
name = "ifHCInMulticastPkts"

# 入方向广播报文统计(64位) ifHCInBroadcastPkts
[[instances.table.field]]
oid = "1.3.6.1.2.1.31.1.1.1.9"
name = "ifHCInBroadcastPkts"

# 出方向报文统计(64位) ifHCOutOctets
[[instances.table.field]]
oid = "1.3.6.1.2.1.31.1.1.1.10"
name = "ifHCOutOctets"

# 出方向单播报文统计(64位) ifHCOutUcastPkts
[[instances.table.field]]
oid = "1.3.6.1.2.1.31.1.1.1.11"
name = "ifHCOutUcastPkts"

# 出方向多播报文统计(64位) ifHCOutMulticastPkts
[[instances.table.field]]
oid = "1.3.6.1.2.1.31.1.1.1.12"
name = "ifHCOutMulticastPkts"

# 出方向广播报文统计(64位) ifHCOutBroadcastPkts
[[instances.table.field]]
oid = "1.3.6.1.2.1.31.1.1.1.13"
name = "ifHCOutBroadcastPkts"

# 新建空table h3c_system 索引 entPhysicalIndex 获取实体CPU和内存信息
[[instances.table]]
name = "h3c_system"
index_as_tag = true
filters = ["exprA:ent_descr:^(MODULE|Module) (LEVEL|level)1$", "exprB:ent_name:.*", "exprC:cpu_usage:.*"]
filters_expression = "exprA && exprB && exprC"

# 实体描述信息 entPhysicalDescr
[[instances.table.field]]
oid = "1.3.6.1.2.1.47.1.1.1.1.2"
name = "ent_descr"
is_tag = true

# 实体名称 entPhysicalName
[[instances.table.field]]
oid = "1.3.6.1.2.1.47.1.1.1.1.7"
name = "ent_name"
is_tag = true

# 实体CPU实时利用率统计周期为5秒钟
[[instances.table.field]]
oid = "1.3.6.1.4.1.25506.2.6.1.1.1.1.6"
#oid = "1.3.6.1.4.1.25506.2.6.1.1.1.1.6.212"
name = "cpu_usage"

# 实体内存实时利用率百分比
[[instances.table.field]]
oid = "1.3.6.1.4.1.25506.2.6.1.1.1.1.8"
#oid = "1.3.6.1.4.1.25506.2.6.1.1.1.1.8.212"
name = "mem_usage"

# 新建空table h3c_system 索引 entPhysicalIndex 获取实体风扇状态信息
[[instances.table]]
name = "h3c_system"
index_as_tag = true
filters = ["exprA:ent_class:7", "exprB:ent_name:.*", "exprC:fan:.*"]
filters_expression = "exprA && exprB && exprC"

# 实体类型 entPhysicalClass
[[instances.table.field]]
oid = "1.3.6.1.2.1.47.1.1.1.1.5"
name = "ent_class"
is_tag = true

# 实体名称 entPhysicalName
[[instances.table.field]]
oid = "1.3.6.1.2.1.47.1.1.1.1.7"
name = "ent_name"
is_tag = true

# 实体错误状态 Normal(2)表示正常
[[instances.table.field]]
oid = "1.3.6.1.4.1.25506.2.6.1.1.1.1.19"
name = "fan"

[[instances.table]]
#oid = "IP-MIB::ipNetToMediaPhysAddress"
oid = "1.3.6.1.2.1.4.22.1"
name = "h3c_system"
filters = ["exprA:ip_addr:.*", "exprB:mac:.*", "exprC:type:.*"]
filters_expression = "exprA && exprB && exprC"

# ipNetToMediaNetAddress 获取ip,其实agent_host已经有了并加入标签。
#[[instances.table]]
[[instances.table.field]]
oid = "1.3.6.1.2.1.4.22.1.3"
name = "ip_addr"
#conversion="ipaddr"
is_tag = true

# ipNetToMediaPhysAddress 获取mac地址
[[instances.table.field]]
#[[instances.table]]
oid = "1.3.6.1.2.1.4.22.1.2"
name = "mac"
conversion="hwaddr"
is_tag = true

#获取ip的方式,手动还是dhcp
[[instances.table.field]]
oid = "1.3.6.1.2.1.4.22.1.4"
name = "type"

# 新建空table h3c_system 索引 entPhysicalIndex 获取实体传感器温度信息
[[instances.table]]
name = "h3c_system"
index_as_tag = true
filters = ["exprA:ent_descr:(T|t)emperature.*(sensor|SENSOR)|(Fabric|FABRIC) (.+) (Module|MODULE)|^(MODULE|Module) (LEVEL|level)1$", "exprB:ent_name:.*", "exprC:temperature_value:.*"]
filters_expression = "exprA && exprB && exprC"

# 实体描述信息 entPhysicalDescr
[[instances.table.field]]
oid = "1.3.6.1.2.1.47.1.1.1.1.2"
name = "ent_descr"
is_tag = true

# 实体名称 entPhysicalName
[[instances.table.field]]
oid = "1.3.6.1.2.1.47.1.1.1.1.7"
name = "ent_name"
is_tag = true

# 实体温度 hh3cEntityExtTemperature
[[instances.table.field]]
oid = "1.3.6.1.4.1.25506.2.6.1.1.1.1.12"
name = "temperature_value"

# 设备堆叠数量 hh3cStackMemberNum
[[instances.field]]
oid = "1.3.6.1.4.1.25506.2.91.1.2.0"
name = "h3c_stack_membernum"

# 设备堆叠拓扑 hh3cStackTopology ring 2 chain 1
[[instances.field]]
oid = "1.3.6.1.4.1.25506.2.91.1.7.0"
name = "h3c_stack_topology"

配置说明

1.snmp插件有两种方式用于解析和处理mib文件。一种是gosmi+path模式;一种是netsnmp+环境变量模式(MIBDIRS)。
gosmi+path模式配置:

 path = ["/app/categraf-v0.3.76-linux-amd64/mibs"]
 translator = "gosmi"

netsnmp+环境变量模式(MIBDIRS)配置:

#path = ["/app/categraf-v0.3.76-linux-amd64/mibs"]
 translator = "netsnmp"

虽然不配置path,但是在环境变量里还是要加上的。两种办法加环境变量。

#临时加
export MIBDIRS="/app/categraf-v0.3.76-linux-amd64/mibs/public:/app/categraf-v0.3.76-linux-amd64/mibs/private"
#systemctl配置里面加
# 永久加,在[Service]下添加Environment
Environment="MIBDIRS=/app/categraf-v0.3.76-linux-amd64/mibs/public:/app/categraf-v0.3.76-linux-amd64/mibs/private"

2.配置解读
详见https://flashcat.cloud/docs/content/flashcat-monitor/categraf/plugin/snmp/

3.指标采集测试

./categraf --test --inputs snmp

4.手动调试oid(对象标识符)

 snmpwalk -v 2c -c public <ip> 1.3.6.1.4.1.25506.2.6.1.1.1.1.6

通过oid,查询并确认自己获取的数据。

5.打开vmui,查看指标数据

配置grafana

接下来就是制作展示图表,对抽取到数据库的数据,进行处理,让网工或者运维人员更加直观看到交换机近期运行的信息
参考了一些大佬网上放出来的图,然后自己做仪表板。

grafana接入数据库


这个地址的获取,在vmui里面能看到

配置的版本要大于或者等于2.24.x

grafana的dashboard模版(json)

点击有惊喜
{
  "annotations": {
    "list": [
      {
        "builtIn": 1,
        "datasource": {
          "type": "grafana",
          "uid": "-- Grafana --"
        },
        "enable": true,
        "hide": true,
        "iconColor": "rgba(0, 211, 255, 1)",
        "name": "Annotations & Alerts",
        "type": "dashboard"
      }
    ]
  },
  "description": "h3c switch dashboard for VictoriaMetrics",
  "editable": true,
  "fiscalYearStartMonth": 0,
  "graphTooltip": 0,
  "id": 4,
  "links": [],
  "panels": [
    {
      "datasource": {
        "type": "prometheus",
        "uid": "cdvdmkr1ml0jka"
      },
      "description": "设备在线",
      "fieldConfig": {
        "defaults": {
          "color": {
            "mode": "thresholds"
          },
          "mappings": [
            {
              "options": {
                "0": {
                  "color": "red",
                  "index": 0,
                  "text": "异常"
                },
                "1": {
                  "color": "green",
                  "index": 1,
                  "text": "正常"
                }
              },
              "type": "value"
            }
          ],
          "thresholds": {
            "mode": "absolute",
            "steps": [
              {
                "color": "green",
                "value": null
              }
            ]
          }
        },
        "overrides": []
      },
      "gridPos": {
        "h": 6,
        "w": 4,
        "x": 0,
        "y": 0
      },
      "id": 2,
      "options": {
        "colorMode": "background",
        "graphMode": "none",
        "justifyMode": "auto",
        "orientation": "auto",
        "percentChangeColorMode": "standard",
        "reduceOptions": {
          "calcs": [
            "lastNotNull"
          ],
          "fields": "",
          "values": false
        },
        "showPercentChange": false,
        "text": {},
        "textMode": "auto",
        "wideLayout": true
      },
      "pluginVersion": "11.1.4",
      "targets": [
        {
          "datasource": {
            "type": "prometheus",
            "uid": "cdvdmkr1ml0jka"
          },
          "disableTextWrap": false,
          "editorMode": "code",
          "expr": "snmp_up{agent_host=~\"$agent_host\"}",
          "fullMetaSearch": false,
          "includeNullMetadata": true,
          "instant": false,
          "legendFormat": "__auto",
          "range": true,
          "refId": "A",
          "useBackend": false
        }
      ],
      "title": "设备在线",
      "type": "stat"
    },
    {
      "datasource": {
        "type": "prometheus",
        "uid": "cdvdmkr1ml0jka"
      },
      "description": "cpu使用情况",
      "fieldConfig": {
        "defaults": {
          "color": {
            "mode": "thresholds"
          },
          "mappings": [],
          "thresholds": {
            "mode": "absolute",
            "steps": [
              {
                "color": "green",
                "value": null
              },
              {
                "color": "orange",
                "value": 80
              },
              {
                "color": "red",
                "value": 90
              }
            ]
          },
          "unit": "percent"
        },
        "overrides": []
      },
      "gridPos": {
        "h": 6,
        "w": 5,
        "x": 4,
        "y": 0
      },
      "id": 3,
      "options": {
        "minVizHeight": 75,
        "minVizWidth": 75,
        "orientation": "auto",
        "reduceOptions": {
          "calcs": [
            "lastNotNull"
          ],
          "fields": "",
          "values": false
        },
        "showThresholdLabels": false,
        "showThresholdMarkers": true,
        "sizing": "auto"
      },
      "pluginVersion": "11.1.4",
      "targets": [
        {
          "datasource": {
            "type": "prometheus",
            "uid": "cdvdmkr1ml0jka"
          },
          "editorMode": "code",
          "expr": "snmp_h3c_system_cpu_usage{agent_host=~\"$agent_host\"}",
          "instant": false,
          "legendFormat": "__auto",
          "range": true,
          "refId": "A"
        }
      ],
      "title": "cpu使用情况",
      "type": "gauge"
    },
    {
      "datasource": {
        "type": "prometheus",
        "uid": "cdvdmkr1ml0jka"
      },
      "description": "内存使用情况",
      "fieldConfig": {
        "defaults": {
          "color": {
            "mode": "thresholds"
          },
          "fieldMinMax": false,
          "mappings": [],
          "thresholds": {
            "mode": "percentage",
            "steps": [
              {
                "color": "green",
                "value": null
              },
              {
                "color": "orange",
                "value": 80
              },
              {
                "color": "red",
                "value": 90
              }
            ]
          },
          "unit": "percent"
        },
        "overrides": []
      },
      "gridPos": {
        "h": 6,
        "w": 5,
        "x": 9,
        "y": 0
      },
      "id": 5,
      "options": {
        "minVizHeight": 75,
        "minVizWidth": 75,
        "orientation": "auto",
        "reduceOptions": {
          "calcs": [
            "lastNotNull"
          ],
          "fields": "",
          "values": false
        },
        "showThresholdLabels": false,
        "showThresholdMarkers": true,
        "sizing": "auto",
        "text": {}
      },
      "pluginVersion": "11.1.4",
      "targets": [
        {
          "datasource": {
            "type": "prometheus",
            "uid": "cdvdmkr1ml0jka"
          },
          "editorMode": "code",
          "expr": "snmp_h3c_system_mem_usage{agent_host=~\"$agent_host\"}",
          "instant": false,
          "legendFormat": "__auto",
          "range": true,
          "refId": "A"
        }
      ],
      "title": "内存使用情况",
      "type": "gauge"
    },
    {
      "datasource": {
        "type": "prometheus",
        "uid": "cdvdmkr1ml0jka"
      },
      "description": "设备温度",
      "fieldConfig": {
        "defaults": {
          "color": {
            "mode": "thresholds"
          },
          "mappings": [],
          "thresholds": {
            "mode": "percentage",
            "steps": [
              {
                "color": "green",
                "value": null
              },
              {
                "color": "orange",
                "value": 80
              },
              {
                "color": "red",
                "value": 90
              }
            ]
          },
          "unit": "celsius"
        },
        "overrides": []
      },
      "gridPos": {
        "h": 6,
        "w": 4,
        "x": 14,
        "y": 0
      },
      "id": 4,
      "options": {
        "minVizHeight": 77,
        "minVizWidth": 75,
        "orientation": "auto",
        "reduceOptions": {
          "calcs": [
            "lastNotNull"
          ],
          "fields": "",
          "values": false
        },
        "showThresholdLabels": false,
        "showThresholdMarkers": true,
        "sizing": "auto"
      },
      "pluginVersion": "11.1.4",
      "targets": [
        {
          "datasource": {
            "type": "prometheus",
            "uid": "cdvdmkr1ml0jka"
          },
          "editorMode": "code",
          "expr": "snmp_h3c_system_temperature_value{agent_host=~\"$agent_host\"}",
          "instant": false,
          "legendFormat": "__auto",
          "range": true,
          "refId": "A"
        }
      ],
      "title": "设备温度",
      "type": "gauge"
    },
    {
      "datasource": {
        "type": "prometheus",
        "uid": "cdvdmkr1ml0jka"
      },
      "description": "",
      "fieldConfig": {
        "defaults": {
          "color": {
            "mode": "thresholds"
          },
          "fieldMinMax": false,
          "mappings": [
            {
              "options": {
                "1": {
                  "color": "light-orange",
                  "index": 2,
                  "text": "不支持"
                },
                "2": {
                  "color": "green",
                  "index": 1,
                  "text": "正常"
                },
                "3": {
                  "color": "semi-dark-red",
                  "index": 0,
                  "text": "自检失败"
                },
                "4": {
                  "color": "#808080",
                  "index": 3,
                  "text": "未安装"
                }
              },
              "type": "value"
            }
          ],
          "thresholds": {
            "mode": "absolute",
            "steps": [
              {
                "color": "green",
                "value": null
              }
            ]
          }
        },
        "overrides": []
      },
      "gridPos": {
        "h": 6,
        "w": 4,
        "x": 0,
        "y": 6
      },
      "id": 6,
      "options": {
        "colorMode": "background",
        "graphMode": "none",
        "justifyMode": "auto",
        "orientation": "auto",
        "percentChangeColorMode": "standard",
        "reduceOptions": {
          "calcs": [
            "lastNotNull"
          ],
          "fields": "",
          "values": false
        },
        "showPercentChange": false,
        "text": {
          "titleSize": 1
        },
        "textMode": "value",
        "wideLayout": true
      },
      "pluginVersion": "11.1.4",
      "targets": [
        {
          "datasource": {
            "type": "prometheus",
            "uid": "cdvdmkr1ml0jka"
          },
          "editorMode": "builder",
          "expr": "snmp_h3c_system_fan{agent_host=~\"$agent_host\"}",
          "instant": false,
          "legendFormat": "{{ent_name}}",
          "range": true,
          "refId": "A"
        }
      ],
      "title": "风扇状态",
      "type": "stat"
    },
    {
      "datasource": {
        "type": "prometheus",
        "uid": "cdvdmkr1ml0jka"
      },
      "fieldConfig": {
        "defaults": {
          "color": {
            "fixedColor": "blue",
            "mode": "fixed"
          },
          "mappings": [],
          "thresholds": {
            "mode": "absolute",
            "steps": [
              {
                "color": "green",
                "value": null
              },
              {
                "color": "red",
                "value": 80
              }
            ]
          }
        },
        "overrides": []
      },
      "gridPos": {
        "h": 6,
        "w": 5,
        "x": 4,
        "y": 6
      },
      "id": 1,
      "options": {
        "colorMode": "value",
        "graphMode": "none",
        "justifyMode": "auto",
        "orientation": "auto",
        "percentChangeColorMode": "standard",
        "reduceOptions": {
          "calcs": [
            "lastNotNull"
          ],
          "fields": "",
          "values": false
        },
        "showPercentChange": false,
        "text": {
          "titleSize": 1
        },
        "textMode": "auto",
        "wideLayout": true
      },
      "pluginVersion": "11.1.4",
      "targets": [
        {
          "datasource": {
            "type": "prometheus",
            "uid": "cdvdmkr1ml0jka"
          },
          "disableTextWrap": false,
          "editorMode": "code",
          "expr": "snmp_uptime{agent_host=~\"$agent_host\"}/86400/100",
          "fullMetaSearch": false,
          "includeNullMetadata": true,
          "instant": false,
          "legendFormat": "__auto",
          "range": true,
          "refId": "A",
          "useBackend": false
        }
      ],
      "title": "设备启动(天)",
      "type": "stat"
    },
    {
      "datasource": {
        "type": "prometheus",
        "uid": "cdvdmkr1ml0jka"
      },
      "description": "设备堆叠数量",
      "fieldConfig": {
        "defaults": {
          "color": {
            "mode": "thresholds"
          },
          "mappings": [],
          "thresholds": {
            "mode": "absolute",
            "steps": [
              {
                "color": "green",
                "value": null
              }
            ]
          }
        },
        "overrides": []
      },
      "gridPos": {
        "h": 6,
        "w": 5,
        "x": 9,
        "y": 6
      },
      "id": 7,
      "options": {
        "colorMode": "value",
        "graphMode": "none",
        "justifyMode": "auto",
        "orientation": "auto",
        "percentChangeColorMode": "standard",
        "reduceOptions": {
          "calcs": [
            "lastNotNull"
          ],
          "fields": "",
          "values": false
        },
        "showPercentChange": false,
        "textMode": "auto",
        "wideLayout": true
      },
      "pluginVersion": "11.1.4",
      "targets": [
        {
          "datasource": {
            "type": "prometheus",
            "uid": "cdvdmkr1ml0jka"
          },
          "editorMode": "code",
          "expr": "snmp_h3c_stack_membernum{agent_host=~\"$agent_host\"}",
          "instant": false,
          "legendFormat": "__auto",
          "range": true,
          "refId": "A"
        }
      ],
      "title": "设备堆叠数量",
      "type": "stat"
    },
    {
      "datasource": {
        "type": "prometheus",
        "uid": "cdvdmkr1ml0jka"
      },
      "description": "设备堆叠拓扑类型",
      "fieldConfig": {
        "defaults": {
          "color": {
            "mode": "thresholds"
          },
          "fieldMinMax": false,
          "mappings": [
            {
              "options": {
                "1": {
                  "index": 0,
                  "text": "链式连接"
                },
                "2": {
                  "index": 1,
                  "text": "环形连接"
                },
                "3": {
                  "index": 2,
                  "text": "星型连接"
                },
                "4": {
                  "index": 3,
                  "text": "树形连接"
                },
                "5": {
                  "index": 4,
                  "text": "全互联"
                }
              },
              "type": "value"
            }
          ],
          "thresholds": {
            "mode": "absolute",
            "steps": [
              {
                "color": "purple",
                "value": null
              }
            ]
          }
        },
        "overrides": []
      },
      "gridPos": {
        "h": 6,
        "w": 4,
        "x": 14,
        "y": 6
      },
      "id": 8,
      "options": {
        "colorMode": "value",
        "graphMode": "none",
        "justifyMode": "auto",
        "orientation": "auto",
        "percentChangeColorMode": "standard",
        "reduceOptions": {
          "calcs": [
            "lastNotNull"
          ],
          "fields": "",
          "values": false
        },
        "showPercentChange": false,
        "textMode": "auto",
        "wideLayout": true
      },
      "pluginVersion": "11.1.4",
      "targets": [
        {
          "datasource": {
            "type": "prometheus",
            "uid": "cdvdmkr1ml0jka"
          },
          "editorMode": "code",
          "exemplar": false,
          "expr": "snmp_h3c_stack_topology{agent_host=~\"$agent_host\"}",
          "instant": false,
          "interval": "",
          "legendFormat": "__auto",
          "range": true,
          "refId": "A"
        }
      ],
      "title": "设备堆叠拓扑类型",
      "type": "stat"
    },
    {
      "datasource": {
        "type": "prometheus",
        "uid": "cdvdmkr1ml0jka"
      },
      "fieldConfig": {
        "defaults": {
          "color": {
            "mode": "palette-classic"
          },
          "custom": {
            "axisBorderShow": false,
            "axisCenteredZero": false,
            "axisColorMode": "text",
            "axisLabel": "上传(-)/下载(+)",
            "axisPlacement": "auto",
            "barAlignment": 0,
            "drawStyle": "line",
            "fillOpacity": 10,
            "gradientMode": "none",
            "hideFrom": {
              "legend": false,
              "tooltip": false,
              "viz": false
            },
            "insertNulls": false,
            "lineInterpolation": "linear",
            "lineWidth": 2,
            "pointSize": 5,
            "scaleDistribution": {
              "type": "linear"
            },
            "showPoints": "never",
            "spanNulls": false,
            "stacking": {
              "group": "A",
              "mode": "none"
            },
            "thresholdsStyle": {
              "mode": "off"
            }
          },
          "mappings": [],
          "thresholds": {
            "mode": "absolute",
            "steps": [
              {
                "color": "green",
                "value": null
              }
            ]
          },
          "unit": "bps"
        },
        "overrides": [
          {
            "matcher": {
              "id": "byRegexp",
              "options": "/.*_out上传$/"
            },
            "properties": [
              {
                "id": "custom.transform",
                "value": "negative-Y"
              }
            ]
          },
          {
            "matcher": {
              "id": "byValue",
              "options": {
                "op": "gte",
                "reducer": "allIsZero",
                "value": 0
              }
            },
            "properties": [
              {
                "id": "custom.hideFrom",
                "value": {
                  "legend": true,
                  "tooltip": true,
                  "viz": false
                }
              }
            ]
          },
          {
            "matcher": {
              "id": "byValue",
              "options": {
                "op": "gte",
                "reducer": "allIsNull",
                "value": 0
              }
            },
            "properties": [
              {
                "id": "custom.hideFrom",
                "value": {
                  "legend": true,
                  "tooltip": true,
                  "viz": false
                }
              }
            ]
          }
        ]
      },
      "gridPos": {
        "h": 11,
        "w": 18,
        "x": 0,
        "y": 12
      },
      "id": 9,
      "options": {
        "legend": {
          "calcs": [
            "lastNotNull",
            "max",
            "min"
          ],
          "displayMode": "list",
          "placement": "right",
          "showLegend": true
        },
        "tooltip": {
          "mode": "single",
          "sort": "none"
        }
      },
      "targets": [
        {
          "datasource": {
            "type": "prometheus",
            "uid": "cdvdmkr1ml0jka"
          },
          "disableTextWrap": false,
          "editorMode": "code",
          "exemplar": false,
          "expr": "irate(snmp_interface_ifHCInOctets{agent_host=~\"$agent_host\"}[5m])*8",
          "fullMetaSearch": false,
          "includeNullMetadata": true,
          "instant": false,
          "interval": "",
          "legendFormat": "{{ifDescr}}_in下载",
          "range": true,
          "refId": "A",
          "useBackend": false
        },
        {
          "datasource": {
            "type": "prometheus",
            "uid": "cdvdmkr1ml0jka"
          },
          "editorMode": "code",
          "expr": "irate(snmp_interface_ifHCOutOctets{agent_host=~\"$agent_host\"}[5m])*8",
          "hide": false,
          "instant": false,
          "legendFormat": "{{ifDescr}}_out上传",
          "range": true,
          "refId": "B"
        }
      ],
      "title": "全接口上行/下行",
      "type": "timeseries"
    },
    {
      "datasource": {
        "type": "prometheus",
        "uid": "cdvdmkr1ml0jka"
      },
      "description": "ip and mac",
      "fieldConfig": {
        "defaults": {
          "color": {
            "mode": "thresholds"
          },
          "custom": {
            "align": "center",
            "cellOptions": {
              "type": "auto",
              "wrapText": false
            },
            "filterable": true,
            "inspect": false
          },
          "fieldMinMax": false,
          "mappings": [
            {
              "options": {
                "1": {
                  "index": 3,
                  "text": "other"
                },
                "2": {
                  "index": 2,
                  "text": "invalid"
                },
                "3": {
                  "index": 1,
                  "text": "dynamic"
                },
                "4": {
                  "index": 0,
                  "text": "static"
                }
              },
              "type": "value"
            }
          ],
          "thresholds": {
            "mode": "absolute",
            "steps": [
              {
                "color": "green",
                "value": null
              }
            ]
          }
        },
        "overrides": [
          {
            "matcher": {
              "id": "byName",
              "options": "ipNetToMediaIfIndex"
            },
            "properties": [
              {
                "id": "mappings",
                "value": [
                  {
                    "options": {
                      "639": {
                        "index": 0,
                        "text": "Vlan20"
                      },
                      "640": {
                        "index": 1,
                        "text": "Vlan30"
                      },
                      "641": {
                        "index": 2,
                        "text": "Vlan40"
                      },
                      "642": {
                        "index": 3,
                        "text": "Vlan50"
                      },
                      "643": {
                        "index": 4,
                        "text": "Vlan60"
                      },
                      "644": {
                        "index": 5,
                        "text": "Vlan70"
                      }
                    },
                    "type": "value"
                  }
                ]
              }
            ]
          },
          {
            "matcher": {
              "id": "byName",
              "options": "mac"
            },
            "properties": [
              {
                "id": "custom.cellOptions",
                "value": {
                  "type": "json-view"
                }
              }
            ]
          }
        ]
      },
      "gridPos": {
        "h": 9,
        "w": 18,
        "x": 0,
        "y": 23
      },
      "id": 12,
      "options": {
        "cellHeight": "sm",
        "footer": {
          "countRows": false,
          "enablePagination": false,
          "fields": "",
          "reducer": [
            "sum"
          ],
          "show": false
        },
        "showHeader": true,
        "sortBy": [
          {
            "desc": true,
            "displayName": "mac"
          }
        ]
      },
      "pluginVersion": "11.1.4",
      "targets": [
        {
          "datasource": {
            "type": "prometheus",
            "uid": "cdvdmkr1ml0jka"
          },
          "editorMode": "code",
          "exemplar": false,
          "expr": "snmp_h3c_system_type{agent_host=~\"$agent_host\"}",
          "format": "table",
          "hide": false,
          "instant": true,
          "interval": "",
          "legendFormat": "__auto",
          "range": false,
          "refId": "A"
        }
      ],
      "title": "ip and mac",
      "transformations": [
        {
          "id": "organize",
          "options": {
            "excludeByName": {
              "Time": true,
              "__name__": true,
              "agent_host": true,
              "agent_hostname": true,
              "index": true,
              "ip_addr": true
            },
            "includeByName": {},
            "indexByName": {},
            "renameByName": {
              "Value": "ip获取方式",
              "ipNetToMediaIfIndex": "VLAN",
              "ipNetToMediaNetAddress": "ip_addr"
            }
          }
        }
      ],
      "type": "table"
    },
    {
      "datasource": {
        "type": "prometheus",
        "uid": "cdvdmkr1ml0jka"
      },
      "description": "上行(实时-Top10)",
      "fieldConfig": {
        "defaults": {
          "color": {
            "mode": "thresholds"
          },
          "mappings": [],
          "thresholds": {
            "mode": "absolute",
            "steps": [
              {
                "color": "green"
              }
            ]
          },
          "unit": "decbits"
        },
        "overrides": [
          {
            "matcher": {
              "id": "byValue",
              "options": {
                "op": "gte",
                "reducer": "allIsZero",
                "value": 0
              }
            },
            "properties": []
          },
          {
            "matcher": {
              "id": "byValue",
              "options": {
                "op": "gte",
                "reducer": "allIsNull",
                "value": 0
              }
            },
            "properties": []
          }
        ]
      },
      "gridPos": {
        "h": 16,
        "w": 9,
        "x": 0,
        "y": 32
      },
      "id": 11,
      "options": {
        "displayMode": "gradient",
        "maxVizHeight": 300,
        "minVizHeight": 16,
        "minVizWidth": 8,
        "namePlacement": "auto",
        "orientation": "horizontal",
        "reduceOptions": {
          "calcs": [
            "lastNotNull"
          ],
          "fields": "",
          "values": false
        },
        "showUnfilled": true,
        "sizing": "auto",
        "valueMode": "color"
      },
      "pluginVersion": "11.1.4",
      "targets": [
        {
          "datasource": {
            "type": "prometheus",
            "uid": "cdvdmkr1ml0jka"
          },
          "disableTextWrap": false,
          "editorMode": "code",
          "exemplar": false,
          "expr": "topk(10,irate(snmp_interface_ifHCInOctets{agent_host=~\"$agent_host\"}[5m])*8)",
          "fullMetaSearch": false,
          "includeNullMetadata": true,
          "instant": false,
          "interval": "",
          "legendFormat": "{{ifDescr}}",
          "range": true,
          "refId": "A",
          "useBackend": false
        }
      ],
      "title": "上行(实时-Top10)",
      "type": "bargauge"
    },
    {
      "datasource": {
        "type": "prometheus",
        "uid": "cdvdmkr1ml0jka"
      },
      "description": "下行(实时-Top10)",
      "fieldConfig": {
        "defaults": {
          "color": {
            "mode": "thresholds"
          },
          "mappings": [],
          "thresholds": {
            "mode": "absolute",
            "steps": [
              {
                "color": "green"
              }
            ]
          },
          "unit": "decbits"
        },
        "overrides": [
          {
            "matcher": {
              "id": "byValue",
              "options": {
                "op": "gte",
                "reducer": "allIsZero",
                "value": 0
              }
            },
            "properties": []
          },
          {
            "matcher": {
              "id": "byValue",
              "options": {
                "op": "gte",
                "reducer": "allIsNull",
                "value": 0
              }
            },
            "properties": []
          }
        ]
      },
      "gridPos": {
        "h": 16,
        "w": 9,
        "x": 9,
        "y": 32
      },
      "id": 10,
      "options": {
        "displayMode": "gradient",
        "maxVizHeight": 300,
        "minVizHeight": 16,
        "minVizWidth": 8,
        "namePlacement": "auto",
        "orientation": "horizontal",
        "reduceOptions": {
          "calcs": [
            "lastNotNull"
          ],
          "fields": "",
          "values": false
        },
        "showUnfilled": true,
        "sizing": "auto",
        "valueMode": "color"
      },
      "pluginVersion": "11.1.4",
      "targets": [
        {
          "datasource": {
            "type": "prometheus",
            "uid": "cdvdmkr1ml0jka"
          },
          "disableTextWrap": false,
          "editorMode": "code",
          "exemplar": false,
          "expr": "topk(10,irate(snmp_interface_ifHCInOctets{agent_host=~\"$agent_host\"}[5m]) * 8) by (interface_name)",
          "fullMetaSearch": false,
          "includeNullMetadata": true,
          "instant": false,
          "interval": "",
          "legendFormat": "{{ifDescr}}",
          "range": true,
          "refId": "A",
          "useBackend": false
        }
      ],
      "title": "下行(实时-Top10)",
      "type": "bargauge"
    },
    {
      "datasource": {
        "type": "prometheus",
        "uid": "cdvdmkr1ml0jka"
      },
      "description": "",
      "gridPos": {
        "h": 15,
        "w": 12,
        "x": 0,
        "y": 48
      },
      "id": 13,
      "options": {
        "code": {
          "language": "plaintext",
          "showLineNumbers": false,
          "showMiniMap": false
        },
        "content": "#XXXXXX说明\n\n\n",
        "mode": "markdown"
      },
      "pluginVersion": "11.1.4",
      "type": "text"
    }
  ],
  "schemaVersion": 39,
  "tags": [
    "H3C Switch ",
    "categraf"
  ],
  "templating": {
    "list": [
      {
        "current": {
          "selected": false,
          "text": "192.168.20.2",
          "value": "192.168.20.2"
        },
        "datasource": {
          "type": "prometheus",
          "uid": "cdvdmkr1ml0jka"
        },
        "definition": "label_values(agent_host)",
        "hide": 0,
        "includeAll": false,
        "label": "设备ip",
        "multi": false,
        "name": "agent_host",
        "options": [],
        "query": {
          "qryType": 4,
          "query": "label_values(agent_host)",
          "refId": "PrometheusVariableQueryEditor-VariableQuery"
        },
        "refresh": 1,
        "regex": "",
        "skipUrlSync": false,
        "sort": 0,
        "type": "query"
      },
      {
        "current": {
          "selected": false,
          "text": "CORE",
          "value": "CORE"
        },
        "datasource": {
          "type": "prometheus",
          "uid": "cdvdmkr1ml0jka"
        },
        "definition": "label_values(deviceName)",
        "hide": 0,
        "includeAll": false,
        "label": "设备名",
        "multi": false,
        "name": "deviceName",
        "options": [],
        "query": {
          "qryType": 4,
          "query": "label_values(deviceName)",
          "refId": "PrometheusVariableQueryEditor-VariableQuery"
        },
        "refresh": 1,
        "regex": "",
        "skipUrlSync": false,
        "sort": 0,
        "type": "query"
      },
      {
        "current": {
          "selected": false,
          "text": "GigabitEthernet1/0/1",
          "value": "GigabitEthernet1/0/1"
        },
        "datasource": {
          "type": "prometheus",
          "uid": "cdvdmkr1ml0jka"
        },
        "definition": "label_values(ifDescr)",
        "hide": 0,
        "includeAll": false,
        "label": "指定接口",
        "multi": false,
        "name": "ifDescr",
        "options": [],
        "query": {
          "qryType": 4,
          "query": "label_values(ifDescr)",
          "refId": "PrometheusVariableQueryEditor-VariableQuery"
        },
        "refresh": 1,
        "regex": "",
        "skipUrlSync": false,
        "sort": 0,
        "type": "query"
      },
      {
        "datasource": {
          "type": "prometheus",
          "uid": "cdvdmkr1ml0jka"
        },
        "filters": [],
        "hide": 0,
        "name": "Filters",
        "skipUrlSync": false,
        "type": "adhoc"
      }
    ]
  },
  "time": {
    "from": "now-6h",
    "to": "now"
  },
  "timepicker": {
    "hidden": false
  },
  "timezone": "browser",
  "title": "h3c switch dashboard for VictoriaMetrics",
  "uid": "bdvgf49jzn08wf",
  "version": 49,
  "weekStart": ""
}

扩展:RFC文档
https://rfc2cn.com/rfc3416.html

posted @ 2024-09-02 18:16  海yo  阅读(407)  评论(0编辑  收藏  举报