This is a simple exporter for the Prometheus metrics using smartctl. 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.
Docker image here: https://hub.docker.com/r/matusnovak/prometheus-smartctl
Note: You don't have to do this if you use the Docker image.
- Copy the
smartprom.servicefile into/etc/systemd/systemfolder. - Copy the
smartprom.pyfile anywhere into your system. - Modify
ExecStart=in thesmartprom.serviceso that it points tosmartprom.pyin your system. - Run
chmod +x smartprom.py - Install
prometheus_clientfor the root user, example:sudo -H python3 -m pip install prometheus_client - Run
systemctl enable smartpromandsystemctl start smartprom - Your metrics will now be available at
http://localhost:9902
No extra configuration needed, should work out of the box. The privileged: true is needed because then smartctl can't access drvies from the host.
version: '3'
services:
smartctl-metrics:
image: matusnovak/prometheus-smartctl:latest
restart: unless-stopped
privileged: true
ports:
- 9902:9902Your metrics will be available at http://localhost:9902/metrics