cfbs add inventory-smartctl
Inventory module for collecting SMART drive health, temperature, and wear data via smartctl.
This module collects S.M.A.R.T. (Self-Monitoring, Analysis and Reporting Technology) data from storage devices and exposes it as inventory attributes in CFEngine Mission Portal.
It provides a rolled-up status for fleet-wide filtering (OK, DEGRADED, SMARTCTL_MISSING) along with per-drive health, temperature, power-on hours, and NVMe-specific metrics.
SMART data helps predict drive failures before they occur and provides visibility into storage device health across your infrastructure.
smartctl from smartmontools package (version 7.0+ for JSON support)Add to your policy via cfbs:
cfbs add inventory-smartctl
cfbs install
Or include directly in your policy:
bundle agent main
{
methods:
"smartctl" usebundle => inventory_smartctl:main;
}
The following attributes are exposed in Mission Portal:
OK, DEGRADED, SMARTCTL_MISSINGOK: All detected drives report PASSEDDEGRADED: One or more drives report FAILEDSMARTCTL_MISSING: smartctl is not installed on the systemSMART drive health - Per-drive health status
PASSED, FAILED/dev/sda: PASSED, /dev/nvme0: FAILEDSMART drive model - Drive model identifier
/dev/sda: Samsung SSD 870 EVOSMART drive temperatures (C) - Current temperature in Celsius
/dev/sda: 35 CSMART drive power-on hours - Cumulative runtime in hours
/dev/sda: 8742 hSMART NVMe available spare - Remaining spare blocks (%)
/dev/nvme0: 100%SMART NVMe percentage used - Drive life consumed (%)
/dev/nvme0: 5%SMART NVMe media errors - Uncorrectable media errors count
/dev/nvme0: 0The SMART status attribute reports SMARTCTL_MISSING when smartctl is not installed. To resolve:
Install smartmontools package:
# Debian/Ubuntu
apt-get install smartmontools
# RHEL/CentOS/Fedora
yum install smartmontools
# SUSE
zypper install smartmontools
Verify installation:
command -v smartctl
smartctl --version
If smartctl is installed but no data appears:
Check if drives are detected:
smartctl --scan
Check cache files:
ls -lh /var/cfengine/state/inventory_smartctl_*.json
Run with verbose mode:
cf-agent -Kvf ./policy.cf
This module has no dependencies