Esempio n. 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);
}
Esempio n. 2
0
static void client_and_status(struct sel *sel, int *x, int col)
{
	char msg[1024];
	snprintf(msg, sizeof(msg), "Client: %s", sel->client->name);
//		sel->client->cntr->ent[CMD_FILE]->phase1,
//		sel->client->cntr->ent[CMD_FILE]->count);
	print_line(msg, (*x)++, col);
	snprintf(msg, sizeof(msg),
		"Status: %s", run_status_to_str(sel->client));
	print_line(msg, (*x)++, col);
}
Esempio n. 3
0
static int json_send_client_start(struct asfd *asfd, struct cstat *cstat)
{
	const char *run_status=run_status_to_str(cstat);

	if(yajl_map_open_w()
	  || yajl_gen_str_pair_w("name", cstat->name)
	  || yajl_gen_str_pair_w("run_status", run_status))
		return -1;
	if(cstat->run_status==RUN_STATUS_RUNNING)
	{
		if(yajl_gen_str_pair_w("phase",
			cntr_status_to_str(cstat->cntr))) return -1;
	}
	if(yajl_gen_str_w("backups")
	  || yajl_array_open_w())
		return -1;
	return 0;
}