Package: smart-prom-next
S.M.A.R.T. Prometheus Metrics Exportersmart-prom-next is aPrometheusmetric exporter forS.M.A.R.T.values of hard disks.
Python and the Linux toolsmartctlare used to read out the hard disk values. These are then exposed usingPrometheus Python Clientover network port 9902.According to Wikipedia, the primary function of S.M.A.R.T. is to detect and report various indicators of drive
reliability with the intent of anticipating imminent hardware failures.Currently, smart-prom-next is available as adocker imageand apypi package.The Docker image is built from the slim version of theofficial Python Docker image,
which usesDebian Bullseye.
It is built for multiple platforms:linux/386, linux/amd64, linux/arm/v5, linux/arm/v7, linux/arm64/v8The second Docker option is also built from theofficial Python Docker image,
but usesAlpine.
It is built for multiple platforms:linux/386, linux/amd64, linux/arm/v6, linux/arm/v7, linux/arm64/v8Configuration Options / Environment Variablessmart-prom-next can be configured by the following environment variables:PROMETHEUS_METRIC_PORT- port number over which the Prometheus metrics are exposed (default: 9902)SMART_INFO_READ_INTERVAL_SECONDS- time interval in seconds at which the SMART values of the hard disk are read
(default: 60)Docker / docker-composeThe images, which are based on Debian Bullseye slim, can be accessed using:ghcr.io/philipmay/smart-prom-next:<version>-slim-bullseyeorghcr.io/philipmay/smart-prom-next:latestThe images, which are based on Alpine, can be accessed using:ghcr.io/philipmay/smart-prom-next:<version>-alpineThe latest versions are visible insmart-prom-next GitHub packages.Below is an example of a complete minimaldocker-compose.yml, how smart-prom-next can be used withdocker-compose:version:"3.0"services:smart-prom-next:# see https://github.com/PhilipMay/smart-prom-next/pkgs/container/smart-prom-nextimage:ghcr.io/philipmay/smart-prom-next:latestcontainer_name:"smart-prom-next"restart:unless-stoppedprivileged:trueports:-9902:9902Theprivileged: truepermission is absolutely necessary so that smartctl can also access the hard disks from
within the container.Security note:In the production environment, you should leave out theports:part in thedocker-compose.ymlin the vast majority of configurations so that it is not visible to the outside. Instead, the container should
be assigned to a network in which the prometheus container is located. This looks like this:networks:-monitorTo adjust the environment variables, the following settings can be added, for example:environment:-PROMETHEUS_METRIC_PORT=9009-SMART_INFO_READ_INTERVAL_SECONDS=120Available Metricssmart_prom_smart_status_failedThe SMART health status of the device. A value of 0 indicates a healthy state.
A value of 1 means that the device has not passed the health check and there is a problem.List of labels used (description see below): "device", "type", "model", "serial"smart_prom_smartctl_exit_statusThe exit status (aka exit code or return code) of thesmartctltool.
Any value other than zero indicates an issue.
A more detailed description can be found in the EXIT STATUS chapter of thesmartctl man pages.List of labels used (description see below): "device", "type", "model", "serial"smart_prom_smart_infoThe SMART Attributes.
A more detailed description can be found in the-A, --attributeschapter of thesmartctl man pages.List of labels used (description see below): "device", "type", "model", "serial", "attr_name", "attr_type", "attr_id"smart_prom_nvme_smart_infoNVMespecific SMART attributes obtained from
the SMART/Health Information log.
A more detailed description can be found in the-A, --attributeschapter of thesmartctl man pages.List of labels used (description see below): "device", "type", "model", "serial", "attr_name"smart_prom_scsi_smart_infoSCSIspecific SMART attributes obtained from
the SMART/Health Information log.
A more detailed description can be found in the-A, --attributeschapter of thesmartctl man pages.List of labels used (description see below): "device", "type", "model", "serial", "attr_name", "attr_type"smart_prom_temperatureThe temperature values of the device. These include not only the current temperature but also other values.List of labels used (description see below): "device", "type", "model", "serial", "temperature_type"smart_prom_scrape_iterations_totalCounter how often the SMART values were scraped.Metrics LabelIn this project, we use different labels on the metrics. These are described here:device- device file, e.g.:/dev/nvme0,/dev/sdatype-  type of the device, e.g.:ata,nvme,usbjmicronmodel- model name, e.g.:KXG6AZNV512G TOSHIBA,WDC WD3200BEVT-60ZCT0serial- serial number, e.g.:WD-WXE708D44703,Y9SF71LHFWZLtemperature_type- type of the temperature value, e.g.:current,power_cycle_max,lifetime_max,op_limit_maxattr_name- SMART attribute name, e.g.:raw_read_error_rate,reallocated_sector_ct,critical_warningattr_id- SMART attribute id, e.g.:1,3,4attr_type- type of the respective SMART attribute - value is one of this:value,worst,thresh,raw,failed_now,failed_past-
a detailed description can be found in the-A, --attributeschapter of thesmartctl man pagesPrometheus AlertsBased on the metrics,Prometheus alertscan be defined. Below are a few suggestions forprometheus_rules.yml:groups:-name:alert_rulesrules:-alert:DiskFailingexpr:smart_prom_smart_info{attr_type="failed_now"} == 1labels:severity:criticalannotations:summary:"diskfailing"-alert:DiskTemperatureHighexpr:smart_prom_temperature{temperature_type="current"} > 50labels:severity:warningannotations:summary:"disktemperature>50"-alert:SMARTStatusFailingexpr:smart_prom_smart_status_failed == 1labels:severity:criticalannotations:summary:"SMARTstatusfailing"Release NewsHere you can find the latest versions of the software:docker image (Debian and Alpine)pypi packageGitHub releasesImportant news and features in the releases:add additional Alpine based image#40-
version0.0.4at 2022-07-28add -slim-bullseye suffix to image#44-
version0.0.4at 2022-07-28improve logs with "error" and "warning" prefix#43-
version0.0.4at 2022-07-28add scsi disk handling- thanks toJopaul-John- version0.0.3at 2022-07-20breaking change onsmart_prom_nvme_smart_info- version0.0.2at 2022-06-23additionalsmart_prom_scrape_iterations_totalmetric - version0.0.2at 2022-06-23first pre-release - pre-release version0.0.1rc9at 2022-06-20Special ThanksA special thanks goes to the following contributors:@Jopaul-Johnfor his help inadding scsi disk handlingMichal Harakal (@michalharakal)for the first PR of this project toimprove the docker-compose exampleDiego Heras (@ngosang)for hishelp in adding the Alpine imageLicensingCopyright (c) 2022 Philip MayLicensed under theMIT License(the "License"); you may not use this file except in compliance with the License.
You may obtain a copy of the License by reviewing the fileLICENSEin the repository.