ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/svn/ircd-hybrid-7.3/modules/m_stats.c
(Generate patch)

Comparing ircd-hybrid-7.2/modules/m_stats.c (file contents):
Revision 584 by michael, Sun May 7 15:26:45 2006 UTC vs.
Revision 948 by michael, Tue Jul 21 17:34:06 2009 UTC

# Line 41 | Line 41
41   #include "s_conf.h"      /* AccessItem, report_configured_links */
42   #include "s_misc.h"      /* serv_info */
43   #include "s_serv.h"      /* hunt_server */
44 #include "s_stats.h"     /* tstats */
44   #include "s_user.h"      /* show_opers */
45   #include "event.h"       /* events */
46   #include "dbuf.h"
# Line 51 | Line 50
50   #include "resv.h"  /* report_resv */
51   #include "whowas.h"
52   #include "list.h"
53 + #include "watch.h"
54  
55   static void do_stats(struct Client *, int, char **);
56   static void m_stats(struct Client *, struct Client *, int, char *[]);
# Line 180 | Line 180 | static const struct StatsStruct
180    { 'z',        stats_memory,           1,      0,      },
181    { 'Z',        stats_ziplinks,         1,      0,      },
182    { '?',        stats_servlinks,        0,      0,      },
183 <  { '\0',       (void(*)())0,           0,      0,      }
183 >  { '\0',       NULL,                   0,      0,      }
184   };
185  
186   const char *from, *to;
# Line 379 | Line 379 | count_memory(struct Client *source_p)
379    const dlink_node *gptr = NULL;
380    const dlink_node *dlink = NULL;
381  
382 <  int local_client_conf_count = 0;      /* local client conf links */
383 <  int users_counted = 0;                /* user structs */
382 >  unsigned int local_client_conf_count = 0;      /* local client conf links */
383 >  unsigned int users_counted = 0;                /* user structs */
384  
385 <  int channel_users = 0; /* XXX */
386 <  int channel_invites = 0;
387 <  int channel_bans = 0;
388 <  int channel_except = 0;
389 <  int channel_invex = 0;
390 <
391 <  int wwu = 0;                  /* whowas users */
392 <  int class_count = 0;          /* classes */
393 <  int users_invited_count = 0;  /* users invited */
394 <  int aways_counted = 0;
395 <  int number_ips_stored;        /* number of ip addresses hashed */
396 <
397 <  unsigned long channel_memory = 0;
398 <  size_t channel_ban_memory = 0;
399 <  size_t channel_except_memory = 0;
400 <  size_t channel_invex_memory = 0;
385 >  unsigned int channel_users = 0; /* XXX */
386 >  unsigned int channel_invites = 0;
387 >  unsigned int channel_bans = 0;
388 >  unsigned int channel_except = 0;
389 >  unsigned int channel_invex = 0;
390 >
391 >  unsigned int wwu = 0;                  /* whowas users */
392 >  unsigned int class_count = 0;          /* classes */
393 >  unsigned int aways_counted = 0;
394 >  unsigned int number_ips_stored;        /* number of ip addresses hashed */
395 >
396 >  uint64_t channel_memory = 0;
397 >  uint64_t channel_ban_memory = 0;
398 >  uint64_t channel_except_memory = 0;
399 >  uint64_t channel_invex_memory = 0;
400  
401    unsigned int safelist_count = 0;
402 <  size_t safelist_memory = 0;
402 >  uint64_t safelist_memory = 0;
403  
404 <  unsigned long away_memory = 0;       /* memory used by aways           */
405 <  unsigned long wwm = 0;               /* whowas array memory used       */
406 <  unsigned long conf_memory = 0;       /* memory used by conf lines      */
407 <  unsigned long mem_ips_stored;        /* memory used by ip address hash */
408 <
409 <  unsigned long client_hash_table_size = 0;
410 <  unsigned long channel_hash_table_size = 0;
411 <  unsigned long resv_hash_table_size = 0;
412 <  unsigned long id_hash_table_size = 0;
413 <  unsigned long total_channel_memory = 0;
414 <  unsigned long totww = 0;
404 >  uint64_t away_memory = 0;       /* memory used by aways           */
405 >  uint64_t wwm = 0;               /* whowas array memory used       */
406 >  uint64_t conf_memory = 0;       /* memory used by conf lines      */
407 >  uint64_t mem_ips_stored;        /* memory used by ip address hash */
408 >
409 >  uint64_t client_hash_table_size = 0;
410 >  uint64_t channel_hash_table_size = 0;
411 >  uint64_t resv_hash_table_size = 0;
412 >  uint64_t id_hash_table_size = 0;
413 >  uint64_t total_channel_memory = 0;
414 >  uint64_t totww = 0;
415  
416    unsigned int local_client_count  = 0;
417    unsigned int remote_client_count = 0;
418  
419 <  unsigned int local_client_memory_used  = 0;
420 <  unsigned int remote_client_memory_used = 0;
419 >  uint64_t local_client_memory_used  = 0;
420 >  uint64_t remote_client_memory_used = 0;
421  
422 <  unsigned long total_memory = 0;
422 >  uint64_t total_memory = 0;
423    unsigned int topic_count = 0;
424  
425 +  unsigned int wlh = 0;   /* watchlist headers     */
426 +  unsigned int wle = 0;   /* watchlist entries     */
427 +  uint64_t wlhm = 0; /* watchlist memory used */
428 +
429    count_whowas_memory(&wwu, &wwm);
430  
431    DLINK_FOREACH(gptr, global_client_list.head)
# Line 433 | Line 436 | count_memory(struct Client *source_p)
436      {
437        ++local_client_count;
438        local_client_conf_count += dlink_list_length(&target_p->localClient->confs);
439 <      users_invited_count += dlink_list_length(&target_p->localClient->invited);
439 >      wle += dlink_list_length(&target_p->localClient->watches);
440      }
441      else
442        ++remote_client_count;
# Line 455 | Line 458 | count_memory(struct Client *source_p)
458                     sizeof(struct Channel);
459    DLINK_FOREACH(gptr, global_channel_list.head)
460    {
461 <    struct Ban *actualBan;
462 <    struct Channel *chptr = gptr->data;
461 >    const struct Ban *actualBan;
462 >    const struct Channel *chptr = gptr->data;
463  
464      channel_users   += dlink_list_length(&chptr->members);
465      channel_invites += dlink_list_length(&chptr->invites);
# Line 512 | Line 515 | count_memory(struct Client *source_p)
515      safelist_memory = safelist_count * sizeof(struct ListTask);
516      DLINK_FOREACH(gptr, listing_client_list.head)
517      {
518 <      struct Client *acptr = gptr->data;
518 >      const struct Client *acptr = gptr->data;
519  
520        DLINK_FOREACH(dlink, acptr->localClient->list_task->show_mask.head)
521          safelist_memory += strlen(dlink->data);
# Line 537 | Line 540 | count_memory(struct Client *source_p)
540    /* count up all classes */
541    class_count = dlink_list_length(&class_items);
542  
543 <  sendto_one(source_p, ":%s %d %s z :Clients %u(%lu) Invites %u(%lu)",
543 >  watch_count_memory(&wlh, &wlhm);
544 >
545 >  sendto_one(source_p, ":%s %d %s z :WATCH headers %u(%u) entries %d(%d)",
546 >             me.name, RPL_STATSDEBUG, source_p->name, wlh, wlhm, wle,
547 >             wle * sizeof(dlink_node));
548 >
549 >  sendto_one(source_p, ":%s %d %s z :Clients %u(%u)",
550               me.name, RPL_STATSDEBUG, source_p->name, users_counted,
551 <             (unsigned long)(users_counted * sizeof(struct Client)),
543 <             users_invited_count, (unsigned long)(users_invited_count * sizeof(dlink_node)));
551 >             (users_counted * sizeof(struct Client)));
552  
553 <  sendto_one(source_p, ":%s %d %s z :User aways %u(%d)",
553 >  sendto_one(source_p, ":%s %d %s z :User aways %u(%llu)",
554               me.name, RPL_STATSDEBUG, source_p->name,
555 <             aways_counted, (int)away_memory);
555 >             aways_counted, away_memory);
556  
557 <  sendto_one(source_p, ":%s %d %s z :Attached confs %u(%lu)",
557 >  sendto_one(source_p, ":%s %d %s z :Attached confs %u(%llu)",
558               me.name, RPL_STATSDEBUG, source_p->name,
559               local_client_conf_count,
560 <             (unsigned long)(local_client_conf_count * sizeof(dlink_node)));
560 >             (unsigned long long)(local_client_conf_count * sizeof(dlink_node)));
561  
562    /* XXX  ConfigItemList fix */
563   #if 0
# Line 565 | Line 573 | count_memory(struct Client *source_p)
573               dlink_list_length(&nresv_items),
574               dlink_list_length(&nresv_items) * sizeof(struct MatchItem));
575  
576 <  sendto_one(source_p, ":%s %d %s z :Classes %u(%lu)",
576 >  sendto_one(source_p, ":%s %d %s z :Classes %u(%llu)",
577               me.name, RPL_STATSDEBUG, source_p->name,
578 <             class_count, (unsigned long)(class_count * sizeof(struct ClassItem)));
578 >             class_count, (unsigned long long)(class_count * sizeof(struct ClassItem)));
579  
580 <  sendto_one(source_p, ":%s %d %s z :Channels %lu(%lu) Topics %u(%d)",
580 >  sendto_one(source_p, ":%s %d %s z :Channels %lu(%llu) Topics %u(%d)",
581               me.name, RPL_STATSDEBUG, source_p->name,
582               dlink_list_length(&global_channel_list),
583               channel_memory, topic_count, topic_count *
584               (TOPICLEN + 1 + USERHOST_REPLYLEN));
585  
586 <  sendto_one(source_p, ":%s %d %s z :Bans %u(%u)",
586 >  sendto_one(source_p, ":%s %d %s z :Bans %u(%llu)",
587               me.name, RPL_STATSDEBUG, source_p->name,
588               channel_bans, channel_ban_memory);
589  
590 <  sendto_one(source_p, ":%s %d %s z :Exceptions %u(%u)",
590 >  sendto_one(source_p, ":%s %d %s z :Exceptions %u(%llu)",
591               me.name, RPL_STATSDEBUG, source_p->name,
592               channel_except, channel_except_memory);
593  
594 <  sendto_one(source_p, ":%s %d %s z :Invex %u(%u)",
594 >  sendto_one(source_p, ":%s %d %s z :Invex %u(%llu)",
595               me.name, RPL_STATSDEBUG, source_p->name,
596               channel_invex, channel_invex_memory);
597  
598 <  sendto_one(source_p, ":%s %d %s z :Channel members %u(%lu) invite %u(%lu)",
598 >  sendto_one(source_p, ":%s %d %s z :Channel members %u(%llu) invites %u(%llu)",
599               me.name, RPL_STATSDEBUG, source_p->name, channel_users,
600 <             (unsigned long)(channel_users * sizeof(struct Membership)),
601 <             channel_invites, (unsigned long)channel_invites *
602 <             sizeof(dlink_node));
600 >             (unsigned long long)(channel_users * sizeof(struct Membership)),
601 >             channel_invites, (unsigned long long)channel_invites *
602 >             sizeof(dlink_node) * 2);
603  
604    total_channel_memory = channel_memory + channel_ban_memory +
605                           channel_users * sizeof(struct Membership) +
606 <                         channel_invites * sizeof(dlink_node);
606 >                         (channel_invites * sizeof(dlink_node)*2);
607  
608 <  sendto_one(source_p, ":%s %d %s z :Safelist %u(%u)",
608 >  sendto_one(source_p, ":%s %d %s z :Safelist %u(%llu)",
609               me.name, RPL_STATSDEBUG, source_p->name,
610               safelist_count, safelist_memory);
611  
612 <  sendto_one(source_p, ":%s %d %s z :Whowas users %u(%lu)",
612 >  sendto_one(source_p, ":%s %d %s z :Whowas users %u(%llu)",
613               me.name, RPL_STATSDEBUG, source_p->name,
614 <             wwu, (unsigned long)(wwu * sizeof(struct Client)));
614 >             wwu, (unsigned long long)(wwu * sizeof(struct Client)));
615  
616 <  sendto_one(source_p, ":%s %d %s z :Whowas array %u(%d)",
616 >  sendto_one(source_p, ":%s %d %s z :Whowas array %u(%llu)",
617               me.name, RPL_STATSDEBUG, source_p->name,
618 <             NICKNAMEHISTORYLENGTH, (int)wwm);
618 >             NICKNAMEHISTORYLENGTH, wwm);
619  
620    totww = wwu * sizeof(struct Client) + wwm;
621   /****
# Line 624 | Line 632 | count_memory(struct Client *source_p)
632               resv_hash_table_size, U_MAX, id_hash_table_size);
633   ****/
634    count_ip_hash(&number_ips_stored,&mem_ips_stored);
635 <  sendto_one(source_p, ":%s %d %s z :iphash %u(%d)",
635 >  sendto_one(source_p, ":%s %d %s z :iphash %u(%llu)",
636               me.name, RPL_STATSDEBUG, source_p->name,
637 <             number_ips_stored, (int)mem_ips_stored);
637 >             number_ips_stored, mem_ips_stored);
638  
639    total_memory = totww + total_channel_memory + conf_memory + class_count *
640                   sizeof(struct ClassItem);
# Line 635 | Line 643 | count_memory(struct Client *source_p)
643    total_memory += resv_hash_table_size;
644    total_memory += id_hash_table_size;
645  
646 <  sendto_one(source_p, ":%s %d %s z :Total: whowas %d channel %d conf %d",
647 <             me.name, RPL_STATSDEBUG, source_p->name, (int)totww,
648 <            (int)total_channel_memory, (int)conf_memory);
646 >  sendto_one(source_p, ":%s %d %s z :Total: whowas %llu channel %llu conf %llu",
647 >             me.name, RPL_STATSDEBUG, source_p->name, totww,
648 >             total_channel_memory, conf_memory);
649  
650    local_client_memory_used = local_client_count*(sizeof(struct Client) + sizeof(struct LocalUser));
651    total_memory += local_client_memory_used;
652 <  sendto_one(source_p, ":%s %d %s z :Local client Memory in use: %d(%d)",
652 >  sendto_one(source_p, ":%s %d %s z :Local client Memory in use: %d(%llu)",
653               me.name, RPL_STATSDEBUG, source_p->name, local_client_count,
654               local_client_memory_used);
655  
656    remote_client_memory_used = remote_client_count * sizeof(struct Client);
657    total_memory += remote_client_memory_used;
658 <  sendto_one(source_p, ":%s %d %s z :Remote client Memory in use: %d(%d)",
658 >  sendto_one(source_p, ":%s %d %s z :Remote client Memory in use: %d(%llu)",
659               me.name, RPL_STATSDEBUG, source_p->name, remote_client_count,
660               remote_client_memory_used);
661  
662    block_heap_report_stats(source_p);
663  
664    sendto_one(source_p,
665 <             ":%s %d %s z :TOTAL: %d Available:  Current max RSS: %lu",
665 >             ":%s %d %s z :TOTAL: %llu",
666               me.name, RPL_STATSDEBUG, source_p->name,
667 <             (int)total_memory, get_maxrss());
667 >             total_memory);
668   }
669  
670   static void
# Line 869 | Line 877 | stats_glines(struct Client *source_p)
877  
878    for (; i < ATABLE_SIZE; ++i)
879    {
880 <    for (arec = atable[i]; arec; arec=arec->next)
880 >    for (arec = atable[i]; arec; arec = arec->next)
881      {
882        if (arec->type == CONF_GLINE)
883        {
# Line 1117 | Line 1125 | stats_usage(struct Client *source_p)
1125   static void
1126   stats_tstats(struct Client *source_p)
1127   {
1128 <  tstats(source_p);
1128 >  const struct Client *target_p = NULL;
1129 >  const dlink_node *ptr = NULL;
1130 >  struct ServerStatistics *sp;
1131 >  struct ServerStatistics tmp;
1132 >
1133 >  sp = &tmp;
1134 >  memcpy(sp, &ServerStats, sizeof(struct ServerStatistics));
1135 >
1136 >  /*
1137 >   * must use the += operator. is_sv is not the number of currently
1138 >   * active server connections. Note the incrementation in
1139 >   * s_bsd.c:close_connection.
1140 >   */
1141 >  sp->is_sv += dlink_list_length(&serv_list);
1142 >
1143 >  DLINK_FOREACH(ptr, serv_list.head)
1144 >  {
1145 >    target_p = ptr->data;
1146 >
1147 >    sp->is_sbs += target_p->localClient->send.bytes;
1148 >    sp->is_sbr += target_p->localClient->recv.bytes;
1149 >    sp->is_sti += CurrentTime - target_p->firsttime;
1150 >  }
1151 >
1152 >  sp->is_cl += dlink_list_length(&local_client_list);
1153 >
1154 >  DLINK_FOREACH(ptr, local_client_list.head)
1155 >  {
1156 >    target_p = ptr->data;
1157 >
1158 >    sp->is_cbs += target_p->localClient->send.bytes;
1159 >    sp->is_cbr += target_p->localClient->recv.bytes;
1160 >    sp->is_cti += CurrentTime - target_p->firsttime;
1161 >  }
1162 >
1163 >  sp->is_ni += dlink_list_length(&unknown_list);
1164 >
1165 >  sendto_one(source_p, ":%s %d %s T :accepts %u refused %u",
1166 >             me.name, RPL_STATSDEBUG, source_p->name, sp->is_ac, sp->is_ref);
1167 >  sendto_one(source_p, ":%s %d %s T :unknown commands %u prefixes %u",
1168 >             me.name, RPL_STATSDEBUG, source_p->name, sp->is_unco, sp->is_unpf);
1169 >  sendto_one(source_p, ":%s %d %s T :nick collisions %u unknown closes %u",
1170 >             me.name, RPL_STATSDEBUG, source_p->name, sp->is_kill, sp->is_ni);
1171 >  sendto_one(source_p, ":%s %d %s T :wrong direction %u empty %u",
1172 >             me.name, RPL_STATSDEBUG, source_p->name, sp->is_wrdi, sp->is_empt);
1173 >  sendto_one(source_p, ":%s %d %s T :numerics seen %u",
1174 >             me.name, RPL_STATSDEBUG, source_p->name, sp->is_num);
1175 >  sendto_one(source_p, ":%s %d %s T :auth successes %u fails %u",
1176 >             me.name, RPL_STATSDEBUG, source_p->name, sp->is_asuc, sp->is_abad);
1177 >  sendto_one(source_p, ":%s %d %s T :Client Server",
1178 >             me.name, RPL_STATSDEBUG, source_p->name);
1179 >
1180 >  sendto_one(source_p, ":%s %d %s T :connected %u %u",
1181 >             me.name, RPL_STATSDEBUG, source_p->name,
1182 >             (unsigned int)sp->is_cl,
1183 >             (unsigned int)sp->is_sv);
1184 >  sendto_one(source_p, ":%s %d %s T :bytes sent %llu %llu",
1185 >             me.name, RPL_STATSDEBUG, source_p->name,
1186 >             sp->is_cbs, sp->is_sbs);
1187 >  sendto_one(source_p, ":%s %d %s T :bytes recv %llu %llu",
1188 >             me.name, RPL_STATSDEBUG, source_p->name,
1189 >             sp->is_cbr, sp->is_sbr);
1190 >  sendto_one(source_p, ":%s %d %s T :time connected %u %u",
1191 >             me.name, RPL_STATSDEBUG, source_p->name,
1192 >             (unsigned int)sp->is_cti,
1193 >             (unsigned int)sp->is_sti);
1194   }
1195  
1196   static void
# Line 1189 | Line 1262 | stats_memory(struct Client *source_p)
1262   static void
1263   stats_ziplinks(struct Client *source_p)
1264   {
1265 <  dlink_node *ptr;
1193 <  struct Client *target_p;
1265 >  dlink_node *ptr = NULL;
1266    unsigned int sent_data = 0;
1267  
1268    DLINK_FOREACH(ptr, serv_list.head)
1269    {
1270 <    target_p = ptr->data;
1270 >    const struct Client *target_p = ptr->data;
1271  
1272      if (IsCapable(target_p, CAP_ZIP))
1273      {
# Line 1204 | Line 1276 | stats_ziplinks(struct Client *source_p)
1276         * -jmallett, 04/27/2002
1277         */
1278        struct ZipStats zipstats;
1279 <      memcpy(&zipstats, &target_p->localClient->zipstats, sizeof (struct ZipStats));
1279 >
1280 >      memcpy(&zipstats, &target_p->localClient->zipstats, sizeof(zipstats));
1281  
1282        sendto_one(source_p, ":%s %d %s Z :ZipLinks stats for %s send[%.2f%% "
1283 <                 "compression (%lu bytes data/%lu bytes wire)] recv[%.2f%% "
1284 <                 "compression (%lu bytes data/%lu bytes wire)]",
1283 >                 "compression (%llu bytes data/%llu bytes wire)] recv[%.2f%% "
1284 >                 "compression (%llu bytes data/%llu bytes wire)]",
1285                   from, RPL_STATSDEBUG, to, target_p->name,
1286                   zipstats.out_ratio, zipstats.out, zipstats.out_wire,
1287                   zipstats.in_ratio,  zipstats.in,  zipstats.in_wire);

Diff Legend

Removed lines
+ Added lines
< Changed lines (old)
> Changed lines (new)