]> git.ipfire.org Git - telemetry.git/commitdiff
sources: disk: Convert temperate from mK to K
authorMichael Tremer <michael.tremer@ipfire.org>
Wed, 22 Oct 2025 20:49:07 +0000 (20:49 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Wed, 22 Oct 2025 20:49:07 +0000 (20:49 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/daemon/sources/disk.c

index 996dfce7a31df33e081861d00b76f6912c6cf435..945cf13ddc59695c103d68dfab7f744516584c24 100644 (file)
@@ -60,7 +60,8 @@ static int disk_read_smart(td_ctx* ctx, const char* node, td_metrics* metrics) {
        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
@@ -159,13 +160,16 @@ static int disk_read_smart(td_ctx* ctx, const char* node, td_metrics* metrics) {
        }
 
        // 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),
@@ -173,7 +177,7 @@ static int disk_read_smart(td_ctx* ctx, const char* node, td_metrics* metrics) {
                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: