smart-exporter is a simple server that periodically scrapes S.M.A.R.T stats and exports them via HTTP for Prometheus consumption, written in Node.js. The attributes it supplies to Prometheus are configurable, as well as the labels it supplies.
docker create --name=smartexporter \
-v <path to config>:/config \
-p 9120:9120 \
--privileged=true \
antilax3/smart-exporter
The parameters are split into two halves, separated by a colon, the left hand side representing the host and the right the container side. For example with a volume -v external:internal - what this shows is the volume mapping from internal to external of the container. So -v /mnt/app/config:/config would map /config from inside the container to be accessible from /mnt/app/config on the host's filesystem.
-v /config
- local path for smartexporter config file-p 9120
- HTTP port for webserver-e PUID
- for UserID, see below for explanation-e PGID
- for GroupID, see below for explanation-e TZ
- for setting timezone information, eg Australia/Melbourne
It is based on alpine linux with s6 overlay, for shell access whilst the container is running do docker exec -it smartexporter /bin/bash
.
Sometimes when using data volumes (-v flags) permissions issues can arise between the host OS and the container. We avoid this issue by allowing you to specify the user PUID
and group PGID
. Ensure the data volume directory on the host is owned by the same user you specify and it will "just work".
In this instance PUID=1001
and PGID=1001
. To find yours use id user
as below:
$ id <dockeruser>
uid=1001(dockeruser) gid=1001(dockergroup) groups=1001(dockergroup)
The container uses a single volume mounted at '/config'. This volume stores the configuration file 'smartexporter.json'.
config
|-- smartexporter.json
The smartexporter.json is copied to the /config volume when first run. It has two parameters, one optional and one mandatory.
The optional parameter is:
- scrapeInterval (default 10 seconds)
The mandatory parameter reportedAttributes is an array of objects. The objects define the SMART attributes that will be parsed and reported. The default file has examples.
Only one of either attributeID or attributeName is required.
attributeID: Number | The attribute ID
attributeName: String | The attribute name
name: String (Required) | The name reported to Prometheus, prepended with 'smartexporter_'
help: String (Required) | Help text provided to Prometheus
labelNames: Array of Strings | Mapped to data from the information section of smartctl. Can be used for labels, ie "Device" for /dev/sdx or "Serial Number" for the serial number of the HDD.
Known S.M.A.R.T. attributes (Wikipedia)
- 24/06/19: Add ability to capture attributes from SAS drives
- 24/02/18: Updated to use alpine 3.7 image and build with jenkins
- 24/01/18: Corrected documentation
- 24/01/18: Refactoring & Cleaning
- 23/01/18: Initial Release