Skip to main content

pySMART-exporter

Copyright (C) 2021 Rafael Leira, Naudit HPCN S.L.

pySMART-exporter is a Python Prometheus exporter for collecting and exposing S.M.A.R.T. metrics of storage devices. It leverages the pySMART library and integrates Prometheus client library functionalities for HTTP publication or file-based metric exports.


Features

  • Collects S.M.A.R.T. metrics from storage devices.
  • Supports Prometheus integration via HTTP or text-based node collector files.
  • Includes support for various storage interfaces, including NVMe attributes and diagnostics.

Installation

The pySMART-exporter can be installed via PyPI:

python -m pip install pySMART-exporter

Ensure that smartctl from the smartmontools package is installed, as it is a prerequisite. For most Linux distributions, use your package manager:

sudo apt-get install smartmontools

# or

sudo yum install smartmontools

Usage

The exporter supports two modes: server mode (HTTP) and file mode (node exporter textfile). It should run as a privileged user to access disk information.

Server Mode

To run the exporter in server mode, execute the following command:

pysmart_exporter -l 0.0.0.0:9099

Then configure Prometheus to scrape metrics from the endpoint.

File Mode

To generate a one-time metric file for use with a Prometheus node exporter:

pysmart_exporter -f /path/to/output/file.txt -1

To continuously generate metric files at a set interval (e.g., 60 seconds):

pysmart_exporter -f /path/to/output/file.txt -i 60

Example Metrics Output

Below is a sample of the metrics exposed by pySMART-exporter:

# HELP pysmart_info PySMART metric info
# TYPE pysmart_info gauge
pysmart_info{device="nvme0",firmware="ADHA0101",interface="nvme",model="KBG30ZMV256G TOSHIBA",rotation="None",serial="*********12P",size="256000000000",size_raw="256 GB",smart_capable="True",smart_enabled="True",ssd="True"} 1.0
# HELP pysmart_assessment PySMART metric assessment
# TYPE pysmart_assessment gauge
pysmart_assessment{device="nvme0",interface="nvme",pysmart_assessment="PASS"} 1.0
# HELP pysmart_temperature PySMART metric temperature
# TYPE pysmart_temperature gauge
pysmart_temperature{device="nvme0",interface="nvme"} 44.0
# HELP pysmart_size PySMART metric size
# TYPE pysmart_size gauge
pysmart_size{device="nvme0",interface="nvme"} 2.56e+011
# HELP pysmart_test_capabilities PySMART metric test_capabilities
# TYPE pysmart_test_capabilities gauge
pysmart_test_capabilities{device="nvme0",interface="nvme",pysmart_test_capabilities="short"} 1.0

CLI Options

Option Description
-f, --textfile-name Path to the file where metrics will be stored for node collection.
-l, --listen Host and port to listen on in HTTP server mode (e.g., 0.0.0.0:9417).
-i, --interval Interval (in seconds) between metric updates. Default: 60.
-1, --oneshot Run only once and exit (useful for cron jobs).
-q, --quiet Suppress error messages and warnings.
--include Comma-separated list of devices to include (e.g., nvme0,/dev/sda).
--exclude Comma-separated list of devices to exclude.
--metric-prefix Custom prefix for metrics. Default: pysmart.
--metrics Comma-separated list of specific metrics to export (e.g., temperature,size,assessment_passed).

Metrics

Metric Name Type Description Labels
pysmart_info info General information about the disk, including model, firmware, size, and other static attributes. device, interface, model, serial, firmware, rotation, size_raw, size, ssd, smart_capable, smart_enabled, vendor, sector_size, and more.
pysmart_assessment_passed gauge Assessment of the disk's health. 1 for PASS, 0 otherwise. device, interface
pysmart_temperature gauge Current temperature of the disk in Celsius. device, interface
pysmart_size gauge Disk size in bytes. device, interface
pysmart_attribute_value gauge SMART attribute values such as error counts, read/write metrics, etc. device, name (attribute name), num, type, flags, updated, whenfailed, and more depending on attribute.
pysmart_attribute_thresh gauge Threshold values for SMART attributes. Similar to pysmart_attribute_value
pysmart_attribute_worst gauge The worst recorded value for a given SMART attribute. Similar to pysmart_attribute_value
pysmart_attribute_raw gauge The raw value for a SMART attribute. Similar to pysmart_attribute_value
pysmart_diagnostics_* gauge Disk diagnostic statistics, including errors and other health-related data. device, interface
pysmart_test_capabilities state Types of self-tests supported by the disk (e.g., short, long, offline). device, interface
pysmart_test gauge Details about completed or pending disk self-tests. device, type (test type), status, hours, num, and other self-test details.

Installation

pySMART-exporter is available on PyPI and installable via pip::

python -m pip install pySMART-exporter

The only external (non-python) dependency is the smartctl component of the smartmontools package. This should be pre-installed in most Linux distributions, or it can be obtained through your package manager. Likely one of the following::

apt-get install smartmontools
    or
yum install smartmontools

License

This program is distributed under the terms of the license specified in the LICENSE file.


References

Metadata

Release files for pySMART-exporter 0.4.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pySMART-exporter 0.4.1
File Size Uploaded
pysmart_exporter-0.4.1.tar.gz 10.4 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for pySMART-exporter 0.4.1
File Interpreter ABI Platform
pysmart_exporter-0.4.1-py3-none-any.whl Python 3 none any Details

Total release size: 21.0 kB

Release files / pysmart_exporter-0.4.1.tar.gz

Download URL pysmart_exporter-0.4.1.tar.gz
Size 10.4 kB
Tags Source
SHA-256 checksum
How to use checksums
86273695ff592838e16fc29496bd46ffddaaa93f2f63595a11ae60b18a9b54c6
BLAKE2b-256 checksum
How to use checksums
444685184aad3fbc44d06d502e3c56961f6331abdf67c0cae764894024305059
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.12.9

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Apr 2, 2025.

Transparency log

Release files / pysmart_exporter-0.4.1-py3-none-any.whl

Download URL pysmart_exporter-0.4.1-py3-none-any.whl
Size 10.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
395d62d4a434069975a8628233e435489b43198cfa9720de413fda45d49a07d2
BLAKE2b-256 checksum
How to use checksums
3e62ab5ad4120c52033520b86833796418f63fac0cd1bbfc07339a365ddceb89
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.12.9

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Apr 2, 2025.

Transparency log
Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page