利用夜莺开源版对H3C无线设备监控
编者荐语:
真正搞监控的人肯定知道 SNMP 水有多深,有时我甚至腹黑猜测,这些厂商是故意的吧,,,指标不标准,格式各异,只能靠一款灵活的采集器了,本文是夜莺社区用户写的文章,转给大家参考。
author:网络小斐
关于夜莺SNMP插件
前文说明了利用夜莺开源版如何监控H3C交换机的,算是抛砖引玉;秉持着授人与鱼不如授人与渔,今天我们就来具体谈谈夜莺SNMP插件的使用,能自己自定义自身需求的监控指标才是真正学会如何利用夜莺去监控SNMP协议设备,今天将以H3C无线作为案例,具体讲解下SNMP插件配置。
场景介绍
企业华三无线AP和AC的设备信息监控,需要通过SNMP协议拿到指标数据,并把数据插入到VictoriaMetrics时序数据库中,通过夜莺对数据的即时查询和提取可以构建需要的监控面板,实现基础的数据指标监控提取。
华三无线指标
由于snmp.toml配置文件(路径:categraf/conf/input.snmp/)中已经存在华三交换机的指标配置文件,为了区分多类型设备采集模板,这里将把交换机采集配置模板文件和无线设备采集配置模板文件进行分开,分别取名:snmp_h3c_sw.toml和snmp_h3c_wireless.toml,配置会同步读取,具体配置如下:interval = 10
# H3C AC信息采集
[[instances]]
agents = [
"udp://192.168.100.100",
]
interval_times = 3
labels = { region = "beijing", role = "ac" }
# 每个请求的超时时间
timeout = "5s"
# SNMP Agent的版本
version = 2
# SNMP团体名
community = "XXXX"
# 自定义 mib 文件路径
# path = ["/usr/share/snmp/mibs"]
# 代理主机标签
agent_host_tag = "ident"
# 尝试的重试次数
retries = 3
# GETBULK 每次获取的最大对象数 如果指标越多 建议数值越大 可加速采集时间
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 (SLOT|slot)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"
name = "cpu_usage"
# 实体内存实时利用率百分比
[[instances.table.field]]
oid = "1.3.6.1.4.1.25506.2.6.1.1.1.1.8"
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"
# 新建空table h3c_system 索引 entPhysicalIndex 获取实体电源状态信息
[[instances.table]]
name = "h3c_system"
index_as_tag = true
filters = ["exprA:ent_class:6", "exprB:ent_name:.*", "exprC:psu:.*"]
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 = "psu"
# 新建空table h3c_system 索引 entPhysicalIndex 获取实体传感器温度信息
[[instances.table]]
name = "h3c_system"
index_as_tag = true
filters = ["exprA:ent_descr:^(Sensor|SENSOR) (SLOT|slot)1#.*",