• Stars
    star
    154
  • Rank 242,095 (Top 5 %)
  • Language
    Python
  • License
    The Unlicense
  • Created about 5 years ago
  • Updated 3 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

HDD S.M.A.R.T exporter for Prometheus written in Python

Prometheus S.M.A.R.T ctl metrics exporter

build

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.

Install

Note: You don't have to do this if you use the Docker image.

  1. Copy the smartprom.service file into /etc/systemd/system folder.
  2. Copy the smartprom.py file anywhere into your system.
  3. Modify ExecStart= in the smartprom.service so that it points to smartprom.py in your system.
  4. Run chmod +x smartprom.py
  5. Install prometheus_client for the root user, example: sudo -H python3 -m pip install prometheus_client
  6. Run systemctl enable smartprom and systemctl start smartprom
  7. Your metrics will now be available at http://localhost:9902

Docker usage

No 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.

Docker image is here: https://hub.docker.com/r/matusnovak/prometheus-smartctl

The architectures supported by this image are: linux/386, linux/amd64, linux/arm/v6, linux/arm/v7, linux/arm64/v8, linux/ppc64le, linux/s390x

Example docker-compose.yml:

version: '3'
services:
  smartctl-exporter:
    image: matusnovak/prometheus-smartctl:latest
    container_name: smartctl-exporter
    privileged: true
    ports:
      - "9902:9902"
    restart: unless-stopped

Your metrics will be available at http://localhost:9902/metrics

The exported metrics looks like these:

smartprom_smart_passed{drive="/dev/sda",model_family="Seagate BarraCuda 3.5 (SMR)",model_name="ST6000DM003-2CY296",serial_number="WCT362XM",type="sat"} 1.0
smartprom_exit_code{drive="/dev/sda",model_family="Seagate BarraCuda 3.5 (SMR)",model_name="ST6000DM003-2CY296",serial_number="WCT362XM",type="sat"} 0.0
smartprom_raw_read_error_rate{drive="/dev/sda",model_family="Seagate BarraCuda 3.5 (SMR)",model_name="ST6000DM003-2CY296",serial_number="WCT362XM",type="sat"} 83.0
smartprom_raw_read_error_rate_raw{drive="/dev/sda",model_family="Seagate BarraCuda 3.5 (SMR)",model_name="ST6000DM003-2CY296",serial_number="WCT362XM",type="sat"} 2.23179896e+08
smartprom_power_on_hours{drive="/dev/sda",model_family="Seagate BarraCuda 3.5 (SMR)",model_name="ST6000DM003-2CY296",serial_number="WCT362XM",type="sat"} 73.0
smartprom_power_on_hours_raw{drive="/dev/sda",model_family="Seagate BarraCuda 3.5 (SMR)",model_name="ST6000DM003-2CY296",serial_number="WCT362XM",type="sat"} 24299.0
smartprom_airflow_temperature_cel{drive="/dev/sda",model_family="Seagate BarraCuda 3.5 (SMR)",model_name="ST6000DM003-2CY296",serial_number="WCT362XM",type="sat"} 60.0
smartprom_airflow_temperature_cel_raw{drive="/dev/sda",model_family="Seagate BarraCuda 3.5 (SMR)",model_name="ST6000DM003-2CY296",serial_number="WCT362XM",type="sat"} 40.0
...

Configuration

All configuration is done with environment variables.

  • SMARTCTL_REFRESH_INTERVAL: (Optional) The refresh interval of the metrics. A larger value reduces CPU usage. The default is 60 seconds.
  • SMARTCTL_EXPORTER_PORT: (Optional) The address the exporter should listen on. The default is 9902.
  • SMARTCTL_EXPORTER_ADDRESS: (Optional) The address the exporter should listen on. The default is to listen on all addresses.

Grafana dashboard

There is a reference Grafana dashboard in grafana/grafana_dashboard.json.

More Repositories

1

doxybook2

Doxygen XML to Markdown (or JSON)
C++
176
star
2

rpi-opengl-without-x

Raspberry Pi OpenGL ES 2 without an X server (using EGL)
C
176
star
3

wrenbind17

A header only library for binding C++17 classes and functions to Wren, an embeddable programming language
C++
65
star
4

simplesquirrel

Yet another simple binding in C++11 for Squirrel scripting language
C++
46
star
5

python-embedded-example-project

This is an example project using mebedded python in C++ console application using CMake
CMake
38
star
6

doxybook

Generate GitBook, VuePress, Docsify, or MkDocs out of Doxygen XML output
Python
32
star
7

homelab

Homelab configuration via docker-compose
Python
27
star
8

prometheus-zfs

Prometheus exporter for (some) ZFS statistics via zpool iostatus and zfs get space
Python
18
star
9

rpi-tftgl

Raspberry Pi SSD1963 TFT Display driver with OpenGL ES (via EGL) support including MSAA
C
14
star
10

cpp-vcpkg-template

C++17 + Vcpkg + GitHub Actions + Create release with changelog automatically
CMake
12
star
11

finegui

The FineGui is a standalone library that provides a simple utf8 enabled graphical user interface with a linear layout system similar to Android GUI development. The library also offers experimental XML parser that generates GUI structure for you.
C++
11
star
12

tiva-c-series-cmake-example

Tiva Ware C Series blinky example using CMake and Visual Studio Code
C
9
star
13

gitbook-plugin-insert-logo

GitBook Plugin to insert logo image into the navigation above search input
JavaScript
8
star
14

texture-compression

Hardware texture Compression via OpenGL
C++
7
star
15

space-3d

Generate a random space skybox with stars and nebulas written in GLSL and C++
C++
5
star
16

HGS2561281

HGS2561281 OLED 256x128 Display library for Arduino and Energia
C++
3
star
17

finegraphics

FineGraphics is a standalone library that provides the basic API wrappers around OpenGL, such as textures, framebuffers, renderbuffers, shaders, including window handling and basic 2D canvas rendering.
C++
2
star
18

fineframework

FineFramework - FFW
2
star
19

finemedia

The FineMedia is a simple image reading and writing library, capable of writing and reading PNG, JPG, BMP, DDS (with mipmaps and cubemaps!), TIFF, PBM, and TGA files.
C++
1
star
20

SM2OBJ

StarMade Blueprint to OBJ Exporter
C++
1
star
21

aspnet-core-vuejs-example

.Net Core 3.0 VueJs Example Project
C#
1
star
22

libui-cmake

libui with CMake instead of Menson
CMake
1
star
23

cudd-example-project

CUDD Example Project
C
1
star
24

energise

Jinja
1
star
25

doxybook2-bsl-license

This is a fork of https://github.com/matusnovak/doxybook2 with BSL 1.0 license
C++
1
star
26

serverless-aws-node-bootstrap-vue

Serverless framework example using AWS Lambda + DyanmoDB + Node.js 8.10 + Bootstrap-Vue (Bootstrap 4 with Vue.js 2.x), serving the front end through API Gateway to avoid CloudFront.
Vue
1
star
27

esp-idf-m95-eeprom

A simple EEPROM library for the m950x0 and m95mx0 series SPI EEPROM chips for the ESP32 ESP-IDF framework. Can be used with PlatformIO.
C
1
star
28

finedata

The FineData is a standalone library that provides the basic API wrappers around reading and writing JSON, YAML, and XML files using a universal API. Meaning, the same piece of code that you can use to load a JSON file can be used to load a YAML file.
C++
1
star
29

asio-tls-example

An example usage of asio and openssl to create encrypted TCP connection via TLS v1.3
C++
1
star