From 2652438f6dd0afa41fde70b42cd615eda235b15c Mon Sep 17 00:00:00 2001 From: Andrea Mazzoleni Date: Sun, 29 Jun 2014 10:49:13 +0200 Subject: [PATCH] More logging info for scrub and commandline. --- cmdline/scrub.c | 15 +++++++++++++++ cmdline/snapraid.c | 18 ++++++++++++++++++ cmdline/state.c | 13 ------------- cmdline/status.c | 9 ++++----- 4 files changed, 37 insertions(+), 18 deletions(-) diff --git a/cmdline/scrub.c b/cmdline/scrub.c index 7d94aeeb..f188a04d 100644 --- a/cmdline/scrub.c +++ b/cmdline/scrub.c @@ -524,6 +524,7 @@ int state_scrub(struct snapraid_state* state, int percentage, int olderthan) /* copy the info in the temp vector */ count = 0; + fprintf(stdlog, "block_count:%u\n", blockmax); for(i=0;iinfoarr, i); @@ -544,6 +545,17 @@ int state_scrub(struct snapraid_state* state, int percentage, int olderthan) /* sort it */ qsort(infomap, count, sizeof(snapraid_info), info_time_compare); + /* output the info map */ + i = 0; + fprintf(stdlog, "info_count:%u\n", count); + while (i < count) { + unsigned j = i + 1; + while (j < count && info_get_time(infomap[i]) == info_get_time(infomap[j])) + ++j; + fprintf(stdlog, "info_time:%"PRIu64":%u\n", (uint64_t)info_get_time(infomap[i]), j - i); + i = j; + } + /* don't check more block than the available ones */ if (countlimit > count) countlimit = count; @@ -561,6 +573,9 @@ int state_scrub(struct snapraid_state* state, int percentage, int olderthan) timelimit = 0; } + fprintf(stdlog, "time_limit:%"PRIu64"\n", (uint64_t)timelimit); + fprintf(stdlog, "count_limit:%u\n", countlimit); + /* free the temp vector */ free(infomap); diff --git a/cmdline/snapraid.c b/cmdline/snapraid.c index fdb54606..a5779537 100644 --- a/cmdline/snapraid.c +++ b/cmdline/snapraid.c @@ -385,6 +385,9 @@ int main(int argc, char* argv[]) const char* gen_conf; const char* run; int period; + time_t t; + struct tm* tm; + int i; os_init(); raid_init(); @@ -796,6 +799,21 @@ int main(int argc, char* argv[]) /* open the log file */ log_open(log); + /* print generic info into the log */ + t = time(0); + tm = localtime(&t); + fprintf(stdlog, "version:%s\n", PACKAGE_VERSION); + fprintf(stdlog, "unixtime:%"PRIi64"\n", (int64_t)t); + if (tm) { + char datetime[64]; + strftime(datetime, sizeof(datetime), "%Y-%m-%d %H:%M:%S", tm); + fprintf(stdlog, "time:%s\n", datetime); + } + fprintf(stdlog, "command:%s\n", command); + for(i=0;iopt = *opt; @@ -373,18 +371,7 @@ void state_config(struct snapraid_state* state, const char* path, const char* co state->command = command; - t = time(0); - tm = localtime(&t); - - fprintf(stdlog, "version:%s\n", PACKAGE_VERSION); - fprintf(stdlog, "unixtime:%"PRIi64"\n", (int64_t)t); - if (tm) { - char datetime[64]; - strftime(datetime, sizeof(datetime), "%Y-%m-%d %H:%M:%S", tm); - fprintf(stdlog, "time:%s\n", datetime); - } fprintf(stdlog, "conf:%s\n", path); - fflush(stdlog); f = sopen_read(path); if (!f) { diff --git a/cmdline/status.c b/cmdline/status.c index 647d5c44..f5dc1bb2 100644 --- a/cmdline/status.c +++ b/cmdline/status.c @@ -137,7 +137,6 @@ int state_status(struct snapraid_state* state) fprintf(stdlog, "summary:hash:%s\n", hash_config_name(state->hash)); fprintf(stdlog, "summary:prev_hash:%s\n", hash_config_name(state->prevhash)); fprintf(stdlog, "summary:best_hash:%s\n", hash_config_name(state->besthash)); - fprintf(stdlog, "summary:block_count:%u\n", blockmax); fflush(stdlog); /* copy the info a temp vector, and count bad/rehash/unsynced blocks */ @@ -146,6 +145,7 @@ int state_status(struct snapraid_state* state) count = 0; rehash = 0; unsynced_blocks = 0; + fprintf(stdlog, "block_count:%u\n", blockmax); for(i=0;i