diff --git a/check.c b/check.c index fa0a5683..41d95193 100644 --- a/check.c +++ b/check.c @@ -1650,6 +1650,35 @@ bail: printf("Everything OK\n"); } + if (state->opt.gui) { + fprintf(stdlog, "summary:error:%u\n", error); + if (fix) + fprintf(stdlog, "summary:error_recovered:%u\n", recovered_error); + if (check) + fprintf(stdlog, "summary:error_unrecoverable:%u\n", unrecoverable_error); + if (fix) { + if (error + recovered_error + unrecoverable_error == 0) + fprintf(stdlog, "summary:exit:ok\n"); + else if (unrecoverable_error == 0) + fprintf(stdlog, "summary:exit:recovered\n"); + else + fprintf(stdlog, "summary:exit:unrecoverable\n"); + } else if (check) { + if (error + unrecoverable_error == 0) + fprintf(stdlog, "summary:exit:ok\n"); + else if (unrecoverable_error == 0) + fprintf(stdlog, "summary:exit:recoverable\n"); + else + fprintf(stdlog, "summary:exit:unrecoverable\n"); + } else { /* audit only */ + if (error == 0) + fprintf(stdlog, "summary:exit:ok\n"); + else + fprintf(stdlog, "summary:exit:error\n"); + } + fflush(stdlog); + } + free(failed); free(failed_map); free(handle); diff --git a/dup.c b/dup.c index d7d6adc5..237ed9f0 100644 --- a/dup.c +++ b/dup.c @@ -140,11 +140,20 @@ void state_dup(struct snapraid_state* state) tommy_list_foreach(&hashlist, (tommy_foreach_func*)hash_free); tommy_hashdyn_done(&hashset); - if (!state->opt.gui) { - if (count) - printf("%u duplicates, for %"PRIu64" MiB.\n", count, size / (1024*1024)); - else - printf("No duplicate\n"); + if (count) + printf("%u duplicates, for %"PRIu64" MiB.\n", count, size / (1024*1024)); + else + printf("No duplicate\n"); + + if (state->opt.gui) { + fprintf(stdlog, "summary:dup_count:%u\n", count); + fprintf(stdlog, "summary:dup_size:%"PRIu64"\n", size); + if (count == 0) { + fprintf(stdlog, "summary:exit:unique\n"); + } else { + fprintf(stdlog, "summary:exit:dup\n"); + } + fflush(stdlog); } } diff --git a/scan.c b/scan.c index 184ffbd3..ef240e64 100644 --- a/scan.c +++ b/scan.c @@ -1104,6 +1104,7 @@ void state_scan(struct snapraid_state* state, int output) if (state->opt.verbose || output) { struct snapraid_scan total; + int no_difference; total.count_equal = 0; total.count_move = 0; @@ -1131,9 +1132,33 @@ void state_scan(struct snapraid_state* state, int output) printf("\tadded %d\n", total.count_insert); } + if (state->opt.gui) { + fprintf(stdlog, "summary:equal:%u\n", total.count_equal); + fprintf(stdlog, "summary:moved:%u\n", total.count_move); + fprintf(stdlog, "summary:restored:%u\n", total.count_restore); + fprintf(stdlog, "summary:changed:%u\n", total.count_change); + fprintf(stdlog, "summary:removed:%u\n", total.count_remove); + fprintf(stdlog, "summary:added:%u\n", total.count_insert); + fflush(stdlog); + } + + no_difference = !total.count_move && !total.count_restore && !total.count_change && !total.count_remove && !total.count_insert; + if (output) { - if (!total.count_move && !total.count_restore && !total.count_change && !total.count_remove && !total.count_insert) { - printf("No difference.\n"); + if (no_difference) { + printf("No difference\n"); + } else { + printf("There are differences\n"); + } + } + + if (state->opt.gui) { + if (no_difference) { + fprintf(stdlog, "summary:exit:equal\n"); + fflush(stdlog); + } else { + fprintf(stdlog, "summary:exit:diff\n"); + fflush(stdlog); } } } diff --git a/scrub.c b/scrub.c index 9965feda..6ad501aa 100644 --- a/scrub.c +++ b/scrub.c @@ -389,6 +389,16 @@ static int state_scrub_process(struct snapraid_state* state, struct snapraid_par printf("Everything OK\n"); } + if (state->opt.gui) { + fprintf(stdlog, "summary:error_read:%u\n", error); + fprintf(stdlog, "summary:error_data:%u\n", silent_error); + if (error + silent_error == 0) + fprintf(stdlog, "summary:exit:ok\n"); + else + fprintf(stdlog, "summary:exit:error\n"); + fflush(stdlog); + } + bail: for(j=0;jlevel;++l) { diff --git a/status.c b/status.c index ade7f28f..8e65000f 100644 --- a/status.c +++ b/status.c @@ -110,17 +110,37 @@ int state_status(struct snapraid_state* state) printf("Files: %u\n", file_count); printf("Fragmented files: %u\n", file_fragmented); printf("Excess fragments: %u\n", extra_fragment); - printf("Files size: %" PRIu64 " GiB\n", file_size / (1024*1024*1024) ); - printf("Parity size: %" PRIu64 " GiB\n", blockmax * (uint64_t)state->block_size / (1024*1024*1024) ); + printf("Files size: %"PRIu64" GiB\n", file_size / (1024*1024*1024) ); + printf("Parity size: %"PRIu64" GiB\n", blockmax * (uint64_t)state->block_size / (1024*1024*1024) ); printf("\n"); - /* count unsynched blocks */ + if (state->opt.gui) { + fprintf(stdlog, "summary:file_count:%u\n", file_count); + fprintf(stdlog, "summary:fragmented_file_count:%u\n", file_fragmented); + fprintf(stdlog, "summary:excess_fragment_count:%u\n", extra_fragment); + fprintf(stdlog, "summary:file_size:%"PRIu64"\n", file_size); + fprintf(stdlog, "summary:parity_size:%"PRIu64"\n", blockmax * (uint64_t)state->block_size); + 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, "block_count:%u\n", blockmax); + fflush(stdlog); + } + + /* copy the info a temp vector, and count bad/rehash/unsynched blocks */ + infomap = malloc_nofail(blockmax * sizeof(snapraid_info)); + bad = 0; + count = 0; + rehash = 0; unsynched_blocks = 0; + for(i=0;iinfoarr, i); + /* for each disk */ one_invalid = 0; one_valid = 0; @@ -138,27 +158,32 @@ int state_status(struct snapraid_state* state) if (one_invalid && one_valid) { ++unsynched_blocks; } - } - - /* copy the info a temp vector, and count bad/rehash blocks */ - infomap = malloc_nofail(blockmax * sizeof(snapraid_info)); - bad = 0; - count = 0; - rehash = 0; - for(i=0;iinfoarr, i); /* skip unused blocks */ - if (info == 0) - continue; - - if (info_get_bad(info)) - ++bad; + if (info != 0) { + if (info_get_bad(info)) + ++bad; - if (info_get_rehash(info)) - ++rehash; + if (info_get_rehash(info)) + ++rehash; - infomap[count++] = info; + infomap[count++] = info; + } + + if (state->opt.gui) { + if (info != 0) + fprintf(stdlog, "block:%u:%"PRIu64":%s:%s:%s:%s\n", i, (uint64_t)info_get_time(info), one_valid ? "used": "", one_invalid ? "unsynched" : "", info_get_bad(info) ? "bad" : "", info_get_rehash(info) ? "rehash" : ""); + else + fprintf(stdlog, "block_noinfo:%u:%s:%s\n", i, one_valid ? "used": "", one_invalid ? "unsynched" : ""); + } + } + + if (state->opt.gui) { + fprintf(stdlog, "summary:has_unsynched:%u\n", unsynched_blocks); + fprintf(stdlog, "summary:has_rehash:%u\n", rehash); + fprintf(stdlog, "summary:has_bad:%u\n", bad); + fprintf(stdlog, "time_count:%u\n", count); + fflush(stdlog); } if (!count) { @@ -169,6 +194,20 @@ int state_status(struct snapraid_state* state) /* sort the info to get the time info */ qsort(infomap, count, sizeof(snapraid_info), info_time_compare); + + if (state->opt.gui) { + /* info for making the graph */ + i = 0; + while (i < count) { + unsigned j = i + 1; + while (j < count && info_get_time(infomap[i]) == info_get_time(infomap[j])) + ++j; + fprintf(stdlog, "time:%"PRIu64":%u\n", (uint64_t)info_get_time(infomap[i]), j - i); + i = j; + } + fflush(stdlog); + } + oldest = info_get_time(infomap[0]); median = info_get_time(infomap[count / 2]); newest = info_get_time(infomap[count - 1]); diff --git a/sync.c b/sync.c index 4c5ae81a..37265526 100644 --- a/sync.c +++ b/sync.c @@ -442,6 +442,16 @@ static int state_sync_process(struct snapraid_state* state, struct snapraid_pari printf("Everything OK\n"); } + if (state->opt.gui) { + fprintf(stdlog, "summary:error_readwrite:%u\n", error); + fprintf(stdlog, "summary:error_data:%u\n", silent_error); + if (error + silent_error == 0) + fprintf(stdlog, "summary:exit:ok\n"); + else + fprintf(stdlog, "summary:exit:error\n"); + fflush(stdlog); + } + bail: for(j=0;j