Beispiel #1
0
static void client_summary(struct cstat *cstat,
	int row, int col, int clientwidth)
{
	char msg[1024]="";
	char fmt[64]="";
	struct bu *cbu=NULL;
	snprintf(fmt, sizeof(fmt), "%%-%d.%ds %%9s %%s%%s",
		clientwidth, clientwidth);

	// Find the current backup.
	cbu=bu_find_current(cstat->bu);

	switch(cstat->run_status)
	{
		case RUN_STATUS_RUNNING:
			if(toggle)
			{
				char f[64]="";
				char b[64]="";
				uint64_t p=0;
				uint64_t t=0;
				struct cntr *cntr=cstat->cntr;
				struct cntr_ent *ent_gtotal=
					cntr->ent[(uint8_t)CMD_GRAND_TOTAL];

				t=ent_gtotal->count
					+ent_gtotal->same
					+ent_gtotal->changed;
				if(ent_gtotal->phase1)
					p=(t*100)/ent_gtotal->phase1;
				snprintf(f, sizeof(f),
					" %"PRIu64"/%"PRIu64" %"PRIu64"%%",
					t, ent_gtotal->phase1, p);
				if(cntr->byte)
					snprintf(b, sizeof(b), "%s",
						bytes_to_human(cntr->byte));
				snprintf(msg, sizeof(msg), fmt,
					cstat->name,
					run_status_to_str(cstat),
					f, b);
				break;
			}
			// Else fall through.
		case RUN_STATUS_IDLE:
		case RUN_STATUS_SERVER_CRASHED:
		case RUN_STATUS_CLIENT_CRASHED:
		default:
			snprintf(msg, sizeof(msg), fmt,
				cstat->name,
				run_status_to_str(cstat),
				" last backup: ",
				get_bu_str(cbu));
			break;
	}

	if(*msg) print_line(msg, row, col);
}
Beispiel #2
0
int json_send(struct asfd *asfd, struct cstat *clist, struct cstat *cstat,
	struct bu *bu, const char *logfile, const char *browse,
	int use_cache)
{
	int ret=-1;
	struct cstat *c;

	if(json_start(asfd)
	  || json_clients())
		goto end;

	if(cstat && bu)
	{
		if(json_send_client_backup(asfd, cstat, bu, NULL,
			logfile, browse, use_cache)) goto end;
	}
	else if(cstat)
	{
		if(json_send_client_backup_list(asfd, cstat, use_cache))
			goto end;
	}
	else for(c=clist; c; c=c->next)
	{
		if(!c->permitted) continue;
		if(json_send_client_backup(asfd, c,
			bu_find_current(c->bu),
			bu_find_working_or_finishing(c->bu),
			NULL, NULL, use_cache))
				goto end;
	}

	ret=0;
end:
	if(json_clients_end()
	  || json_end(asfd)) return -1;
	return ret;
}