S.M.A.R.T. Prometheus指标导出器
项目描述
S.M.A.R.T. Prometheus指标导出器
smart-prom-next 是一个针对硬盘的 Prometheus 指标导出器,用于读取 S.M.A.R.T. 值。Python 和 Linux 工具 smartctl 用于读取硬盘值。然后通过网络端口 9902 使用 Prometheus Python客户端 暴露。
根据维基百科,S.M.A.R.T. 的主要功能是检测并报告各种驱动器可靠性的指标,目的是预测即将发生的硬件故障。
目前,smart-prom-next 以 Docker镜像 和 pypi包 的形式提供。
Docker镜像基于官方Python Docker镜像的精简版构建,使用官方Python Docker镜像,采用Debian Bullseye。支持多平台
linux/386, linux/amd64, linux/arm/v5, linux/arm/v7, linux/arm64/v8
第二个Docker选项同样基于官方Python Docker镜像构建,但使用Alpine。支持多平台
linux/386, linux/amd64, linux/arm/v6, linux/arm/v7, linux/arm64/v8
配置选项/环境变量
smart-prom-next可以通过以下环境变量进行配置
PROMETHEUS_METRIC_PORT
- Prometheus指标暴露的端口号(默认:9902)SMART_INFO_READ_INTERVAL_SECONDS
- 以秒为单位读取硬盘SMART值的时间间隔(默认:60)
Docker / docker-compose
基于Debian Bullseye slim的镜像可以通过:ghcr.io/philipmay/smart-prom-next:<version>-slim-bullseye
或 ghcr.io/philipmay/smart-prom-next:latest
访问
基于Alpine的镜像可以通过:ghcr.io/philipmay/smart-prom-next:<version>-alpine
访问
最新版本可在smart-prom-next GitHub包中查看。
以下是完整的示例docker-compose.yml
,展示如何使用docker-compose使用smart-prom-next
version: "3.0"
services:
smart-prom-next:
# see https://github.com/PhilipMay/smart-prom-next/pkgs/container/smart-prom-next
image: ghcr.io/philipmay/smart-prom-next:latest
container_name: "smart-prom-next"
restart: unless-stopped
privileged: true
ports:
- 9902:9902
privileged: true
权限是绝对必要的,以便smartctl也能从容器内部访问硬盘。
安全提示:在生产环境中,在大多数配置中应省略docker-compose.yml
中的ports:
部分,以确保其对外不可见。相反,容器应分配给包含prometheus容器的网络。这看起来像这样
networks:
- monitor
要调整环境变量,可以添加以下设置,例如
environment:
- PROMETHEUS_METRIC_PORT=9009
- SMART_INFO_READ_INTERVAL_SECONDS=120
可用指标
smart_prom_smart_status_failed
设备的SMART健康状态。0表示健康状态,1表示设备未通过健康检查,存在问题。
使用的标签列表(描述见下文):"device","type","model","serial"
smart_prom_smartctl_exit_status
smartctl工具的退出状态(即退出代码或返回代码)。任何非零值都表示存在问题。更详细的描述可以在smartctl man页面的EXIT STATUS部分中找到。
使用的标签列表(描述见下文):"device","type","model","serial"
smart_prom_smart_info
SMART属性。更详细的描述可以在smartctl man页面的-A, --attributes部分中找到。
使用的标签列表(描述见下文):"device","type","model","serial","attr_name","attr_type","attr_id"
smart_prom_nvme_smart_info
从SMART/Health Information日志获取的NVMe特定SMART属性。更详细的描述可以在smartctl man页面的-A, --attributes部分中找到。
使用的标签列表(描述见下文):"device","type","model","serial","attr_name"
smart_prom_scsi_smart_info
从SMART/Health Information日志获取的SCSI特定SMART属性。更详细的描述可以在smartctl man页面的-A, --attributes部分中找到。
使用的标签列表(描述见下文):"device","type","model","serial","attr_name","attr_type"
smart_prom_temperature
设备温度值。这包括当前温度以及其他值。
使用的标签列表(描述见下文): "device", "type", "model", "serial", "temperature_type"
smart_prom_scrape_iterations_total
记录SMART值抓取的频率。
度量标签
在本项目中,我们使用不同的标签来表示度量。这些将在下面进行描述
device
- 设备文件,例如:/dev/nvme0
,/dev/sda
type
- 设备类型,例如:ata
,nvme
,usbjmicron
model
- 型号名称,例如:KXG6AZNV512G TOSHIBA
,WDC WD3200BEVT-60ZCT0
serial
- 序列号,例如:WD-WXE708D44703
,Y9SF71LHFWZL
temperature_type
- 温度值的类型,例如:current
,power_cycle_max
,lifetime_max
,op_limit_max
attr_name
- SMART属性名称,例如:raw_read_error_rate
,reallocated_sector_ct
,critical_warning
attr_id
- SMART属性ID,例如:1
,3
,4
attr_type
- 对应SMART属性的类型 - 值为以下之一:value
,worst
,thresh
,raw
,failed_now
,failed_past
- 详细描述请见smartctl man pages中的-A, --attributes
章节
Prometheus警报
基于度量,可以定义Prometheus警报。以下是对prometheus_rules.yml
的一些建议
groups:
- name: alert_rules
rules:
- alert: DiskFailing
expr: smart_prom_smart_info{attr_type="failed_now"} == 1
labels:
severity: critical
annotations:
summary: "disk failing"
- alert: DiskTemperatureHigh
expr: smart_prom_temperature{temperature_type="current"} > 50
labels:
severity: warning
annotations:
summary: "disk temperature > 50"
- alert: SMARTStatusFailing
expr: smart_prom_smart_status_failed == 1
labels:
severity: critical
annotations:
summary: "SMART status failing"
发布新闻
在这里可以找到软件的最新版本
发布中的重要新闻和功能
- 添加基于Alpine的镜像#40 - 版本
0.0.4
于2022-07-28 - 给镜像添加-slim-bullseye后缀#44 - 版本
0.0.4
于2022-07-28 - 通过"error"和"warning"前缀改进日志#43 - 版本
0.0.4
于2022-07-28 - 添加scsi磁盘处理 - 感谢Jopaul-John - 版本
0.0.3
于2022-07-20 - 在
smart_prom_nvme_smart_info
上的重大变更 - 版本0.0.2
于2022-06-23 - 添加额外的
smart_prom_scrape_iterations_total
度量 - 版本0.0.2
于2022-06-23 - 第一个预发布版 - 预发布版
0.0.1rc9
于2022-06-20
特别感谢
以下是对以下贡献者的特别感谢
- @Jopaul-John在添加scsi磁盘处理方面的帮助
- Michal Harakal (@michalharakal)为本项目改进docker-compose示例提交的第一个PR
- Diego Heras (@ngosang)在添加Alpine镜像方面的帮助
许可
版权(c)2022 Philip May
根据MIT许可证
(以下简称“许可证”);除非遵守本许可证,否则不得使用此文件。您可以通过查看存储库中的文件LICENSE来获得本许可证的副本。
项目详情
下载文件
下载适用于您平台的应用程序文件。如果您不确定选择哪个,请了解有关安装包的更多信息。