Unbreak /stats ? and fix a bug in /stats Z.

This commit is contained in:
Jilles Tjoelker 2008-04-03 23:21:20 +02:00
parent 28d337da4d
commit 70b72a0792

View file

@ -1130,6 +1130,7 @@ stats_ziplinks (struct Client *source_p)
rb_dlink_node *ptr; rb_dlink_node *ptr;
struct Client *target_p; struct Client *target_p;
int sent_data = 0; int sent_data = 0;
char buf[128], buf1[128];
RB_DLINK_FOREACH (ptr, serv_list.head) RB_DLINK_FOREACH (ptr, serv_list.head)
{ {
@ -1143,13 +1144,16 @@ stats_ziplinks (struct Client *source_p)
struct ZipStats zipstats; struct ZipStats zipstats;
memcpy (&zipstats, &target_p->localClient->zipstats, memcpy (&zipstats, &target_p->localClient->zipstats,
sizeof (struct ZipStats)); sizeof (struct ZipStats));
snprintf(buf, sizeof buf, "%.2f%%", zipstats.out_ratio);
snprintf(buf1, sizeof buf1, "%.2f%%", zipstats.in_ratio);
sendto_one_numeric(source_p, RPL_STATSDEBUG, sendto_one_numeric(source_p, RPL_STATSDEBUG,
"Z :ZipLinks stats for %s send[%.2f%% compression " "Z :ZipLinks stats for %s send[%s compression "
"(%lu kB data/%lu kB wire)] recv[%.2f%% compression " "(%lu kB data/%lu kB wire)] recv[%s compression "
"(%lu kB data/%lu kB wire)]", "(%lu kB data/%lu kB wire)]",
target_p->name, target_p->name,
zipstats.out_ratio, zipstats.outK, zipstats.outK_wire, buf, zipstats.outK, zipstats.outK_wire,
zipstats.in_ratio, zipstats.inK, zipstats.inK_wire); buf1, zipstats.inK, zipstats.inK_wire);
sent_data++; sent_data++;
} }
} }
@ -1166,6 +1170,7 @@ stats_servlinks (struct Client *source_p)
struct Client *target_p; struct Client *target_p;
rb_dlink_node *ptr; rb_dlink_node *ptr;
int j = 0; int j = 0;
char buf[128];
if(ConfigServerHide.flatten_links && !IsOper (source_p) && if(ConfigServerHide.flatten_links && !IsOper (source_p) &&
!IsExemptShide(source_p)) !IsExemptShide(source_p))
@ -1202,25 +1207,26 @@ stats_servlinks (struct Client *source_p)
sendto_one_numeric(source_p, RPL_STATSDEBUG, sendto_one_numeric(source_p, RPL_STATSDEBUG,
"? :%u total server(s)", j); "? :%u total server(s)", j);
snprintf(buf, sizeof buf, "%7.2f", _GMKv ((sendK)));
sendto_one_numeric(source_p, RPL_STATSDEBUG, sendto_one_numeric(source_p, RPL_STATSDEBUG,
"? :Sent total : %7.2f %s", "? :Sent total : %s %s",
_GMKv (sendK), _GMKs (sendK)); buf, _GMKs (sendK));
snprintf(buf, sizeof buf, "%7.2f", _GMKv ((receiveK)));
sendto_one_numeric(source_p, RPL_STATSDEBUG, sendto_one_numeric(source_p, RPL_STATSDEBUG,
"? :Recv total : %7.2f %s", "? :Recv total : %s %s",
_GMKv (receiveK), _GMKs (receiveK)); buf, _GMKs (receiveK));
uptime = (rb_current_time() - startup_time); uptime = (rb_current_time() - startup_time);
snprintf(buf, sizeof buf, "%7.2f %s (%4.1f K/s)",
sendto_one_numeric(source_p, RPL_STATSDEBUG,
"? :Server send: %7.2f %s (%4.1f K/s)",
_GMKv (me.localClient->sendK), _GMKv (me.localClient->sendK),
_GMKs (me.localClient->sendK), _GMKs (me.localClient->sendK),
(float) ((float) me.localClient->sendK / (float) uptime)); (float) ((float) me.localClient->sendK / (float) uptime));
sendto_one_numeric(source_p, RPL_STATSDEBUG, sendto_one_numeric(source_p, RPL_STATSDEBUG, "? :Server send: %s", buf);
"? :Server recv: %7.2f %s (%4.1f K/s)", snprintf(buf, sizeof buf, "%7.2f %s (%4.1f K/s)",
_GMKv (me.localClient->receiveK), _GMKv (me.localClient->receiveK),
_GMKs (me.localClient->receiveK), _GMKs (me.localClient->receiveK),
(float) ((float) me.localClient->receiveK / (float) uptime)); (float) ((float) me.localClient->receiveK / (float) uptime));
sendto_one_numeric(source_p, RPL_STATSDEBUG, "? :Server recv: %s", buf);
} }
static void static void