{"id":13585456,"url":"https://github.com/matusnovak/prometheus-smartctl","last_synced_at":"2025-04-07T09:34:47.442Z","repository":{"id":37252220,"uuid":"220654431","full_name":"matusnovak/prometheus-smartctl","owner":"matusnovak","description":"HDD S.M.A.R.T exporter for Prometheus written in Python","archived":false,"fork":false,"pushed_at":"2024-08-23T22:21:06.000Z","size":326,"stargazers_count":144,"open_issues_count":6,"forks_count":42,"subscribers_count":7,"default_branch":"master","last_synced_at":"2024-08-23T23:23:53.085Z","etag":null,"topics":["metrics","metrics-exporter","prometheus","prometheus-exporter","prometheus-metrics","smartctl"],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"unlicense","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/matusnovak.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-11-09T14:31:26.000Z","updated_at":"2024-08-23T22:05:54.000Z","dependencies_parsed_at":"2024-08-23T23:23:12.644Z","dependency_job_id":null,"html_url":"https://github.com/matusnovak/prometheus-smartctl","commit_stats":null,"previous_names":[],"tags_count":15,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/matusnovak%2Fprometheus-smartctl","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/matusnovak%2Fprometheus-smartctl/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/matusnovak%2Fprometheus-smartctl/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/matusnovak%2Fprometheus-smartctl/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/matusnovak","download_url":"https://codeload.github.com/matusnovak/prometheus-smartctl/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":223277879,"owners_count":17118665,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["metrics","metrics-exporter","prometheus","prometheus-exporter","prometheus-metrics","smartctl"],"created_at":"2024-08-01T15:04:57.186Z","updated_at":"2025-04-07T09:34:47.435Z","avatar_url":"https://github.com/matusnovak.png","language":"Python","funding_links":[],"categories":["Python"],"sub_categories":[],"readme":"# Prometheus S.M.A.R.T ctl metrics exporter\r\n\r\n![build](https://github.com/matusnovak/prometheus-smartctl/workflows/build/badge.svg)\r\n\r\nThis is a simple exporter for the [Prometheus metrics](https://prometheus.io/) using [smartctl](https://www.smartmontools.org/). The script `smartprom.py` also comes with `smartprom.service` so that you can run this script in the background on your Linux OS via `systemctl`. The script will use port `9902`, you can change it by changing it directly in the script. This script exports all of the data available from the smartctl.\r\n\r\n## Install\r\n\r\n_Note: You don't have to do this if you use the Docker image._\r\n\r\n1. Copy the `smartprom.service` file into `/etc/systemd/system` folder.\r\n2. Copy the `smartprom.py` file anywhere into your system.\r\n3. Modify `ExecStart=` in the `smartprom.service` so that it points to `smartprom.py` in your system.\r\n4. Run `chmod +x smartprom.py`\r\n5. Install Python dependencies for the root user, example: `sudo -H python3 -m pip install -r requirements.txt`\r\n6. Run `systemctl enable smartprom` and `systemctl start smartprom`\r\n7. Your metrics will now be available at `http://localhost:9902`\r\n\r\n## Docker usage\r\n\r\nNo extra configuration needed, should work out of the box. The `privileged: true` is required in order for `smartctl` to be able to access drives from the host.\r\n\r\nDocker image is here: \u003chttps://hub.docker.com/r/matusnovak/prometheus-smartctl\u003e\r\n\r\nThe architectures supported by this image are: linux/386, linux/amd64, linux/arm/v6, linux/arm/v7, linux/arm64/v8, linux/ppc64le, linux/s390x\r\n\r\nExample docker-compose.yml:\r\n\r\n```yml\r\nversion: '3'\r\nservices:\r\n  smartctl-exporter:\r\n    image: matusnovak/prometheus-smartctl:latest\r\n    container_name: smartctl-exporter\r\n    privileged: true\r\n    ports:\r\n      - \"9902:9902\"\r\n    restart: unless-stopped\r\n```\r\n\r\nExample docker-compose.yml with node-exporter and file export:\r\n\r\n\r\n```yml\r\nversion: \"3\"\r\nservices:\r\n    node-exporter:\r\n        image: quay.io/prometheus/node-exporter\r\n        restart: always\r\n        volumes:\r\n            - '/:/host:ro,rslave'\r\n            - './tmp/:/tmp/'\r\n        network_mode: \"host\"\r\n        pid: \"host\"\r\n        command:\r\n            - \"--path.rootfs=/host\"\r\n            - \"--collector.textfile.directory=/tmp/\"\r\n    smartctl-exporter:\r\n      image: matusnovak/prometheus-smartctl:latest\r\n      container_name: smartctl-exporter\r\n      privileged: true\r\n      environment:\r\n        - \"SMARTCTL_METRICS_FILE_ENABLE=True\"\r\n      volumes:\r\n        - ./tmp/:/metrics/\r\n      restart: unless-stopped\r\n```\r\n\r\n\r\n\r\nYour metrics will be available at \u003chttp://localhost:9902/metrics\u003e\r\n\r\nThe exported metrics looks like these:\r\n\r\n```shell\r\nsmartprom_smart_passed{drive=\"/dev/sda\",model_family=\"Seagate BarraCuda 3.5 (SMR)\",model_name=\"ST6000DM003-2CY296\",serial_number=\"WCT362XM\",type=\"sat\",user_capacity=\"6001175126016\"} 1.0\r\nsmartprom_exit_code{drive=\"/dev/sda\",model_family=\"Seagate BarraCuda 3.5 (SMR)\",model_name=\"ST6000DM003-2CY296\",serial_number=\"WCT362XM\",type=\"sat\",user_capacity=\"6001175126016\"} 0.0\r\nsmartprom_raw_read_error_rate{drive=\"/dev/sda\",model_family=\"Seagate BarraCuda 3.5 (SMR)\",model_name=\"ST6000DM003-2CY296\",serial_number=\"WCT362XM\",type=\"sat\",user_capacity=\"6001175126016\"} 83.0\r\nsmartprom_raw_read_error_rate_raw{drive=\"/dev/sda\",model_family=\"Seagate BarraCuda 3.5 (SMR)\",model_name=\"ST6000DM003-2CY296\",serial_number=\"WCT362XM\",type=\"sat\",user_capacity=\"6001175126016\"} 2.23179896e+08\r\nsmartprom_power_on_hours{drive=\"/dev/sda\",model_family=\"Seagate BarraCuda 3.5 (SMR)\",model_name=\"ST6000DM003-2CY296\",serial_number=\"WCT362XM\",type=\"sat\",user_capacity=\"6001175126016\"} 73.0\r\nsmartprom_power_on_hours_raw{drive=\"/dev/sda\",model_family=\"Seagate BarraCuda 3.5 (SMR)\",model_name=\"ST6000DM003-2CY296\",serial_number=\"WCT362XM\",type=\"sat\",user_capacity=\"6001175126016\"} 24299.0\r\nsmartprom_airflow_temperature_cel{drive=\"/dev/sda\",model_family=\"Seagate BarraCuda 3.5 (SMR)\",model_name=\"ST6000DM003-2CY296\",serial_number=\"WCT362XM\",type=\"sat\",user_capacity=\"6001175126016\"} 60.0\r\nsmartprom_airflow_temperature_cel_raw{drive=\"/dev/sda\",model_family=\"Seagate BarraCuda 3.5 (SMR)\",model_name=\"ST6000DM003-2CY296\",serial_number=\"WCT362XM\",type=\"sat\",user_capacity=\"6001175126016\"} 40.0\r\n...\r\n```\r\n\r\nIf you are using a MegaRAID card to connect the drives, the metrics will export look like these:\r\n\r\n```shell\r\nsmartprom_power_on_hours_raw{drive=\"megaraid,0\",model_family=\"Western Digital Ultrastar He10/12\",model_name=\"WDC WD80EMAZ-00M9AA0\",serial_number=\"XXXXXXXX\",type=\"sat\",user_capacity=\"6001175126016\"} 28522.0\r\nsmartprom_power_on_time_hours{drive=\"megaraid,1\",model_family=\"Unknown\",model_name=\"HGST HUH728080AL5200\",serial_number=\"XXXXXXXX\",type=\"scsi\",user_capacity=\"6001175126016\"} 37341.0\r\n```\r\n\r\n## Configuration\r\n\r\nAll configuration is done with environment variables.\r\n\r\n- `SMARTCTL_REFRESH_INTERVAL`: (Optional) The refresh interval of the metrics. A larger value reduces CPU usage. The default is `60` seconds.\r\n- `SMARTCTL_EXPORTER_PORT`: (Optional) The address the exporter should listen on. The default is `9902`.\r\n- `SMARTCTL_EXPORTER_ADDRESS`: (Optional) The address the exporter should listen on. The default is to listen on all addresses.\r\n- `SMARTCTL_METRICS_FILE_ENABLE`: (Optional) To enable metrics file, if you have a node exporter running anyway, you can simply read out this file . The default is `False`.\r\n- `SMARTCTL_METRICS_FILE_PATH`: (Optional) the path, this must then also be specified in the docker-compose as volume. The default is `/metrics/`.\r\n\r\n## Grafana dashboard\r\n\r\nThere is a reference Grafana dashboard in [grafana/grafana_dashboard.json](./grafana/grafana_dashboard.json).\r\n\r\n![](./grafana/grafana_dashboard_1.png)\r\n![](./grafana/grafana_dashboard_2.png)\r\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmatusnovak%2Fprometheus-smartctl","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmatusnovak%2Fprometheus-smartctl","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmatusnovak%2Fprometheus-smartctl/lists"}