static void update_screen_live_counters(struct cstat *client, int *x, int col) { char msg[128]=""; struct cntr_ent *e; struct cntr *cntr=client->cntr; time_t start=(time_t)cntr->ent[(uint8_t)CMD_TIMESTAMP]->count; time_t end=(time_t)cntr->ent[(uint8_t)CMD_TIMESTAMP_END]->count; struct cntr_ent *gtotal=cntr->ent[(uint8_t)CMD_GRAND_TOTAL]; print_line("", (*x)++, col); snprintf(msg, sizeof(msg), "Start time: %s", getdatestr(start)); print_line(msg, (*x)++, col); snprintf(msg, sizeof(msg), " End time: %s", getdatestr(end)); print_line(msg, (*x)++, col); snprintf(msg, sizeof(msg), "Time taken: %s", time_taken(end-start)); print_line(msg, (*x)++, col); table_header(x, col); for(e=client->cntr->list; e; e=e->next) update_screen_live_counter_table(e, x, col); print_line("", (*x)++, col); snprintf(msg, sizeof(msg), "%19s: %"PRIu64"%%", "Percentage complete", ((gtotal->count+gtotal->same+gtotal->changed)*100)/gtotal->phase1); print_line(msg, (*x)++, col); print_line("", (*x)++, col); for(e=client->cntr->list; e; e=e->next) update_screen_live_counter_single(e, x, col); }
static int input_integer(void *ctx, long long val) { if(in_counters) { if(!strcmp(lastkey, "count")) { if(!cntr_ent) goto error; cntr_ent->count=(unsigned long long)val; } else if(!strcmp(lastkey, "changed")) { if(!cntr_ent) goto error; cntr_ent->changed=(unsigned long long)val; } else if(!strcmp(lastkey, "same")) { if(!cntr_ent) goto error; cntr_ent->same=(unsigned long long)val; } else if(!strcmp(lastkey, "deleted")) { if(!cntr_ent) goto error; cntr_ent->deleted=(unsigned long long)val; } else if(!strcmp(lastkey, "scanned")) { if(!cntr_ent) goto error; cntr_ent->phase1=(unsigned long long)val; } else { goto error; } return 1; } else if(in_backups && !in_flags && !in_counters && !in_logslist) { if(!current) goto error; if(!strcmp(lastkey, "number")) { number=(unsigned long)val; return 1; } else if(!strcmp(lastkey, "timestamp")) { time_t t; t=(unsigned long)val; free_w(×tamp); if(!(timestamp=strdup_w(getdatestr(t), __func__))) return 0; return 1; } } error: logp("Unexpected integer: %s %llu\n", lastkey, val); return 0; }
void cntr_print(struct cntr *cntr, enum action act) { int x=0; time_t now=time(NULL); border(); logc("Start time: %s\n", getdatestr(cntr->start)); logc(" End time: %s\n", getdatestr(now)); logc("Time taken: %s\n", time_taken(now-cntr->start)); if(act==ACTION_BACKUP || act==ACTION_BACKUP_TIMED) { logc("% 18s % 9s % 9s % 9s % 9s % 9s |% 9s\n", " ", "New", "Changed", "Unchanged", "Deleted", "Total", "Scanned"); } if(act==ACTION_RESTORE || act==ACTION_VERIFY) { logc("% 18s % 9s % 9s |% 9s\n", " ", "", "Attempted", "Expected"); } if(act==ACTION_ESTIMATE) { logc("% 18s % 9s % 9s %9s\n", " ", "", "", "Scanned"); } table_border(act); for(x=0; x<cntr->colen; x++) quint_print(cntr->ent[(uint8_t)cntr->cmd_order[x]], act); table_border(act); bottom_part(cntr, act); border(); }
static char *get_backup_str(const char *s, bool dateonly) { static char str[32]=""; const char *cp=NULL; if(!(cp=strchr(s, ' '))) snprintf(str, sizeof(str), "never"); else { unsigned long backupnum=0; backupnum=strtoul(s, NULL, 10); snprintf(str, sizeof(str), "%07lu %s", backupnum, getdatestr(atol(cp+1))); } return str; }
void cntr_print(struct cntr *cntr, enum action act) { struct cntr_ent *e; time_t now=time(NULL); border(); logc("Start time: %s\n", getdatestr(cntr->start)); logc(" End time: %s\n", getdatestr(now)); logc("Time taken: %s\n", time_taken(now-cntr->start)); if(act==ACTION_BACKUP || act==ACTION_BACKUP_TIMED) { logc("% 18s % 9s % 9s % 9s % 9s % 9s |% 9s\n", " ", "New", "Changed", "Unchanged", "Deleted", "Total", "Scanned"); } if(act==ACTION_RESTORE || act==ACTION_VERIFY) { logc("% 18s % 9s % 9s |% 9s\n", " ", "", "Attempted", "Expected"); } if(act==ACTION_ESTIMATE) { logc("% 18s % 9s % 9s %9s\n", " ", "", "", "Scanned"); } table_border(act); for(e=cntr->list; e; e=e->next) quint_print(e, act); table_border(act); bottom_part(cntr, act); border(); }
static void screen_header(int row, int col) { int l; const char *date=NULL; #ifdef UTEST date="1977-10-02 00:10:20"; #else time_t t=time(NULL); date=getdatestr(t); #endif l=strlen(date); #ifdef HAVE_NCURSES if(actg==ACTION_STATUS) { screen_header_ncurses(date, l, row, col); return; } #endif screen_header_stdout(date, l, row, col); }
static void blank_screen(int row, int col) { int c=0; int l=0; const char *date=NULL; time_t t=time(NULL); date=getdatestr(t); l=strlen(date); #ifdef HAVE_NCURSES_H if(actg==ACTION_STATUS) { char v[32]=""; clear(); snprintf(v, sizeof(v), " burp monitor %s", VERSION); mvprintw(0, 0, v); mvprintw(0, col-l-1, date); return; } #endif printf("\n burp status"); for(c=0; c<(int)(col-strlen(" burp status")-l-1); c++) printf(" "); printf("%s\n\n", date); }
void print_filecounters(struct cntr *p1c, struct cntr *c, enum action act) { time_t now=time(NULL); if(!p1c || !c) return; border(); logc("Start time: %s\n", getdatestr(p1c->start)); logc(" End time: %s\n", getdatestr(now)); logc("Time taken: %s\n", time_taken(now-p1c->start)); if(act==ACTION_BACKUP || act==ACTION_BACKUP_TIMED) { logc("% 18s % 9s % 9s % 9s % 9s % 9s |% 9s\n", " ", "New", "Changed", "Unchanged", "Deleted", "Total", "Scanned"); } if(act==ACTION_RESTORE || act==ACTION_VERIFY) { logc("% 18s % 9s % 9s |% 9s\n", " ", "", "Attempted", "Expected"); } if(act==ACTION_ESTIMATE) { logc("% 18s % 9s % 9s %9s\n", " ", "", "", "Scanned"); } table_border(act); quint_print("Files:", c->file, c->file_changed, c->file_same, c->file_deleted, p1c->file, act); quint_print("Files (encrypted):", c->enc, c->enc_changed, c->enc_same, c->enc_deleted, p1c->enc, act); quint_print("Meta data:", c->meta, c->meta_changed, c->meta_same, c->meta_deleted, p1c->meta, act); quint_print("Meta data (enc):", c->encmeta, c->encmeta_changed, c->encmeta_same, c->encmeta_deleted, p1c->encmeta, act); quint_print("Directories:", c->dir, c->dir_changed, c->dir_same, c->dir_deleted, p1c->dir, act); quint_print("Soft links:", c->slink, c->slink_changed, c->slink_same, c->slink_deleted, p1c->slink, act); quint_print("Hard links:", c->hlink, c->hlink_changed, c->hlink_same, c->hlink_deleted, p1c->hlink, act); quint_print("Special files:", c->special, c->special_changed, c->special_same, c->special_deleted, p1c->special, act); quint_print("EFS files:", c->efs, c->efs_changed, c->efs_same, c->efs_deleted, p1c->efs, act); quint_print("VSS headers:", c->vss, c->vss_changed, c->vss_same, c->vss_deleted, p1c->vss, act); quint_print("VSS headers (enc):", c->encvss, c->encvss_changed, c->encvss_same, c->encvss_deleted, p1c->encvss, act); quint_print("VSS footers:", c->vss_t, c->vss_t_changed, c->vss_t_same, c->vss_t_deleted, p1c->vss_t, act); quint_print("VSS footers (enc):", c->encvss_t, c->encvss_t_changed, c->encvss_t_same, c->encvss_t_deleted, p1c->encvss_t, act); quint_print("Grand total:", c->total, c->total_changed, c->total_same, c->total_deleted, p1c->total, act); table_border(act); bottom_part(p1c, c, act); border(); }
static void detail(char *toks[], int t, struct config *conf, int row, int col) { int x=0; char msg[1024]=""; const char *tmp=NULL; if(toks[0]) { snprintf(msg, sizeof(msg), "Client: %s", toks[0]); print_line(msg, x++, col); } if(toks[1]) { switch(*(toks[1])) { case STATUS_IDLE: { print_line("Status: idle", x++, col); show_all_backups(toks, t, &x, col); return; } case STATUS_SERVER_CRASHED: { print_line("Status: server crashed", x++, col); show_all_backups(toks, t, &x, col); return; } case STATUS_CLIENT_CRASHED: { print_line("Status: client crashed", x++, col); show_all_backups(toks, t, &x, col); return; } case STATUS_RUNNING: { if(toks[2]) { char msg[64]=""; if(t<3) return; snprintf(msg, sizeof(msg), "Status: running (%s)", running_status_to_text( *(toks[2]))); print_line(msg, x++, col); } break; } } } print_line("", x++, col); table_header(&x, col); if(t>4) print_detail("Files", toks[4], &x, col, 0); if(t>5) print_detail("Encrypted files", toks[5], &x, col, 0); if(t>6) print_detail("Meta data", toks[6], &x, col, 0); if(t>7) print_detail("Encrypted meta data", toks[7], &x, col, 0); if(t>8) print_detail("Directories", toks[8], &x, col, 0); if(t>9) print_detail("Soft links", toks[9], &x, col, 0); if(t>10) print_detail("Hard links", toks[10], &x, col, 0); if(t>11) print_detail("Special files", toks[11], &x, col, 0); if(t>12) { print_detail("Total", toks[12], &x, col, 1); } print_line("", x++, col); if(t>14) print_detail2("Warnings", toks[14], "", &x, col); if(t>15) { tmp=bytes_to_human_str(toks[15]); print_detail2("Bytes expected", toks[15], tmp, &x, col); } if(t>16) { tmp=bytes_to_human_str(toks[16]); print_detail2("Bytes in backup", toks[16], tmp, &x, col); } if(t>17) { tmp=bytes_to_human_str(toks[17]); print_detail2("Bytes received", toks[17], tmp, &x, col); } if(t>18) { tmp=bytes_to_human_str(toks[18]); print_detail2("Bytes sent", toks[18], tmp, &x, col); } if(t>19) { long start=0; time_t now=0; time_t diff=0; now=time(NULL); start=atol(toks[19]); diff=now-start; print_detail2("Start time", getdatestr(start), " ", &x, col); print_detail2("Time taken", time_taken(diff), " ", &x, col); if(diff>0) { unsigned long long bytesleft=0; unsigned long long byteswant=0; unsigned long long bytesgot=0; float bytespersec=0; byteswant=strtoull(toks[15], NULL, 10); bytesgot=strtoull(toks[16], NULL, 10); bytespersec=(float)(bytesgot/diff); bytesleft=byteswant-bytesgot; if(bytespersec>0) { time_t timeleft=0; timeleft=(time_t)(bytesleft/bytespersec); print_detail2("Time left", time_taken(timeleft), " ", &x, col); } } } if(t>20 && toks[20]) { #ifdef HAVE_NCURSES_H if(actg==ACTION_STATUS) { printw("\n%s\n", toks[20]); return; } #else printf("\n%s\n", toks[20]); #endif } }
void print_filecounters(struct cntr *p1c, struct cntr *c, enum action act, int client) { time_t now=time(NULL); if(!p1c || !c) return; border(); logc("Start time: %s\n", getdatestr(p1c->start)); logc(" End time: %s\n", getdatestr(now)); logc("Time taken: %s\n", time_taken(now-p1c->start)); logc("% 22s % 9s % 9s % 9s % 9s |% 9s\n", " ", "New", "Changed", "Unchanged", "Total", "Scanned"); table_border(); if(act==ACTION_RESTORE) { restore_print("Files:", c->file); restore_print("Files (encrypted):", c->enc); restore_print("Meta data:", c->meta); restore_print("Meta (encrypted):", c->encmeta); restore_print("Directories:", c->dir); restore_print("Soft links:", c->slink); restore_print("Hard links:", c->hlink); restore_print("Special files:", c->special); restore_print("EFS files:", c->efs); restore_print("Grand total:", c->total); } else if(act==ACTION_VERIFY) { restore_print("Verified files:", c->file); restore_print("Verified files (enc):", c->enc); restore_print("Verified meta data:", c->meta); restore_print("Verified meta (enc):", c->encmeta); restore_print("Verified directories:", c->dir); restore_print("Verified soft links:", c->slink); restore_print("Verified hard links:", c->hlink); restore_print("Verified special:", c->special); restore_print("Verified EFS files:", c->efs); restore_print("Grand total:", c->total); } else { quint_print("Files:", c->file, c->file_changed, c->file_same, p1c->file, client?FORMAT_CLIENT_DATA:FORMAT_SERVER); quint_print("Files (encrypted):", c->enc, c->enc_changed, c->enc_same, p1c->enc, client?FORMAT_CLIENT_DATA:FORMAT_SERVER); quint_print("Meta data:", c->meta, c->meta_changed, c->meta_same, p1c->meta, client?FORMAT_CLIENT_DATA:FORMAT_SERVER); quint_print("Meta data (encrypted):", c->encmeta, c->meta_changed, c->meta_same, p1c->encmeta, client?FORMAT_CLIENT_DATA:FORMAT_SERVER); quint_print("Directories:", c->dir, c->dir_changed, c->dir_same, p1c->dir, client?FORMAT_CLIENT_NODE:FORMAT_SERVER); quint_print("Soft links:", c->slink, c->slink_changed, c->slink_same, p1c->slink, client?FORMAT_CLIENT_NODE:FORMAT_SERVER); quint_print("Hard links:", c->hlink, c->hlink_changed, c->hlink_same, p1c->hlink, client?FORMAT_CLIENT_NODE:FORMAT_SERVER); quint_print("Special files:", c->special, c->special_changed, c->special_same, p1c->special, client?FORMAT_CLIENT_NODE:FORMAT_SERVER); quint_print("EFS files:", c->efs, c->efs_changed, c->efs_same, p1c->efs, client?FORMAT_CLIENT_NODE:FORMAT_SERVER); quint_print("Grand total:", c->total, c->total_changed, c->total_same, p1c->total, client?FORMAT_CLIENT_DATA:FORMAT_SERVER); } table_border(); bottom_part(p1c, c, act); border(); }