大家好,我是小斐呀。
前面分享了国内几种主流防火墙的监控指标采集和可视化(飞塔、华为、深信服、奇安信、华三、天融信),这篇继续补全国内使用比较广泛的山石网科防火墙如何采集指标和可视化。
本文还是基于 SNMP Exporter
对山石网科防火墙的做指标采集,然后通过把数据抓取存入到 VictoriaMetrics
时序库中,非常适合需要对山石网科防火墙做监控可视化呈现和后续的指标告警的企业。
环境介绍
这里所用到的组件都是基于开源组件构建的一套架构,在操作采集和指标监控之前,请务必把了解清楚架构组件组成,并完成相关架构组件的部署工作,下面了解一下我基于 SNMP
协议这一块的采集架构:
比较推荐的架构组件是 SNMP Exporter <=> vmagent <=> VictoriaMetrics <=> 夜莺
我也建议你使用这套组件进行构建你的网络设备指标监控体系。
如果你在使用原生的 Prometheus
而因为各种历史问题不能使用 VictoriaMetrics
时序库时,你可以直接通过 SNMP Exporter <=> VictoriaMetrics <=> 夜莺
三个组件构建你的网络设备指标监控体系。
这里就不直接呈现部署的步骤,可看前面的文章或者通过星球的详细二进制或集群等部署文档进行操作落地。
山石网科防火墙一般情况下是 NAT
模式, HA
未启用单节点运行,固件版本是 StoneOS 5.5RX
系列,这里实际测试使用 StoneOS 5.5R6
和 StoneOS 5.5R10
版本固件,实际模块支持 StoneOS 5.5R5 ~ R11
系列,现在到防火墙上开启 SNMP
:
系统 > SNMP 代理 > 勾选开启代理 系统 > SNMP 主机 > SNMP主机配置
开启并配置了山石网科防火墙的 SNMP
信息后,就可以开始调试采集指标信息。
配置生成
山石网科防火墙的配置主要以下几大指标模块:
通过上面模块采集对应防火墙的指标,这些模块指标都是最佳实践中关注的指标,如果需要更多其他非常见指标,可以做一些自定义的采集,下面列出生成器配置文件:
auths:
hillstone_auth:
version:2
community:public
modules:
# 适配版本:StoneOS 5.5R6、StoneOS 5.5R7 或以上版本
hillstone_interface:
walk:
-1.3.6.1.2.1.31.1.1.1.1
-1.3.6.1.2.1.2.2.1.7
-1.3.6.1.2.1.2.2.1.8
-1.3.6.1.2.1.31.1.1.1.15
-1.3.6.1.2.1.2.2.1.4
-1.3.6.1.2.1.31.1.1.1.18
-1.3.6.1.2.1.2.2.1.6
-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.13
-1.3.6.1.2.1.2.2.1.19
-1.3.6.1.2.1.2.2.1.14
-1.3.6.1.2.1.2.2.1.20
-1.3.6.1.2.1.31.1.1.1.7
-1.3.6.1.2.1.31.1.1.1.8
-1.3.6.1.2.1.31.1.1.1.9
-1.3.6.1.2.1.31.1.1.1.11
-1.3.6.1.2.1.31.1.1.1.12
-1.3.6.1.2.1.31.1.1.1.13
-1.3.6.1.4.1.28557.2.6.1.3.1.19
-1.3.6.1.4.1.28557.2.6.1.3.1.20
-1.3.6.1.4.1.28557.2.6.1.3.1.2
-1.3.6.1.4.1.28557.2.6.1.3.1.3
-1.3.6.1.4.1.28557.2.6.1.3.1.4
-1.3.6.1.4.1.28557.2.6.1.3.1.5
-1.3.6.1.4.1.28557.2.6.1.3.1.21
-1.3.6.1.4.1.28557.2.6.1.3.1.22
max_repetitions:25
retries:3
timeout:5s
allow_nonincreasing_oids:false
use_unconnected_udp_socket:false
lookups:
-source_indexes:[ifIndex]
lookup:ifName
-source_indexes:[hillstoneIfIndex]
lookup:hillstoneIfName
overrides:
ifAlias:
ignore:false
type:DisplayString
ifName:
ignore:true
type:DisplayString
ifPhysAddress:
ignore:false
type:PhysAddress48
hillstoneIfName:
ignore:true
type:DisplayString
filters:
dynamic:
-oid:1.3.6.1.2.1.2.2.1.7
targets:
-"1.3.6.1.2.1.2.2.1.8"
-"1.3.6.1.2.1.31.1.1.1.15"
-"1.3.6.1.2.1.2.2.1.4"
-"1.3.6.1.2.1.31.1.1.1.18"
-"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.13"
-"1.3.6.1.2.1.2.2.1.19"
-"1.3.6.1.2.1.2.2.1.14"
-"1.3.6.1.2.1.2.2.1.20"
-"1.3.6.1.2.1.31.1.1.1.7"
-"1.3.6.1.2.1.31.1.1.1.8"
-"1.3.6.1.2.1.31.1.1.1.9"
-"1.3.6.1.2.1.31.1.1.1.11"
-"1.3.6.1.2.1.31.1.1.1.12"
-"1.3.6.1.2.1.31.1.1.1.13"
-"1.3.6.1.2.1.2.2.1.6"
-"1.3.6.1.4.1.28557.2.6.1.3.1.3"
-"1.3.6.1.4.1.28557.2.6.1.3.1.4"
-"1.3.6.1.4.1.28557.2.6.1.3.1.5"
-"1.3.6.1.4.1.28557.2.6.1.3.1.19"
-"1.3.6.1.4.1.28557.2.6.1.3.1.20"
-"1.3.6.1.4.1.28557.2.6.1.3.1.21"
-"1.3.6.1.4.1.28557.2.6.1.3.1.22"
values:["1"]
# 适配版本:StoneOS 5.5R11 固件版本以上
# 仅在 SG-6000-A200/A200G4/A200W/A200WG4 上支持
hillstone_optical:
walk:
-1.3.6.1.4.1.28557.2.6.1.3.1.2
-1.3.6.1.4.1.28557.2.6.1.3.1.28
-1.3.6.1.4.1.28557.2.6.1.3.1.29
-1.3.6.1.4.1.28557.2.6.1.3.1.30
-1.3.6.1.4.1.28557.2.6.1.3.1.31
-1.3.6.1.4.1.28557.2.6.1.3.1.32
max_repetitions:15
retries:3
timeout:5s
allow_nonincreasing_oids:false
use_unconnected_udp_socket:false
lookups:
-source_indexes:[hillstoneIfIndex]
lookup:hillstoneIfName
overrides:
hillstoneIfSfpModuleTemperature:
ignore:false
type:DisplayString
regex_extracts:
'':
-regex:'(.*)'
value:'$1'
hillstoneIfSfpTxSupplyVoltage:
ignore:false
type:DisplayString
regex_extracts:
'':
-regex:'(.*)'
value:'$1'
hillstoneIfSfpTxBiasCurrent:
ignore:false
type:DisplayString
regex_extracts:
'':
-regex:'(.*)'
value:'$1'
hillstoneIfTxOpticalPower:
ignore:false
type:DisplayString
regex_extracts:
'':
-regex:'(.*)'
value:'$1'
hillstoneIfRxOpticalPower:
ignore:false
type:DisplayString
regex_extracts:
'':
-regex:'(.*)'
value:'$1'
...
如何使用
使用 SNMP Exporter
下的生成器生成最终的采集配置文件即可,生成步骤如下:
把山石网科防火墙 mib
文件放入指定目录中;使用 SNMP Exporter
源码构建生成器二进制文件;编写构建自定义 生成器配置文件
,也就是我上面的提供的类似 yaml 结构文件;使用生成器二进制文件以及对应的参数去生成最终的采集配置文件。
山石网科防火墙 mib
目前通用 V8、V9、V10、V11
版本,对应山石网科防火墙的固件版本如下所示:
如下所示,把山石网科防火墙对应版本的私有 mib
文件放入对应的目录 /opt/snmp_exporter/generator/mibs/hillstone/firewall
下(需要把公有 MIB
也放入该目录下以解决私有 MIB
依赖的问题),然后执行相关命令对 mib
文件做语法和依赖错误检查:
/opt/snmp_exporter/generator/generator --fail-on-parse-errors parse_errors -m /opt/snmp_exporter/generator/mibs/hillstone/firewall
把 generator_hillstone.yml
放入 /opt/snmp_exporter/generator/conf/hillstone/firewall
目录下,执行如下命令生成即可:
/opt/snmp_exporter/generator/generator --fail-on-parse-errors generate -m /opt/snmp_exporter/generator/mibs/hillstone/firewall -g /opt/snmp_exporter/generator/conf/hillstone/firewall/generator_hillstone.yml -o /opt/snmp_exporter/generator/conf/hillstone/firewall/snmp_hillstone.yml
如果执行上面的命令后,输出的以下信息没有任何报错,就代表配置文件语法没有任何问题, 并且 oid
都能正常读取以及 mib
节点依赖都是正常:
root@demo:/opt/snmp_exporter/generator/conf/hillstone/firewall# /opt/snmp_exporter/generator/generator --fail-on-parse-errors generate -m /opt/snmp_exporter/generator/mibs/hillstone/firewall -g /opt/snmp_exporter/generator/conf/hillstone/firewall/generator_hillstone.yml -o /opt/snmp_exporter/generator/conf/hillstone/firewall/snmp_hillstone.yml
time=2025-04-02T14:35:33.394Z level=INFO source=net_snmp.go:174 msg="Loading MIBs" from=/opt/snmp_exporter/generator/mibs/hillstone/firewall
time=2025-04-02T14:35:33.462Z level=INFO source=main.go:57 msg="Generating config for module" module=hillstone_interface
time=2025-04-02T14:35:33.487Z level=INFO source=main.go:75 msg="Generated metrics" module=hillstone_interface metrics=25
time=2025-04-02T14:35:33.487Z level=INFO source=main.go:57 msg="Generating config for module" module=hillstone_system
time=2025-04-02T14:35:33.498Z level=INFO source=main.go:75 msg="Generated metrics" module=hillstone_system metrics=12
time=2025-04-02T14:35:33.498Z level=INFO source=main.go:57 msg="Generating config for module" module=hillstone_module
time=2025-04-02T14:35:33.504Z level=INFO source=main.go:75 msg="Generated metrics" module=hillstone_module metrics=11
time=2025-04-02T14:35:33.504Z level=INFO source=main.go:57 msg="Generating config for module" module=hillstone_component
time=2025-04-02T14:35:33.515Z level=INFO source=main.go:75 msg="Generated metrics" module=hillstone_component metrics=8
time=2025-04-02T14:35:33.515Z level=INFO source=main.go:57 msg="Generating config for module" module=hillstone_ipsec
time=2025-04-02T14:35:33.522Z level=INFO source=main.go:75 msg="Generated metrics" module=hillstone_ipsec metrics=11
time=2025-04-02T14:35:33.530Z level=INFO source=main.go:100 msg="Config written" file=/opt/snmp_exporter/generator/conf/hillstone/firewall/snmp_hillstone.yml
最终得到可以直接放在 SNMP Exporter
下加载运行的 snmp_hillstone.yml
文件,这个文件也就是山石网科防火墙的最终采集配置文件(如果直接拿这个文件做采集使用,注意对认证模块的信息修改后在使用)。
在现网环境中网络设备往往都是多品牌多类型设备并存,故为了区分和后续好管理采集配置文,建议是对采集配置文件命名做合理命名规划,以便后续好区分并运维,最佳实践方式是推荐 snmp_
前缀开头,品牌名称紧随其后,最后就是对应角色名称最后,比如山石网科防火墙就可以这样命名 snmp_hillstone_firewall.yml
。
运行采集
把生成好的配置文件 snmp_hillstone.yml
放入指定的加载配置文件的文件夹中,如下所示:
将 snmp_exporter
的作为服务运行,新建服务启动文件 /etc/systemd/system/snmp_exporter.service
[Unit]
Description=snmp_exporter
After=network.target
[Service]
ExecStart=/opt/snmp_exporter/snmp_exporter --config.file=/opt/snmp_exporter/conf/snmp_*.yml --snmp.module-concurrency=3
Restart=on-failure
[Install]
WantedBy=multi-user.target
把 snmp_hillstone.yml
放入 /opt/snmp_exporter/conf/
目录下,启动并运行测试如下:
你加载最终的采集配置文件后,还是需要打开 SNMP Exporter
的 WEB UI
单独测试指标采集是否成功:
Target
填写需要采集对象的IP
比如这里我填写山石网科的管理地址Auth
填写采集配置文件中定义的认证模块名称Module
填写采集配置文件中定义的指标模块名称
抓取配置
打开 SNMP Exporter
调试 web
页面后,测试编写的指标模块是否符合自己的需求,并且数据返回是否正常,当这些步骤完成后,我们就要把数据采集到时序库中,由于 SNMP Exporter
是基于 pull
模式,需要配置 job_name
以定时抓取指标数据存入时序库中,实现数据的持久化。
如果使用 Prometheus
时序库,我们可以直接编辑 prometheus.yml
文件,在 prometheus.yml
文件下直接配置对应的抓取任务:
global:
scrape_interval:15s
evaluation_interval:15s
scrape_timeout:10s
#external_labels:
# env: "prod"
# 告警插件配置
alerting:
alertmanagers:
-static_configs:
-targets:
# - 127.0.0.1:9093
rule_files:
# - "second_rules.yml"
scrape_configs:
# 采集山石网科防火墙
-job_name:"hillstone"
scrape_interval:15s
scrape_timeout:10s
file_sd_configs:
-files:
-/opt/prometheus/targets/hillstone_firewall.yml
refresh_interval:2m
metrics_path:/snmp
relabel_configs:
-source_labels:["__address__"]
target_label:__param_target
-source_labels:["__param_target"]
target_label:instance
-target_label:__address__
replacement:172.16.10.10:9116
-source_labels:["module"]
target_label:__param_module
-source_labels:["auth"]
target_label:__param_auth
如果使用 VictoriaMetrics
时序库,我习惯在在前面使用 vmagent
去做抓取组件,然后在 vmagent
中配置对应的抓取任务:
global:
scrape_interval:15s
scrape_timeout:10s
scrape_configs:
-job_name:"hillstone"
scrape_interval:15s
scrape_timeout:10s
file_sd_configs:
-files:
-/etc/victoriametrics/vmagent/hillstone_firewall.yml
metrics_path:/snmp
relabel_configs:
-source_labels:["__address__"]
target_label:__param_target
-source_labels:["__param_target"]
target_label:instance
-target_label:__address__
replacement:172.16.10.10:9116
-source_labels:["module"]
target_label:__param_module
-source_labels:["auth"]
target_label:__param_auth
由于上面使用了文件服务发现,我们需要在对应目录下添加山石网科防火墙的信息 hillstone_firewall.yml
文件模版内容如下:
-labels:
module:hillstone_system,hillstone_interface,hillstone_module,hillstone_ipsec
auth:hillstone_auth
brand:Hillstone
role:firewall
region:chengdu
targets:
-172.16.10.111
-172.16.10.100
面板展示
当采集动作在正常抓取数据时,我们就可以检查时序库中指标信息是否正常写入,没有问题后可在 Grafana
中添加数据源,构建数据可视化面板,我基于我的采集配置后通过 Grafana
构建如下仪表盘:
基于 SNMP Exporter
实现对山石网科防火墙在 Prometheus
体系下的监控告警已完成适配,还有更多其他内容,这些都是耗费很多精力的适配的,获取可通过加入星球获取这些监控面板和采集配置,里面也不仅仅是网络监控了,更多内容可公众号私信联系我,如果您要加群找到组织也可以公众号获取微信 备注加群
我拉你进群。
最后有个小请求,如果你一直在关注本公众号,从中得到了一些帮助,希望您能动动小手帮忙一键三连,差一些关注就达到万粉了,感谢您一直以来的支持。
推荐站内搜索:最好用的开发软件、免费开源系统、渗透测试工具云盘下载、最新渗透测试资料、最新黑客工具下载……
还没有评论,来说两句吧...