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

Comparing:
ircd-hybrid/modules/m_stats.c (file contents), Revision 30 by adx, Sun Oct 2 20:03:27 2005 UTC vs.
ircd-hybrid-8/modules/m_stats.c (file contents), Revision 1241 by michael, Thu Sep 29 20:26:09 2011 UTC

# Line 19 | Line 19
19   *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307
20   *  USA
21   *
22 < *  $Id: m_stats.c,v 1.190 2005/09/27 12:43:33 adx Exp $
22 > *  $Id$
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"
54 <
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 *[]);
59 <
60 < struct Message stats_msgtab = {
61 <  "STATS", 0, 0, 2, 0, MFLG_SLOW, 0,
62 <  { m_unregistered, m_stats, ms_stats, m_ignore, mo_stats, m_ignore }
63 < };
53 > #include "watch.h"
54  
65 – #ifndef STATIC_MODULES
66 – const char *_version = "$Revision: 1.190 $";
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 – }
79 –
80 – void
81 – _modinit(void)
82 – {
83 –  stats_cb = register_callback("doing_stats", va_stats);
84 –  mod_add_cmd(&stats_msgtab);
85 – }
86 –
87 – void
88 – _moddeinit(void)
89 – {
90 –  mod_del_cmd(&stats_msgtab);
91 –  uninstall_hook(stats_cb, va_stats);
92 – }
93 – #endif
55  
56   static char *parse_stats_args(int, char **, int *, int *);
57   static void stats_L(struct Client *, char *, int, int, char);
58 < static void stats_L_list(struct Client *s, char *, int, int, dlink_list *, char);
98 <
58 > static void stats_L_list(struct Client *, char *, int, int, dlink_list *, char);
59   static void stats_dns_servers(struct Client *);
60   static void stats_connect(struct Client *);
61   static void stats_deny(struct Client *);
# Line 115 | Line 75 | static void stats_operedup(struct Client
75   static void stats_ports(struct Client *);
76   static void stats_resv(struct Client *);
77   static void stats_usage(struct Client *);
78 + static void stats_service(struct Client *);
79   static void stats_tstats(struct Client *);
80   static void stats_uptime(struct Client *);
81   static void stats_shared(struct Client *);
# Line 137 | Line 98 | static const struct StatsStruct
98    const unsigned int need_admin;
99   } stats_cmd_table[] = {
100    /* letter     function            need_oper need_admin */
101 <  { 'a',        stats_dns_servers,      1,      1,      },
102 <  { 'A',        stats_dns_servers,      1,      1,      },
103 <  { 'c',        stats_connect,          1,      0,      },
104 <  { 'C',        stats_connect,          1,      0,      },
105 <  { 'd',        stats_tdeny,            1,      0,      },
106 <  { 'D',        stats_deny,             1,      0,      },
107 <  { 'e',        stats_exempt,           1,      0,      },
108 <  { 'E',        stats_events,           1,      1,      },
109 <  { 'f',        fd_dump,                1,      1,      },
110 <  { 'F',        fd_dump,                1,      1,      },
111 <  { 'g',        stats_pending_glines,   1,      0,      },
112 <  { 'G',        stats_glines,           1,      0,      },
113 <  { 'h',        stats_hooks,            1,      1,      },
114 <  { 'H',        stats_hubleaf,          1,      0,      },
115 <  { 'i',        stats_auth,             0,      0,      },
116 <  { 'I',        stats_auth,             0,      0,      },
117 <  { 'k',        stats_tklines,          0,      0,      },
118 <  { 'K',        stats_klines,           0,      0,      },
119 <  { 'l',        stats_ltrace,           1,      0,      },
120 <  { 'L',        stats_ltrace,           1,      0,      },
121 <  { 'm',        stats_messages,         0,      0,      },
122 <  { 'M',        stats_messages,         0,      0,      },
123 <  { 'o',        stats_oper,             0,      0,      },
124 <  { 'O',        stats_oper,             0,      0,      },
125 <  { 'p',        stats_operedup,         0,      0,      },
126 <  { 'P',        stats_ports,            0,      0,      },
127 <  { 'q',        stats_resv,             1,      0,      },
128 <  { 'Q',        stats_resv,             1,      0,      },
129 <  { 'r',        stats_usage,            1,      0,      },
130 <  { 'R',        stats_usage,            1,      0,      },
131 <  { 't',        stats_tstats,           1,      0,      },
132 <  { 'T',        stats_tstats,           1,      0,      },
133 <  { 'u',        stats_uptime,           0,      0,      },
134 <  { 'U',        stats_shared,           1,      0,      },
135 <  { 'v',        stats_servers,          1,      0,      },
136 <  { 'V',        stats_gdeny,            1,      0,      },
137 <  { 'x',        stats_gecos,            1,      0,      },
138 <  { 'X',        stats_gecos,            1,      0,      },
139 <  { 'y',        stats_class,            1,      0,      },
140 <  { 'Y',        stats_class,            1,      0,      },
141 <  { 'z',        stats_memory,           1,      0,      },
142 <  { 'Z',        stats_ziplinks,         1,      0,      },
143 <  { '?',        stats_servlinks,        0,      0,      },
144 <  { '\0',       (void(*)())0,           0,      0,      }
101 >  { 'a',        stats_dns_servers,      1,      1       },
102 >  { 'A',        stats_dns_servers,      1,      1       },
103 >  { 'c',        stats_connect,          1,      0       },
104 >  { 'C',        stats_connect,          1,      0       },
105 >  { 'd',        stats_tdeny,            1,      0       },
106 >  { 'D',        stats_deny,             1,      0       },
107 >  { 'e',        stats_exempt,           1,      0       },
108 >  { 'E',        stats_events,           1,      1       },
109 >  { 'f',        fd_dump,                1,      1       },
110 >  { 'F',        fd_dump,                1,      1       },
111 >  { 'g',        stats_pending_glines,   1,      0       },
112 >  { 'G',        stats_glines,           1,      0       },
113 >  { 'h',        stats_hooks,            1,      1       },
114 >  { 'H',        stats_hubleaf,          1,      0       },
115 >  { 'i',        stats_auth,             0,      0       },
116 >  { 'I',        stats_auth,             0,      0       },
117 >  { 'k',        stats_tklines,          0,      0       },
118 >  { 'K',        stats_klines,           0,      0       },
119 >  { 'l',        stats_ltrace,           1,      0       },
120 >  { 'L',        stats_ltrace,           1,      0       },
121 >  { 'm',        stats_messages,         0,      0       },
122 >  { 'M',        stats_messages,         0,      0       },
123 >  { 'o',        stats_oper,             0,      0       },
124 >  { 'O',        stats_oper,             0,      0       },
125 >  { 'p',        stats_operedup,         0,      0       },
126 >  { 'P',        stats_ports,            0,      0       },
127 >  { 'q',        stats_resv,             1,      0       },
128 >  { 'Q',        stats_resv,             1,      0       },
129 >  { 'r',        stats_usage,            1,      0       },
130 >  { 'R',        stats_usage,            1,      0       },
131 >  { 'S',        stats_service,          1,      0       },
132 >  { 't',        stats_tstats,           1,      0       },
133 >  { 'T',        stats_tstats,           1,      0       },
134 >  { 'u',        stats_uptime,           0,      0       },
135 >  { 'U',        stats_shared,           1,      0       },
136 >  { 'v',        stats_servers,          1,      0       },
137 >  { 'V',        stats_gdeny,            1,      0       },
138 >  { 'x',        stats_gecos,            1,      0       },
139 >  { 'X',        stats_gecos,            1,      0       },
140 >  { 'y',        stats_class,            1,      0       },
141 >  { 'Y',        stats_class,            1,      0       },
142 >  { 'z',        stats_memory,           1,      0       },
143 >  { 'Z',        stats_ziplinks,         1,      0       },
144 >  { '?',        stats_servlinks,        0,      0       },
145 >  { '\0',       NULL,                   0,      0       }
146   };
147  
148   const char *from, *to;
149  
150   static void
151 < do_stats(struct Client *source_p, int parc, char **parv)
151 > do_stats(struct Client *source_p, int parc, char *parv[])
152   {
153 +  const struct StatsStruct *tab = stats_cmd_table;
154    char statchar = *parv[1];
192 –  int i;
155  
156    if (statchar == '\0')
157    {
# Line 198 | Line 160 | do_stats(struct Client *source_p, int pa
160      return;
161    }
162  
163 <  for (i = 0; stats_cmd_table[i].handler; i++)
163 >  for (; tab->handler; ++tab)
164    {
165 <    if (stats_cmd_table[i].letter == statchar)
165 >    if (tab->letter == statchar)
166      {
167        /* The stats table says what privs are needed, so check --fl_ */
168 <      if ((stats_cmd_table[i].need_admin && !IsAdmin(source_p)) ||
169 <          (stats_cmd_table[i].need_oper && !IsOper(source_p)))
168 >      if ((tab->need_admin && !HasUMode(source_p, UMODE_ADMIN)) ||
169 >          (tab->need_oper && !HasUMode(source_p, UMODE_OPER)))
170        {
171          sendto_one(source_p, form_str(ERR_NOPRIVILEGES),
172                     from, to);
# Line 213 | Line 175 | do_stats(struct Client *source_p, int pa
175  
176        /* Blah, stats L needs the parameters, none of the others do.. */
177        if (statchar == 'L' || statchar == 'l')
178 <        stats_cmd_table[i].handler(source_p, parc, parv);
178 >      {
179 >        sendto_realops_flags(UMODE_SPY, L_ALL,
180 >                             "STATS %c requested by %s (%s@%s) [%s] on %s",
181 >                             statchar, source_p->name, source_p->username,
182 >                             source_p->host, source_p->servptr->name,
183 >                             parc > 2 ? parv[2] : "<no recipient>");
184 >        tab->handler(source_p, parc, parv);
185 >      }
186        else
187 <        stats_cmd_table[i].handler(source_p);
187 >      {
188 >        sendto_realops_flags(UMODE_SPY, L_ALL,
189 >                             "STATS %c requested by %s (%s@%s) [%s]",
190 >                             statchar, source_p->name, source_p->username,
191 >                             source_p->host, source_p->servptr->name);
192 >        tab->handler(source_p);
193 >      }
194  
195        break;
196      }
# Line 242 | Line 217 | m_stats(struct Client *client_p, struct
217  
218    /* Is the stats meant for us? */
219    if (!ConfigFileEntry.disable_remote)
220 <    if (hunt_server(client_p,source_p,":%s STATS %s :%s",2,parc,parv) != HUNTED_ISME)
220 >    if (hunt_server(client_p, source_p, ":%s STATS %s :%s", 2,
221 >                    parc, parv) != HUNTED_ISME)
222        return;
223  
224    if (!MyClient(source_p) && IsCapable(source_p->from, CAP_TS6) && HasID(source_p))
# Line 263 | Line 239 | m_stats(struct Client *client_p, struct
239                 from, to);
240      return;
241    }
266 –  else
267 –    last_used = CurrentTime;
242  
243 < #ifdef STATIC_MODULES
243 >  last_used = CurrentTime;
244 >
245    do_stats(source_p, parc, parv);
271 – #else
272 –  execute_callback(stats_cb, source_p, parc, parv);
273 – #endif
246   }
247  
248   /*
# Line 301 | Line 273 | mo_stats(struct Client *client_p, struct
273      to = source_p->name;
274    }
275  
304 – #ifdef STATIC_MODULES
276    do_stats(source_p, parc, parv);
277 < #else
278 <  execute_callback(stats_cb, source_p, parc, parv);
279 < #endif
277 > }
278 >
279 > /*
280 > * ms_stats - STATS message handler
281 > *      parv[0] = sender prefix
282 > *      parv[1] = statistics selector (defaults to Message frequency)
283 > *      parv[2] = server name (current server defaulted, if omitted)
284 > */
285 > static void
286 > ms_stats(struct Client *client_p, struct Client *source_p,
287 >         int parc, char *parv[])
288 > {
289 >  if (hunt_server(client_p, source_p, ":%s STATS %s :%s", 2,
290 >                  parc, parv) != HUNTED_ISME)
291 >    return;
292 >
293 >  if (IsClient(source_p))
294 >    mo_stats(client_p, source_p, parc, parv);
295   }
296  
297   /*
# Line 318 | Line 304 | mo_stats(struct Client *client_p, struct
304   static void
305   send_usage(struct Client *source_p)
306   {
321 – #ifndef _WIN32
307    struct rusage rus;
308    time_t secs;
309    time_t rup;
# Line 344 | Line 329 | send_usage(struct Client *source_p)
329    if (secs == 0)
330      secs = 1;
331  
332 <  rup = (CurrentTime - me.since) * hzz;
332 >  rup = (CurrentTime - me.localClient->since) * hzz;
333  
334    if (rup == 0)
335      rup = 1;
# Line 370 | Line 355 | send_usage(struct Client *source_p)
355    sendto_one(source_p, ":%s %d %s R :Signals %d Context Vol. %d Invol %d",
356               me.name, RPL_STATSDEBUG, source_p->name, (int)rus.ru_nsignals,
357               (int)rus.ru_nvcsw, (int)rus.ru_nivcsw);
373 – #endif
358   }
359  
360   static void
# Line 379 | Line 363 | count_memory(struct Client *source_p)
363    const dlink_node *gptr = NULL;
364    const dlink_node *dlink = NULL;
365  
366 <  int local_client_conf_count = 0;      /* local client conf links */
367 <  int users_counted = 0;                /* user structs */
366 >  unsigned int local_client_conf_count = 0;      /* local client conf links */
367 >  unsigned int users_counted = 0;                /* user structs */
368  
369 <  int channel_users = 0; /* XXX */
370 <  int channel_invites = 0;
371 <  int channel_bans = 0;
372 <  int channel_except = 0;
373 <  int channel_invex = 0;
374 <
375 <  int wwu = 0;                  /* whowas users */
376 <  int class_count = 0;          /* classes */
377 <  int users_invited_count = 0;  /* users invited */
378 <  int aways_counted = 0;
379 <  int number_ips_stored;        /* number of ip addresses hashed */
380 <
381 <  unsigned long channel_memory = 0;
382 <  size_t channel_ban_memory = 0;
383 <  size_t channel_except_memory = 0;
400 <  size_t channel_invex_memory = 0;
369 >  unsigned int channel_members = 0;
370 >  unsigned int channel_invites = 0;
371 >  unsigned int channel_bans = 0;
372 >  unsigned int channel_except = 0;
373 >  unsigned int channel_invex = 0;
374 >
375 >  unsigned int wwu = 0;                  /* whowas users */
376 >  unsigned int class_count = 0;          /* classes */
377 >  unsigned int aways_counted = 0;
378 >  unsigned int number_ips_stored;        /* number of ip addresses hashed */
379 >
380 >  uint64_t channel_memory = 0;
381 >  uint64_t channel_ban_memory = 0;
382 >  uint64_t channel_except_memory = 0;
383 >  uint64_t channel_invex_memory = 0;
384  
385    unsigned int safelist_count = 0;
386 <  size_t safelist_memory = 0;
386 >  uint64_t safelist_memory = 0;
387 >
388 >  uint64_t away_memory = 0;       /* memory used by aways           */
389 >  uint64_t wwm = 0;               /* whowas array memory used       */
390 >  uint64_t conf_memory = 0;       /* memory used by conf lines      */
391 >  uint64_t mem_ips_stored;        /* memory used by ip address hash */
392  
393 <  unsigned long away_memory = 0;       /* memory used by aways           */
394 <  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;
393 >  uint64_t total_channel_memory = 0;
394 >  uint64_t totww = 0;
395  
396    unsigned int local_client_count  = 0;
397    unsigned int remote_client_count = 0;
398  
399 <  unsigned int local_client_memory_used  = 0;
400 <  unsigned int remote_client_memory_used = 0;
399 >  uint64_t local_client_memory_used  = 0;
400 >  uint64_t remote_client_memory_used = 0;
401  
402 <  unsigned long total_memory = 0;
402 >  uint64_t total_memory = 0;
403    unsigned int topic_count = 0;
404  
405 <  count_whowas_memory(&wwu, &wwm);
405 >  unsigned int watch_list_headers = 0;   /* watchlist headers     */
406 >  unsigned int watch_list_entries = 0;   /* watchlist entries     */
407 >  uint64_t watch_list_memory = 0; /* watchlist memory used */
408 >
409  
410    DLINK_FOREACH(gptr, global_client_list.head)
411    {
# Line 433 | Line 415 | count_memory(struct Client *source_p)
415      {
416        ++local_client_count;
417        local_client_conf_count += dlink_list_length(&target_p->localClient->confs);
418 +      watch_list_entries += dlink_list_length(&target_p->localClient->watches);
419      }
420      else
421        ++remote_client_count;
# Line 440 | Line 423 | count_memory(struct Client *source_p)
423      if (IsClient(target_p))
424      {
425        ++users_counted;
443 –      users_invited_count += dlink_list_length(&target_p->invited);
426  
427        if (target_p->away != NULL)
428        {
# Line 455 | Line 437 | count_memory(struct Client *source_p)
437                     sizeof(struct Channel);
438    DLINK_FOREACH(gptr, global_channel_list.head)
439    {
440 <    struct Ban *actualBan;
441 <    struct Channel *chptr = gptr->data;
440 >    const struct Ban *actualBan;
441 >    const struct Channel *chptr = gptr->data;
442  
443 <    channel_users   += dlink_list_length(&chptr->members);
443 >    channel_members += dlink_list_length(&chptr->members);
444      channel_invites += dlink_list_length(&chptr->invites);
445  
446 <    if (chptr->topic != NULL)
446 >    if (chptr->topic[0])
447        ++topic_count;
448  
449 <    if ((channel_bans = dlink_list_length(&chptr->banlist)))
450 <    {
469 <      channel_ban_memory = channel_bans * sizeof(struct Ban);
449 >    channel_bans += dlink_list_length(&chptr->banlist);
450 >    channel_ban_memory += dlink_list_length(&chptr->banlist) * sizeof(struct Ban);
451  
452 <      DLINK_FOREACH(dlink, chptr->banlist.head)
453 <      {
454 <        actualBan = dlink->data;
455 <        assert(actualBan->who);
452 >    DLINK_FOREACH(dlink, chptr->banlist.head)
453 >    {
454 >      actualBan = dlink->data;
455 >      assert(actualBan->who);
456  
457 <        channel_ban_memory += actualBan->len + 3;
458 <        channel_ban_memory += strlen(actualBan->who) + 1;
478 <      }
457 >      channel_ban_memory += actualBan->len + 1;
458 >      channel_ban_memory += strlen(actualBan->who) + 1;
459      }
460  
461 <    if ((channel_except = dlink_list_length(&chptr->exceptlist)))
462 <    {
483 <      channel_except_memory = channel_except * sizeof(struct Ban);
461 >    channel_except += dlink_list_length(&chptr->exceptlist);
462 >    channel_except_memory += dlink_list_length(&chptr->exceptlist) * sizeof(struct Ban);
463  
464 <      DLINK_FOREACH(dlink, chptr->exceptlist.head)
465 <      {
466 <        actualBan = dlink->data;
467 <        assert(actualBan->who);
464 >    DLINK_FOREACH(dlink, chptr->exceptlist.head)
465 >    {
466 >      actualBan = dlink->data;
467 >      assert(actualBan->who);
468  
469 <        channel_except_memory += actualBan->len + 3;
470 <        channel_except_memory += strlen(actualBan->who) + 1;
492 <      }
469 >      channel_except_memory += actualBan->len + 1;
470 >      channel_except_memory += strlen(actualBan->who) + 1;
471      }
472  
473 <    if ((channel_invex = dlink_list_length(&chptr->invexlist)))
474 <    {
497 <      channel_invex_memory = channel_invex * sizeof(struct Ban);
473 >    channel_invex += dlink_list_length(&chptr->invexlist);
474 >    channel_invex_memory += dlink_list_length(&chptr->invexlist) * sizeof(struct Ban);
475  
476 <      DLINK_FOREACH(dlink, chptr->invexlist.head)
477 <      {
478 <        actualBan = dlink->data;
479 <        assert(actualBan->who);
476 >    DLINK_FOREACH(dlink, chptr->invexlist.head)
477 >    {
478 >      actualBan = dlink->data;
479 >      assert(actualBan->who);
480  
481 <        channel_invex_memory += actualBan->len + 3;
482 <        channel_invex_memory += strlen(actualBan->who) + 1;
506 <      }
481 >      channel_invex_memory += actualBan->len + 1;
482 >      channel_invex_memory += strlen(actualBan->who) + 1;
483      }
484    }
485  
# Line 512 | Line 488 | count_memory(struct Client *source_p)
488      safelist_memory = safelist_count * sizeof(struct ListTask);
489      DLINK_FOREACH(gptr, listing_client_list.head)
490      {
491 <      struct Client *acptr = gptr->data;
491 >      const struct Client *acptr = gptr->data;
492  
493        DLINK_FOREACH(dlink, acptr->localClient->list_task->show_mask.head)
494          safelist_memory += strlen(dlink->data);
# Line 537 | Line 513 | count_memory(struct Client *source_p)
513    /* count up all classes */
514    class_count = dlink_list_length(&class_items);
515  
516 <  sendto_one(source_p, ":%s %d %s z :Clients %u(%lu) Invites %u(%lu)",
516 >  count_whowas_memory(&wwu, &wwm);
517 >  watch_count_memory(&watch_list_headers, &watch_list_memory);
518 >
519 >  sendto_one(source_p, ":%s %d %s z :WATCH headers %u(%u) entries %d(%u)",
520 >             me.name, RPL_STATSDEBUG, source_p->name, watch_list_headers,
521 >             watch_list_memory, watch_list_entries,
522 >             watch_list_entries * sizeof(dlink_node) * 2);
523 >
524 >  sendto_one(source_p, ":%s %d %s z :Clients %u(%u)",
525               me.name, RPL_STATSDEBUG, source_p->name, users_counted,
526 <             (unsigned long)(users_counted * sizeof(struct Client)),
543 <             users_invited_count, (unsigned long)(users_invited_count * sizeof(dlink_node)));
526 >             (users_counted * sizeof(struct Client)));
527  
528 <  sendto_one(source_p, ":%s %d %s z :User aways %u(%d)",
528 >  sendto_one(source_p, ":%s %d %s z :User aways %u(%llu)",
529               me.name, RPL_STATSDEBUG, source_p->name,
530 <             aways_counted, (int)away_memory);
530 >             aways_counted, away_memory);
531  
532 <  sendto_one(source_p, ":%s %d %s z :Attached confs %u(%lu)",
532 >  sendto_one(source_p, ":%s %d %s z :Attached confs %u(%llu)",
533               me.name, RPL_STATSDEBUG, source_p->name,
534               local_client_conf_count,
535 <             (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
535 >             (unsigned long long)(local_client_conf_count * sizeof(dlink_node)));
536  
537 <  sendto_one(source_p, ":%s %d %s z :Resv channels %lu(%lu) nicks %lu(%lu)",
537 >  sendto_one(source_p, ":%s %d %s z :Resv channels %u(%lu) nicks %u(%lu)",
538               me.name, RPL_STATSDEBUG, source_p->name,
539               dlink_list_length(&resv_channel_list),
540               dlink_list_length(&resv_channel_list) * sizeof(struct ResvChannel),
541               dlink_list_length(&nresv_items),
542               dlink_list_length(&nresv_items) * sizeof(struct MatchItem));
543  
544 <  sendto_one(source_p, ":%s %d %s z :Classes %u(%lu)",
544 >  sendto_one(source_p, ":%s %d %s z :Classes %u(%llu)",
545               me.name, RPL_STATSDEBUG, source_p->name,
546 <             class_count, (unsigned long)(class_count * sizeof(struct ClassItem)));
546 >             class_count, (unsigned long long)(class_count * sizeof(struct ClassItem)));
547  
548 <  sendto_one(source_p, ":%s %d %s z :Channels %lu(%lu) Topics %u(%d)",
548 >  sendto_one(source_p, ":%s %d %s z :Channels %uu(%llu) Topics %u(%u)",
549               me.name, RPL_STATSDEBUG, source_p->name,
550               dlink_list_length(&global_channel_list),
551               channel_memory, topic_count, topic_count *
552               (TOPICLEN + 1 + USERHOST_REPLYLEN));
553  
554 <  sendto_one(source_p, ":%s %d %s z :Bans %u(%u)",
554 >  sendto_one(source_p, ":%s %d %s z :Bans %u(%llu)",
555               me.name, RPL_STATSDEBUG, source_p->name,
556               channel_bans, channel_ban_memory);
557  
558 <  sendto_one(source_p, ":%s %d %s z :Exceptions %u(%u)",
558 >  sendto_one(source_p, ":%s %d %s z :Exceptions %u(%llu)",
559               me.name, RPL_STATSDEBUG, source_p->name,
560               channel_except, channel_except_memory);
561  
562 <  sendto_one(source_p, ":%s %d %s z :Invex %u(%u)",
562 >  sendto_one(source_p, ":%s %d %s z :Invex %u(%llu)",
563               me.name, RPL_STATSDEBUG, source_p->name,
564               channel_invex, channel_invex_memory);
565  
566 <  sendto_one(source_p, ":%s %d %s z :Channel members %u(%lu) invite %u(%lu)",
567 <             me.name, RPL_STATSDEBUG, source_p->name, channel_users,
568 <             (unsigned long)(channel_users * sizeof(struct Membership)),
569 <             channel_invites, (unsigned long)channel_invites *
570 <             sizeof(dlink_node));
566 >  sendto_one(source_p, ":%s %d %s z :Channel members %u(%llu) invites %u(%llu)",
567 >             me.name, RPL_STATSDEBUG, source_p->name, channel_members,
568 >             (unsigned long long)(channel_members * sizeof(struct Membership)),
569 >             channel_invites, (unsigned long long)channel_invites *
570 >             sizeof(dlink_node) * 2);
571  
572    total_channel_memory = channel_memory + channel_ban_memory +
573 <                         channel_users * sizeof(struct Membership) +
574 <                         channel_invites * sizeof(dlink_node);
573 >                         channel_members * sizeof(struct Membership) +
574 >                         (channel_invites * sizeof(dlink_node)*2);
575  
576 <  sendto_one(source_p, ":%s %d %s z :Safelist %u(%u)",
576 >  sendto_one(source_p, ":%s %d %s z :Safelist %u(%llu)",
577               me.name, RPL_STATSDEBUG, source_p->name,
578               safelist_count, safelist_memory);
579  
580 <  sendto_one(source_p, ":%s %d %s z :Whowas users %u(%lu)",
580 >  sendto_one(source_p, ":%s %d %s z :Whowas users %u(%llu)",
581               me.name, RPL_STATSDEBUG, source_p->name,
582 <             wwu, (unsigned long)(wwu * sizeof(struct Client)));
582 >             wwu, (unsigned long long)(wwu * sizeof(struct Client)));
583  
584 <  sendto_one(source_p, ":%s %d %s z :Whowas array %u(%d)",
584 >  sendto_one(source_p, ":%s %d %s z :Whowas array %u(%llu)",
585               me.name, RPL_STATSDEBUG, source_p->name,
586 <             NICKNAMEHISTORYLENGTH, (int)wwm);
586 >             NICKNAMEHISTORYLENGTH, wwm);
587  
588    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();
589  
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 – ****/
590    count_ip_hash(&number_ips_stored,&mem_ips_stored);
591 <  sendto_one(source_p, ":%s %d %s z :iphash %u(%d)",
591 >  sendto_one(source_p, ":%s %d %s z :iphash %u(%llu)",
592               me.name, RPL_STATSDEBUG, source_p->name,
593 <             number_ips_stored, (int)mem_ips_stored);
593 >             number_ips_stored, mem_ips_stored);
594  
595    total_memory = totww + total_channel_memory + conf_memory + class_count *
596                   sizeof(struct ClassItem);
597 <  total_memory += client_hash_table_size;
598 <  total_memory += channel_hash_table_size;
599 <  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);
597 >  sendto_one(source_p, ":%s %d %s z :Total: whowas %llu channel %llu conf %llu",
598 >             me.name, RPL_STATSDEBUG, source_p->name, totww,
599 >             total_channel_memory, conf_memory);
600  
601    local_client_memory_used = local_client_count*(sizeof(struct Client) + sizeof(struct LocalUser));
602    total_memory += local_client_memory_used;
603 <  sendto_one(source_p, ":%s %d %s z :Local client Memory in use: %d(%d)",
603 >  sendto_one(source_p, ":%s %d %s z :Local client Memory in use: %u(%llu)",
604               me.name, RPL_STATSDEBUG, source_p->name, local_client_count,
605               local_client_memory_used);
606  
607    remote_client_memory_used = remote_client_count * sizeof(struct Client);
608    total_memory += remote_client_memory_used;
609 <  sendto_one(source_p, ":%s %d %s z :Remote client Memory in use: %d(%d)",
609 >  sendto_one(source_p, ":%s %d %s z :Remote client Memory in use: %u(%llu)",
610               me.name, RPL_STATSDEBUG, source_p->name, remote_client_count,
611               remote_client_memory_used);
612  
613    block_heap_report_stats(source_p);
614  
615    sendto_one(source_p,
616 <             ":%s %d %s z :TOTAL: %d Available:  Current max RSS: %lu",
616 >             ":%s %d %s z :TOTAL: %llu",
617               me.name, RPL_STATSDEBUG, source_p->name,
618 <             (int)total_memory, get_maxrss());
618 >             total_memory);
619   }
620  
621   static void
# Line 757 | Line 716 | stats_exempt(struct Client *source_p)
716    struct AccessItem *aconf;
717    int i;
718  
719 +  if (ConfigFileEntry.stats_e_disabled)
720 +  {
721 +    sendto_one(source_p, form_str(ERR_NOPRIVILEGES),
722 +               from, to);
723 +    return;
724 +  }
725 +
726    for (i = 0; i < ATABLE_SIZE; i++)
727    {
728      for (arec = atable[i]; arec; arec=arec->next)
# Line 790 | Line 756 | stats_events(struct Client *source_p)
756   static void
757   stats_pending_glines(struct Client *source_p)
758   {
759 < #ifdef GLINE_VOTING
760 <  dlink_node *pending_node;
761 <  struct gline_pending *glp_ptr;
762 <  char timebuffer[MAX_DATE_STRING];
797 <  struct tm *tmptr;
759 >  const dlink_node *dn_ptr = NULL;
760 >  const struct gline_pending *glp_ptr = NULL;
761 >  char timebuffer[MAX_DATE_STRING] = { '\0' };
762 >  struct tm *tmptr = NULL;
763  
764    if (!ConfigFileEntry.glines)
765    {
# Line 803 | Line 768 | stats_pending_glines(struct Client *sour
768      return;
769    }
770  
771 <  if (dlink_list_length(&pending_glines) > 0)
771 >  if (dlink_list_length(&pending_glines[GLINE_PENDING_ADD_TYPE]) > 0)
772      sendto_one(source_p, ":%s NOTICE %s :Pending G-lines",
773                 from, to);
774  
775 <  DLINK_FOREACH(pending_node, pending_glines.head)
775 >  DLINK_FOREACH(dn_ptr, pending_glines[GLINE_PENDING_ADD_TYPE].head)
776    {
777 <    glp_ptr = pending_node->data;
778 <    tmptr   = localtime(&glp_ptr->time_request1);
777 >    glp_ptr = dn_ptr->data;
778 >    tmptr   = localtime(&glp_ptr->vote_1.time_request);
779      strftime(timebuffer, MAX_DATE_STRING, "%Y/%m/%d %H:%M:%S", tmptr);
780  
781      sendto_one(source_p,
782                 ":%s NOTICE %s :1) %s!%s@%s on %s requested gline at %s for %s@%s [%s]",
783 <               from, to, glp_ptr->oper_nick1,
784 <               glp_ptr->oper_user1, glp_ptr->oper_host1,
785 <               glp_ptr->oper_server1, timebuffer,
786 <               glp_ptr->user, glp_ptr->host, glp_ptr->reason1);
783 >               from, to, glp_ptr->vote_1.oper_nick,
784 >               glp_ptr->vote_1.oper_user, glp_ptr->vote_1.oper_host,
785 >               glp_ptr->vote_1.oper_server, timebuffer,
786 >               glp_ptr->user, glp_ptr->host, glp_ptr->vote_1.reason);
787  
788 <    if (glp_ptr->oper_nick2[0] != '\0')
788 >    if (glp_ptr->vote_2.oper_nick[0] != '\0')
789      {
790 <      tmptr = localtime(&glp_ptr->time_request2);
790 >      tmptr = localtime(&glp_ptr->vote_2.time_request);
791        strftime(timebuffer, MAX_DATE_STRING, "%Y/%m/%d %H:%M:%S", tmptr);
792        sendto_one(source_p,
793        ":%s NOTICE %s :2) %s!%s@%s on %s requested gline at %s for %s@%s [%s]",
794 <                 from, to, glp_ptr->oper_nick2,
795 <                 glp_ptr->oper_user2, glp_ptr->oper_host2,
796 <                 glp_ptr->oper_server2, timebuffer,
797 <                 glp_ptr->user, glp_ptr->host, glp_ptr->reason2);
794 >               from, to, glp_ptr->vote_2.oper_nick,
795 >               glp_ptr->vote_2.oper_user, glp_ptr->vote_2.oper_host,
796 >               glp_ptr->vote_2.oper_server, timebuffer,
797 >               glp_ptr->user, glp_ptr->host, glp_ptr->vote_2.reason);
798      }
799    }
800  
801    sendto_one(source_p, ":%s NOTICE %s :End of Pending G-lines",
802               from, to);
803 < #else
804 <  sendto_one(source_p, ":%s NOTICE %s :This server does not support G-Line voting",
803 >
804 >  if (dlink_list_length(&pending_glines[GLINE_PENDING_DEL_TYPE]) > 0)
805 >    sendto_one(source_p, ":%s NOTICE %s :Pending UNG-lines",
806 >               from, to);
807 >
808 >  DLINK_FOREACH(dn_ptr, pending_glines[GLINE_PENDING_DEL_TYPE].head)
809 >  {
810 >    glp_ptr = dn_ptr->data;
811 >    tmptr   = localtime(&glp_ptr->vote_1.time_request);
812 >    strftime(timebuffer, MAX_DATE_STRING, "%Y/%m/%d %H:%M:%S", tmptr);
813 >
814 >    sendto_one(source_p,
815 >               ":%s NOTICE %s :1) %s!%s@%s on %s requested ungline at %s for %s@%s [%s]",
816 >               from, to, glp_ptr->vote_1.oper_nick,
817 >               glp_ptr->vote_1.oper_user, glp_ptr->vote_1.oper_host,
818 >               glp_ptr->vote_1.oper_server, timebuffer,
819 >               glp_ptr->user, glp_ptr->host, glp_ptr->vote_1.reason);
820 >
821 >    if (glp_ptr->vote_2.oper_nick[0] != '\0')
822 >    {
823 >      tmptr = localtime(&glp_ptr->vote_2.time_request);
824 >      strftime(timebuffer, MAX_DATE_STRING, "%Y/%m/%d %H:%M:%S", tmptr);
825 >      sendto_one(source_p,
826 >      ":%s NOTICE %s :2) %s!%s@%s on %s requested ungline at %s for %s@%s [%s]",
827 >               from, to, glp_ptr->vote_2.oper_nick,
828 >               glp_ptr->vote_2.oper_user, glp_ptr->vote_2.oper_host,
829 >               glp_ptr->vote_2.oper_server, timebuffer,
830 >               glp_ptr->user, glp_ptr->host, glp_ptr->vote_2.reason);
831 >
832 >    }
833 >  }
834 >
835 >  sendto_one(source_p, ":%s NOTICE %s :End of Pending UNG-lines",
836               from, to);
841 – #endif /* GLINE VOTING */
837   }
838  
839   /* stats_glines()
# Line 862 | Line 857 | stats_glines(struct Client *source_p)
857  
858    for (; i < ATABLE_SIZE; ++i)
859    {
860 <    for (arec = atable[i]; arec; arec=arec->next)
860 >    for (arec = atable[i]; arec; arec = arec->next)
861      {
862        if (arec->type == CONF_GLINE)
863        {
# Line 908 | Line 903 | static void
903   stats_auth(struct Client *source_p)
904   {
905    /* Oper only, if unopered, return ERR_NOPRIVILEGES */
906 <  if ((ConfigFileEntry.stats_i_oper_only == 2) && !IsOper(source_p))
906 >  if ((ConfigFileEntry.stats_i_oper_only == 2) && !HasUMode(source_p, UMODE_OPER))
907      sendto_one(source_p, form_str(ERR_NOPRIVILEGES),
908                 from, to);
909  
910    /* If unopered, Only return matching auth blocks */
911 <  else if ((ConfigFileEntry.stats_i_oper_only == 1) && !IsOper(source_p))
911 >  else if ((ConfigFileEntry.stats_i_oper_only == 1) && !HasUMode(source_p, UMODE_OPER))
912    {
913      struct ConfItem *conf;
914      struct AccessItem *aconf;
# Line 950 | Line 945 | stats_tklines(struct Client *source_p)
945   {
946    struct ConfItem *conf;
947    /* Oper only, if unopered, return ERR_NOPRIVILEGES */
948 <  if ((ConfigFileEntry.stats_k_oper_only == 2) && !IsOper(source_p))
948 >  if ((ConfigFileEntry.stats_k_oper_only == 2) && !HasUMode(source_p, UMODE_OPER))
949      sendto_one(source_p, form_str(ERR_NOPRIVILEGES),
950                 from, to);
951  
952    /* If unopered, Only return matching klines */
953 <  else if ((ConfigFileEntry.stats_k_oper_only == 1) && !IsOper(source_p))
953 >  else if ((ConfigFileEntry.stats_k_oper_only == 1) && !HasUMode(source_p, UMODE_OPER))
954    {
955      struct AccessItem *aconf;
956  
# Line 992 | Line 987 | static void
987   stats_klines(struct Client *source_p)
988   {
989    /* Oper only, if unopered, return ERR_NOPRIVILEGES */
990 <  if ((ConfigFileEntry.stats_k_oper_only == 2) && !IsOper(source_p))
990 >  if ((ConfigFileEntry.stats_k_oper_only == 2) && !HasUMode(source_p, UMODE_OPER))
991      sendto_one(source_p, form_str(ERR_NOPRIVILEGES),
992                 from, to);
993  
994    /* If unopered, Only return matching klines */
995 <  else if ((ConfigFileEntry.stats_k_oper_only == 1) && !IsOper(source_p))
995 >  else if ((ConfigFileEntry.stats_k_oper_only == 1) && !HasUMode(source_p, UMODE_OPER))
996    {
997      struct AccessItem *aconf;
998  
999      /* search for a kline */
1000 <    if(MyConnect(source_p))
1000 >    if (MyConnect(source_p))
1001        aconf = find_conf_by_address(source_p->host,
1002                                     &source_p->localClient->ip,
1003                                     CONF_KILL,
# Line 1012 | Line 1007 | stats_klines(struct Client *source_p)
1007        aconf = find_conf_by_address(source_p->host, NULL, CONF_KILL,
1008                                     0, source_p->username, NULL);
1009  
1010 <    if(aconf == NULL)
1010 >    if (aconf == NULL)
1011        return;
1012  
1013      /* dont report a tkline as a kline */
1014 <    if(aconf->flags & CONF_FLAGS_TEMPORARY)
1014 >    if (aconf->flags & CONF_FLAGS_TEMPORARY)
1015        return;
1016        
1017      sendto_one(source_p, form_str(RPL_STATSKLINE), from,
# Line 1039 | Line 1034 | stats_messages(struct Client *source_p)
1034   static void
1035   stats_oper(struct Client *source_p)
1036   {
1037 <  if (!IsOper(source_p) && ConfigFileEntry.stats_o_oper_only)
1037 >  if (!HasUMode(source_p, UMODE_OPER) && ConfigFileEntry.stats_o_oper_only)
1038      sendto_one(source_p, form_str(ERR_NOPRIVILEGES),
1039                 from, to);
1040    else
# Line 1061 | Line 1056 | stats_operedup(struct Client *source_p)
1056    {
1057      const struct Client *target_p = ptr->data;
1058  
1059 <    if (IsOperHidden(target_p) && !IsOper(source_p))
1059 >    if (HasOFlag(target_p, OPER_FLAG_HIDDEN_OPER) && !HasUMode(source_p, UMODE_OPER))
1060        continue;
1061  
1062 <    if (MyClient(source_p) && IsOper(source_p))
1062 >    if (MyClient(source_p) && HasUMode(source_p, UMODE_OPER))
1063        sendto_one(source_p, ":%s %d %s p :[%c][%s] %s (%s@%s) Idle: %d",
1064                   from, RPL_STATSDEBUG, to,
1065 <                 IsAdmin(target_p) ?
1066 <                 (IsOperHiddenAdmin(target_p) ? 'O' : 'A') : 'O',
1065 >                 HasUMode(target_p, UMODE_ADMIN) ?
1066 >                 (HasOFlag(target_p, OPER_FLAG_HIDDEN_ADMIN) ? 'O' : 'A') : 'O',
1067                   oper_privs_as_string(target_p->localClient->operflags),
1068                   target_p->name, target_p->username, target_p->host,
1069 <                 (int)(CurrentTime - target_p->localClient->last));
1069 >                 (int)(CurrentTime - target_p->localClient->last_privmsg));
1070      else
1071        sendto_one(source_p, ":%s %d %s p :[%c] %s (%s@%s) Idle: %d",
1072                   from, RPL_STATSDEBUG, to,
1073 <                 IsAdmin(target_p) ?
1074 <                 (IsOperHiddenAdmin(target_p) ? 'O' : 'A') : 'O',
1073 >                 HasUMode(target_p, UMODE_ADMIN) ?
1074 >                 (HasOFlag(target_p, OPER_FLAG_HIDDEN_ADMIN) ? 'O' : 'A') : 'O',
1075                   target_p->name, target_p->username, target_p->host,
1076 <                 (int)(CurrentTime - target_p->localClient->last));
1076 >                 (int)(CurrentTime - target_p->localClient->last_privmsg));
1077    }
1078  
1079    sendto_one(source_p, ":%s %d %s p :%lu OPER(s)",
# Line 1088 | Line 1083 | stats_operedup(struct Client *source_p)
1083   static void
1084   stats_ports(struct Client *source_p)
1085   {
1086 <  if (!IsOper(source_p) && ConfigFileEntry.stats_P_oper_only)
1086 >  if (!HasUMode(source_p, UMODE_OPER) && ConfigFileEntry.stats_P_oper_only)
1087      sendto_one(source_p, form_str(ERR_NOPRIVILEGES),
1088                 from, to);
1089    else
# Line 1108 | Line 1103 | stats_usage(struct Client *source_p)
1103   }
1104  
1105   static void
1106 + stats_service(struct Client *source_p)
1107 + {
1108 +  report_confitem_types(source_p, SERVICE_TYPE, 0);
1109 + }
1110 +
1111 + static void
1112   stats_tstats(struct Client *source_p)
1113   {
1114 <  tstats(source_p);
1114 >  const struct Client *target_p = NULL;
1115 >  const dlink_node *ptr = NULL;
1116 >  struct ServerStatistics *sp;
1117 >  struct ServerStatistics tmp;
1118 >
1119 >  sp = &tmp;
1120 >  memcpy(sp, &ServerStats, sizeof(struct ServerStatistics));
1121 >
1122 >  /*
1123 >   * must use the += operator. is_sv is not the number of currently
1124 >   * active server connections. Note the incrementation in
1125 >   * s_bsd.c:close_connection.
1126 >   */
1127 >  sp->is_sv += dlink_list_length(&serv_list);
1128 >
1129 >  DLINK_FOREACH(ptr, serv_list.head)
1130 >  {
1131 >    target_p = ptr->data;
1132 >
1133 >    sp->is_sbs += target_p->localClient->send.bytes;
1134 >    sp->is_sbr += target_p->localClient->recv.bytes;
1135 >    sp->is_sti += CurrentTime - target_p->localClient->firsttime;
1136 >  }
1137 >
1138 >  sp->is_cl += dlink_list_length(&local_client_list);
1139 >
1140 >  DLINK_FOREACH(ptr, local_client_list.head)
1141 >  {
1142 >    target_p = ptr->data;
1143 >
1144 >    sp->is_cbs += target_p->localClient->send.bytes;
1145 >    sp->is_cbr += target_p->localClient->recv.bytes;
1146 >    sp->is_cti += CurrentTime - target_p->localClient->firsttime;
1147 >  }
1148 >
1149 >  sp->is_ni += dlink_list_length(&unknown_list);
1150 >
1151 >  sendto_one(source_p, ":%s %d %s T :accepts %u refused %u",
1152 >             me.name, RPL_STATSDEBUG, source_p->name, sp->is_ac, sp->is_ref);
1153 >  sendto_one(source_p, ":%s %d %s T :unknown commands %u prefixes %u",
1154 >             me.name, RPL_STATSDEBUG, source_p->name, sp->is_unco, sp->is_unpf);
1155 >  sendto_one(source_p, ":%s %d %s T :nick collisions %u unknown closes %u",
1156 >             me.name, RPL_STATSDEBUG, source_p->name, sp->is_kill, sp->is_ni);
1157 >  sendto_one(source_p, ":%s %d %s T :wrong direction %u empty %u",
1158 >             me.name, RPL_STATSDEBUG, source_p->name, sp->is_wrdi, sp->is_empt);
1159 >  sendto_one(source_p, ":%s %d %s T :numerics seen %u",
1160 >             me.name, RPL_STATSDEBUG, source_p->name, sp->is_num);
1161 >  sendto_one(source_p, ":%s %d %s T :auth successes %u fails %u",
1162 >             me.name, RPL_STATSDEBUG, source_p->name, sp->is_asuc, sp->is_abad);
1163 >  sendto_one(source_p, ":%s %d %s T :Client Server",
1164 >             me.name, RPL_STATSDEBUG, source_p->name);
1165 >
1166 >  sendto_one(source_p, ":%s %d %s T :connected %u %u",
1167 >             me.name, RPL_STATSDEBUG, source_p->name,
1168 >             (unsigned int)sp->is_cl,
1169 >             (unsigned int)sp->is_sv);
1170 >  sendto_one(source_p, ":%s %d %s T :bytes sent %llu %llu",
1171 >             me.name, RPL_STATSDEBUG, source_p->name,
1172 >             sp->is_cbs, sp->is_sbs);
1173 >  sendto_one(source_p, ":%s %d %s T :bytes recv %llu %llu",
1174 >             me.name, RPL_STATSDEBUG, source_p->name,
1175 >             sp->is_cbr, sp->is_sbr);
1176 >  sendto_one(source_p, ":%s %d %s T :time connected %u %u",
1177 >             me.name, RPL_STATSDEBUG, source_p->name,
1178 >             (unsigned int)sp->is_cti,
1179 >             (unsigned int)sp->is_sti);
1180   }
1181  
1182   static void
1183   stats_uptime(struct Client *source_p)
1184   {
1185 <  time_t now = CurrentTime - me.since;
1185 >  time_t now = CurrentTime - me.localClient->since;
1186 >
1187    sendto_one(source_p, form_str(RPL_STATSUPTIME), from, to,
1188 <             now/86400, (now/3600)%24, (now/60)%60, now%60);
1189 <  if (!ConfigFileEntry.disable_remote || IsOper(source_p))
1188 >             now / 86400, (now / 3600) % 24, (now / 60) % 60, now % 60);
1189 >
1190 >  if (!ConfigFileEntry.disable_remote || HasUMode(source_p, UMODE_OPER))
1191       sendto_one(source_p, form_str(RPL_STATSCONN), from, to,
1192 <                MaxConnectionCount, MaxClientCount, Count.totalrestartcount);
1192 >                Count.max_loc_con, Count.max_loc_cli, Count.totalrestartcount);
1193   }
1194  
1195   static void
# Line 1139 | Line 1207 | stats_shared(struct Client *source_p)
1207   static void
1208   stats_servers(struct Client *source_p)
1209   {
1210 <  struct Client *target_p;
1143 <  dlink_node *ptr;
1144 <  int j = 0;
1210 >  dlink_node *ptr = NULL;
1211  
1212    DLINK_FOREACH(ptr, serv_list.head)
1213    {
1214 <    target_p = ptr->data;
1149 <
1150 <    j++;
1214 >    const struct Client *target_p = ptr->data;
1215  
1216      sendto_one(source_p, ":%s %d %s v :%s (%s!%s@%s) Idle: %d",
1217 <               from, RPL_STATSDEBUG, to,
1218 <               target_p->name,
1219 <               (target_p->serv->by[0] ? target_p->serv->by : "Remote."),
1156 <               "*", "*", (int)(CurrentTime - target_p->lasttime));
1217 >               from, RPL_STATSDEBUG, to, target_p->name,
1218 >               (target_p->serv->by[0] ? target_p->serv->by : "Remote."),
1219 >               "*", "*", (int)(CurrentTime - target_p->localClient->lasttime));
1220    }
1221  
1222 <  sendto_one(source_p, ":%s %d %s v :%d Server(s)",
1223 <             from, RPL_STATSDEBUG, to, j);
1222 >  sendto_one(source_p, ":%s %d %s v :%u Server(s)",
1223 >             from, RPL_STATSDEBUG, to, dlink_list_length(&serv_list));
1224   }
1225  
1226   static void
# Line 1182 | Line 1245 | stats_memory(struct Client *source_p)
1245   static void
1246   stats_ziplinks(struct Client *source_p)
1247   {
1248 <  dlink_node *ptr;
1186 <  struct Client *target_p;
1248 >  dlink_node *ptr = NULL;
1249    unsigned int sent_data = 0;
1250  
1251    DLINK_FOREACH(ptr, serv_list.head)
1252    {
1253 <    target_p = ptr->data;
1253 >    const struct Client *target_p = ptr->data;
1254  
1255      if (IsCapable(target_p, CAP_ZIP))
1256      {
# Line 1197 | Line 1259 | stats_ziplinks(struct Client *source_p)
1259         * -jmallett, 04/27/2002
1260         */
1261        struct ZipStats zipstats;
1262 <      memcpy(&zipstats, &target_p->localClient->zipstats, sizeof (struct ZipStats));
1262 >
1263 >      memcpy(&zipstats, &target_p->localClient->zipstats, sizeof(zipstats));
1264  
1265        sendto_one(source_p, ":%s %d %s Z :ZipLinks stats for %s send[%.2f%% "
1266 <                 "compression (%lu bytes data/%lu bytes wire)] recv[%.2f%% "
1267 <                 "compression (%lu bytes data/%lu bytes wire)]",
1266 >                 "compression (%llu bytes data/%llu bytes wire)] recv[%.2f%% "
1267 >                 "compression (%llu bytes data/%llu bytes wire)]",
1268                   from, RPL_STATSDEBUG, to, target_p->name,
1269 <                 zipstats.out_ratio, zipstats.out, zipstats.out_wire,
1270 <                 zipstats.in_ratio,  zipstats.in,  zipstats.in_wire);
1269 >                 zipstats.out_ratio, zipstats.out, zipstats.out_wire,
1270 >                 zipstats.in_ratio,  zipstats.in,  zipstats.in_wire);
1271        ++sent_data;
1272      }
1273    }
# Line 1218 | Line 1281 | stats_servlinks(struct Client *source_p)
1281   {
1282    uint64_t sendB = 0, recvB = 0;
1283    time_t uptime = 0;
1284 <  int j = 0;
1222 <  struct Client *target_p = NULL;
1223 <  dlink_node *ptr;
1284 >  dlink_node *ptr = NULL;
1285  
1286 <  if (ConfigServerHide.flatten_links && !IsOper(source_p))
1286 >  if (ConfigServerHide.flatten_links && !HasUMode(source_p, UMODE_OPER))
1287    {
1288      sendto_one(source_p, form_str(ERR_NOPRIVILEGES),
1289                 from, to);
# Line 1231 | Line 1292 | stats_servlinks(struct Client *source_p)
1292  
1293    DLINK_FOREACH(ptr, serv_list.head)
1294    {
1295 <    target_p = ptr->data;
1295 >    struct Client *target_p = ptr->data;
1296  
1236 –    ++j;
1297      sendB += target_p->localClient->send.bytes;
1298      recvB += target_p->localClient->recv.bytes;
1299  
1300      /* ":%s 211 %s %s %u %u %llu %u %llu :%u %u %s" */
1301      sendto_one(source_p, form_str(RPL_STATSLINKINFO),
1302                 from, to,
1303 <               get_client_name(target_p, IsAdmin(source_p) ? SHOW_IP : MASK_IP),
1303 >               get_client_name(target_p, HasUMode(source_p, UMODE_ADMIN) ? SHOW_IP : MASK_IP),
1304                 dbuf_length(&target_p->localClient->buf_sendq),
1305                 target_p->localClient->send.messages,
1306                 target_p->localClient->send.bytes >> 10,
1307                 target_p->localClient->recv.messages,
1308                 target_p->localClient->recv.bytes >> 10,
1309 <               (unsigned)(CurrentTime - target_p->firsttime),
1310 <               (CurrentTime > target_p->since) ? (unsigned)(CurrentTime - target_p->since): 0,
1311 <               IsOper(source_p) ? show_capabilities(target_p) : "TS");
1309 >               (unsigned)(CurrentTime - target_p->localClient->firsttime),
1310 >               (CurrentTime > target_p->localClient->since) ? (unsigned)(CurrentTime - target_p->localClient->since): 0,
1311 >               HasUMode(source_p, UMODE_OPER) ? show_capabilities(target_p) : "TS");
1312    }
1313  
1314    sendB >>= 10;
1315    recvB >>= 10;
1316  
1317    sendto_one(source_p, ":%s %d %s ? :%u total server(s)",
1318 <             from, RPL_STATSDEBUG, to, j);
1318 >             from, RPL_STATSDEBUG, to, dlink_list_length(&serv_list));
1319    sendto_one(source_p, ":%s %d %s ? :Sent total : %7.2f %s",
1320               from, RPL_STATSDEBUG, to,
1321 <             _GMKv((signed)sendB), _GMKs((signed)sendB));
1321 >             _GMKv(sendB), _GMKs(sendB));
1322    sendto_one(source_p, ":%s %d %s ? :Recv total : %7.2f %s",
1323               from, RPL_STATSDEBUG, to,
1324 <             _GMKv((signed)recvB), _GMKs((signed)recvB));
1324 >             _GMKv(recvB), _GMKs(recvB));
1325  
1326 <  uptime = (CurrentTime - me.since);
1326 >  uptime = (CurrentTime - me.localClient->since);
1327  
1328    sendto_one(source_p, ":%s %d %s ? :Server send: %7.2f %s (%4.1f K/s)",
1329               from, RPL_STATSDEBUG, to,
1330 <             _GMKv((signed)(me.localClient->send.bytes>>10)),
1331 <             _GMKs((signed)(me.localClient->send.bytes>>10)),
1332 <             (float)((float)(((signed)me.localClient->send.bytes) >> 10) /
1333 <             (float)uptime));
1330 >             _GMKv((me.localClient->send.bytes>>10)),
1331 >             _GMKs((me.localClient->send.bytes>>10)),
1332 >             (float)((float)((me.localClient->send.bytes) >> 10) /
1333 >             (float)uptime));
1334    sendto_one(source_p, ":%s %d %s ? :Server recv: %7.2f %s (%4.1f K/s)",
1335               from, RPL_STATSDEBUG, to,
1336 <             _GMKv((signed)(me.localClient->recv.bytes>>10)),
1337 <             _GMKs((signed)(me.localClient->recv.bytes>>10)),
1338 <             (float)((float)(((signed)me.localClient->recv.bytes) >> 10) /
1339 <             (float)uptime));
1336 >             _GMKv((me.localClient->recv.bytes>>10)),
1337 >             _GMKs((me.localClient->recv.bytes>>10)),
1338 >             (float)((float)((me.localClient->recv.bytes) >> 10) /
1339 >             (float)uptime));
1340   }
1341  
1342   static void
# Line 1299 | Line 1359 | stats_ltrace(struct Client *source_p, in
1359   }
1360  
1361   /*
1302 – * ms_stats - STATS message handler
1303 – *      parv[0] = sender prefix
1304 – *      parv[1] = statistics selector (defaults to Message frequency)
1305 – *      parv[2] = server name (current server defaulted, if omitted)
1306 – */
1307 – static void
1308 – ms_stats(struct Client *client_p, struct Client *source_p,
1309 –         int parc, char *parv[])
1310 – {
1311 –  if (hunt_server(client_p,source_p,":%s STATS %s :%s",2,parc,parv)!=HUNTED_ISME)
1312 –    return;
1313 –
1314 –  if (IsClient(source_p))
1315 –    mo_stats(client_p, source_p, parc, parv);
1316 – }
1317 –
1318 – /*
1362   * stats_L
1363   *
1364   * inputs       - pointer to client to report to
# Line 1350 | Line 1393 | stats_L_list(struct Client *source_p,cha
1393    {
1394      target_p = ptr->data;
1395  
1396 <    if (IsInvisible(target_p) && (doall || wilds) &&
1397 <        !(MyConnect(source_p) && IsOper(source_p)) &&
1398 <        !IsOper(target_p) && (target_p != source_p))
1396 >    if (HasUMode(target_p, UMODE_INVISIBLE) && (doall || wilds) &&
1397 >        !(MyConnect(source_p) && HasUMode(source_p, UMODE_OPER)) &&
1398 >        !HasUMode(target_p, UMODE_OPER) && (target_p != source_p))
1399        continue;
1400      if (!doall && wilds && !match(name, target_p->name))
1401        continue;
# Line 1361 | Line 1404 | stats_L_list(struct Client *source_p,cha
1404  
1405      /* This basically shows ips for our opers if its not a server/admin, or
1406       * its one of our admins.  */
1407 <    if(MyClient(source_p) && IsOper(source_p) &&
1408 <       (IsAdmin(source_p) ||
1409 <       (!IsServer(target_p) && !IsAdmin(target_p) &&
1407 >    if(MyClient(source_p) && HasUMode(source_p, UMODE_OPER) &&
1408 >       (HasUMode(source_p, UMODE_ADMIN) ||
1409 >       (!IsServer(target_p) && !HasUMode(target_p, UMODE_ADMIN) &&
1410         !IsHandshake(target_p) && !IsConnecting(target_p))))
1411      {
1412        sendto_one(source_p, form_str(RPL_STATSLINKINFO),
# Line 1376 | Line 1419 | stats_L_list(struct Client *source_p,cha
1419                   target_p->localClient->send.bytes>>10,
1420                   target_p->localClient->recv.messages,
1421                   target_p->localClient->recv.bytes>>10,
1422 <                 (unsigned)(CurrentTime - target_p->firsttime),
1423 <                 (CurrentTime > target_p->since) ? (unsigned)(CurrentTime - target_p->since):0,
1422 >                 (unsigned)(CurrentTime - target_p->localClient->firsttime),
1423 >                 (CurrentTime > target_p->localClient->since) ? (unsigned)(CurrentTime - target_p->localClient->since):0,
1424                   IsServer(target_p) ? show_capabilities(target_p) : "-");
1425      }
1426      else
1427      {
1428        /* If its a hidden ip, an admin, or a server, mask the real IP */
1429 <      if(IsIPSpoof(target_p) || IsServer(target_p) || IsAdmin(target_p)
1429 >      if(IsIPSpoof(target_p) || IsServer(target_p) || HasUMode(target_p, UMODE_ADMIN)
1430           || IsHandshake(target_p) || IsConnecting(target_p))
1431          sendto_one(source_p, form_str(RPL_STATSLINKINFO),
1432                     from, to,
# Line 1393 | Line 1436 | stats_L_list(struct Client *source_p,cha
1436                     target_p->localClient->send.bytes>>10,
1437                     target_p->localClient->recv.messages,
1438                     target_p->localClient->recv.bytes>>10,
1439 <                   (unsigned)(CurrentTime - target_p->firsttime),
1440 <                   (CurrentTime > target_p->since) ? (unsigned)(CurrentTime - target_p->since):0,
1439 >                   (unsigned)(CurrentTime - target_p->localClient->firsttime),
1440 >                   (CurrentTime > target_p->localClient->since) ? (unsigned)(CurrentTime - target_p->localClient->since):0,
1441                     IsServer(target_p) ? show_capabilities(target_p) : "-");
1442        else /* show the real IP */
1443          sendto_one(source_p, form_str(RPL_STATSLINKINFO),
# Line 1407 | Line 1450 | stats_L_list(struct Client *source_p,cha
1450                     target_p->localClient->send.bytes>>10,
1451                     target_p->localClient->recv.messages,
1452                     target_p->localClient->recv.bytes>>10,
1453 <                   (unsigned)(CurrentTime - target_p->firsttime),
1454 <                   (CurrentTime > target_p->since) ? (unsigned)(CurrentTime - target_p->since):0,
1453 >                   (unsigned)(CurrentTime - target_p->localClient->firsttime),
1454 >                   (CurrentTime > target_p->localClient->since) ? (unsigned)(CurrentTime - target_p->localClient->since):0,
1455                     IsServer(target_p) ? show_capabilities(target_p) : "-");
1456      }
1457    }
# Line 1448 | Line 1491 | parse_stats_args(int parc, char *parv[],
1491    else
1492      return(NULL);
1493   }
1494 +
1495 + static struct Message stats_msgtab = {
1496 +  "STATS", 0, 0, 2, MAXPARA, MFLG_SLOW, 0,
1497 +  { m_unregistered, m_stats, ms_stats, m_ignore, mo_stats, m_ignore }
1498 + };
1499 +
1500 + static void
1501 + module_init(void)
1502 + {
1503 +  mod_add_cmd(&stats_msgtab);
1504 + }
1505 +
1506 + static void
1507 + module_exit(void)
1508 + {
1509 +  mod_del_cmd(&stats_msgtab);
1510 + }
1511 +
1512 + struct module module_entry = {
1513 +  .node    = { NULL, NULL, NULL },
1514 +  .name    = NULL,
1515 +  .version = "$Revision$",
1516 +  .handle  = NULL,
1517 +  .modinit = module_init,
1518 +  .modexit = module_exit,
1519 +  .flags   = 0
1520 + };

Comparing:
ircd-hybrid/modules/m_stats.c (property svn:keywords), Revision 30 by adx, Sun Oct 2 20:03:27 2005 UTC vs.
ircd-hybrid-8/modules/m_stats.c (property svn:keywords), Revision 1241 by michael, Thu Sep 29 20:26:09 2011 UTC

# Line 1 | Line 1
1 < "Id Revision"
1 > Id Revision

Diff Legend

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