Browse Source

Show tracker counts in btcli stat.

The counts are for "reachable" trackers, ie. trackers that haven't
timed out or been disabled for one reason or other.
master
Richard Nyberg 16 years ago
parent
commit
a32c7814cc
3 changed files with 10 additions and 7 deletions
  1. +4
    -0
      btpd/cli_if.c
  2. +5
    -7
      cli/stat.c
  3. +1
    -0
      misc/ipcdefs.h

+ 4
- 0
btpd/cli_if.c View File

@@ -153,6 +153,10 @@ write_ans(struct iobuf *iob, struct tlib *tl, enum ipc_tval val)
case IPC_TVAL_TRERR: case IPC_TVAL_TRERR:
iobuf_print(iob, "i%dei%ue", IPC_TYPE_NUM, 0); iobuf_print(iob, "i%dei%ue", IPC_TYPE_NUM, 0);
return; return;
case IPC_TVAL_TRGOOD:
iobuf_print(iob, "i%dei%de", IPC_TYPE_NUM,
tl->tp == NULL ? 0 : tr_good_count(tl->tp));
return;
case IPC_TVALCOUNT: case IPC_TVALCOUNT:
break; break;
} }


+ 5
- 7
cli/stat.c View File

@@ -28,7 +28,7 @@ usage_stat(void)
struct btstat { struct btstat {
unsigned num; unsigned num;
enum ipc_tstate state; enum ipc_tstate state;
unsigned peers, tr_errors;
unsigned peers, tr_good;
long long content_got, content_size, downloaded, uploaded, rate_up, long long content_got, content_size, downloaded, uploaded, rate_up,
rate_down, tot_up; rate_down, tot_up;
uint32_t pieces_seen, torrent_pieces; uint32_t pieces_seen, torrent_pieces;
@@ -44,7 +44,7 @@ static enum ipc_tval stkeys[] = {
IPC_TVAL_NUM, IPC_TVAL_NUM,
IPC_TVAL_NAME, IPC_TVAL_NAME,
IPC_TVAL_PCOUNT, IPC_TVAL_PCOUNT,
IPC_TVAL_TRERR,
IPC_TVAL_TRGOOD,
IPC_TVAL_PCCOUNT, IPC_TVAL_PCCOUNT,
IPC_TVAL_PCSEEN, IPC_TVAL_PCSEEN,
IPC_TVAL_SESSUP, IPC_TVAL_SESSUP,
@@ -69,8 +69,7 @@ print_stat(struct btstat *st)
print_ratio(st->tot_up, st->content_size); print_ratio(st->tot_up, st->content_size);
printf("%4u ", st->peers); printf("%4u ", st->peers);
print_percent(st->pieces_seen, st->torrent_pieces); print_percent(st->pieces_seen, st->torrent_pieces);
if (st->tr_errors > 0)
printf("E%u", st->tr_errors);
printf("%3u", st->tr_good);
printf("\n"); printf("\n");
} }


@@ -94,8 +93,7 @@ stat_cb(int obji, enum ipc_err objerr, struct ipc_get_res *res, void *arg)
tot->rate_up += (st.rate_up = res[IPC_TVAL_RATEUP].v.num); tot->rate_up += (st.rate_up = res[IPC_TVAL_RATEUP].v.num);
tot->peers += (st.peers = res[IPC_TVAL_PCOUNT].v.num); tot->peers += (st.peers = res[IPC_TVAL_PCOUNT].v.num);
tot->tot_up += (st.tot_up = res[IPC_TVAL_TOTUP].v.num); tot->tot_up += (st.tot_up = res[IPC_TVAL_TOTUP].v.num);
if ((st.tr_errors = res[IPC_TVAL_TRERR].v.num) > 0)
tot->tr_errors++;
tot->tr_good += (st.tr_good = res[IPC_TVAL_TRGOOD].v.num);
if (cba->individual) { if (cba->individual) {
if (cba->names) if (cba->names)
printf("%.*s\n", (int)res[IPC_TVAL_NAME].v.str.l, printf("%.*s\n", (int)res[IPC_TVAL_NAME].v.str.l,
@@ -125,7 +123,7 @@ again:
} else } else
header = 20; header = 20;
printf(" HAVE DLOAD RTDWN ULOAD RTUP RATIO CONN" printf(" HAVE DLOAD RTDWN ULOAD RTUP RATIO CONN"
" AVAIL\n");
" AVAIL TR\n");
} }


bzero(&cba.tot, sizeof(cba.tot)); bzero(&cba.tot, sizeof(cba.tot));


+ 1
- 0
misc/ipcdefs.h View File

@@ -41,6 +41,7 @@ TVDEF(STATE, TSTATE, "state")
TVDEF(TOTDWN, NUM, "total_down") TVDEF(TOTDWN, NUM, "total_down")
TVDEF(TOTUP, NUM, "total_up") TVDEF(TOTUP, NUM, "total_up")
TVDEF(TRERR, NUM, "tr_errors") TVDEF(TRERR, NUM, "tr_errors")
TVDEF(TRGOOD, NUM, "tr_good")
#ifdef __IPCTV #ifdef __IPCTV
#undef __IPCTV #undef __IPCTV
#undef TVDEF #undef TVDEF


Loading…
Cancel
Save