tstats stuff gone to m_stats.c

This commit is contained in:
Valery Yatsko 2008-04-02 16:04:43 +04:00
parent 0328101a9b
commit 8750c6e6b7
4 changed files with 67 additions and 90 deletions

View File

@ -76,9 +76,6 @@ struct ServerStatistics
extern struct ServerStatistics ServerStats;
extern void init_stats(void);
extern void tstats(struct Client *client);
extern void count_memory(struct Client *);
#endif /* INCLUDED_s_stats_h */

View File

@ -924,10 +924,73 @@ stats_usage (struct Client *source_p)
(int) rus.ru_nivcsw);
}
static void
stats_tstats (struct Client *source_p)
{
tstats (source_p);
static void
stats_tstats(struct Client *source_p)
{
struct Client *target_p;
struct ServerStatistics sp;
rb_dlink_node *ptr;
memcpy(&sp, &ServerStats, sizeof(struct ServerStatistics));
RB_DLINK_FOREACH(ptr, serv_list.head)
{
target_p = ptr->data;
sp.is_sbs += target_p->localClient->sendB;
sp.is_sbr += target_p->localClient->receiveB;
sp.is_sti += rb_current_time() - target_p->localClient->firsttime;
sp.is_sv++;
}
RB_DLINK_FOREACH(ptr, lclient_list.head)
{
target_p = ptr->data;
sp.is_cbs += target_p->localClient->sendB;
sp.is_cbr += target_p->localClient->receiveB;
sp.is_cti += rb_current_time() - target_p->localClient->firsttime;
sp.is_cl++;
}
sendto_one_numeric(source_p, RPL_STATSDEBUG,
"T :accepts %u refused %u",
sp.is_ac, sp.is_ref);
sendto_one_numeric(source_p, RPL_STATSDEBUG,
"T :rejected %u delaying %lu",
sp.is_rej, delay_exit_length());
sendto_one_numeric(source_p, RPL_STATSDEBUG,
"T :nicks being delayed %lu", get_nd_count());
sendto_one_numeric(source_p, RPL_STATSDEBUG,
"T :unknown commands %u prefixes %u",
sp.is_unco, sp.is_unpf);
sendto_one_numeric(source_p, RPL_STATSDEBUG,
"T :nick collisions %u saves %u unknown closes %u",
sp.is_kill, sp.is_save, sp.is_ni);
sendto_one_numeric(source_p, RPL_STATSDEBUG,
"T :wrong direction %u empty %u",
sp.is_wrdi, sp.is_empt);
sendto_one_numeric(source_p, RPL_STATSDEBUG,
"T :numerics seen %u",
sp.is_num);
sendto_one_numeric(source_p, RPL_STATSDEBUG,
"T :auth successes %u fails %u",
sp.is_asuc, sp.is_abad);
sendto_one_numeric(source_p, RPL_STATSDEBUG, "T :Client Server");
sendto_one_numeric(source_p, RPL_STATSDEBUG,
"T :connected %u %u",
sp.is_cl, sp.is_sv);
sendto_one_numeric(source_p, RPL_STATSDEBUG,
"T :bytes sent %lluK %lluK",
sp.is_cbs / 1024,
sp.is_sbs / 1024);
sendto_one_numeric(source_p, RPL_STATSDEBUG,
"T :bytes recv %lluK %lluK",
sp.is_cbr / 1024,
sp.is_sbr / 1024);
sendto_one_numeric(source_p, RPL_STATSDEBUG,
"T :time connected %lu %lu",
sp.is_cti, sp.is_sti);
}
static void

View File

@ -578,7 +578,6 @@ main(int argc, char *argv[])
init_channels();
initclass();
initwhowas();
init_stats();
init_reject();
init_cache();
init_monitor();

View File

@ -43,88 +43,6 @@
*/
struct ServerStatistics ServerStats;
void
init_stats()
{
/* XXX nothing to do - was ServerStats init -- dwr */
}
/*
* tstats
*
* inputs - client to report to
* output - NONE
* side effects -
*/
void
tstats(struct Client *source_p)
{
struct Client *target_p;
struct ServerStatistics sp;
rb_dlink_node *ptr;
memcpy(&sp, &ServerStats, sizeof(struct ServerStatistics));
RB_DLINK_FOREACH(ptr, serv_list.head)
{
target_p = ptr->data;
sp.is_sbs += target_p->localClient->sendB;
sp.is_sbr += target_p->localClient->receiveB;
sp.is_sti += rb_current_time() - target_p->localClient->firsttime;
sp.is_sv++;
}
RB_DLINK_FOREACH(ptr, lclient_list.head)
{
target_p = ptr->data;
sp.is_cbs += target_p->localClient->sendB;
sp.is_cbr += target_p->localClient->receiveB;
sp.is_cti += rb_current_time() - target_p->localClient->firsttime;
sp.is_cl++;
}
sendto_one_numeric(source_p, RPL_STATSDEBUG,
"T :accepts %u refused %u",
sp.is_ac, sp.is_ref);
sendto_one_numeric(source_p, RPL_STATSDEBUG,
"T :rejected %u delaying %lu",
sp.is_rej, delay_exit_length());
sendto_one_numeric(source_p, RPL_STATSDEBUG,
"T :nicks being delayed %lu", get_nd_count());
sendto_one_numeric(source_p, RPL_STATSDEBUG,
"T :unknown commands %u prefixes %u",
sp.is_unco, sp.is_unpf);
sendto_one_numeric(source_p, RPL_STATSDEBUG,
"T :nick collisions %u saves %u unknown closes %u",
sp.is_kill, sp.is_save, sp.is_ni);
sendto_one_numeric(source_p, RPL_STATSDEBUG,
"T :wrong direction %u empty %u",
sp.is_wrdi, sp.is_empt);
sendto_one_numeric(source_p, RPL_STATSDEBUG,
"T :numerics seen %u",
sp.is_num);
sendto_one_numeric(source_p, RPL_STATSDEBUG,
"T :auth successes %u fails %u",
sp.is_asuc, sp.is_abad);
sendto_one_numeric(source_p, RPL_STATSDEBUG, "T :Client Server");
sendto_one_numeric(source_p, RPL_STATSDEBUG,
"T :connected %u %u",
sp.is_cl, sp.is_sv);
sendto_one_numeric(source_p, RPL_STATSDEBUG,
"T :bytes sent %lluK %lluK",
sp.is_cbs / 1024,
sp.is_sbs / 1024);
sendto_one_numeric(source_p, RPL_STATSDEBUG,
"T :bytes recv %lluK %lluK",
sp.is_cbr / 1024,
sp.is_sbr / 1024);
sendto_one_numeric(source_p, RPL_STATSDEBUG,
"T :time connected %lu %lu",
sp.is_cti, sp.is_sti);
}
void
count_memory(struct Client *source_p)
{