More logging info for scrub and commandline.

This commit is contained in:
Andrea Mazzoleni 2014-06-29 10:49:13 +02:00
parent 35fb2085dc
commit 2652438f6d
4 changed files with 37 additions and 18 deletions

View file

@ -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;i<blockmax;++i) {
snapraid_info info = info_get(&state->infoarr, 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);

View file

@ -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;i<argc;++i)
fprintf(stdlog, "argv:%u:%s\n", i, argv[i]);
fflush(stdlog);
if (!opt.skip_self)
selftest();

View file

@ -361,8 +361,6 @@ void state_config(struct snapraid_state* state, const char* path, const char* co
unsigned line;
tommy_node* i;
unsigned l;
time_t t;
struct tm* tm;
/* copy the options */
state->opt = *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) {

View file

@ -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<blockmax;++i) {
int one_invalid;
int one_valid;
@ -192,7 +192,6 @@ int state_status(struct snapraid_state* state)
fprintf(stdlog, "summary:has_unsynced:%u\n", unsynced_blocks);
fprintf(stdlog, "summary:has_rehash:%u\n", rehash);
fprintf(stdlog, "summary:has_bad:%u\n", bad);
fprintf(stdlog, "summary:time_count:%u\n", count);
fflush(stdlog);
if (!count) {
@ -204,16 +203,16 @@ int state_status(struct snapraid_state* state)
/* sort the info to get the time info */
qsort(infomap, count, sizeof(snapraid_info), info_time_compare);
/* info for making the graph */
/* 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, "time:%"PRIu64":%u\n", (uint64_t)info_get_time(infomap[i]), j - i);
fprintf(stdlog, "info_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]);