使用snmp-exporter监控h3c路由器
source link: https://www.bboy.app/2023/03/09/%E4%BD%BF%E7%94%A8snmp-exporter%E7%9B%91%E6%8E%A7h3c%E8%B7%AF%E7%94%B1%E5%99%A8/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
家里的h3c路由器是支持snmp的,所以就想着监控起来,型号是ER3200G3
首先要找mib,貌似h3c的mib都是通用的,我是从下面这个地址下载的
配置路由器
路由器这边首先开启snmp,我是v1到v3全开的,然后本地引擎ID随便输入一个比如800007DB03360102101100
其他的保持默认
编译generator
首先clone项目
git clone https://github.com/prometheus/snmp_exporter.git
进入到generator工具目录
cd snmp_exporter/generator
apt install golang libsnmp-dev
go build
创建generator.yml
下面是我的generator.yml
mmodules:
# Default IF-MIB interfaces table with ifIndex.
if_mib:
walk:
- 1.3.6.1.2.1.1.3 # 启动时间
- 1.3.6.1.2.1.31.1.1.1.6 # 入方向字节数
- 1.3.6.1.2.1.31.1.1.1.10 # 出方向字节数
- 1.3.6.1.2.1.2.2.1.8 # 端口运行状态
- 1.3.6.1.2.1.4.20.1.1 # 获取所有的接口ip
- 1.3.6.1.4.1.25506.2.6.1.1.1.1.6 # 获取单板CPU利用率
- 1.3.6.1.4.1.25506.2.6.1.1.1.1.8 # 获取单板内存利用率
auth:
community: public
h3c路由器常用mib清单在下面
https://www.h3c.com/cn/Service/Document_Software/TechnicalInfo/PorductMaintanInfo/Router/DailyMainten/MIBList/
随便选择一个清单列表,然后找到你需要的oid就好了,然后填到上面的generator.yml中
如果你不确定oid是不是可以使用,你可以安装snmpwalk,然后使用下面的命令确认下
snmpwalk -v 2c -c public 10.10.100.1 1.3.6.1.4.1.25506.8.35.9.1.2.1.2
-v 表示的是snmp的版本,-c 表示团体名,之后就是ip,最后是oid
生成snmp.yaml
把最上面的mib文件解压,然后把里面所有的单独文件都放到项目里面的mib文件夹中
./generator generate -o snmp.yml
安装snmp-exporter
编写deployment
apiVersion: apps/v1
kind: Deployment
metadata:
name: h3c-snmp-exporter
namespace: app
spec:
selector:
matchLabels:
app: h3c-snmp-exporter
template:
metadata:
labels:
app: h3c-snmp-exporter
spec:
imagePullSecrets:
- name: regcred
containers:
- name: h3c-snmp-exporter
image: prom/snmp-exporter:v0.21.0
ports:
- containerPort: 9116
env:
- name: TZ
value: "Asia/Shanghai"
args:
- "--config.file=/h3c-snmp-exporter/snmp.yml"
volumeMounts:
- mountPath: /h3c-snmp-exporter/snmp.yml
name: h3c-snmp-exporter-config
subPath: snmp.yml
resources:
limits:
memory: "128Mi"
cpu: "500m"
volumes:
- name: h3c-snmp-exporter-config
configMap:
name: h3c-snmp-exporter-config
items:
- key: snmp.yml
path: snmp.yml
编写configmap
apiVersion: v1
kind: ConfigMap
metadata:
name: h3c-snmp-exporter-config
namespace: app
data:
snmp.yml: |-
# WARNING: This file was auto-generated using snmp_exporter generator, manual changes will be lost.
if_mib:
walk:
- 1.3.6.1.2.1.2.2.1.8
- 1.3.6.1.2.1.31.1.1.1.10
- 1.3.6.1.2.1.31.1.1.1.6
- 1.3.6.1.2.1.4.20.1.1
- 1.3.6.1.4.1.25506.2.6.1.1.1.1.6
- 1.3.6.1.4.1.25506.2.6.1.1.1.1.8
get:
- 1.3.6.1.2.1.1.3.0
metrics:
- name: sysUpTime
oid: 1.3.6.1.2.1.1.3
type: gauge
help: The time (in hundredths of a second) since the network management portion
of the system was last re-initialized. - 1.3.6.1.2.1.1.3
- name: ifOperStatus
oid: 1.3.6.1.2.1.2.2.1.8
type: gauge
help: The current operational state of the interface - 1.3.6.1.2.1.2.2.1.8
indexes:
- labelname: ifIndex
type: gauge
enum_values:
1: up
2: down
3: testing
4: unknown
5: dormant
6: notPresent
7: lowerLayerDown
- name: ifHCOutOctets
oid: 1.3.6.1.2.1.31.1.1.1.10
type: counter
help: The total number of octets transmitted out of the interface, including framing
characters - 1.3.6.1.2.1.31.1.1.1.10
indexes:
- labelname: ifIndex
type: gauge
- name: ifHCInOctets
oid: 1.3.6.1.2.1.31.1.1.1.6
type: counter
help: The total number of octets received on the interface, including framing
characters - 1.3.6.1.2.1.31.1.1.1.6
indexes:
- labelname: ifIndex
type: gauge
- name: ipAdEntAddr
oid: 1.3.6.1.2.1.4.20.1.1
type: InetAddressIPv4
help: The IPv4 address to which this entry's addressing information pertains.
- 1.3.6.1.2.1.4.20.1.1
indexes:
- labelname: ipAdEntAddr
type: InetAddressIPv4
- name: hh3cEntityExtCpuUsage
oid: 1.3.6.1.4.1.25506.2.6.1.1.1.1.6
type: gauge
help: The CPU usage for this entity - 1.3.6.1.4.1.25506.2.6.1.1.1.1.6
indexes:
- labelname: hh3cEntityExtPhysicalIndex
type: gauge
- name: hh3cEntityExtMemUsage
oid: 1.3.6.1.4.1.25506.2.6.1.1.1.1.8
type: gauge
help: The memory usage for the entity - 1.3.6.1.4.1.25506.2.6.1.1.1.1.8
indexes:
- labelname: hh3cEntityExtPhysicalIndex
type: gauge
auth:
community: public
编写service
apiVersion: v1
kind: Service
metadata:
name: h3c-snmp-exporter
namespace: app
spec:
type: ClusterIP
selector:
app: h3c-snmp-exporter
ports:
- port: 80
targetPort: 9116
name: http
然后是kustomization.yaml
resources:
- deploy.yaml
- svc.yaml
- configmap.yaml
argocd 部分
apiVersion: argoproj.io/v1alpha1
kind: Application
metadata:
name: h3c-snmp-exporter
spec:
destination:
name: ''
namespace: ''
server: 'https://kubernetes.default.svc'
source:
path: k8s/h3c-snmp-exporter
repoURL: 'https://xxxxx.xxx.xx/bboysoul/kubernetes-yaml'
targetRevision: HEAD
project: default
syncPolicy:
automated: null
配置prometheus
- job_name: 'h3c-snmp-exporter'
static_configs:
- targets:
- 10.10.100.1 # SNMP device.
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: h3c-snmp-exporter
添加grafana dashboard
这个就没有什么好说的了
最后吐槽两句
如果的产品过了保修期,那么你打h3c的客服,他们是不会帮助你的,你只能论坛发帖子,草
欢迎关注我的博客www.bboy.app
Have Fun
Recommend
-
117
README.md Prometheus SNMP Exporter This is an exporter that exposes information gathered from SNMP for use by the Prometheus monitoring system. ...
-
6
H3C配置管理实验 图1-1 注:如无特别说明,描述中的R1或SW1对应拓扑中设备名称末尾数字为1的设备,R2或SW2对应拓扑中设备名称末尾数字为2的设备,以此类推
-
7
H3C Magic NX54双频5400M Wi-Fi 6路由器H3C Magic NX54双频5400M Wi-Fi 6路由器 2021-06-08 15:14:53 来源: 摘要:作为新华三智能终端家用路由器的又一全新力作,H3C Magic NX54路由器采用全新的立式造型...
-
6
H3C交换机常用命令及基本配置2017年7月28日 by anzhihe·0评论 · 1,669 人阅读 · 隐藏边栏
-
1
使用JMX Exporter监控Rainbond上的Java应用 ...
-
4
FTP方式升级H3C交换机 精选 原创
-
6
使用pve-exporter监控proxmox 2022-10-24 21:47:00 kubernetes
-
5
监控域名和 URL 是可观察性的一个重要方面,主要用于诊断可用性问题。接下来会详细介绍如何使用 Blackbox Exporter 和 Prometheus 在 Kubernetes 中实现 URL 监控。 Blackbox Exporter 简介 Blackbox Exporter 是 Prome...
-
4
SNMP OID来监控网络设备流量 2024-01-08 2 分钟阅读 想自己画图来监控交换机的流量,第一步就是通过snmpwalk来得到交换机的进出流量: 我们用得是Cisco 3750的24口交换机,给个OID表:
-
5
H3C路由器引发的“网络惰性”发表于2024-02-05|日志字数总计:1.5k|阅读时长:4分钟|阅读量:|评论数:
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK