s_stats.c removed, now we use new style of stats handling.
This commit is contained in:
parent
93f767eb28
commit
8325120565
|
@ -27,8 +27,6 @@
|
|||
#ifndef INCLUDED_s_stats_h
|
||||
#define INCLUDED_s_stats_h
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#define _1MEG (1024.0)
|
||||
#define _1GIG (1024.0*1024.0)
|
||||
#define _1TER (1024.0*1024.0*1024.0)
|
||||
|
@ -74,11 +72,6 @@ struct ServerStatistics
|
|||
unsigned int is_tgch; /* messages blocked due to target change */
|
||||
};
|
||||
|
||||
extern struct ServerStatistics *ServerStats;
|
||||
|
||||
extern void init_stats(void);
|
||||
extern void tstats(struct Client *client);
|
||||
|
||||
extern void count_memory(struct Client *);
|
||||
extern struct ServerStatistics ServerStats;
|
||||
|
||||
#endif /* INCLUDED_s_stats_h */
|
||||
|
|
|
@ -612,7 +612,7 @@ add_target(struct Client *source_p, struct Client *target_p)
|
|||
/* cant clear any, full target list */
|
||||
else if(USED_TARGETS(source_p) == 10)
|
||||
{
|
||||
ServerStats->is_tgch++;
|
||||
ServerStats.is_tgch++;
|
||||
add_tgchange(source_p->sockhost);
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -281,7 +281,7 @@ mc_nick(struct Client *client_p, struct Client *source_p, int parc, const char *
|
|||
/* if nicks erroneous, or too long, kill */
|
||||
if(!clean_nick(parv[1], 0))
|
||||
{
|
||||
ServerStats->is_kill++;
|
||||
ServerStats.is_kill++;
|
||||
sendto_realops_snomask(SNO_DEBUG, L_ALL,
|
||||
"Bad Nick: %s From: %s(via %s)",
|
||||
parv[1], source_p->servptr->name, client_p->name);
|
||||
|
@ -343,7 +343,7 @@ ms_nick(struct Client *client_p, struct Client *source_p, int parc, const char *
|
|||
/* if nicks empty, erroneous, or too long, kill */
|
||||
if(!clean_nick(parv[1], 0))
|
||||
{
|
||||
ServerStats->is_kill++;
|
||||
ServerStats.is_kill++;
|
||||
sendto_realops_snomask(SNO_DEBUG, L_ALL,
|
||||
"Bad Nick: %s From: %s(via %s)",
|
||||
parv[1], parv[7], client_p->name);
|
||||
|
@ -354,7 +354,7 @@ ms_nick(struct Client *client_p, struct Client *source_p, int parc, const char *
|
|||
/* invalid username or host? */
|
||||
if(!clean_username(parv[5]) || !clean_host(parv[6]))
|
||||
{
|
||||
ServerStats->is_kill++;
|
||||
ServerStats.is_kill++;
|
||||
sendto_realops_snomask(SNO_DEBUG, L_ALL,
|
||||
"Bad user@host: %s@%s From: %s(via %s)",
|
||||
parv[5], parv[6], parv[7], client_p->name);
|
||||
|
@ -435,7 +435,7 @@ ms_uid(struct Client *client_p, struct Client *source_p, int parc, const char *p
|
|||
/* if nicks erroneous, or too long, kill */
|
||||
if(!clean_nick(parv[1], 0))
|
||||
{
|
||||
ServerStats->is_kill++;
|
||||
ServerStats.is_kill++;
|
||||
sendto_realops_snomask(SNO_DEBUG, L_ALL,
|
||||
"Bad Nick: %s From: %s(via %s)",
|
||||
parv[1], source_p->name, client_p->name);
|
||||
|
@ -445,7 +445,7 @@ ms_uid(struct Client *client_p, struct Client *source_p, int parc, const char *p
|
|||
|
||||
if(!clean_username(parv[5]) || !clean_host(parv[6]))
|
||||
{
|
||||
ServerStats->is_kill++;
|
||||
ServerStats.is_kill++;
|
||||
sendto_realops_snomask(SNO_DEBUG, L_ALL,
|
||||
"Bad user@host: %s@%s From: %s(via %s)",
|
||||
parv[5], parv[6], source_p->name, client_p->name);
|
||||
|
@ -455,7 +455,7 @@ ms_uid(struct Client *client_p, struct Client *source_p, int parc, const char *p
|
|||
|
||||
if(!clean_uid(parv[8]))
|
||||
{
|
||||
ServerStats->is_kill++;
|
||||
ServerStats.is_kill++;
|
||||
sendto_realops_snomask(SNO_DEBUG, L_ALL,
|
||||
"Bad UID: %s From: %s(via %s)",
|
||||
parv[8], source_p->name, client_p->name);
|
||||
|
@ -527,7 +527,7 @@ ms_euid(struct Client *client_p, struct Client *source_p, int parc, const char *
|
|||
/* if nicks erroneous, or too long, kill */
|
||||
if(!clean_nick(parv[1], 0))
|
||||
{
|
||||
ServerStats->is_kill++;
|
||||
ServerStats.is_kill++;
|
||||
sendto_realops_snomask(SNO_DEBUG, L_ALL,
|
||||
"Bad Nick: %s From: %s(via %s)",
|
||||
parv[1], source_p->name, client_p->name);
|
||||
|
@ -537,7 +537,7 @@ ms_euid(struct Client *client_p, struct Client *source_p, int parc, const char *
|
|||
|
||||
if(!clean_username(parv[5]) || !clean_host(parv[6]))
|
||||
{
|
||||
ServerStats->is_kill++;
|
||||
ServerStats.is_kill++;
|
||||
sendto_realops_snomask(SNO_DEBUG, L_ALL,
|
||||
"Bad user@host: %s@%s From: %s(via %s)",
|
||||
parv[5], parv[6], source_p->name, client_p->name);
|
||||
|
@ -547,7 +547,7 @@ ms_euid(struct Client *client_p, struct Client *source_p, int parc, const char *
|
|||
|
||||
if(!clean_uid(parv[8]))
|
||||
{
|
||||
ServerStats->is_kill++;
|
||||
ServerStats.is_kill++;
|
||||
sendto_realops_snomask(SNO_DEBUG, L_ALL,
|
||||
"Bad UID: %s From: %s(via %s)",
|
||||
parv[8], source_p->name, client_p->name);
|
||||
|
@ -557,7 +557,7 @@ ms_euid(struct Client *client_p, struct Client *source_p, int parc, const char *
|
|||
|
||||
if(strcmp(parv[9], "*") && !clean_host(parv[9]))
|
||||
{
|
||||
ServerStats->is_kill++;
|
||||
ServerStats.is_kill++;
|
||||
sendto_realops_snomask(SNO_DEBUG, L_ALL,
|
||||
"Bad realhost: %s From: %s(via %s)",
|
||||
parv[9], source_p->name, client_p->name);
|
||||
|
@ -930,7 +930,7 @@ perform_nick_collides(struct Client *source_p, struct Client *client_p,
|
|||
if (use_save)
|
||||
{
|
||||
save_user(&me, &me, target_p);
|
||||
ServerStats->is_save++;
|
||||
ServerStats.is_save++;
|
||||
sendto_one(client_p, ":%s SAVE %s %ld", me.id,
|
||||
uid, (long)newts);
|
||||
register_client(client_p, source_p,
|
||||
|
@ -950,7 +950,7 @@ perform_nick_collides(struct Client *source_p, struct Client *client_p,
|
|||
|
||||
/* we then need to KILL the old client everywhere */
|
||||
kill_client_serv_butone(NULL, target_p, "%s (Nick collision (new))", me.name);
|
||||
ServerStats->is_kill++;
|
||||
ServerStats.is_kill++;
|
||||
|
||||
target_p->flags |= FLAGS_KILLED;
|
||||
exit_client(client_p, target_p, &me, "Nick collision (new)");
|
||||
|
@ -998,12 +998,12 @@ perform_nick_collides(struct Client *source_p, struct Client *client_p,
|
|||
|
||||
if (use_save)
|
||||
{
|
||||
ServerStats->is_save++;
|
||||
ServerStats.is_save++;
|
||||
save_user(&me, &me, target_p);
|
||||
}
|
||||
else
|
||||
{
|
||||
ServerStats->is_kill++;
|
||||
ServerStats.is_kill++;
|
||||
sendto_one_numeric(target_p, ERR_NICKCOLLISION,
|
||||
form_str(ERR_NICKCOLLISION), target_p->name);
|
||||
|
||||
|
@ -1047,7 +1047,7 @@ perform_nickchange_collides(struct Client *source_p, struct Client *client_p,
|
|||
|
||||
if (use_save)
|
||||
{
|
||||
ServerStats->is_save += 2;
|
||||
ServerStats.is_save += 2;
|
||||
save_user(&me, &me, target_p);
|
||||
sendto_one(client_p, ":%s SAVE %s %ld", me.id,
|
||||
source_p->id, (long)newts);
|
||||
|
@ -1057,13 +1057,13 @@ perform_nickchange_collides(struct Client *source_p, struct Client *client_p,
|
|||
}
|
||||
else
|
||||
{
|
||||
ServerStats->is_kill++;
|
||||
ServerStats.is_kill++;
|
||||
sendto_one_numeric(target_p, ERR_NICKCOLLISION,
|
||||
form_str(ERR_NICKCOLLISION), target_p->name);
|
||||
|
||||
kill_client_serv_butone(NULL, source_p, "%s (Nick change collision)", me.name);
|
||||
|
||||
ServerStats->is_kill++;
|
||||
ServerStats.is_kill++;
|
||||
|
||||
kill_client_serv_butone(NULL, target_p, "%s (Nick change collision)", me.name);
|
||||
|
||||
|
@ -1095,7 +1095,7 @@ perform_nickchange_collides(struct Client *source_p, struct Client *client_p,
|
|||
|
||||
if (use_save)
|
||||
{
|
||||
ServerStats->is_save++;
|
||||
ServerStats.is_save++;
|
||||
/* can't broadcast a SAVE because the
|
||||
* nickchange has happened at client_p
|
||||
* but not in other directions -- jilles */
|
||||
|
@ -1107,7 +1107,7 @@ perform_nickchange_collides(struct Client *source_p, struct Client *client_p,
|
|||
}
|
||||
else
|
||||
{
|
||||
ServerStats->is_kill++;
|
||||
ServerStats.is_kill++;
|
||||
|
||||
sendto_one_numeric(target_p, ERR_NICKCOLLISION,
|
||||
form_str(ERR_NICKCOLLISION), target_p->name);
|
||||
|
@ -1140,7 +1140,7 @@ perform_nickchange_collides(struct Client *source_p, struct Client *client_p,
|
|||
|
||||
if (use_save)
|
||||
{
|
||||
ServerStats->is_save++;
|
||||
ServerStats.is_save++;
|
||||
save_user(&me, &me, target_p);
|
||||
}
|
||||
else
|
||||
|
@ -1151,7 +1151,7 @@ perform_nickchange_collides(struct Client *source_p, struct Client *client_p,
|
|||
/* kill the client who existed before hand */
|
||||
kill_client_serv_butone(client_p, target_p, "%s (Nick collision)", me.name);
|
||||
|
||||
ServerStats->is_kill++;
|
||||
ServerStats.is_kill++;
|
||||
|
||||
target_p->flags |= FLAGS_KILLED;
|
||||
(void) exit_client(client_p, target_p, &me, "Nick collision");
|
||||
|
@ -1339,7 +1339,7 @@ save_user(struct Client *client_p, struct Client *source_p,
|
|||
"Killed %s!%s@%s for nick collision detected by %s (%s does not support SAVE)",
|
||||
target_p->name, target_p->username, target_p->host, source_p->name, target_p->from->name);
|
||||
kill_client_serv_butone(NULL, target_p, "%s (Nick collision (no SAVE support))", me.name);
|
||||
ServerStats->is_kill++;
|
||||
ServerStats.is_kill++;
|
||||
|
||||
target_p->flags |= FLAGS_KILLED;
|
||||
(void) exit_client(NULL, target_p, &me, "Nick collision (no SAVE support)");
|
||||
|
|
|
@ -161,7 +161,7 @@ me_sasl(struct Client *client_p, struct Client *source_p,
|
|||
else if(*parv[4] == 'S') {
|
||||
sendto_one(target_p, form_str(RPL_SASLSUCCESS), me.name, EmptyString(target_p->name) ? "*" : target_p->name);
|
||||
target_p->preClient->sasl_complete = 1;
|
||||
ServerStats->is_ssuc++;
|
||||
ServerStats.is_ssuc++;
|
||||
}
|
||||
*target_p->preClient->sasl_agent = '\0'; /* Blank the stored agent so someone else can answer */
|
||||
}
|
||||
|
@ -179,7 +179,7 @@ abort_sasl(struct Client *data)
|
|||
return;
|
||||
|
||||
data->preClient->sasl_out = data->preClient->sasl_complete = 0;
|
||||
ServerStats->is_sbad++;
|
||||
ServerStats.is_sbad++;
|
||||
|
||||
if(!IsClosing(data))
|
||||
sendto_one(data, form_str(ERR_SASLABORTED), me.name, EmptyString(data->name) ? "*" : data->name);
|
||||
|
|
|
@ -276,7 +276,7 @@ ms_signon(struct Client *client_p, struct Client *source_p,
|
|||
|
||||
if(!clean_nick(parv[1]))
|
||||
{
|
||||
ServerStats->is_kill++;
|
||||
ServerStats.is_kill++;
|
||||
sendto_realops_snomask(SNO_DEBUG, L_ALL,
|
||||
"Bad Nick from SIGNON: %s From: %s(via %s)",
|
||||
parv[1], source_p->servptr->name, client_p->name);
|
||||
|
@ -294,7 +294,7 @@ ms_signon(struct Client *client_p, struct Client *source_p,
|
|||
|
||||
if(!clean_username(parv[2]) || !clean_host(parv[3]))
|
||||
{
|
||||
ServerStats->is_kill++;
|
||||
ServerStats.is_kill++;
|
||||
sendto_realops_snomask(SNO_DEBUG, L_ALL,
|
||||
"Bad user@host from SIGNON: %s@%s From: %s(via %s)",
|
||||
parv[2], parv[3], source_p->servptr->name, client_p->name);
|
||||
|
@ -338,13 +338,13 @@ ms_signon(struct Client *client_p, struct Client *source_p,
|
|||
source_p->name, target_p->name, target_p->from->name,
|
||||
client_p->name);
|
||||
|
||||
ServerStats->is_kill++;
|
||||
ServerStats.is_kill++;
|
||||
sendto_one_numeric(target_p, ERR_NICKCOLLISION,
|
||||
form_str(ERR_NICKCOLLISION), target_p->name);
|
||||
|
||||
kill_client_serv_butone(NULL, source_p, "%s (Nick change collision)", me.name);
|
||||
|
||||
ServerStats->is_kill++;
|
||||
ServerStats.is_kill++;
|
||||
|
||||
kill_client_serv_butone(NULL, target_p, "%s (Nick change collision)", me.name);
|
||||
|
||||
|
@ -373,7 +373,7 @@ ms_signon(struct Client *client_p, struct Client *source_p,
|
|||
source_p->name, target_p->name,
|
||||
target_p->from->name, client_p->name);
|
||||
|
||||
ServerStats->is_kill++;
|
||||
ServerStats.is_kill++;
|
||||
|
||||
sendto_one_numeric(target_p, ERR_NICKCOLLISION,
|
||||
form_str(ERR_NICKCOLLISION), target_p->name);
|
||||
|
@ -410,7 +410,7 @@ ms_signon(struct Client *client_p, struct Client *source_p,
|
|||
kill_client_serv_butone(client_p, target_p,
|
||||
"%s (Nick collision)", me.name);
|
||||
|
||||
ServerStats->is_kill++;
|
||||
ServerStats.is_kill++;
|
||||
|
||||
target_p->flags |= FLAGS_KILLED;
|
||||
(void) exit_client(client_p, target_p, &me, "Nick collision");
|
||||
|
|
|
@ -39,7 +39,7 @@
|
|||
#include "send.h" /* sendto_one */
|
||||
#include "s_conf.h" /* ConfItem */
|
||||
#include "s_serv.h" /* hunt_server */
|
||||
#include "s_stats.h" /* tstats */
|
||||
#include "s_stats.h"
|
||||
#include "s_user.h" /* show_opers */
|
||||
#include "blacklist.h" /* dnsbl stuff */
|
||||
#include "parse.h"
|
||||
|
@ -47,6 +47,8 @@
|
|||
#include "hook.h"
|
||||
#include "s_newconf.h"
|
||||
#include "hash.h"
|
||||
#include "reject.h"
|
||||
#include "whowas.h"
|
||||
|
||||
static int m_stats (struct Client *, struct Client *, int, const char **);
|
||||
|
||||
|
@ -926,7 +928,104 @@ stats_usage (struct Client *source_p)
|
|||
static void
|
||||
stats_tstats (struct Client *source_p)
|
||||
{
|
||||
tstats (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_sks += target_p->localClient->sendK;
|
||||
sp.is_skr += target_p->localClient->receiveK;
|
||||
sp.is_sti += rb_current_time() - target_p->localClient->firsttime;
|
||||
sp.is_sv++;
|
||||
if(sp.is_sbs > 1023)
|
||||
{
|
||||
sp.is_sks += (sp.is_sbs >> 10);
|
||||
sp.is_sbs &= 0x3ff;
|
||||
}
|
||||
if(sp.is_sbr > 1023)
|
||||
{
|
||||
sp.is_skr += (sp.is_sbr >> 10);
|
||||
sp.is_sbr &= 0x3ff;
|
||||
}
|
||||
}
|
||||
|
||||
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_cks += target_p->localClient->sendK;
|
||||
sp.is_ckr += target_p->localClient->receiveK;
|
||||
sp.is_cti += rb_current_time() - target_p->localClient->firsttime;
|
||||
sp.is_cl++;
|
||||
if(sp.is_cbs > 1023)
|
||||
{
|
||||
sp.is_cks += (sp.is_cbs >> 10);
|
||||
sp.is_cbs &= 0x3ff;
|
||||
}
|
||||
if(sp.is_cbr > 1023)
|
||||
{
|
||||
sp.is_ckr += (sp.is_cbr >> 10);
|
||||
sp.is_cbr &= 0x3ff;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
RB_DLINK_FOREACH(ptr, unknown_list.head)
|
||||
{
|
||||
sp.is_ni++;
|
||||
}
|
||||
|
||||
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, rb_dlink_list_length(&delay_exit));
|
||||
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 :tgchange blocked msgs %u restricted addrs %lu",
|
||||
sp.is_tgch, rb_dlink_list_length(&tgchange_list));
|
||||
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 :sasl successes %u fails %u",
|
||||
sp.is_ssuc, sp.is_sbad);
|
||||
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 %d.%uK %d.%uK",
|
||||
(int) sp.is_cks, sp.is_cbs,
|
||||
(int) sp.is_sks, sp.is_sbs);
|
||||
sendto_one_numeric(source_p, RPL_STATSDEBUG,
|
||||
"T :bytes recv %d.%uK %d.%uK",
|
||||
(int) sp.is_ckr, sp.is_cbr,
|
||||
(int) sp.is_skr, sp.is_sbr);
|
||||
sendto_one_numeric(source_p, RPL_STATSDEBUG,
|
||||
"T :time connected %d %d",
|
||||
(int) sp.is_cti, (int) sp.is_sti);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -1121,7 +1220,224 @@ stats_class(struct Client *source_p)
|
|||
static void
|
||||
stats_memory (struct Client *source_p)
|
||||
{
|
||||
count_memory (source_p);
|
||||
struct Client *target_p;
|
||||
struct Channel *chptr;
|
||||
struct Ban *actualBan;
|
||||
rb_dlink_node *rb_dlink;
|
||||
rb_dlink_node *ptr;
|
||||
int channel_count = 0;
|
||||
int local_client_conf_count = 0; /* local client conf links */
|
||||
int users_counted = 0; /* user structs */
|
||||
|
||||
int channel_users = 0;
|
||||
int channel_invites = 0;
|
||||
int channel_bans = 0;
|
||||
int channel_except = 0;
|
||||
int channel_invex = 0;
|
||||
int channel_quiets = 0;
|
||||
|
||||
int class_count = 0; /* classes */
|
||||
int conf_count = 0; /* conf lines */
|
||||
int users_invited_count = 0; /* users invited */
|
||||
int user_channels = 0; /* users in channels */
|
||||
int aways_counted = 0;
|
||||
size_t number_servers_cached; /* number of servers cached by scache */
|
||||
|
||||
size_t channel_memory = 0;
|
||||
size_t channel_ban_memory = 0;
|
||||
size_t channel_except_memory = 0;
|
||||
size_t channel_invex_memory = 0;
|
||||
size_t channel_quiet_memory = 0;
|
||||
|
||||
size_t away_memory = 0; /* memory used by aways */
|
||||
size_t ww = 0; /* whowas array count */
|
||||
size_t wwm = 0; /* whowas array memory used */
|
||||
size_t conf_memory = 0; /* memory used by conf lines */
|
||||
size_t mem_servers_cached; /* memory used by scache */
|
||||
|
||||
size_t linebuf_count = 0;
|
||||
size_t linebuf_memory_used = 0;
|
||||
|
||||
size_t total_channel_memory = 0;
|
||||
size_t totww = 0;
|
||||
|
||||
size_t local_client_count = 0;
|
||||
size_t local_client_memory_used = 0;
|
||||
|
||||
size_t remote_client_count = 0;
|
||||
size_t remote_client_memory_used = 0;
|
||||
|
||||
size_t total_memory = 0;
|
||||
|
||||
count_whowas_memory(&ww, &wwm);
|
||||
|
||||
RB_DLINK_FOREACH(ptr, global_client_list.head)
|
||||
{
|
||||
target_p = ptr->data;
|
||||
if(MyConnect(target_p))
|
||||
{
|
||||
local_client_conf_count++;
|
||||
}
|
||||
|
||||
if(target_p->user)
|
||||
{
|
||||
users_counted++;
|
||||
users_invited_count += rb_dlink_list_length(&target_p->user->invited);
|
||||
user_channels += rb_dlink_list_length(&target_p->user->channel);
|
||||
if(target_p->user->away)
|
||||
{
|
||||
aways_counted++;
|
||||
away_memory += (strlen(target_p->user->away) + 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Count up all channels, ban lists, except lists, Invex lists */
|
||||
RB_DLINK_FOREACH(ptr, global_channel_list.head)
|
||||
{
|
||||
chptr = ptr->data;
|
||||
channel_count++;
|
||||
channel_memory += (strlen(chptr->chname) + sizeof(struct Channel));
|
||||
|
||||
channel_users += rb_dlink_list_length(&chptr->members);
|
||||
channel_invites += rb_dlink_list_length(&chptr->invites);
|
||||
|
||||
RB_DLINK_FOREACH(rb_dlink, chptr->banlist.head)
|
||||
{
|
||||
actualBan = rb_dlink->data;
|
||||
channel_bans++;
|
||||
|
||||
channel_ban_memory += sizeof(rb_dlink_node) + sizeof(struct Ban);
|
||||
}
|
||||
|
||||
RB_DLINK_FOREACH(rb_dlink, chptr->exceptlist.head)
|
||||
{
|
||||
actualBan = rb_dlink->data;
|
||||
channel_except++;
|
||||
|
||||
channel_except_memory += (sizeof(rb_dlink_node) + sizeof(struct Ban));
|
||||
}
|
||||
|
||||
RB_DLINK_FOREACH(rb_dlink, chptr->invexlist.head)
|
||||
{
|
||||
actualBan = rb_dlink->data;
|
||||
channel_invex++;
|
||||
|
||||
channel_invex_memory += (sizeof(rb_dlink_node) + sizeof(struct Ban));
|
||||
}
|
||||
|
||||
RB_DLINK_FOREACH(rb_dlink, chptr->quietlist.head)
|
||||
{
|
||||
actualBan = rb_dlink->data;
|
||||
channel_quiets++;
|
||||
|
||||
channel_quiet_memory += (sizeof(rb_dlink_node) + sizeof(struct Ban));
|
||||
}
|
||||
}
|
||||
|
||||
/* count up all classes */
|
||||
|
||||
class_count = rb_dlink_list_length(&class_list) + 1;
|
||||
|
||||
rb_count_rb_linebuf_memory(&linebuf_count, &linebuf_memory_used);
|
||||
|
||||
sendto_one_numeric(source_p, RPL_STATSDEBUG,
|
||||
"z :Users %u(%lu) Invites %u(%lu)",
|
||||
users_counted,
|
||||
(unsigned long) users_counted * sizeof(struct User),
|
||||
users_invited_count,
|
||||
(unsigned long) users_invited_count * sizeof(rb_dlink_node));
|
||||
|
||||
sendto_one_numeric(source_p, RPL_STATSDEBUG,
|
||||
"z :User channels %u(%lu) Aways %u(%d)",
|
||||
user_channels,
|
||||
(unsigned long) user_channels * sizeof(rb_dlink_node),
|
||||
aways_counted, (int) away_memory);
|
||||
|
||||
sendto_one_numeric(source_p, RPL_STATSDEBUG,
|
||||
"z :Attached confs %u(%lu)",
|
||||
local_client_conf_count,
|
||||
(unsigned long) local_client_conf_count * sizeof(rb_dlink_node));
|
||||
|
||||
sendto_one_numeric(source_p, RPL_STATSDEBUG,
|
||||
"z :Conflines %u(%d)", conf_count, (int) conf_memory);
|
||||
|
||||
sendto_one_numeric(source_p, RPL_STATSDEBUG,
|
||||
"z :Classes %u(%lu)",
|
||||
class_count,
|
||||
(unsigned long) class_count * sizeof(struct Class));
|
||||
|
||||
sendto_one_numeric(source_p, RPL_STATSDEBUG,
|
||||
"z :Channels %u(%d)",
|
||||
channel_count, (int) channel_memory);
|
||||
|
||||
sendto_one_numeric(source_p, RPL_STATSDEBUG,
|
||||
"z :Bans %u(%d) Exceptions %u(%d) Invex %u(%d) Quiets %u(%d)",
|
||||
channel_bans, (int) channel_ban_memory,
|
||||
channel_except, (int) channel_except_memory,
|
||||
channel_invex, (int) channel_invex_memory,
|
||||
channel_quiets, (int) channel_quiet_memory);
|
||||
|
||||
sendto_one_numeric(source_p, RPL_STATSDEBUG,
|
||||
"z :Channel members %u(%lu) invite %u(%lu)",
|
||||
channel_users,
|
||||
(unsigned long) channel_users * sizeof(rb_dlink_node),
|
||||
channel_invites,
|
||||
(unsigned long) channel_invites * sizeof(rb_dlink_node));
|
||||
|
||||
total_channel_memory = channel_memory +
|
||||
channel_ban_memory +
|
||||
channel_users * sizeof(rb_dlink_node) + channel_invites * sizeof(rb_dlink_node);
|
||||
|
||||
sendto_one_numeric(source_p, RPL_STATSDEBUG,
|
||||
"z :Whowas array %ld(%ld)",
|
||||
(long)ww, (long)wwm);
|
||||
|
||||
totww = wwm;
|
||||
|
||||
sendto_one_numeric(source_p, RPL_STATSDEBUG,
|
||||
"z :Hash: client %u(%ld) chan %u(%ld)",
|
||||
U_MAX, (long)(U_MAX * sizeof(rb_dlink_list)),
|
||||
CH_MAX, (long)(CH_MAX * sizeof(rb_dlink_list)));
|
||||
|
||||
sendto_one_numeric(source_p, RPL_STATSDEBUG,
|
||||
"z :linebuf %ld(%ld)",
|
||||
(long)linebuf_count, (long)linebuf_memory_used);
|
||||
|
||||
count_scache(&number_servers_cached, &mem_servers_cached);
|
||||
|
||||
sendto_one_numeric(source_p, RPL_STATSDEBUG,
|
||||
"z :scache %ld(%ld)",
|
||||
(long)number_servers_cached, (long)mem_servers_cached);
|
||||
|
||||
sendto_one_numeric(source_p, RPL_STATSDEBUG,
|
||||
"z :hostname hash %d(%ld)",
|
||||
HOST_MAX, (long)HOST_MAX * sizeof(rb_dlink_list));
|
||||
|
||||
total_memory = totww + total_channel_memory + conf_memory +
|
||||
class_count * sizeof(struct Class);
|
||||
|
||||
total_memory += mem_servers_cached;
|
||||
sendto_one_numeric(source_p, RPL_STATSDEBUG,
|
||||
"z :Total: whowas %d channel %d conf %d",
|
||||
(int) totww, (int) total_channel_memory,
|
||||
(int) conf_memory);
|
||||
|
||||
count_local_client_memory(&local_client_count, &local_client_memory_used);
|
||||
total_memory += local_client_memory_used;
|
||||
|
||||
sendto_one_numeric(source_p, RPL_STATSDEBUG,
|
||||
"z :Local client Memory in use: %ld(%ld)",
|
||||
(long)local_client_count, (long)local_client_memory_used);
|
||||
|
||||
|
||||
count_remote_client_memory(&remote_client_count, &remote_client_memory_used);
|
||||
total_memory += remote_client_memory_used;
|
||||
|
||||
sendto_one_numeric(source_p, RPL_STATSDEBUG,
|
||||
"z :Remote client Memory in use: %ld(%ld)",
|
||||
(long)remote_client_count,
|
||||
(long)remote_client_memory_used);
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
|
@ -89,7 +89,6 @@ SRCS = \
|
|||
s_newconf.c \
|
||||
s_gline.c \
|
||||
s_serv.c \
|
||||
s_stats.c \
|
||||
s_user.c \
|
||||
scache.c \
|
||||
send.c \
|
||||
|
|
50
src/client.c
50
src/client.c
|
@ -2027,21 +2027,21 @@ close_connection(struct Client *client_p)
|
|||
{
|
||||
struct server_conf *server_p;
|
||||
|
||||
ServerStats->is_sv++;
|
||||
ServerStats->is_sbs += client_p->localClient->sendB;
|
||||
ServerStats->is_sbr += client_p->localClient->receiveB;
|
||||
ServerStats->is_sks += client_p->localClient->sendK;
|
||||
ServerStats->is_skr += client_p->localClient->receiveK;
|
||||
ServerStats->is_sti += rb_current_time() - client_p->localClient->firsttime;
|
||||
if(ServerStats->is_sbs > 2047)
|
||||
ServerStats.is_sv++;
|
||||
ServerStats.is_sbs += client_p->localClient->sendB;
|
||||
ServerStats.is_sbr += client_p->localClient->receiveB;
|
||||
ServerStats.is_sks += client_p->localClient->sendK;
|
||||
ServerStats.is_skr += client_p->localClient->receiveK;
|
||||
ServerStats.is_sti += rb_current_time() - client_p->localClient->firsttime;
|
||||
if(ServerStats.is_sbs > 2047)
|
||||
{
|
||||
ServerStats->is_sks += (ServerStats->is_sbs >> 10);
|
||||
ServerStats->is_sbs &= 0x3ff;
|
||||
ServerStats.is_sks += (ServerStats.is_sbs >> 10);
|
||||
ServerStats.is_sbs &= 0x3ff;
|
||||
}
|
||||
if(ServerStats->is_sbr > 2047)
|
||||
if(ServerStats.is_sbr > 2047)
|
||||
{
|
||||
ServerStats->is_skr += (ServerStats->is_sbr >> 10);
|
||||
ServerStats->is_sbr &= 0x3ff;
|
||||
ServerStats.is_skr += (ServerStats.is_sbr >> 10);
|
||||
ServerStats.is_sbr &= 0x3ff;
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -2065,25 +2065,25 @@ close_connection(struct Client *client_p)
|
|||
}
|
||||
else if(IsClient(client_p))
|
||||
{
|
||||
ServerStats->is_cl++;
|
||||
ServerStats->is_cbs += client_p->localClient->sendB;
|
||||
ServerStats->is_cbr += client_p->localClient->receiveB;
|
||||
ServerStats->is_cks += client_p->localClient->sendK;
|
||||
ServerStats->is_ckr += client_p->localClient->receiveK;
|
||||
ServerStats->is_cti += rb_current_time() - client_p->localClient->firsttime;
|
||||
if(ServerStats->is_cbs > 2047)
|
||||
ServerStats.is_cl++;
|
||||
ServerStats.is_cbs += client_p->localClient->sendB;
|
||||
ServerStats.is_cbr += client_p->localClient->receiveB;
|
||||
ServerStats.is_cks += client_p->localClient->sendK;
|
||||
ServerStats.is_ckr += client_p->localClient->receiveK;
|
||||
ServerStats.is_cti += rb_current_time() - client_p->localClient->firsttime;
|
||||
if(ServerStats.is_cbs > 2047)
|
||||
{
|
||||
ServerStats->is_cks += (ServerStats->is_cbs >> 10);
|
||||
ServerStats->is_cbs &= 0x3ff;
|
||||
ServerStats.is_cks += (ServerStats.is_cbs >> 10);
|
||||
ServerStats.is_cbs &= 0x3ff;
|
||||
}
|
||||
if(ServerStats->is_cbr > 2047)
|
||||
if(ServerStats.is_cbr > 2047)
|
||||
{
|
||||
ServerStats->is_ckr += (ServerStats->is_cbr >> 10);
|
||||
ServerStats->is_cbr &= 0x3ff;
|
||||
ServerStats.is_ckr += (ServerStats.is_cbr >> 10);
|
||||
ServerStats.is_cbr &= 0x3ff;
|
||||
}
|
||||
}
|
||||
else
|
||||
ServerStats->is_ni++;
|
||||
ServerStats.is_ni++;
|
||||
|
||||
if(client_p->localClient->F)
|
||||
{
|
||||
|
|
|
@ -80,6 +80,8 @@ extern char **myargv;
|
|||
|
||||
int maxconnections; /* XXX */
|
||||
|
||||
struct ServerStatistics ServerStats;
|
||||
|
||||
/*
|
||||
* print_startup - print startup information
|
||||
*/
|
||||
|
@ -451,6 +453,7 @@ main(int argc, char *argv[])
|
|||
memset((void *) &Count, 0, sizeof(Count));
|
||||
memset((void *) &ServerInfo, 0, sizeof(ServerInfo));
|
||||
memset((void *) &AdminInfo, 0, sizeof(AdminInfo));
|
||||
memset((void *) &ServerStats, 0, sizeof(struct ServerStatistics));
|
||||
|
||||
/* Initialise the channel capability usage counts... */
|
||||
init_chcap_usage_counts();
|
||||
|
@ -527,7 +530,6 @@ main(int argc, char *argv[])
|
|||
init_channels();
|
||||
initclass();
|
||||
initwhowas();
|
||||
init_stats();
|
||||
init_reject();
|
||||
init_cache();
|
||||
init_monitor();
|
||||
|
|
|
@ -481,7 +481,7 @@ accept_precallback(rb_fde_t *F, struct sockaddr *addr, rb_socklen_t addrlen, voi
|
|||
|
||||
if((maxconnections - 10) < rb_get_fd(F)) /* XXX this is kinda bogus */
|
||||
{
|
||||
++ServerStats->is_ref;
|
||||
++ServerStats.is_ref;
|
||||
/*
|
||||
* slow down the whining to opers bit
|
||||
*/
|
||||
|
@ -507,7 +507,7 @@ accept_precallback(rb_fde_t *F, struct sockaddr *addr, rb_socklen_t addrlen, voi
|
|||
* from this IP... */
|
||||
if(aconf != NULL)
|
||||
{
|
||||
ServerStats->is_ref++;
|
||||
ServerStats.is_ref++;
|
||||
|
||||
if(ConfigFileEntry.dline_with_reason)
|
||||
{
|
||||
|
@ -536,7 +536,7 @@ accept_callback(rb_fde_t *F, int status, struct sockaddr *addr, rb_socklen_t add
|
|||
struct rb_sockaddr_storage lip;
|
||||
unsigned int locallen = sizeof(struct rb_sockaddr_storage);
|
||||
|
||||
ServerStats->is_ac++;
|
||||
ServerStats.is_ac++;
|
||||
|
||||
if(getsockname(rb_get_fd(F), (struct sockaddr *) &lip, &locallen) < 0)
|
||||
{
|
||||
|
|
10
src/parse.c
10
src/parse.c
|
@ -162,7 +162,7 @@ parse(struct Client *client_p, char *pbuffer, char *bufend)
|
|||
/* didnt find any matching client, issue a kill */
|
||||
if(from == NULL)
|
||||
{
|
||||
ServerStats->is_unpf++;
|
||||
ServerStats.is_unpf++;
|
||||
remove_unknown(client_p, sender, pbuffer);
|
||||
return;
|
||||
}
|
||||
|
@ -172,7 +172,7 @@ parse(struct Client *client_p, char *pbuffer, char *bufend)
|
|||
/* fake direction, hmm. */
|
||||
if(from->from != client_p)
|
||||
{
|
||||
ServerStats->is_wrdi++;
|
||||
ServerStats.is_wrdi++;
|
||||
cancel_clients(client_p, from, pbuffer);
|
||||
return;
|
||||
}
|
||||
|
@ -183,7 +183,7 @@ parse(struct Client *client_p, char *pbuffer, char *bufend)
|
|||
|
||||
if(*ch == '\0')
|
||||
{
|
||||
ServerStats->is_empt++;
|
||||
ServerStats.is_empt++;
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -204,7 +204,7 @@ parse(struct Client *client_p, char *pbuffer, char *bufend)
|
|||
{
|
||||
mptr = NULL;
|
||||
numeric = ch;
|
||||
ServerStats->is_num++;
|
||||
ServerStats.is_num++;
|
||||
s = ch + 3; /* I know this is ' ' from above if */
|
||||
*s++ = '\0'; /* blow away the ' ', and point s to next part */
|
||||
}
|
||||
|
@ -248,7 +248,7 @@ parse(struct Client *client_p, char *pbuffer, char *bufend)
|
|||
me.name, from->name, ch);
|
||||
}
|
||||
}
|
||||
ServerStats->is_unco++;
|
||||
ServerStats.is_unco++;
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -174,7 +174,7 @@ check_reject(struct Client *client_p)
|
|||
rdata->time = rb_current_time();
|
||||
if(rdata->count > ConfigFileEntry.reject_after_count)
|
||||
{
|
||||
ServerStats->is_rej++;
|
||||
ServerStats.is_rej++;
|
||||
SetReject(client_p);
|
||||
rb_setselect(client_p->localClient->F, RB_SELECT_WRITE | RB_SELECT_READ, NULL, NULL);
|
||||
SetClosing(client_p);
|
||||
|
|
10
src/s_auth.c
10
src/s_auth.c
|
@ -240,7 +240,7 @@ auth_dns_callback(void *vptr, struct DNSReply *reply)
|
|||
static void
|
||||
auth_error(struct AuthRequest *auth)
|
||||
{
|
||||
++ServerStats->is_abad;
|
||||
++ServerStats.is_abad;
|
||||
|
||||
rb_close(auth->F);
|
||||
auth->F = NULL;
|
||||
|
@ -274,7 +274,7 @@ start_auth_query(struct AuthRequest *auth)
|
|||
if((F = rb_socket(family, SOCK_STREAM, 0, "ident")) == NULL)
|
||||
{
|
||||
ilog_error("creating auth stream socket");
|
||||
++ServerStats->is_abad;
|
||||
++ServerStats.is_abad;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -445,7 +445,7 @@ timeout_auth_queries_event(void *notused)
|
|||
if(IsDoingAuth(auth))
|
||||
{
|
||||
ClearAuth(auth);
|
||||
++ServerStats->is_abad;
|
||||
++ServerStats.is_abad;
|
||||
sendheader(auth->client, REPORT_FAIL_ID);
|
||||
auth->client->localClient->auth_request = NULL;
|
||||
}
|
||||
|
@ -575,14 +575,14 @@ read_auth_reply(rb_fde_t *F, void *data)
|
|||
|
||||
if(s == NULL)
|
||||
{
|
||||
++ServerStats->is_abad;
|
||||
++ServerStats.is_abad;
|
||||
strcpy(auth->client->username, "unknown");
|
||||
sendheader(auth->client, REPORT_FAIL_ID);
|
||||
}
|
||||
else
|
||||
{
|
||||
sendheader(auth->client, REPORT_FIN_ID);
|
||||
++ServerStats->is_asuc;
|
||||
++ServerStats.is_asuc;
|
||||
SetGotId(auth->client);
|
||||
}
|
||||
|
||||
|
|
12
src/s_conf.c
12
src/s_conf.c
|
@ -194,7 +194,7 @@ check_client(struct Client *client_p, struct Client *source_p, const char *usern
|
|||
source_p->name, IsGotId(source_p) ? "" : "~",
|
||||
source_p->username, source_p->sockhost);
|
||||
|
||||
ServerStats->is_ref++;
|
||||
ServerStats.is_ref++;
|
||||
exit_client(client_p, source_p, &me, "Too many host connections (local)");
|
||||
break;
|
||||
|
||||
|
@ -208,7 +208,7 @@ check_client(struct Client *client_p, struct Client *source_p, const char *usern
|
|||
source_p->name, IsGotId(source_p) ? "" : "~",
|
||||
source_p->username, source_p->sockhost);
|
||||
|
||||
ServerStats->is_ref++;
|
||||
ServerStats.is_ref++;
|
||||
exit_client(client_p, source_p, &me, "Too many host connections (global)");
|
||||
break;
|
||||
|
||||
|
@ -222,7 +222,7 @@ check_client(struct Client *client_p, struct Client *source_p, const char *usern
|
|||
source_p->name, IsGotId(source_p) ? "" : "~",
|
||||
source_p->username, source_p->sockhost);
|
||||
|
||||
ServerStats->is_ref++;
|
||||
ServerStats.is_ref++;
|
||||
exit_client(client_p, source_p, &me, "Too many user connections (global)");
|
||||
break;
|
||||
|
||||
|
@ -237,7 +237,7 @@ check_client(struct Client *client_p, struct Client *source_p, const char *usern
|
|||
source_p->name, IsGotId(source_p) ? "" : "~",
|
||||
source_p->username, source_p->sockhost);
|
||||
|
||||
ServerStats->is_ref++;
|
||||
ServerStats.is_ref++;
|
||||
exit_client(client_p, source_p, &me,
|
||||
"No more connections allowed in your connection class");
|
||||
break;
|
||||
|
@ -252,7 +252,7 @@ check_client(struct Client *client_p, struct Client *source_p, const char *usern
|
|||
#endif
|
||||
port = ntohs(((struct sockaddr_in *)&source_p->localClient->listener->addr)->sin_port);
|
||||
|
||||
ServerStats->is_ref++;
|
||||
ServerStats.is_ref++;
|
||||
/* jdc - lists server name & port connections are on */
|
||||
/* a purely cosmetical change */
|
||||
/* why ipaddr, and not just source_p->sockhost? --fl */
|
||||
|
@ -280,7 +280,7 @@ check_client(struct Client *client_p, struct Client *source_p, const char *usern
|
|||
}
|
||||
case BANNED_CLIENT:
|
||||
exit_client(client_p, client_p, &me, "*** Banned ");
|
||||
ServerStats->is_ref++;
|
||||
ServerStats.is_ref++;
|
||||
break;
|
||||
|
||||
case 0:
|
||||
|
|
|
@ -1031,7 +1031,7 @@ server_estab(struct Client *client_p)
|
|||
{
|
||||
if(client_p != serv_list.head->data || serv_list.head->next)
|
||||
{
|
||||
ServerStats->is_ref++;
|
||||
ServerStats.is_ref++;
|
||||
sendto_one(client_p, "ERROR :I'm a leaf not a hub");
|
||||
return exit_client(client_p, client_p, client_p, "I'm a leaf");
|
||||
}
|
||||
|
|
386
src/s_stats.c
386
src/s_stats.c
|
@ -1,386 +0,0 @@
|
|||
/*
|
||||
* ircd-ratbox: A slightly useful ircd.
|
||||
* s_stats.c: Statistics related functions
|
||||
*
|
||||
* Copyright (C) 1990 Jarkko Oikarinen and University of Oulu, Co Center
|
||||
* Copyright (C) 1996-2002 Hybrid Development Team
|
||||
* Copyright (C) 2002-2005 ircd-ratbox development team
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
|
||||
* USA
|
||||
*
|
||||
* $Id: s_stats.c 3249 2007-03-05 18:51:17Z nenolod $
|
||||
*/
|
||||
|
||||
#include "stdinc.h"
|
||||
#include "s_stats.h"
|
||||
#include "client.h"
|
||||
#include "irc_string.h"
|
||||
#include "ircd.h"
|
||||
#include "numeric.h"
|
||||
#include "send.h"
|
||||
#include "s_conf.h"
|
||||
#include "s_newconf.h"
|
||||
#include "whowas.h"
|
||||
#include "hash.h"
|
||||
#include "scache.h"
|
||||
#include "reject.h"
|
||||
|
||||
/*
|
||||
* stats stuff
|
||||
*/
|
||||
static struct ServerStatistics ircst;
|
||||
struct ServerStatistics *ServerStats = &ircst;
|
||||
|
||||
void
|
||||
init_stats()
|
||||
{
|
||||
memset(&ircst, 0, sizeof(ircst));
|
||||
}
|
||||
|
||||
/*
|
||||
* tstats
|
||||
*
|
||||
* inputs - client to report to
|
||||
* output - NONE
|
||||
* side effects -
|
||||
*/
|
||||
void
|
||||
tstats(struct Client *source_p)
|
||||
{
|
||||
struct Client *target_p;
|
||||
struct ServerStatistics *sp;
|
||||
struct ServerStatistics tmp;
|
||||
rb_dlink_node *ptr;
|
||||
|
||||
sp = &tmp;
|
||||
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_sks += target_p->localClient->sendK;
|
||||
sp->is_skr += target_p->localClient->receiveK;
|
||||
sp->is_sti += rb_current_time() - target_p->localClient->firsttime;
|
||||
sp->is_sv++;
|
||||
if(sp->is_sbs > 1023)
|
||||
{
|
||||
sp->is_sks += (sp->is_sbs >> 10);
|
||||
sp->is_sbs &= 0x3ff;
|
||||
}
|
||||
if(sp->is_sbr > 1023)
|
||||
{
|
||||
sp->is_skr += (sp->is_sbr >> 10);
|
||||
sp->is_sbr &= 0x3ff;
|
||||
}
|
||||
}
|
||||
|
||||
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_cks += target_p->localClient->sendK;
|
||||
sp->is_ckr += target_p->localClient->receiveK;
|
||||
sp->is_cti += rb_current_time() - target_p->localClient->firsttime;
|
||||
sp->is_cl++;
|
||||
if(sp->is_cbs > 1023)
|
||||
{
|
||||
sp->is_cks += (sp->is_cbs >> 10);
|
||||
sp->is_cbs &= 0x3ff;
|
||||
}
|
||||
if(sp->is_cbr > 1023)
|
||||
{
|
||||
sp->is_ckr += (sp->is_cbr >> 10);
|
||||
sp->is_cbr &= 0x3ff;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
RB_DLINK_FOREACH(ptr, unknown_list.head)
|
||||
{
|
||||
sp->is_ni++;
|
||||
}
|
||||
|
||||
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, rb_dlink_list_length(&delay_exit));
|
||||
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 :tgchange blocked msgs %u restricted addrs %lu",
|
||||
sp->is_tgch, rb_dlink_list_length(&tgchange_list));
|
||||
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 :sasl successes %u fails %u",
|
||||
sp->is_ssuc, sp->is_sbad);
|
||||
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 %d.%uK %d.%uK",
|
||||
(int) sp->is_cks, sp->is_cbs,
|
||||
(int) sp->is_sks, sp->is_sbs);
|
||||
sendto_one_numeric(source_p, RPL_STATSDEBUG,
|
||||
"T :bytes recv %d.%uK %d.%uK",
|
||||
(int) sp->is_ckr, sp->is_cbr,
|
||||
(int) sp->is_skr, sp->is_sbr);
|
||||
sendto_one_numeric(source_p, RPL_STATSDEBUG,
|
||||
"T :time connected %d %d",
|
||||
(int) sp->is_cti, (int) sp->is_sti);
|
||||
}
|
||||
|
||||
void
|
||||
count_memory(struct Client *source_p)
|
||||
{
|
||||
struct Client *target_p;
|
||||
struct Channel *chptr;
|
||||
struct Ban *actualBan;
|
||||
rb_dlink_node *rb_dlink;
|
||||
rb_dlink_node *ptr;
|
||||
int channel_count = 0;
|
||||
int local_client_conf_count = 0; /* local client conf links */
|
||||
int users_counted = 0; /* user structs */
|
||||
|
||||
int channel_users = 0;
|
||||
int channel_invites = 0;
|
||||
int channel_bans = 0;
|
||||
int channel_except = 0;
|
||||
int channel_invex = 0;
|
||||
int channel_quiets = 0;
|
||||
|
||||
int class_count = 0; /* classes */
|
||||
int conf_count = 0; /* conf lines */
|
||||
int users_invited_count = 0; /* users invited */
|
||||
int user_channels = 0; /* users in channels */
|
||||
int aways_counted = 0;
|
||||
size_t number_servers_cached; /* number of servers cached by scache */
|
||||
|
||||
size_t channel_memory = 0;
|
||||
size_t channel_ban_memory = 0;
|
||||
size_t channel_except_memory = 0;
|
||||
size_t channel_invex_memory = 0;
|
||||
size_t channel_quiet_memory = 0;
|
||||
|
||||
size_t away_memory = 0; /* memory used by aways */
|
||||
size_t ww = 0; /* whowas array count */
|
||||
size_t wwm = 0; /* whowas array memory used */
|
||||
size_t conf_memory = 0; /* memory used by conf lines */
|
||||
size_t mem_servers_cached; /* memory used by scache */
|
||||
|
||||
size_t linebuf_count = 0;
|
||||
size_t linebuf_memory_used = 0;
|
||||
|
||||
size_t total_channel_memory = 0;
|
||||
size_t totww = 0;
|
||||
|
||||
size_t local_client_count = 0;
|
||||
size_t local_client_memory_used = 0;
|
||||
|
||||
size_t remote_client_count = 0;
|
||||
size_t remote_client_memory_used = 0;
|
||||
|
||||
size_t total_memory = 0;
|
||||
|
||||
count_whowas_memory(&ww, &wwm);
|
||||
|
||||
RB_DLINK_FOREACH(ptr, global_client_list.head)
|
||||
{
|
||||
target_p = ptr->data;
|
||||
if(MyConnect(target_p))
|
||||
{
|
||||
local_client_conf_count++;
|
||||
}
|
||||
|
||||
if(target_p->user)
|
||||
{
|
||||
users_counted++;
|
||||
users_invited_count += rb_dlink_list_length(&target_p->user->invited);
|
||||
user_channels += rb_dlink_list_length(&target_p->user->channel);
|
||||
if(target_p->user->away)
|
||||
{
|
||||
aways_counted++;
|
||||
away_memory += (strlen(target_p->user->away) + 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Count up all channels, ban lists, except lists, Invex lists */
|
||||
RB_DLINK_FOREACH(ptr, global_channel_list.head)
|
||||
{
|
||||
chptr = ptr->data;
|
||||
channel_count++;
|
||||
channel_memory += (strlen(chptr->chname) + sizeof(struct Channel));
|
||||
|
||||
channel_users += rb_dlink_list_length(&chptr->members);
|
||||
channel_invites += rb_dlink_list_length(&chptr->invites);
|
||||
|
||||
RB_DLINK_FOREACH(rb_dlink, chptr->banlist.head)
|
||||
{
|
||||
actualBan = rb_dlink->data;
|
||||
channel_bans++;
|
||||
|
||||
channel_ban_memory += sizeof(rb_dlink_node) + sizeof(struct Ban);
|
||||
}
|
||||
|
||||
RB_DLINK_FOREACH(rb_dlink, chptr->exceptlist.head)
|
||||
{
|
||||
actualBan = rb_dlink->data;
|
||||
channel_except++;
|
||||
|
||||
channel_except_memory += (sizeof(rb_dlink_node) + sizeof(struct Ban));
|
||||
}
|
||||
|
||||
RB_DLINK_FOREACH(rb_dlink, chptr->invexlist.head)
|
||||
{
|
||||
actualBan = rb_dlink->data;
|
||||
channel_invex++;
|
||||
|
||||
channel_invex_memory += (sizeof(rb_dlink_node) + sizeof(struct Ban));
|
||||
}
|
||||
|
||||
RB_DLINK_FOREACH(rb_dlink, chptr->quietlist.head)
|
||||
{
|
||||
actualBan = rb_dlink->data;
|
||||
channel_quiets++;
|
||||
|
||||
channel_quiet_memory += (sizeof(rb_dlink_node) + sizeof(struct Ban));
|
||||
}
|
||||
}
|
||||
|
||||
/* count up all classes */
|
||||
|
||||
class_count = rb_dlink_list_length(&class_list) + 1;
|
||||
|
||||
rb_count_rb_linebuf_memory(&linebuf_count, &linebuf_memory_used);
|
||||
|
||||
sendto_one_numeric(source_p, RPL_STATSDEBUG,
|
||||
"z :Users %u(%lu) Invites %u(%lu)",
|
||||
users_counted,
|
||||
(unsigned long) users_counted * sizeof(struct User),
|
||||
users_invited_count,
|
||||
(unsigned long) users_invited_count * sizeof(rb_dlink_node));
|
||||
|
||||
sendto_one_numeric(source_p, RPL_STATSDEBUG,
|
||||
"z :User channels %u(%lu) Aways %u(%d)",
|
||||
user_channels,
|
||||
(unsigned long) user_channels * sizeof(rb_dlink_node),
|
||||
aways_counted, (int) away_memory);
|
||||
|
||||
sendto_one_numeric(source_p, RPL_STATSDEBUG,
|
||||
"z :Attached confs %u(%lu)",
|
||||
local_client_conf_count,
|
||||
(unsigned long) local_client_conf_count * sizeof(rb_dlink_node));
|
||||
|
||||
sendto_one_numeric(source_p, RPL_STATSDEBUG,
|
||||
"z :Conflines %u(%d)", conf_count, (int) conf_memory);
|
||||
|
||||
sendto_one_numeric(source_p, RPL_STATSDEBUG,
|
||||
"z :Classes %u(%lu)",
|
||||
class_count,
|
||||
(unsigned long) class_count * sizeof(struct Class));
|
||||
|
||||
sendto_one_numeric(source_p, RPL_STATSDEBUG,
|
||||
"z :Channels %u(%d)",
|
||||
channel_count, (int) channel_memory);
|
||||
|
||||
sendto_one_numeric(source_p, RPL_STATSDEBUG,
|
||||
"z :Bans %u(%d) Exceptions %u(%d) Invex %u(%d) Quiets %u(%d)",
|
||||
channel_bans, (int) channel_ban_memory,
|
||||
channel_except, (int) channel_except_memory,
|
||||
channel_invex, (int) channel_invex_memory,
|
||||
channel_quiets, (int) channel_quiet_memory);
|
||||
|
||||
sendto_one_numeric(source_p, RPL_STATSDEBUG,
|
||||
"z :Channel members %u(%lu) invite %u(%lu)",
|
||||
channel_users,
|
||||
(unsigned long) channel_users * sizeof(rb_dlink_node),
|
||||
channel_invites,
|
||||
(unsigned long) channel_invites * sizeof(rb_dlink_node));
|
||||
|
||||
total_channel_memory = channel_memory +
|
||||
channel_ban_memory +
|
||||
channel_users * sizeof(rb_dlink_node) + channel_invites * sizeof(rb_dlink_node);
|
||||
|
||||
sendto_one_numeric(source_p, RPL_STATSDEBUG,
|
||||
"z :Whowas array %ld(%ld)",
|
||||
(long)ww, (long)wwm);
|
||||
|
||||
totww = wwm;
|
||||
|
||||
sendto_one_numeric(source_p, RPL_STATSDEBUG,
|
||||
"z :Hash: client %u(%ld) chan %u(%ld)",
|
||||
U_MAX, (long)(U_MAX * sizeof(rb_dlink_list)),
|
||||
CH_MAX, (long)(CH_MAX * sizeof(rb_dlink_list)));
|
||||
|
||||
sendto_one_numeric(source_p, RPL_STATSDEBUG,
|
||||
"z :linebuf %ld(%ld)",
|
||||
(long)linebuf_count, (long)linebuf_memory_used);
|
||||
|
||||
count_scache(&number_servers_cached, &mem_servers_cached);
|
||||
|
||||
sendto_one_numeric(source_p, RPL_STATSDEBUG,
|
||||
"z :scache %ld(%ld)",
|
||||
(long)number_servers_cached, (long)mem_servers_cached);
|
||||
|
||||
sendto_one_numeric(source_p, RPL_STATSDEBUG,
|
||||
"z :hostname hash %d(%ld)",
|
||||
HOST_MAX, (long)HOST_MAX * sizeof(rb_dlink_list));
|
||||
|
||||
total_memory = totww + total_channel_memory + conf_memory +
|
||||
class_count * sizeof(struct Class);
|
||||
|
||||
total_memory += mem_servers_cached;
|
||||
sendto_one_numeric(source_p, RPL_STATSDEBUG,
|
||||
"z :Total: whowas %d channel %d conf %d",
|
||||
(int) totww, (int) total_channel_memory,
|
||||
(int) conf_memory);
|
||||
|
||||
count_local_client_memory(&local_client_count, &local_client_memory_used);
|
||||
total_memory += local_client_memory_used;
|
||||
|
||||
sendto_one_numeric(source_p, RPL_STATSDEBUG,
|
||||
"z :Local client Memory in use: %ld(%ld)",
|
||||
(long)local_client_count, (long)local_client_memory_used);
|
||||
|
||||
|
||||
count_remote_client_memory(&remote_client_count, &remote_client_memory_used);
|
||||
total_memory += remote_client_memory_used;
|
||||
|
||||
sendto_one_numeric(source_p, RPL_STATSDEBUG,
|
||||
"z :Remote client Memory in use: %ld(%ld)",
|
||||
(long)remote_client_count,
|
||||
(long)remote_client_memory_used);
|
||||
}
|
14
src/s_user.c
14
src/s_user.c
|
@ -323,7 +323,7 @@ register_local_user(struct Client *client_p, struct Client *source_p, const char
|
|||
|
||||
if(IsNeedIdentd(aconf))
|
||||
{
|
||||
ServerStats->is_ref++;
|
||||
ServerStats.is_ref++;
|
||||
sendto_one_notice(source_p, ":*** Notice -- You need to install identd to use this server");
|
||||
exit_client(client_p, source_p, &me, "Install identd");
|
||||
return (CLIENT_EXITED);
|
||||
|
@ -350,7 +350,7 @@ register_local_user(struct Client *client_p, struct Client *source_p, const char
|
|||
|
||||
if(IsNeedSasl(aconf) && !*user->suser)
|
||||
{
|
||||
ServerStats->is_ref++;
|
||||
ServerStats.is_ref++;
|
||||
sendto_one_notice(source_p, ":*** Notice -- You need to identify via SASL to use this server");
|
||||
exit_client(client_p, source_p, &me, "SASL access only");
|
||||
return (CLIENT_EXITED);
|
||||
|
@ -370,7 +370,7 @@ register_local_user(struct Client *client_p, struct Client *source_p, const char
|
|||
|
||||
if(strcmp(encr, aconf->passwd))
|
||||
{
|
||||
ServerStats->is_ref++;
|
||||
ServerStats.is_ref++;
|
||||
sendto_one(source_p, form_str(ERR_PASSWDMISMATCH), me.name, source_p->name);
|
||||
exit_client(client_p, source_p, &me, "Bad Password");
|
||||
return (CLIENT_EXITED);
|
||||
|
@ -404,7 +404,7 @@ register_local_user(struct Client *client_p, struct Client *source_p, const char
|
|||
sendto_realops_snomask(SNO_FULL, L_ALL,
|
||||
"Too many clients, rejecting %s[%s].", source_p->name, source_p->host);
|
||||
|
||||
ServerStats->is_ref++;
|
||||
ServerStats.is_ref++;
|
||||
exit_client(client_p, source_p, &me, "Sorry, server is full - try later");
|
||||
return (CLIENT_EXITED);
|
||||
}
|
||||
|
@ -413,7 +413,7 @@ register_local_user(struct Client *client_p, struct Client *source_p, const char
|
|||
if(!IsExemptKline(source_p) &&
|
||||
(xconf = find_xline(source_p->info, 1)) != NULL)
|
||||
{
|
||||
ServerStats->is_ref++;
|
||||
ServerStats.is_ref++;
|
||||
add_reject(source_p, xconf->name, NULL);
|
||||
exit_client(client_p, source_p, &me, "Bad user info");
|
||||
return CLIENT_EXITED;
|
||||
|
@ -435,7 +435,7 @@ register_local_user(struct Client *client_p, struct Client *source_p, const char
|
|||
substitution_append_var(&varlist, "dnsbl-host", source_p->preClient->dnsbl_listed->host);
|
||||
substitution_append_var(&varlist, "network-name", ServerInfo.network_name);
|
||||
|
||||
ServerStats->is_ref++;
|
||||
ServerStats.is_ref++;
|
||||
|
||||
sendto_one(source_p, form_str(ERR_YOUREBANNEDCREEP),
|
||||
me.name, source_p->name,
|
||||
|
@ -459,7 +459,7 @@ register_local_user(struct Client *client_p, struct Client *source_p, const char
|
|||
sendto_realops_snomask(SNO_REJ, L_ALL,
|
||||
"Invalid username: %s (%s@%s)",
|
||||
source_p->name, source_p->username, source_p->host);
|
||||
ServerStats->is_ref++;
|
||||
ServerStats.is_ref++;
|
||||
sendto_one_notice(source_p, ":*** Your username is invalid. Please make sure that your username contains "
|
||||
"only alphanumeric characters.");
|
||||
rb_sprintf(tmpstr2, "Invalid username [%s]", source_p->username);
|
||||
|
|
Loading…
Reference in New Issue