Signed-off-by: Arne Fitzenreiter arne_f@ipfire.org --- src/_collecty/blockdev.c | 8 +++++++- src/collecty/plugins/disk.py | 5 ++++- 2 files changed, 11 insertions(+), 2 deletions(-)
diff --git a/src/_collecty/blockdev.c b/src/_collecty/blockdev.c index 2c715b9..09d3994 100644 --- a/src/_collecty/blockdev.c +++ b/src/_collecty/blockdev.c @@ -296,8 +296,14 @@ PyObject* BlockDevice_get_temperature(PyObject* self) {
uint64_t mkelvin; int r = sk_disk_smart_get_temperature(device->disk, &mkelvin); - if (r) + if (r) { + // Temperature not available but SMART is supported + if (errno == ENOENT) { + PyErr_Format(PyExc_OSError, "Device does not have a temperature"); + } + return NULL; + }
// Convert the temperature to Kelvin return PyFloat_FromDouble((double)mkelvin / 1000.0); diff --git a/src/collecty/plugins/disk.py b/src/collecty/plugins/disk.py index 1b12c5c..a822eb2 100644 --- a/src/collecty/plugins/disk.py +++ b/src/collecty/plugins/disk.py @@ -267,7 +267,10 @@ class DiskObject(base.Object): if not self.is_smart_supported(): return "NaN"
- return self.device.get_temperature() + try: + return self.device.get_temperature() + except OSError: + return "NaN"
def get_bad_sectors(self): if not self.is_smart_supported():