From 4d39bd5adff60acbda1597e2e3d6e74f9dd25db6 Mon Sep 17 00:00:00 2001 From: Andrea Mazzoleni Date: Sun, 8 Feb 2026 14:40:06 +0100 Subject: [PATCH] Log ETA in seconds. Also use empty fields if the value is not available. --- cmdline/state.c | 31 ++++++++++++++++++++++++++++--- doc/snapraid_log.1 | 18 ++++++++++++++---- doc/snapraid_log.d | 14 ++++++++++---- doc/snapraid_log.txt | 14 ++++++++++---- 4 files changed, 62 insertions(+), 15 deletions(-) diff --git a/cmdline/state.c b/cmdline/state.c index 7952631a..cd50f8a8 100644 --- a/cmdline/state.c +++ b/cmdline/state.c @@ -4990,7 +4990,7 @@ int state_progress(struct snapraid_state* state, struct snapraid_io* io, block_o /* estimate the remaining time in minutes */ if (delta_pos != 0) - out_eta = muldiv(countmax - countpos, delta_time, 60 * delta_pos); + out_eta = muldiv(countmax - countpos, delta_time, delta_pos); if (state->opt.force_stats) { os_clear(); @@ -5020,7 +5020,31 @@ int state_progress(struct snapraid_state* state, struct snapraid_io* io, block_o } if (state->opt.gui) { - log_tag("run:pos:%u:%u:%" PRIu64 ":%u:%u:%u:%u:%" PRIu64 "\n", blockpos, countpos, countsize, out_perc, out_eta, out_size_speed, out_cpu, (uint64_t)elapsed); + char str_eta[32]; + char str_size_speed[32]; + char str_cpu[32]; + char str_temp[32]; + char str_steady[32]; + if (out_computed) { + snprintf(str_eta, sizeof(str_eta), "%u", out_eta); + snprintf(str_size_speed, sizeof(str_size_speed), "%u", out_size_speed); + snprintf(str_cpu, sizeof(str_cpu), "%u", out_cpu); + } else { + str_eta[0] = 0; + str_size_speed[0] = 0; + str_cpu[0] = 0; + } + if (out_temperature) { + snprintf(str_temp, sizeof(str_eta), "%u", out_temperature); + } else { + str_temp[0] = 0; + } + if (out_steady) { + snprintf(str_steady, sizeof(str_steady), "%u", out_steady); + } else { + str_steady[0] = 0; + } + log_tag("run:pos:%u:%u:%" PRIu64 ":%u:%s:%s:%s:%" PRIu64 ":%s:%s\n", blockpos, countpos, countsize, out_perc, str_eta, str_size_speed, str_cpu, (uint64_t)elapsed, str_temp, str_steady); log_flush(); } else { msg_bar("%u%%, %u MB", out_perc, (unsigned)(countsize / MEGA)); @@ -5034,7 +5058,8 @@ int state_progress(struct snapraid_state* state, struct snapraid_io* io, block_o else msg_bar(", Tmax %u", out_temperature); } - msg_bar(", %u:%02u ETA", out_eta / 60, out_eta % 60); + unsigned out_eta_minutes = out_eta / 60; /* minutes */ + msg_bar(", %u:%02u ETA", out_eta_minutes / 60, out_eta_minutes % 60); } msg_bar("\r"); msg_flush(); diff --git a/doc/snapraid_log.1 b/doc/snapraid_log.1 index 336aaacc..6d1f2e90 100644 --- a/doc/snapraid_log.1 +++ b/doc/snapraid_log.1 @@ -516,7 +516,7 @@ are going to be skipped (uint). .B run:end A zero\-argument tag indicating the end of the command execution. .TP -.B run:pos:::::::: +.B run:pos:::::::::: Detailed progress information during command execution. .RS 4 .PD 0 @@ -534,16 +534,26 @@ Current size processed (uint). Completion percentage (uint). .HP 4 .I -Estimated time to completion in seconds (uint). +Estimated time to completion in seconds. Empty if not +available (uint). .HP 4 .I -Data processing speed in MB/s (uint). +Data processing speed in MB/s. Empty if not +available (uint). .HP 4 .I -CPU usage percentage (uint). +CPU usage percentage. Empty if not available (uint). .HP 4 .I Elapsed time in seconds (uint). +.HP 4 +.I +Current max temperature of the disks. Empty if not +available (uint). +.HP 4 +.I +Expected steady temperature of the disks. +Empty if not available (uint). .PD .RE .TP diff --git a/doc/snapraid_log.d b/doc/snapraid_log.d index 2045c1de..04df876f 100644 --- a/doc/snapraid_log.d +++ b/doc/snapraid_log.d @@ -350,17 +350,23 @@ General Progress and Execution Tags =run:end A zero-argument tag indicating the end of the command execution. - =run:pos:::::::: + =run:pos:::::::::: Detailed progress information during command execution. - Current block index position processed (uint). - Number of blocks processed (uint). - Current size processed (uint). - Completion percentage (uint). - - Estimated time to completion in seconds (uint). - - Data processing speed in MB/s (uint). - - CPU usage percentage (uint). + - Estimated time to completion in seconds. Empty if not + available (uint). + - Data processing speed in MB/s. Empty if not + available (uint). + - CPU usage percentage. Empty if not available (uint). - Elapsed time in seconds (uint). + - Current max temperature of the disks. Empty if not + available (uint). + - Expected steady temperature of the disks. + Empty if not available (uint). =sigint:: A user interruption (e.g., Ctrl+C) was signaled. The process diff --git a/doc/snapraid_log.txt b/doc/snapraid_log.txt index da7a5b67..7f7dbac3 100644 --- a/doc/snapraid_log.txt +++ b/doc/snapraid_log.txt @@ -369,17 +369,23 @@ Only produced when `--gui` option is used. run:end A zero-argument tag indicating the end of the command execution. - run:pos:::::::: + run:pos:::::::::: Detailed progress information during command execution. - Current block index position processed (uint). - Number of blocks processed (uint). - Current size processed (uint). - Completion percentage (uint). - - Estimated time to completion in seconds (uint). - - Data processing speed in MB/s (uint). - - CPU usage percentage (uint). + - Estimated time to completion in seconds. Empty if not + available (uint). + - Data processing speed in MB/s. Empty if not + available (uint). + - CPU usage percentage. Empty if not available (uint). - Elapsed time in seconds (uint). + - Current max temperature of the disks. Empty if not + available (uint). + - Expected steady temperature of the disks. + Empty if not available (uint). sigint:: A user interruption (e.g., Ctrl+C) was signaled. The process