smartctl exporter
obtain metrics from disks
install and check
export DEBIAN_FRONTEND=noninteractive && apt update && apt install smartmontools
curl -L https://github.com/prometheus-community/smartctl_exporter/releases/download/v0.14.0/smartctl_exporter-0.14.0.linux-amd64.tar.gz | tar xz -C /tmp/
timeout 5 --preserve-status -s SIGTERM /tmp/smartctl_exporter-0.14.0.linux-amd64/smartctl_exporter --web.listen-address=localhost:9633 --smartctl.rescan=60m --smartctl.interval=15s ; mv /tmp/smartctl_exporter-0.14.0.linux-amd64/smartctl_exporter /usr/local/bin/smartctl_exporter
systemd unit file
#!/bin/bash
if [ "$EUID" -ne 0 ]; then
echo "Please run as root"
exit
fi
tee -a /etc/systemd/system/smartctl_exporter.service <<ECHO
[Unit]
Description=Smartctl Exporter Service
After=network.target
[Service]
ExecStart=/usr/local/bin/smartctl_exporter --web.listen-address=localhost:9633 --smartctl.rescan=60m --smartctl.interval=15s
Restart=on-failure
[Install]
WantedBy=multi-user.target
ECHO
systemctl daemon-reload && systemctl enable --now smartctl_exporter.service
On reload/edit sysd-unit:
systemctl daemon-reload && systemctl restart smartctl_exporter.service
vector.dev config
vim /etc/vector/vector.yaml
sources:
smartctl:
type: prometheus_scrape
scrape_interval_secs: 15
honor_labels: true
endpoints:
- http://localhost:9633/metrics
prometheus metrics to check
sum by (instance) (smartctl_device_critical_warning > 0)