大家好,我是小斐呀。
去年写了一篇关于物理服务器监控告警,是基于夜莺体系下开源的采集器 Categraf
的 snmp
插件去做数据的采集,有部分好友反馈用的挺好的,最近又有星球好友反馈物理服务器故障了,但是没有及时发现,被领导吐槽了,但是使用的采集器是 SNMP Exporter
,所以想统一去做采集,我这应好友之所难,立马就给适配起来,阅读之前可先跳转到这篇文章查看一下:
通过前面文章我们知道物理服务器基本上都有带外管理卡,可支持的协议也挺丰富,但是从监控数据采集的角度来看,无非就是这三种 IPMI
、 SNMP
、 Redfish
。
由于 IPMI
协议自 2.0
版本后就没有再更新了,所以我推荐数据采集的协议就剩下 SNMP
、 Redfish
了,而最终指标需要存储到 Prometheus
中,故我们的监控架构如下:
所以我这里提供了两种协议选择,采集器也分别是两种采集器:
|
|
|
---|---|---|
|
|
|
|
|
|
|
|
|
|
|
|
基于 Categraf
下 SNMP
的插件采集物理服务器指标写好如何使用,下面我详细介绍下 SNMP Exporter
采集物理服务器指标。
采集配置
在这里将以戴尔 iDRAC
为例,详细描述如何生成 SNMP Exporter
采集配置,通过 SNMP Exporter
配置生成器生成最终采集配置,配置生成器采集配置如下:
auths:
idrac_auth:
version:2
community:public
modules:
idrac_system:
walk:
# globalSystemStatus 设备全局系统状态
-1.3.6.1.4.1.674.10892.5.2.1
# systemPowerState 设备系统电源(开机)状态
-1.3.6.1.4.1.674.10892.5.2.4
# systemPowerUpTime 设备系统电源在线时长
-1.3.6.1.4.1.674.10892.5.2.5
# globalStorageStatus 设备全局存储状态
-1.3.6.1.4.1.674.10892.5.2.3
# systemLCDStatus 设备LCD状态
-1.3.6.1.4.1.674.10892.5.2.2
# systemOSName 操作系统名称
-1.3.6.1.4.1.674.10892.5.1.3.6
# systemModelName 设备型号
-1.3.6.1.4.1.674.10892.5.1.3.12
# systemSystemID 系统ID
-1.3.6.1.4.1.674.10892.5.1.3.13
# systemOSVersion 操作系统版本
-1.3.6.1.4.1.674.10892.5.1.3.14
# systemServiceTag 服务标签
-1.3.6.1.4.1.674.10892.5.1.3.2
# systemExpressServiceCode 快速服务代码
-1.3.6.1.4.1.674.10892.5.1.3.3
# racFirmwareVersion iDRAC 固件版本
-1.3.6.1.4.1.674.10892.5.1.1.8
# racShortName iDRAC 版本
-1.3.6.1.4.1.674.10892.5.1.1.2
# racURL iDRAC 界面的 URL
-1.3.6.1.4.1.674.10892.5.1.1.6
# numEventLogEntries 事件日志中的条目数
-1.3.6.1.4.1.674.10892.5.4.300.1
# systemBIOSStateSettings BIOS状态设置
-1.3.6.1.4.1.674.10892.5.4.300.50.1.4
# systemBIOSStatus BIOS状态
-1.3.6.1.4.1.674.10892.5.4.300.50.1.5
# systemBIOSVersionName Bios版本信息
-1.3.6.1.4.1.674.10892.5.4.300.50.1.8
# firmwareStateSettings 固件状态设置
-1.3.6.1.4.1.674.10892.5.4.300.60.1.4
# firmwareStatus 固件状态
-1.3.6.1.4.1.674.10892.5.4.300.60.1.5
# firmwareTypeName 固件类型名称
-1.3.6.1.4.1.674.10892.5.4.300.60.1.8
# firmwareVersionName 固件版本名称
-1.3.6.1.4.1.674.10892.5.4.300.60.1.11
# intrusionStateSettings 侵入设备状态设置
-1.3.6.1.4.1.674.10892.5.4.300.70.1.4
# intrusionStatus 侵入设备状态
-1.3.6.1.4.1.674.10892.5.4.300.70.1.5
# intrusionLocationName 入侵位置名称
-1.3.6.1.4.1.674.10892.5.4.300.70.1.8
# amperageProbeStateCapabilities 电流探头状态功能
-1.3.6.1.4.1.674.10892.5.4.600.30.1.3.1.3
# amperageProbeStateSettings 电流探头状态设置
-1.3.6.1.4.1.674.10892.5.4.600.30.1.4.1.3
# amperageProbeStatus 电流探头实体状态
-1.3.6.1.4.1.674.10892.5.4.600.30.1.5.1.3
# amperageProbeReading 电流探头探测的实际功率 单位:瓦特
-1.3.6.1.4.1.674.10892.5.4.600.30.1.6.1.3
# amperageProbeType 电流探头类型
-1.3.6.1.4.1.674.10892.5.4.600.30.1.7.1.3
# amperageProbeLocationName 电流探头名称
-1.3.6.1.4.1.674.10892.5.4.600.30.1.8.1.3
# systemBatteryStateSettings 电池启用状态
-1.3.6.1.4.1.674.10892.5.4.600.50.1.4
# systemBatteryStatus 电池状态
-1.3.6.1.4.1.674.10892.5.4.600.50.1.5
# systemBatteryLocationName 电池位置名称
-1.3.6.1.4.1.674.10892.5.4.600.50.1.7
# temperatureProbeStateSettings 温度探针状态设置
-1.3.6.1.4.1.674.10892.5.4.700.20.1.4
# temperatureProbeStatus 温度探针状态
-1.3.6.1.4.1.674.10892.5.4.700.20.1.5
# temperatureProbeReading 温度值
-1.3.6.1.4.1.674.10892.5.4.700.20.1.6
# temperatureProbeLocationName 探测器名称
-1.3.6.1.4.1.674.10892.5.4.700.20.1.8
# temperatureProbeUpperCriticalThreshold 温度告警高阈值 单位:十分之一摄氏度
-1.3.6.1.4.1.674.10892.5.4.700.20.1.10
max_repetitions:25
retries:3
timeout:5s
allow_nonincreasing_oids:false
use_unconnected_udp_socket:false
lookups:
-source_indexes:[systemBIOSchassisIndex,systemBIOSIndex]
lookup:systemBIOSVersionName
-source_indexes:[firmwarechassisIndex,firmwareIndex]
lookup:firmwareTypeName
-source_indexes:[firmwarechassisIndex,firmwareIndex]
lookup:firmwareVersionName
-source_indexes:[intrusionchassisIndex,intrusionIndex]
lookup:intrusionLocationName
-source_indexes:[amperageProbechassisIndex,amperageProbeIndex]
lookup:amperageProbeLocationName
-source_indexes:[systemBatteryChassisIndex,systemBatteryIndex]
lookup:systemBatteryLocationName
-source_indexes:[temperatureProbechassisIndex,temperatureProbeIndex]
lookup:temperatureProbeLocationName
overrides:
systemOSName:
ignore:false
type:DisplayString
systemModelName:
ignore:false
type:DisplayString
systemOSVersion:
ignore:false
type:DisplayString
systemServiceTag:
ignore:false
type:DisplayString
systemExpressServiceCode:
ignore:false
type:DisplayString
racFirmwareVersion:
ignore:false
type:DisplayString
racShortName:
ignore:false
type:DisplayString
racURL:
ignore:false
type:DisplayString
systemBIOSVersionName:
ignore:true
type:DisplayString
firmwareTypeName:
ignore:true
type:DisplayString
firmwareVersionName:
ignore:true
type:DisplayString
intrusionLocationName:
ignore:true
type:DisplayString
systemBatteryLocationName:
ignore:true
type:DisplayString
amperageProbeLocationName:
ignore:true
type:DisplayString
temperatureProbeLocationName:
ignore:true
type:DisplayString
......
更多信息在我的开源项目中查看。
整个采集配置有哪些模块呢,都分别采集物理服务器什么指标信息呢?
部署 SNMP Exporter
并生成最终采集配置 snmp_idrac.yml
,生成器配置和生成好的采集配置已在开源项目中,可自行去拿。
运行采集
把上面生成好的采集配置文件 snmp_idrac.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
这里的 --config.file
使用了通配符 *
匹配加载 /opt/snmp_exporter/conf
目录下的所有 snmp_
为前缀的采集配置文件,主要是后续可以加载多品牌配置文件。
把 snmp_idrac.yml
放入 /opt/snmp_exporter/conf/
目录下,启动并运行测试如下:
sudo systemctl restart snmp_exporter.service
sudo systemctl status snmp_exporter.service
启动成功后,浏览器打开 SNMP Exporter
的 9116
端口测试采集是否正常。
抓取配置
接下来就需要在 vmagent
下设置抓取配置,打开抓取配置文件,在 scrape_configs
下配置 job_name
以固定的频率抓取指标数据存入时序库中。
下面以 VictoriaMetrics
下的 vmagent
组件为例:
如果使用原生的
Prometheus
时序数据库,下面的抓取配置也是兼容的,可直接复制到prometheus.yml
下使用。
job_name
配置如下所示:
scrape_configs:
-job_name:"dell_idrac"
scrape_interval:60s
scrape_timeout:50s
file_sd_configs:
-files:
-/etc/victoriametrics/vmagent/dell_idrac.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.17.10.5:9116
-source_labels:["module"]
target_label:__param_module
-source_labels:["auth"]
target_label:__param_auth
由于上面使用了文件服务发现,我们需要在目录 /etc/victoriametrics/vmagent
下添加定义物理服务器的信息 dell_idrac.yml
文件模版内容如下:
-labels:
module:idrac_system,idrac_hardware,idrac_frupci,idrac_storage,idrac_power
auth:idrac_auth
brand:Dell
role:server
region:hangzhou
targets:
-172.16.10.1
-172.16.10.2
-172.16.10.3
-172.16.10.4
-172.16.10.5
这里要监控几千台物理机,如果用 yaml
维护对象配置好像有点麻烦,故针对大量设备的监控对象管理,我将适配基于 Web
管理监控对象的 SNMP Exporter
的 Consul
服务发现,这样一来针对大批量的物理服务器监控就可以很方便的快速添加。
面板呈现
开源说明
以上所有资源已开源,需要相关配置和资源的可直接去开源项目中获取:
https://github.com/robotneo/phymonarch
for Prometheus
面板是针对 Prometheus
数据源, for VictoriaMetrics
的是针对 VictoriaMetrics
数据源,如需使用需要单独在 Grafana
插件市场中安装 VictoriaMetrics
数据源插件。
SNMP
系列会优先完善, redfish
系列需要根据手上的设备适配来排期,**redfish
** 目前基于戴尔 idrac
、 HPE iLO
、 联想 XClarity
可以先使用 idrac_exporter
可以满足一些基础性指标需求。
加群
如果你对监控或可观测有兴趣需要找到合适的组织,你可以加我,我拉你进群和更多志同道合朋友沟通。
📣欢迎朋友们关注公众号📢📢:【网络小斐】!
🙋♂️有想法的朋友也可以加我沟通,朋友🔘做个点赞之交!😂😂
欢迎点赞 👍、收藏 💗、关注 💡 三连支持一下,我们下期见~✨
原文始发于微信公众号(网络小斐):物理机监控:超万台物理服务器应该如何快速实现监控告警
- 左青龙
- 微信扫一扫
-
- 右白虎
- 微信扫一扫
-
评论