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 34 by lusky, Sun Oct 2 21:05:51 2005 UTC vs.
ircd-hybrid-7.3/modules/m_stats.c (file contents), Revision 1144 by michael, Tue Jul 26 19:33:54 2011 UTC

# Line 23 | Line 23
23   */
24  
25   #include "stdinc.h"
26 < #include "tools.h"       /* dlink_node/dlink_list */
26 > #include "list.h"        /* dlink_node/dlink_list */
27 > #include "balloc.h"
28   #include "handlers.h"    /* m_pass prototype */
29   #include "client.h"      /* Client */
30   #include "common.h"      /* TRUE/FALSE */
# Line 41 | Line 42
42   #include "s_conf.h"      /* AccessItem, report_configured_links */
43   #include "s_misc.h"      /* serv_info */
44   #include "s_serv.h"      /* hunt_server */
44 #include "s_stats.h"     /* tstats */
45   #include "s_user.h"      /* show_opers */
46   #include "event.h"       /* events */
47   #include "dbuf.h"
48 + #include "hook.h"
49   #include "parse.h"
50   #include "modules.h"
50 #include "hook.h"
51   #include "resv.h"  /* report_resv */
52   #include "whowas.h"
53 < #include "list.h"
53 > #include "watch.h"
54  
55 < static void do_stats(struct Client *, int, char **);
55 > static void do_stats(struct Client *, int, char *[]);
56   static void m_stats(struct Client *, struct Client *, int, char *[]);
57   static void mo_stats(struct Client *, struct Client *, int, char *[]);
58   static void ms_stats(struct Client *, struct Client *, int, char *[]);
# Line 62 | Line 62 | struct Message stats_msgtab = {
62    { m_unregistered, m_stats, ms_stats, m_ignore, mo_stats, m_ignore }
63   };
64  
65 #ifndef STATIC_MODULES
65   const char *_version = "$Revision$";
67 static struct Callback *stats_cb;
68
69 static void *
70 va_stats(va_list args)
71 {
72  struct Client *source_p = va_arg(args, struct Client *);
73  int parc = va_arg(args, int);
74  char **parv = va_arg(args, char **);
75
76  do_stats(source_p, parc, parv);
77  return NULL;
78 }
66  
67   void
68   _modinit(void)
69   {
83  stats_cb = register_callback("doing_stats", va_stats);
70    mod_add_cmd(&stats_msgtab);
71   }
72  
# Line 88 | Line 74 | void
74   _moddeinit(void)
75   {
76    mod_del_cmd(&stats_msgtab);
91  uninstall_hook(stats_cb, va_stats);
77   }
93 #endif
78  
79   static char *parse_stats_args(int, char **, int *, int *);
80   static void stats_L(struct Client *, char *, int, int, char);
# Line 180 | Line 164 | static const struct StatsStruct
164    { 'z',        stats_memory,           1,      0,      },
165    { 'Z',        stats_ziplinks,         1,      0,      },
166    { '?',        stats_servlinks,        0,      0,      },
167 <  { '\0',       (void(*)())0,           0,      0,      }
167 >  { '\0',       NULL,                   0,      0,      }
168   };
169  
170   const char *from, *to;
171  
172   static void
173 < do_stats(struct Client *source_p, int parc, char **parv)
173 > do_stats(struct Client *source_p, int parc, char *parv[])
174   {
175 +  static const struct StatsStruct *tab = stats_cmd_table;
176    char statchar = *parv[1];
177    int i;
178  
# Line 198 | Line 183 | do_stats(struct Client *source_p, int pa
183      return;
184    }
185  
186 <  for (i = 0; stats_cmd_table[i].handler; i++)
186 >  for (; tab->handler; ++tab)
187    {
188 <    if (stats_cmd_table[i].letter == statchar)
188 >    if (tab->letter == statchar)
189      {
190        /* The stats table says what privs are needed, so check --fl_ */
191 <      if ((stats_cmd_table[i].need_admin && !IsAdmin(source_p)) ||
192 <          (stats_cmd_table[i].need_oper && !IsOper(source_p)))
191 >      if ((tab->need_admin && !IsAdmin(source_p)) ||
192 >          (tab->need_oper && !IsOper(source_p)))
193        {
194          sendto_one(source_p, form_str(ERR_NOPRIVILEGES),
195                     from, to);
# Line 213 | Line 198 | do_stats(struct Client *source_p, int pa
198  
199        /* Blah, stats L needs the parameters, none of the others do.. */
200        if (statchar == 'L' || statchar == 'l')
201 <        stats_cmd_table[i].handler(source_p, parc, parv);
201 >      {
202 >        sendto_realops_flags(UMODE_SPY, L_ALL,
203 >                             "STATS %c requested by %s (%s@%s) [%s] on %s",
204 >                             statchar, source_p->name, source_p->username,
205 >                             source_p->host, source_p->servptr->name,
206 >                             parc > 2 ? parv[2] : "<no recipient>");
207 >        tab->handler(source_p, parc, parv);
208 >      }
209        else
210 <        stats_cmd_table[i].handler(source_p);
210 >      {
211 >        sendto_realops_flags(UMODE_SPY, L_ALL,
212 >                             "STATS %c requested by %s (%s@%s) [%s]",
213 >                             statchar, source_p->name, source_p->username,
214 >                             source_p->host, source_p->servptr->name);
215 >        tab->handler(source_p);
216 >      }
217  
218        break;
219      }
# Line 242 | Line 240 | m_stats(struct Client *client_p, struct
240  
241    /* Is the stats meant for us? */
242    if (!ConfigFileEntry.disable_remote)
243 <    if (hunt_server(client_p,source_p,":%s STATS %s :%s",2,parc,parv) != HUNTED_ISME)
243 >    if (hunt_server(client_p, source_p, ":%s STATS %s :%s", 2,
244 >                    parc, parv) != HUNTED_ISME)
245        return;
246  
247    if (!MyClient(source_p) && IsCapable(source_p->from, CAP_TS6) && HasID(source_p))
# Line 263 | Line 262 | m_stats(struct Client *client_p, struct
262                 from, to);
263      return;
264    }
266  else
267    last_used = CurrentTime;
265  
266 < #ifdef STATIC_MODULES
266 >  last_used = CurrentTime;
267 >
268    do_stats(source_p, parc, parv);
271 #else
272  execute_callback(stats_cb, source_p, parc, parv);
273 #endif
269   }
270  
271   /*
# Line 301 | Line 296 | mo_stats(struct Client *client_p, struct
296      to = source_p->name;
297    }
298  
304 #ifdef STATIC_MODULES
299    do_stats(source_p, parc, parv);
306 #else
307  execute_callback(stats_cb, source_p, parc, parv);
308 #endif
300   }
301  
302   /*
# Line 318 | Line 309 | mo_stats(struct Client *client_p, struct
309   static void
310   send_usage(struct Client *source_p)
311   {
321 #ifndef _WIN32
312    struct rusage rus;
313    time_t secs;
314    time_t rup;
# Line 370 | Line 360 | send_usage(struct Client *source_p)
360    sendto_one(source_p, ":%s %d %s R :Signals %d Context Vol. %d Invol %d",
361               me.name, RPL_STATSDEBUG, source_p->name, (int)rus.ru_nsignals,
362               (int)rus.ru_nvcsw, (int)rus.ru_nivcsw);
373 #endif
363   }
364  
365   static void
# Line 379 | Line 368 | count_memory(struct Client *source_p)
368    const dlink_node *gptr = NULL;
369    const dlink_node *dlink = NULL;
370  
371 <  int local_client_conf_count = 0;      /* local client conf links */
372 <  int users_counted = 0;                /* user structs */
371 >  unsigned int local_client_conf_count = 0;      /* local client conf links */
372 >  unsigned int users_counted = 0;                /* user structs */
373  
374 <  int channel_users = 0; /* XXX */
375 <  int channel_invites = 0;
376 <  int channel_bans = 0;
377 <  int channel_except = 0;
378 <  int channel_invex = 0;
379 <
380 <  int wwu = 0;                  /* whowas users */
381 <  int class_count = 0;          /* classes */
382 <  int users_invited_count = 0;  /* users invited */
383 <  int aways_counted = 0;
384 <  int number_ips_stored;        /* number of ip addresses hashed */
385 <
386 <  unsigned long channel_memory = 0;
387 <  size_t channel_ban_memory = 0;
388 <  size_t channel_except_memory = 0;
400 <  size_t channel_invex_memory = 0;
374 >  unsigned int channel_members = 0;
375 >  unsigned int channel_invites = 0;
376 >  unsigned int channel_bans = 0;
377 >  unsigned int channel_except = 0;
378 >  unsigned int channel_invex = 0;
379 >
380 >  unsigned int wwu = 0;                  /* whowas users */
381 >  unsigned int class_count = 0;          /* classes */
382 >  unsigned int aways_counted = 0;
383 >  unsigned int number_ips_stored;        /* number of ip addresses hashed */
384 >
385 >  uint64_t channel_memory = 0;
386 >  uint64_t channel_ban_memory = 0;
387 >  uint64_t channel_except_memory = 0;
388 >  uint64_t channel_invex_memory = 0;
389  
390    unsigned int safelist_count = 0;
391 <  size_t safelist_memory = 0;
391 >  uint64_t safelist_memory = 0;
392 >
393 >  uint64_t away_memory = 0;       /* memory used by aways           */
394 >  uint64_t wwm = 0;               /* whowas array memory used       */
395 >  uint64_t conf_memory = 0;       /* memory used by conf lines      */
396 >  uint64_t mem_ips_stored;        /* memory used by ip address hash */
397  
398 <  unsigned long away_memory = 0;       /* memory used by aways           */
399 <  unsigned long wwm = 0;               /* whowas array memory used       */
407 <  unsigned long conf_memory = 0;       /* memory used by conf lines      */
408 <  unsigned long mem_ips_stored;        /* memory used by ip address hash */
409 <
410 <  unsigned long client_hash_table_size = 0;
411 <  unsigned long channel_hash_table_size = 0;
412 <  unsigned long resv_hash_table_size = 0;
413 <  unsigned long id_hash_table_size = 0;
414 <  unsigned long total_channel_memory = 0;
415 <  unsigned long totww = 0;
398 >  uint64_t total_channel_memory = 0;
399 >  uint64_t totww = 0;
400  
401    unsigned int local_client_count  = 0;
402    unsigned int remote_client_count = 0;
403  
404 <  unsigned int local_client_memory_used  = 0;
405 <  unsigned int remote_client_memory_used = 0;
404 >  uint64_t local_client_memory_used  = 0;
405 >  uint64_t remote_client_memory_used = 0;
406  
407 <  unsigned long total_memory = 0;
407 >  uint64_t total_memory = 0;
408    unsigned int topic_count = 0;
409  
410 <  count_whowas_memory(&wwu, &wwm);
410 >  unsigned int watch_list_headers = 0;   /* watchlist headers     */
411 >  unsigned int watch_list_entries = 0;   /* watchlist entries     */
412 >  uint64_t watch_list_memory = 0; /* watchlist memory used */
413 >
414  
415    DLINK_FOREACH(gptr, global_client_list.head)
416    {
# Line 433 | Line 420 | count_memory(struct Client *source_p)
420      {
421        ++local_client_count;
422        local_client_conf_count += dlink_list_length(&target_p->localClient->confs);
423 +      watch_list_entries += dlink_list_length(&target_p->localClient->watches);
424      }
425      else
426        ++remote_client_count;
# Line 440 | Line 428 | count_memory(struct Client *source_p)
428      if (IsClient(target_p))
429      {
430        ++users_counted;
443      users_invited_count += dlink_list_length(&target_p->invited);
431  
432        if (target_p->away != NULL)
433        {
# Line 455 | Line 442 | count_memory(struct Client *source_p)
442                     sizeof(struct Channel);
443    DLINK_FOREACH(gptr, global_channel_list.head)
444    {
445 <    struct Ban *actualBan;
446 <    struct Channel *chptr = gptr->data;
445 >    const struct Ban *actualBan;
446 >    const struct Channel *chptr = gptr->data;
447  
448 <    channel_users   += dlink_list_length(&chptr->members);
448 >    channel_members += dlink_list_length(&chptr->members);
449      channel_invites += dlink_list_length(&chptr->invites);
450  
451      if (chptr->topic != NULL)
452        ++topic_count;
453  
454 <    if ((channel_bans = dlink_list_length(&chptr->banlist)))
455 <    {
469 <      channel_ban_memory = channel_bans * sizeof(struct Ban);
454 >    channel_bans += dlink_list_length(&chptr->banlist);
455 >    channel_ban_memory += dlink_list_length(&chptr->banlist) * sizeof(struct Ban);
456  
457 <      DLINK_FOREACH(dlink, chptr->banlist.head)
458 <      {
459 <        actualBan = dlink->data;
460 <        assert(actualBan->who);
457 >    DLINK_FOREACH(dlink, chptr->banlist.head)
458 >    {
459 >      actualBan = dlink->data;
460 >      assert(actualBan->who);
461  
462 <        channel_ban_memory += actualBan->len + 3;
463 <        channel_ban_memory += strlen(actualBan->who) + 1;
478 <      }
462 >      channel_ban_memory += actualBan->len + 1;
463 >      channel_ban_memory += strlen(actualBan->who) + 1;
464      }
465  
466 <    if ((channel_except = dlink_list_length(&chptr->exceptlist)))
467 <    {
483 <      channel_except_memory = channel_except * sizeof(struct Ban);
466 >    channel_except += dlink_list_length(&chptr->exceptlist);
467 >    channel_except_memory += dlink_list_length(&chptr->exceptlist) * sizeof(struct Ban);
468  
469 <      DLINK_FOREACH(dlink, chptr->exceptlist.head)
470 <      {
471 <        actualBan = dlink->data;
472 <        assert(actualBan->who);
469 >    DLINK_FOREACH(dlink, chptr->exceptlist.head)
470 >    {
471 >      actualBan = dlink->data;
472 >      assert(actualBan->who);
473  
474 <        channel_except_memory += actualBan->len + 3;
475 <        channel_except_memory += strlen(actualBan->who) + 1;
492 <      }
474 >      channel_except_memory += actualBan->len + 1;
475 >      channel_except_memory += strlen(actualBan->who) + 1;
476      }
477  
478 <    if ((channel_invex = dlink_list_length(&chptr->invexlist)))
479 <    {
497 <      channel_invex_memory = channel_invex * sizeof(struct Ban);
478 >    channel_invex += dlink_list_length(&chptr->invexlist);
479 >    channel_invex_memory += dlink_list_length(&chptr->invexlist) * sizeof(struct Ban);
480  
481 <      DLINK_FOREACH(dlink, chptr->invexlist.head)
482 <      {
483 <        actualBan = dlink->data;
484 <        assert(actualBan->who);
481 >    DLINK_FOREACH(dlink, chptr->invexlist.head)
482 >    {
483 >      actualBan = dlink->data;
484 >      assert(actualBan->who);
485  
486 <        channel_invex_memory += actualBan->len + 3;
487 <        channel_invex_memory += strlen(actualBan->who) + 1;
506 <      }
486 >      channel_invex_memory += actualBan->len + 1;
487 >      channel_invex_memory += strlen(actualBan->who) + 1;
488      }
489    }
490  
# Line 512 | Line 493 | count_memory(struct Client *source_p)
493      safelist_memory = safelist_count * sizeof(struct ListTask);
494      DLINK_FOREACH(gptr, listing_client_list.head)
495      {
496 <      struct Client *acptr = gptr->data;
496 >      const struct Client *acptr = gptr->data;
497  
498        DLINK_FOREACH(dlink, acptr->localClient->list_task->show_mask.head)
499          safelist_memory += strlen(dlink->data);
# Line 537 | Line 518 | count_memory(struct Client *source_p)
518    /* count up all classes */
519    class_count = dlink_list_length(&class_items);
520  
521 <  sendto_one(source_p, ":%s %d %s z :Clients %u(%lu) Invites %u(%lu)",
521 >  count_whowas_memory(&wwu, &wwm);
522 >  watch_count_memory(&watch_list_headers, &watch_list_memory);
523 >
524 >  sendto_one(source_p, ":%s %d %s z :WATCH headers %u(%u) entries %d(%u)",
525 >             me.name, RPL_STATSDEBUG, source_p->name, watch_list_headers,
526 >             watch_list_memory, watch_list_entries,
527 >             watch_list_entries * sizeof(dlink_node) * 2);
528 >
529 >  sendto_one(source_p, ":%s %d %s z :Clients %u(%u)",
530               me.name, RPL_STATSDEBUG, source_p->name, users_counted,
531 <             (unsigned long)(users_counted * sizeof(struct Client)),
543 <             users_invited_count, (unsigned long)(users_invited_count * sizeof(dlink_node)));
531 >             (users_counted * sizeof(struct Client)));
532  
533 <  sendto_one(source_p, ":%s %d %s z :User aways %u(%d)",
533 >  sendto_one(source_p, ":%s %d %s z :User aways %u(%llu)",
534               me.name, RPL_STATSDEBUG, source_p->name,
535 <             aways_counted, (int)away_memory);
535 >             aways_counted, away_memory);
536  
537 <  sendto_one(source_p, ":%s %d %s z :Attached confs %u(%lu)",
537 >  sendto_one(source_p, ":%s %d %s z :Attached confs %u(%llu)",
538               me.name, RPL_STATSDEBUG, source_p->name,
539               local_client_conf_count,
540 <             (unsigned long)(local_client_conf_count * sizeof(dlink_node)));
553 <
554 <  /* XXX  ConfigItemList fix */
555 < #if 0
556 <  sendto_one(source_p, ":%s %d %s z :Conflines %lu(%d)",
557 <             me.name, RPL_STATSDEBUG, source_p->name,
558 <             dlink_list_length(&ConfigItemList), (int) conf_memory);
559 < #endif
540 >             (unsigned long long)(local_client_conf_count * sizeof(dlink_node)));
541  
542 <  sendto_one(source_p, ":%s %d %s z :Resv channels %lu(%lu) nicks %lu(%lu)",
542 >  sendto_one(source_p, ":%s %d %s z :Resv channels %u(%lu) nicks %u(%lu)",
543               me.name, RPL_STATSDEBUG, source_p->name,
544               dlink_list_length(&resv_channel_list),
545               dlink_list_length(&resv_channel_list) * sizeof(struct ResvChannel),
546               dlink_list_length(&nresv_items),
547               dlink_list_length(&nresv_items) * sizeof(struct MatchItem));
548  
549 <  sendto_one(source_p, ":%s %d %s z :Classes %u(%lu)",
549 >  sendto_one(source_p, ":%s %d %s z :Classes %u(%llu)",
550               me.name, RPL_STATSDEBUG, source_p->name,
551 <             class_count, (unsigned long)(class_count * sizeof(struct ClassItem)));
551 >             class_count, (unsigned long long)(class_count * sizeof(struct ClassItem)));
552  
553 <  sendto_one(source_p, ":%s %d %s z :Channels %lu(%lu) Topics %u(%d)",
553 >  sendto_one(source_p, ":%s %d %s z :Channels %uu(%llu) Topics %u(%u)",
554               me.name, RPL_STATSDEBUG, source_p->name,
555               dlink_list_length(&global_channel_list),
556               channel_memory, topic_count, topic_count *
557               (TOPICLEN + 1 + USERHOST_REPLYLEN));
558  
559 <  sendto_one(source_p, ":%s %d %s z :Bans %u(%u)",
559 >  sendto_one(source_p, ":%s %d %s z :Bans %u(%llu)",
560               me.name, RPL_STATSDEBUG, source_p->name,
561               channel_bans, channel_ban_memory);
562  
563 <  sendto_one(source_p, ":%s %d %s z :Exceptions %u(%u)",
563 >  sendto_one(source_p, ":%s %d %s z :Exceptions %u(%llu)",
564               me.name, RPL_STATSDEBUG, source_p->name,
565               channel_except, channel_except_memory);
566  
567 <  sendto_one(source_p, ":%s %d %s z :Invex %u(%u)",
567 >  sendto_one(source_p, ":%s %d %s z :Invex %u(%llu)",
568               me.name, RPL_STATSDEBUG, source_p->name,
569               channel_invex, channel_invex_memory);
570  
571 <  sendto_one(source_p, ":%s %d %s z :Channel members %u(%lu) invite %u(%lu)",
572 <             me.name, RPL_STATSDEBUG, source_p->name, channel_users,
573 <             (unsigned long)(channel_users * sizeof(struct Membership)),
574 <             channel_invites, (unsigned long)channel_invites *
575 <             sizeof(dlink_node));
571 >  sendto_one(source_p, ":%s %d %s z :Channel members %u(%llu) invites %u(%llu)",
572 >             me.name, RPL_STATSDEBUG, source_p->name, channel_members,
573 >             (unsigned long long)(channel_members * sizeof(struct Membership)),
574 >             channel_invites, (unsigned long long)channel_invites *
575 >             sizeof(dlink_node) * 2);
576  
577    total_channel_memory = channel_memory + channel_ban_memory +
578 <                         channel_users * sizeof(struct Membership) +
579 <                         channel_invites * sizeof(dlink_node);
578 >                         channel_members * sizeof(struct Membership) +
579 >                         (channel_invites * sizeof(dlink_node)*2);
580  
581 <  sendto_one(source_p, ":%s %d %s z :Safelist %u(%u)",
581 >  sendto_one(source_p, ":%s %d %s z :Safelist %u(%llu)",
582               me.name, RPL_STATSDEBUG, source_p->name,
583               safelist_count, safelist_memory);
584  
585 <  sendto_one(source_p, ":%s %d %s z :Whowas users %u(%lu)",
585 >  sendto_one(source_p, ":%s %d %s z :Whowas users %u(%llu)",
586               me.name, RPL_STATSDEBUG, source_p->name,
587 <             wwu, (unsigned long)(wwu * sizeof(struct Client)));
587 >             wwu, (unsigned long long)(wwu * sizeof(struct Client)));
588  
589 <  sendto_one(source_p, ":%s %d %s z :Whowas array %u(%d)",
589 >  sendto_one(source_p, ":%s %d %s z :Whowas array %u(%llu)",
590               me.name, RPL_STATSDEBUG, source_p->name,
591 <             NICKNAMEHISTORYLENGTH, (int)wwm);
591 >             NICKNAMEHISTORYLENGTH, wwm);
592  
593    totww = wwu * sizeof(struct Client) + wwm;
613 /****
614  client_hash_table_size  = hash_get_client_table_size();
615  channel_hash_table_size = hash_get_channel_table_size();
616  resv_hash_table_size    = hash_get_resv_table_size();
617  id_hash_table_size      = hash_get_id_table_size();
594  
619  sendto_one(source_p, ":%s %d %s z :Hash: client %u(%lu) chan %u(%lu) resv "
620             "%u(%lu) id %u(%lu)",
621             me.name, RPL_STATSDEBUG, source_p->name,
622             U_MAX, client_hash_table_size,
623             CH_MAX, channel_hash_table_size , R_MAX,
624             resv_hash_table_size, U_MAX, id_hash_table_size);
625 ****/
595    count_ip_hash(&number_ips_stored,&mem_ips_stored);
596 <  sendto_one(source_p, ":%s %d %s z :iphash %u(%d)",
596 >  sendto_one(source_p, ":%s %d %s z :iphash %u(%llu)",
597               me.name, RPL_STATSDEBUG, source_p->name,
598 <             number_ips_stored, (int)mem_ips_stored);
598 >             number_ips_stored, mem_ips_stored);
599  
600    total_memory = totww + total_channel_memory + conf_memory + class_count *
601                   sizeof(struct ClassItem);
602 <  total_memory += client_hash_table_size;
603 <  total_memory += channel_hash_table_size;
604 <  total_memory += resv_hash_table_size;
636 <  total_memory += id_hash_table_size;
637 <
638 <  sendto_one(source_p, ":%s %d %s z :Total: whowas %d channel %d conf %d",
639 <             me.name, RPL_STATSDEBUG, source_p->name, (int)totww,
640 <            (int)total_channel_memory, (int)conf_memory);
602 >  sendto_one(source_p, ":%s %d %s z :Total: whowas %llu channel %llu conf %llu",
603 >             me.name, RPL_STATSDEBUG, source_p->name, totww,
604 >             total_channel_memory, conf_memory);
605  
606    local_client_memory_used = local_client_count*(sizeof(struct Client) + sizeof(struct LocalUser));
607    total_memory += local_client_memory_used;
608 <  sendto_one(source_p, ":%s %d %s z :Local client Memory in use: %d(%d)",
608 >  sendto_one(source_p, ":%s %d %s z :Local client Memory in use: %u(%llu)",
609               me.name, RPL_STATSDEBUG, source_p->name, local_client_count,
610               local_client_memory_used);
611  
612    remote_client_memory_used = remote_client_count * sizeof(struct Client);
613    total_memory += remote_client_memory_used;
614 <  sendto_one(source_p, ":%s %d %s z :Remote client Memory in use: %d(%d)",
614 >  sendto_one(source_p, ":%s %d %s z :Remote client Memory in use: %u(%llu)",
615               me.name, RPL_STATSDEBUG, source_p->name, remote_client_count,
616               remote_client_memory_used);
617  
618    block_heap_report_stats(source_p);
619  
620    sendto_one(source_p,
621 <             ":%s %d %s z :TOTAL: %d Available:  Current max RSS: %lu",
621 >             ":%s %d %s z :TOTAL: %llu",
622               me.name, RPL_STATSDEBUG, source_p->name,
623 <             (int)total_memory, get_maxrss());
623 >             total_memory);
624   }
625  
626   static void
# Line 757 | Line 721 | stats_exempt(struct Client *source_p)
721    struct AccessItem *aconf;
722    int i;
723  
724 +  if (ConfigFileEntry.stats_e_disabled)
725 +  {
726 +    sendto_one(source_p, form_str(ERR_NOPRIVILEGES),
727 +               from, to);
728 +    return;
729 +  }
730 +
731    for (i = 0; i < ATABLE_SIZE; i++)
732    {
733      for (arec = atable[i]; arec; arec=arec->next)
# Line 790 | Line 761 | stats_events(struct Client *source_p)
761   static void
762   stats_pending_glines(struct Client *source_p)
763   {
764 < #ifdef GLINE_VOTING
765 <  dlink_node *pending_node;
766 <  struct gline_pending *glp_ptr;
767 <  char timebuffer[MAX_DATE_STRING];
797 <  struct tm *tmptr;
764 >  const dlink_node *dn_ptr = NULL;
765 >  const struct gline_pending *glp_ptr = NULL;
766 >  char timebuffer[MAX_DATE_STRING] = { '\0' };
767 >  struct tm *tmptr = NULL;
768  
769    if (!ConfigFileEntry.glines)
770    {
# Line 803 | Line 773 | stats_pending_glines(struct Client *sour
773      return;
774    }
775  
776 <  if (dlink_list_length(&pending_glines) > 0)
776 >  if (dlink_list_length(&pending_glines[GLINE_PENDING_ADD_TYPE]) > 0)
777      sendto_one(source_p, ":%s NOTICE %s :Pending G-lines",
778                 from, to);
779  
780 <  DLINK_FOREACH(pending_node, pending_glines.head)
780 >  DLINK_FOREACH(dn_ptr, pending_glines[GLINE_PENDING_ADD_TYPE].head)
781    {
782 <    glp_ptr = pending_node->data;
783 <    tmptr   = localtime(&glp_ptr->time_request1);
782 >    glp_ptr = dn_ptr->data;
783 >    tmptr   = localtime(&glp_ptr->vote_1.time_request);
784      strftime(timebuffer, MAX_DATE_STRING, "%Y/%m/%d %H:%M:%S", tmptr);
785  
786      sendto_one(source_p,
787                 ":%s NOTICE %s :1) %s!%s@%s on %s requested gline at %s for %s@%s [%s]",
788 <               from, to, glp_ptr->oper_nick1,
789 <               glp_ptr->oper_user1, glp_ptr->oper_host1,
790 <               glp_ptr->oper_server1, timebuffer,
791 <               glp_ptr->user, glp_ptr->host, glp_ptr->reason1);
788 >               from, to, glp_ptr->vote_1.oper_nick,
789 >               glp_ptr->vote_1.oper_user, glp_ptr->vote_1.oper_host,
790 >               glp_ptr->vote_1.oper_server, timebuffer,
791 >               glp_ptr->user, glp_ptr->host, glp_ptr->vote_1.reason);
792  
793 <    if (glp_ptr->oper_nick2[0] != '\0')
793 >    if (glp_ptr->vote_2.oper_nick[0] != '\0')
794      {
795 <      tmptr = localtime(&glp_ptr->time_request2);
795 >      tmptr = localtime(&glp_ptr->vote_2.time_request);
796        strftime(timebuffer, MAX_DATE_STRING, "%Y/%m/%d %H:%M:%S", tmptr);
797        sendto_one(source_p,
798        ":%s NOTICE %s :2) %s!%s@%s on %s requested gline at %s for %s@%s [%s]",
799 <                 from, to, glp_ptr->oper_nick2,
800 <                 glp_ptr->oper_user2, glp_ptr->oper_host2,
801 <                 glp_ptr->oper_server2, timebuffer,
802 <                 glp_ptr->user, glp_ptr->host, glp_ptr->reason2);
799 >               from, to, glp_ptr->vote_2.oper_nick,
800 >               glp_ptr->vote_2.oper_user, glp_ptr->vote_2.oper_host,
801 >               glp_ptr->vote_2.oper_server, timebuffer,
802 >               glp_ptr->user, glp_ptr->host, glp_ptr->vote_2.reason);
803      }
804    }
805  
806    sendto_one(source_p, ":%s NOTICE %s :End of Pending G-lines",
807               from, to);
808 < #else
809 <  sendto_one(source_p, ":%s NOTICE %s :This server does not support G-Line voting",
808 >
809 >  if (dlink_list_length(&pending_glines[GLINE_PENDING_DEL_TYPE]) > 0)
810 >    sendto_one(source_p, ":%s NOTICE %s :Pending UNG-lines",
811 >               from, to);
812 >
813 >  DLINK_FOREACH(dn_ptr, pending_glines[GLINE_PENDING_DEL_TYPE].head)
814 >  {
815 >    glp_ptr = dn_ptr->data;
816 >    tmptr   = localtime(&glp_ptr->vote_1.time_request);
817 >    strftime(timebuffer, MAX_DATE_STRING, "%Y/%m/%d %H:%M:%S", tmptr);
818 >
819 >    sendto_one(source_p,
820 >               ":%s NOTICE %s :1) %s!%s@%s on %s requested ungline at %s for %s@%s [%s]",
821 >               from, to, glp_ptr->vote_1.oper_nick,
822 >               glp_ptr->vote_1.oper_user, glp_ptr->vote_1.oper_host,
823 >               glp_ptr->vote_1.oper_server, timebuffer,
824 >               glp_ptr->user, glp_ptr->host, glp_ptr->vote_1.reason);
825 >
826 >    if (glp_ptr->vote_2.oper_nick[0] != '\0')
827 >    {
828 >      tmptr = localtime(&glp_ptr->vote_2.time_request);
829 >      strftime(timebuffer, MAX_DATE_STRING, "%Y/%m/%d %H:%M:%S", tmptr);
830 >      sendto_one(source_p,
831 >      ":%s NOTICE %s :2) %s!%s@%s on %s requested ungline at %s for %s@%s [%s]",
832 >               from, to, glp_ptr->vote_2.oper_nick,
833 >               glp_ptr->vote_2.oper_user, glp_ptr->vote_2.oper_host,
834 >               glp_ptr->vote_2.oper_server, timebuffer,
835 >               glp_ptr->user, glp_ptr->host, glp_ptr->vote_2.reason);
836 >
837 >    }
838 >  }
839 >
840 >  sendto_one(source_p, ":%s NOTICE %s :End of Pending UNG-lines",
841               from, to);
841 #endif /* GLINE VOTING */
842   }
843  
844   /* stats_glines()
# Line 862 | Line 862 | stats_glines(struct Client *source_p)
862  
863    for (; i < ATABLE_SIZE; ++i)
864    {
865 <    for (arec = atable[i]; arec; arec=arec->next)
865 >    for (arec = atable[i]; arec; arec = arec->next)
866      {
867        if (arec->type == CONF_GLINE)
868        {
# Line 1002 | Line 1002 | stats_klines(struct Client *source_p)
1002      struct AccessItem *aconf;
1003  
1004      /* search for a kline */
1005 <    if(MyConnect(source_p))
1005 >    if (MyConnect(source_p))
1006        aconf = find_conf_by_address(source_p->host,
1007                                     &source_p->localClient->ip,
1008                                     CONF_KILL,
# Line 1012 | Line 1012 | stats_klines(struct Client *source_p)
1012        aconf = find_conf_by_address(source_p->host, NULL, CONF_KILL,
1013                                     0, source_p->username, NULL);
1014  
1015 <    if(aconf == NULL)
1015 >    if (aconf == NULL)
1016        return;
1017  
1018      /* dont report a tkline as a kline */
1019 <    if(aconf->flags & CONF_FLAGS_TEMPORARY)
1019 >    if (aconf->flags & CONF_FLAGS_TEMPORARY)
1020        return;
1021        
1022      sendto_one(source_p, form_str(RPL_STATSKLINE), from,
# Line 1110 | Line 1110 | stats_usage(struct Client *source_p)
1110   static void
1111   stats_tstats(struct Client *source_p)
1112   {
1113 <  tstats(source_p);
1113 >  const struct Client *target_p = NULL;
1114 >  const dlink_node *ptr = NULL;
1115 >  struct ServerStatistics *sp;
1116 >  struct ServerStatistics tmp;
1117 >
1118 >  sp = &tmp;
1119 >  memcpy(sp, &ServerStats, sizeof(struct ServerStatistics));
1120 >
1121 >  /*
1122 >   * must use the += operator. is_sv is not the number of currently
1123 >   * active server connections. Note the incrementation in
1124 >   * s_bsd.c:close_connection.
1125 >   */
1126 >  sp->is_sv += dlink_list_length(&serv_list);
1127 >
1128 >  DLINK_FOREACH(ptr, serv_list.head)
1129 >  {
1130 >    target_p = ptr->data;
1131 >
1132 >    sp->is_sbs += target_p->localClient->send.bytes;
1133 >    sp->is_sbr += target_p->localClient->recv.bytes;
1134 >    sp->is_sti += CurrentTime - target_p->firsttime;
1135 >  }
1136 >
1137 >  sp->is_cl += dlink_list_length(&local_client_list);
1138 >
1139 >  DLINK_FOREACH(ptr, local_client_list.head)
1140 >  {
1141 >    target_p = ptr->data;
1142 >
1143 >    sp->is_cbs += target_p->localClient->send.bytes;
1144 >    sp->is_cbr += target_p->localClient->recv.bytes;
1145 >    sp->is_cti += CurrentTime - target_p->firsttime;
1146 >  }
1147 >
1148 >  sp->is_ni += dlink_list_length(&unknown_list);
1149 >
1150 >  sendto_one(source_p, ":%s %d %s T :accepts %u refused %u",
1151 >             me.name, RPL_STATSDEBUG, source_p->name, sp->is_ac, sp->is_ref);
1152 >  sendto_one(source_p, ":%s %d %s T :unknown commands %u prefixes %u",
1153 >             me.name, RPL_STATSDEBUG, source_p->name, sp->is_unco, sp->is_unpf);
1154 >  sendto_one(source_p, ":%s %d %s T :nick collisions %u unknown closes %u",
1155 >             me.name, RPL_STATSDEBUG, source_p->name, sp->is_kill, sp->is_ni);
1156 >  sendto_one(source_p, ":%s %d %s T :wrong direction %u empty %u",
1157 >             me.name, RPL_STATSDEBUG, source_p->name, sp->is_wrdi, sp->is_empt);
1158 >  sendto_one(source_p, ":%s %d %s T :numerics seen %u",
1159 >             me.name, RPL_STATSDEBUG, source_p->name, sp->is_num);
1160 >  sendto_one(source_p, ":%s %d %s T :auth successes %u fails %u",
1161 >             me.name, RPL_STATSDEBUG, source_p->name, sp->is_asuc, sp->is_abad);
1162 >  sendto_one(source_p, ":%s %d %s T :Client Server",
1163 >             me.name, RPL_STATSDEBUG, source_p->name);
1164 >
1165 >  sendto_one(source_p, ":%s %d %s T :connected %u %u",
1166 >             me.name, RPL_STATSDEBUG, source_p->name,
1167 >             (unsigned int)sp->is_cl,
1168 >             (unsigned int)sp->is_sv);
1169 >  sendto_one(source_p, ":%s %d %s T :bytes sent %llu %llu",
1170 >             me.name, RPL_STATSDEBUG, source_p->name,
1171 >             sp->is_cbs, sp->is_sbs);
1172 >  sendto_one(source_p, ":%s %d %s T :bytes recv %llu %llu",
1173 >             me.name, RPL_STATSDEBUG, source_p->name,
1174 >             sp->is_cbr, sp->is_sbr);
1175 >  sendto_one(source_p, ":%s %d %s T :time connected %u %u",
1176 >             me.name, RPL_STATSDEBUG, source_p->name,
1177 >             (unsigned int)sp->is_cti,
1178 >             (unsigned int)sp->is_sti);
1179   }
1180  
1181   static void
# Line 1139 | Line 1204 | stats_shared(struct Client *source_p)
1204   static void
1205   stats_servers(struct Client *source_p)
1206   {
1207 <  struct Client *target_p;
1143 <  dlink_node *ptr;
1144 <  int j = 0;
1207 >  dlink_node *ptr = NULL;
1208  
1209    DLINK_FOREACH(ptr, serv_list.head)
1210    {
1211 <    target_p = ptr->data;
1149 <
1150 <    j++;
1211 >    const struct Client *target_p = ptr->data;
1212  
1213      sendto_one(source_p, ":%s %d %s v :%s (%s!%s@%s) Idle: %d",
1214 <               from, RPL_STATSDEBUG, to,
1215 <               target_p->name,
1216 <               (target_p->serv->by[0] ? target_p->serv->by : "Remote."),
1156 <               "*", "*", (int)(CurrentTime - target_p->lasttime));
1214 >               from, RPL_STATSDEBUG, to, target_p->name,
1215 >               (target_p->serv->by[0] ? target_p->serv->by : "Remote."),
1216 >               "*", "*", (int)(CurrentTime - target_p->lasttime));
1217    }
1218  
1219 <  sendto_one(source_p, ":%s %d %s v :%d Server(s)",
1220 <             from, RPL_STATSDEBUG, to, j);
1219 >  sendto_one(source_p, ":%s %d %s v :%u Server(s)",
1220 >             from, RPL_STATSDEBUG, to, dlink_list_length(&serv_list));
1221   }
1222  
1223   static void
# Line 1182 | Line 1242 | stats_memory(struct Client *source_p)
1242   static void
1243   stats_ziplinks(struct Client *source_p)
1244   {
1245 <  dlink_node *ptr;
1186 <  struct Client *target_p;
1245 >  dlink_node *ptr = NULL;
1246    unsigned int sent_data = 0;
1247  
1248    DLINK_FOREACH(ptr, serv_list.head)
1249    {
1250 <    target_p = ptr->data;
1250 >    const struct Client *target_p = ptr->data;
1251  
1252      if (IsCapable(target_p, CAP_ZIP))
1253      {
# Line 1197 | Line 1256 | stats_ziplinks(struct Client *source_p)
1256         * -jmallett, 04/27/2002
1257         */
1258        struct ZipStats zipstats;
1259 <      memcpy(&zipstats, &target_p->localClient->zipstats, sizeof (struct ZipStats));
1259 >
1260 >      memcpy(&zipstats, &target_p->localClient->zipstats, sizeof(zipstats));
1261  
1262        sendto_one(source_p, ":%s %d %s Z :ZipLinks stats for %s send[%.2f%% "
1263 <                 "compression (%lu bytes data/%lu bytes wire)] recv[%.2f%% "
1264 <                 "compression (%lu bytes data/%lu bytes wire)]",
1263 >                 "compression (%llu bytes data/%llu bytes wire)] recv[%.2f%% "
1264 >                 "compression (%llu bytes data/%llu bytes wire)]",
1265                   from, RPL_STATSDEBUG, to, target_p->name,
1266 <                 zipstats.out_ratio, zipstats.out, zipstats.out_wire,
1267 <                 zipstats.in_ratio,  zipstats.in,  zipstats.in_wire);
1266 >                 zipstats.out_ratio, zipstats.out, zipstats.out_wire,
1267 >                 zipstats.in_ratio,  zipstats.in,  zipstats.in_wire);
1268        ++sent_data;
1269      }
1270    }
# Line 1218 | Line 1278 | stats_servlinks(struct Client *source_p)
1278   {
1279    uint64_t sendB = 0, recvB = 0;
1280    time_t uptime = 0;
1281 <  int j = 0;
1222 <  struct Client *target_p = NULL;
1223 <  dlink_node *ptr;
1281 >  dlink_node *ptr = NULL;
1282  
1283    if (ConfigServerHide.flatten_links && !IsOper(source_p))
1284    {
# Line 1231 | Line 1289 | stats_servlinks(struct Client *source_p)
1289  
1290    DLINK_FOREACH(ptr, serv_list.head)
1291    {
1292 <    target_p = ptr->data;
1292 >    struct Client *target_p = ptr->data;
1293  
1236    ++j;
1294      sendB += target_p->localClient->send.bytes;
1295      recvB += target_p->localClient->recv.bytes;
1296  
# Line 1255 | Line 1312 | stats_servlinks(struct Client *source_p)
1312    recvB >>= 10;
1313  
1314    sendto_one(source_p, ":%s %d %s ? :%u total server(s)",
1315 <             from, RPL_STATSDEBUG, to, j);
1315 >             from, RPL_STATSDEBUG, to, dlink_list_length(&serv_list));
1316    sendto_one(source_p, ":%s %d %s ? :Sent total : %7.2f %s",
1317               from, RPL_STATSDEBUG, to,
1318 <             _GMKv((signed)sendB), _GMKs((signed)sendB));
1318 >             _GMKv(sendB), _GMKs(sendB));
1319    sendto_one(source_p, ":%s %d %s ? :Recv total : %7.2f %s",
1320               from, RPL_STATSDEBUG, to,
1321 <             _GMKv((signed)recvB), _GMKs((signed)recvB));
1321 >             _GMKv(recvB), _GMKs(recvB));
1322  
1323    uptime = (CurrentTime - me.since);
1324  
1325    sendto_one(source_p, ":%s %d %s ? :Server send: %7.2f %s (%4.1f K/s)",
1326               from, RPL_STATSDEBUG, to,
1327 <             _GMKv((signed)(me.localClient->send.bytes>>10)),
1328 <             _GMKs((signed)(me.localClient->send.bytes>>10)),
1329 <             (float)((float)(((signed)me.localClient->send.bytes) >> 10) /
1330 <             (float)uptime));
1327 >             _GMKv((me.localClient->send.bytes>>10)),
1328 >             _GMKs((me.localClient->send.bytes>>10)),
1329 >             (float)((float)((me.localClient->send.bytes) >> 10) /
1330 >             (float)uptime));
1331    sendto_one(source_p, ":%s %d %s ? :Server recv: %7.2f %s (%4.1f K/s)",
1332               from, RPL_STATSDEBUG, to,
1333 <             _GMKv((signed)(me.localClient->recv.bytes>>10)),
1334 <             _GMKs((signed)(me.localClient->recv.bytes>>10)),
1335 <             (float)((float)(((signed)me.localClient->recv.bytes) >> 10) /
1336 <             (float)uptime));
1333 >             _GMKv((me.localClient->recv.bytes>>10)),
1334 >             _GMKs((me.localClient->recv.bytes>>10)),
1335 >             (float)((float)((me.localClient->recv.bytes) >> 10) /
1336 >             (float)uptime));
1337   }
1338  
1339   static void

Diff Legend

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