uint64_t bad_sectors;
uint64_t power_cycles;
uint64_t power_on_time;
- uint64_t temperature;
+ uint64_t temp_mk;
+ double temp_k;
int r;
// Open the disk
}
// Read temperature
- r = sk_disk_smart_get_temperature(disk, &temperature);
+ r = sk_disk_smart_get_temperature(disk, &temp_mk);
if (r < 0) {
ERROR(ctx, "Failed to read temperature from %s: %m\n", node);
r = -errno;
goto ERROR;
}
+ // Convert to Kelvin
+ temp_k = (double)temp_mk / 1000.0;
+
// Push all values
r = td_metrics_set(metrics, VALUES(
VALUE_BOOL ("awake", &awake),
VALUE_BOOL ("smart_status", &smart_status),
VALUE_UINT64("power_cycle", &power_cycles),
VALUE_UINT64("bad_sectors", &bad_sectors),
- VALUE_FLOAT ("temperature", &temperature)
+ VALUE_FLOAT ("temperature", &temp_k)
));
ERROR: