smartctl JSON 输入插件
此插件使用 smartmontools 包收集存储设备的 SMART (自我监控、分析和报告技术) 信息。与 smart 插件 不同,此插件不使用 nvme-cli 包来收集有关 NVMe 设备的附加信息。
此插件要求在您的系统上安装 smartmontools。smartctl 命令必须可由 Telegraf 执行,并且必须支持 JSON 输出。JSON 输出在 v7.0 中添加,并在后续版本中得到改进。
引入于: Telegraf v1.31.0 标签: hardware, system 操作系统支持: all
全局配置选项
插件支持其他全局和插件配置设置,用于修改指标、标签和字段,创建别名以及配置插件顺序等任务。更多详情请参阅 CONFIGURATION.md。
配置
# Read metrics from SMART storage devices using smartclt's JSON output
[[inputs.smartctl]]
## Optionally specify the path to the smartctl executable
# path = "/usr/sbin/smartctl"
## Use sudo
## On most platforms used, smartctl requires root access. Setting 'use_sudo'
## to true will make use of sudo to run smartctl. Sudo must be configured to
## allow the telegraf user to run smartctl without a password.
# use_sudo = false
## Devices to include or exclude
## By default, the plugin will use all devices found in the output of
## `smartctl --scan-open`. Only one option is allowed at a time. If set, include
## sets the specific devices to scan, while exclude omits specific devices.
# devices_include = []
# devices_exclude = []
## Skip checking disks in specified power mode
## Defaults to "standby" to not wake up disks that have stopped rotating.
## For full details on the options here, see the --nocheck section in the
## smartctl man page. Choose from:
## * never: always check the device
## * sleep: check the device unless it is in sleep mode
## * standby: check the device unless it is in sleep or standby mode
## * idle: check the device unless it is in sleep, standby, or idle mode
# nocheck = "standby"
## Timeout for the cli command to complete
# timeout = "30s"权限
请注意,此插件引用了 smartctl,这可能需要额外的权限才能成功执行。根据执行此插件的 telegraf 用户的用户/组权限,用户可能需要使用 sudo。
用户需要在 Telegraf 配置中包含以下内容
[[inputs.smart_json]]
use_sudo = true并更新 /etc/sudoers 文件以允许运行 smartctl
$ visudo
# Add the following lines:
Cmnd_Alias SMARTCTL = /usr/sbin/smartctl
telegraf ALL=(ALL) NOPASSWD: SMARTCTL
Defaults!SMARTCTL !logfile, !syslog, !pam_session故障排除
此插件使用以下命令来确定设备和收集指标
smartctl --json --scan-opensmartctl --json --all $DEVICE --device $TYPE --nocheck=$NOCHECK
请为所有出现问题的设备提供以上两个命令的输出。
Metrics
smartctl
- 标签 (tags)
- model (存储设备的型号名称)
- name (系统中的设备 ID)
- serial (设备的序列号)
- type (设备类型,如 SATA 等)
- wwn (设备的全球唯一编号)
- 字段 (fields)
- 取决于设备信息
- 标签 (tags)
smartctl_attributes
- 标签 (tags)
- model (存储设备的型号名称)
- name (属性名称)
- serial (设备的序列号)
- type (设备类型,如 SATA 等)
- wwn (设备的全球唯一编号)
- 字段 (fields)
- raw_value (整数)
- threshold (整数)
- value (整数)
- worst (整数)
- 标签 (tags)
示例输出
smartctl,model=SanDisk\ pSSD,name=/dev/sda,serial=06c9f4c44,type=sat,wwn=5001b4409f6c444c capacity=15693664256i,firmware="3",health_ok=true,logical_block_size=512i,power_on_hours=11i,temperature=0i 1711480345675066854
smartctl_attributes,model=SanDisk\ pSSD,name=Reallocated_Sector_Ct,serial=06c9f4c44,type=sat,wwn=5001b4409f6c444c raw_value=0i,threshold=0i,value=100i,worst=100i 1711480345675066854
smartctl_attributes,model=SanDisk\ pSSD,name=Power_On_Hours,serial=06c9f4c44,type=sat,wwn=5001b4409f6c444c raw_value=11i,threshold=0i,value=100i,worst=100i 1711480345675066854
smartctl_attributes,model=SanDisk\ pSSD,name=Power_Cycle_Count,serial=06c9f4c44,type=sat,wwn=5001b4409f6c444c raw_value=223i,threshold=0i,value=100i,worst=100i 1711480345675066854
smartctl_attributes,model=SanDisk\ pSSD,name=Program_Fail_Count,serial=06c9f4c44,type=sat,wwn=5001b4409f6c444c raw_value=0i,threshold=0i,value=100i,worst=100i 1711480345675066854
smartctl_attributes,model=SanDisk\ pSSD,name=Erase_Fail_Count,serial=06c9f4c44,type=sat,wwn=5001b4409f6c444c raw_value=0i,threshold=0i,value=100i,worst=100i 1711480345675066854
smartctl_attributes,model=SanDisk\ pSSD,name=Avg_Write/Erase_Count,serial=06c9f4c44,type=sat,wwn=5001b4409f6c444c raw_value=3i,threshold=0i,value=100i,worst=100i 1711480345675066854
smartctl_attributes,model=SanDisk\ pSSD,name=Unexpect_Power_Loss_Ct,serial=06c9f4c44,type=sat,wwn=5001b4409f6c444c raw_value=114i,threshold=0i,value=100i,worst=100i 1711480345675066854
smartctl_attributes,model=SanDisk\ pSSD,name=Reported_Uncorrect,serial=06c9f4c44,type=sat,wwn=5001b4409f6c444c raw_value=0i,threshold=0i,value=100i,worst=100i 1711480345675066854
smartctl_attributes,model=SanDisk\ pSSD,name=Perc_Write/Erase_Count,serial=06c9f4c44,type=sat,wwn=5001b4409f6c444c raw_value=10i,threshold=0i,value=100i,worst=100i 1711480345675066854
smartctl_attributes,model=SanDisk\ pSSD,name=Perc_Avail_Resrvd_Space,serial=06c9f4c44,type=sat,wwn=5001b4409f6c444c raw_value=0i,threshold=5i,value=100i,worst=100i 1711480345675066854
smartctl_attributes,model=SanDisk\ pSSD,name=Perc_Write/Erase_Ct_BC,serial=06c9f4c44,type=sat,wwn=5001b4409f6c444c raw_value=0i,threshold=0i,value=100i,worst=100i 1711480345675066854
smartctl_attributes,model=SanDisk\ pSSD,name=Total_LBAs_Written,serial=06c9f4c44,type=sat,wwn=5001b4409f6c444c raw_value=10171055i,threshold=0i,value=100i,worst=100i 1711480345675066854
smartctl_attributes,model=SanDisk\ pSSD,name=Total_LBAs_Read,serial=06c9f4c44,type=sat,wwn=5001b4409f6c444c raw_value=94845144i,threshold=0i,value=100i,worst=100i 1711480345675066854此页面是否有帮助?
感谢您的反馈!
支持和反馈
感谢您成为我们社区的一员!我们欢迎并鼓励您对 Telegraf 和本文档提出反馈和 bug 报告。要获取支持,请使用以下资源
具有年度合同或支持合同的客户可以 联系 InfluxData 支持。