* Add better error logging on smartctl exec failure
We will now log a warning if smartctl path passed via command line is invalid.
Signed-off-by: Piotr Dobrowolski <admin@tastycode.pl>
(cherry picked from commit 1c9c6943e8)
* Add support for autoscan device types and predictable device paths
This adds a new command line option allowing for customization of
autodetected device types and enables use of special "by-id" device type
that forces use of predictable device paths (/dev/disk/by-id/...)
Relevant change to device name parsing regular expression is included
now, so predictable device paths are now also usable when directly
specified.
Signed-off-by: Piotr Dobrowolski <admin@tastycode.pl>
(cherry picked from commit 4c5f721e11)
Conflicts:
- file: 'readjson.go'
comment: 'manually resolve new logger issues'
* Rework device label, fix SATA discovery, per-device type specification
Signed-off-by: Piotr Dobrowolski <admin@tastycode.pl>
(cherry picked from commit 319184ce66)
Conflicts:
- file: 'main.go'
comment: 'manually resolve new logger issues'
- file: 'readjson.go'
comment: 'manually resolve new logger issues'
---------
Co-authored-by: Piotr Dobrowolski <admin@tastycode.pl>
The bulk of this change set was automated by the following script which
is being used to aid in converting the various exporters/projects to use
slog:
https://gist.github.com/tjhop/49f96fb7ebbe55b12deee0b0312d8434
Other changes include:
- bumping prometheus/{common,client_golang,exporter-toolkit}
- bump minimum go version to go1.22
- remove old go-kit/log linter configs, add sloglint
Signed-off-by: TJ Hoplock <t.hoplock@gmail.com>
* Update Go to 1.20.
* Update CI orb.
* Update golangci-lint.
* Update Go modules.
* Use new landing page function.
Signed-off-by: SuperQ <superq@gmail.com>
All errors are already logged from the called functions: readSMARTctl,
resultCodeIsOk, jsonIsOk. Logging twice due to the same error is useless
and the "smartctl returned bad data for device" message is confusing
since that condition may happen when a device is in a low-power mode.
Signed-off-by: Jakub Klinkovský <j.l.k@gmx.com>
Switch exporter over to standard Prometheus exporter flags and logging.
This eliminates the need for a configuraion file.
Signed-off-by: SuperQ <superq@gmail.com>
* Return the cached value if it's not time to scan again yet
This should ensure that if we have a valid value cached (which ought
to be every time after the first scan), we return it as metrics.
This fixes the crashes that would happen if queries happened earlier
than the re-scan interval allowed.
* Address review feedback: Shorten the time-to-scan logic
We can express this in a single if statement, so it takes fewer lines
to do the "should we check again" check.
Use standard Prometheus Community build infra.
* Update Go modules for new location
* Update references to github URLs
* Update for Go 1.17+
Signed-off-by: SuperQ <superq@gmail.com>
The previous code was parsing left-to-right, but the bits are actually
numbered right-to-left (least to most significant). Instead of
converting to strings, just use bitmasks.
Fixes https://github.com/prometheus-community/smartctl_exporter/issues/22
Signed-off-by: Eric Culp <eculperic@gmail.com>