2 * ircd-ratbox: an advanced Internet Relay Chat Daemon(ircd).
3 * m_stats.c: Sends the user statistics or config information.
5 * Copyright (C) 1990 Jarkko Oikarinen and University of Oulu, Co Center
6 * Copyright (C) 1996-2002 Hybrid Development Team
7 * Copyright (C) 2002-2005 ircd-ratbox development team
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
24 * $Id: m_stats.c 1608 2006-06-04 02:11:40Z jilles $
28 #include "class.h" /* report_classes */
29 #include "client.h" /* Client */
30 #include "common.h" /* TRUE/FALSE */
32 #include "ircd.h" /* me */
33 #include "listener.h" /* show_ports */
34 #include "msg.h" /* Message */
35 #include "hostmask.h" /* report_mtrie_conf_links */
36 #include "numeric.h" /* ERR_xxx */
37 #include "scache.h" /* list_scache */
38 #include "send.h" /* sendto_one */
39 #include "s_conf.h" /* ConfItem */
40 #include "s_serv.h" /* hunt_server */
42 #include "s_user.h" /* show_opers */
43 #include "blacklist.h" /* dnsbl stuff */
47 #include "s_newconf.h"
52 static int m_stats (struct Client
*, struct Client
*, int, const char **);
54 struct Message stats_msgtab
= {
55 "STATS", 0, 0, 0, MFLG_SLOW
,
56 {mg_unreg
, {m_stats
, 2}, {m_stats
, 3}, mg_ignore
, mg_ignore
, {m_stats
, 2}}
60 int doing_stats_p_hook
;
62 mapi_clist_av1 stats_clist
[] = { &stats_msgtab
, NULL
};
63 mapi_hlist_av1 stats_hlist
[] = {
64 { "doing_stats", &doing_stats_hook
},
65 { "doing_stats_p", &doing_stats_p_hook
},
69 DECLARE_MODULE_AV1(stats
, NULL
, NULL
, stats_clist
, stats_hlist
, NULL
, "$Revision: 1608 $");
71 const char *Lformat
= "%s %u %u %u %u %u :%u %u %s";
73 static void stats_l_list(struct Client
*s
, const char *, int, int, rb_dlink_list
*, char);
74 static void stats_l_client(struct Client
*source_p
, struct Client
*target_p
,
77 static void stats_spy(struct Client
*, char, const char *);
78 static void stats_p_spy(struct Client
*);
80 /* Heres our struct for the stats table */
84 void (*handler
) (struct Client
*source_p
);
89 static void stats_dns_servers(struct Client
*);
90 static void stats_delay(struct Client
*);
91 static void stats_hash(struct Client
*);
92 static void stats_connect(struct Client
*);
93 static void stats_tdeny(struct Client
*);
94 static void stats_deny(struct Client
*);
95 static void stats_exempt(struct Client
*);
96 static void stats_events(struct Client
*);
97 static void stats_hubleaf(struct Client
*);
98 static void stats_auth(struct Client
*);
99 static void stats_tklines(struct Client
*);
100 static void stats_klines(struct Client
*);
101 static void stats_messages(struct Client
*);
102 static void stats_dnsbl(struct Client
*);
103 static void stats_oper(struct Client
*);
104 static void stats_operedup(struct Client
*);
105 static void stats_ports(struct Client
*);
106 static void stats_tresv(struct Client
*);
107 static void stats_resv(struct Client
*);
108 static void stats_usage(struct Client
*);
109 static void stats_tstats(struct Client
*);
110 static void stats_uptime(struct Client
*);
111 static void stats_shared(struct Client
*);
112 static void stats_servers(struct Client
*);
113 static void stats_tgecos(struct Client
*);
114 static void stats_gecos(struct Client
*);
115 static void stats_class(struct Client
*);
116 static void stats_memory(struct Client
*);
117 static void stats_servlinks(struct Client
*);
118 static void stats_ltrace(struct Client
*, int, const char **);
119 static void stats_ziplinks(struct Client
*);
120 static void stats_comm(struct Client
*);
121 /* This table contains the possible stats items, in order:
122 * stats letter, function to call, operonly? adminonly?
123 * case only matters in the stats letter column.. -- fl_
125 static struct StatsStruct stats_cmd_table
[] = {
126 /* letter function need_oper need_admin */
127 {'a', stats_dns_servers
, 1, 1, },
128 {'A', stats_dns_servers
, 1, 1, },
129 {'b', stats_delay
, 1, 1, },
130 {'B', stats_hash
, 1, 1, },
131 {'c', stats_connect
, 0, 0, },
132 {'C', stats_connect
, 0, 0, },
133 {'d', stats_tdeny
, 1, 0, },
134 {'D', stats_deny
, 1, 0, },
135 {'e', stats_exempt
, 1, 0, },
136 {'E', stats_events
, 1, 1, },
137 {'f', stats_comm
, 1, 1, },
138 {'F', stats_comm
, 1, 1, },
139 {'h', stats_hubleaf
, 0, 0, },
140 {'H', stats_hubleaf
, 0, 0, },
141 {'i', stats_auth
, 0, 0, },
142 {'I', stats_auth
, 0, 0, },
143 {'k', stats_tklines
, 0, 0, },
144 {'K', stats_klines
, 0, 0, },
145 {'l', NULL
/* special */, 0, 0, },
146 {'L', NULL
/* special */, 0, 0, },
147 {'m', stats_messages
, 0, 0, },
148 {'M', stats_messages
, 0, 0, },
149 {'n', stats_dnsbl
, 0, 0, },
150 {'o', stats_oper
, 0, 0, },
151 {'O', stats_oper
, 0, 0, },
152 {'p', stats_operedup
, 0, 0, },
153 {'P', stats_ports
, 0, 0, },
154 {'q', stats_tresv
, 1, 0, },
155 {'Q', stats_resv
, 1, 0, },
156 {'r', stats_usage
, 1, 0, },
157 {'R', stats_usage
, 1, 0, },
158 {'t', stats_tstats
, 1, 0, },
159 {'T', stats_tstats
, 1, 0, },
160 {'u', stats_uptime
, 0, 0, },
161 {'U', stats_shared
, 1, 0, },
162 {'v', stats_servers
, 0, 0, },
163 {'V', stats_servers
, 0, 0, },
164 {'x', stats_tgecos
, 1, 0, },
165 {'X', stats_gecos
, 1, 0, },
166 {'y', stats_class
, 0, 0, },
167 {'Y', stats_class
, 0, 0, },
168 {'z', stats_memory
, 1, 0, },
169 {'Z', stats_ziplinks
, 1, 0, },
170 {'?', stats_servlinks
, 0, 0, },
171 {(char) 0, (void (*)()) 0, 0, 0, }
176 * parv[0] = sender prefix
177 * parv[1] = stat letter/command
178 * parv[2] = (if present) server/mask in stats L, or target
180 * This will search the tables for the appropriate stats letter,
181 * if found execute it.
184 m_stats(struct Client
*client_p
, struct Client
*source_p
, int parc
, const char *parv
[])
186 static time_t last_used
= 0;
190 statchar
= parv
[1][0];
192 if(MyClient(source_p
) && !IsOper(source_p
))
194 /* Check the user is actually allowed to do /stats, and isnt flooding */
195 if((last_used
+ ConfigFileEntry
.pace_wait
) > rb_current_time())
197 /* safe enough to give this on a local connect only */
198 sendto_one(source_p
, form_str(RPL_LOAD2HI
),
199 me
.name
, source_p
->name
, "STATS");
200 sendto_one_numeric(source_p
, RPL_ENDOFSTATS
,
201 form_str(RPL_ENDOFSTATS
), statchar
);
205 last_used
= rb_current_time();
208 if(hunt_server (client_p
, source_p
, ":%s STATS %s :%s", 2, parc
, parv
) != HUNTED_ISME
)
211 if((statchar
!= 'L') && (statchar
!= 'l'))
212 stats_spy(source_p
, statchar
, NULL
);
214 for (i
= 0; stats_cmd_table
[i
].letter
; i
++)
216 if(stats_cmd_table
[i
].letter
== statchar
)
218 /* The stats table says what privs are needed, so check --fl_ */
219 /* Called for remote clients and for local opers, so check need_admin
222 if(stats_cmd_table
[i
].need_oper
&& !IsOper(source_p
))
224 sendto_one_numeric(source_p
, ERR_NOPRIVILEGES
,
225 form_str (ERR_NOPRIVILEGES
));
228 if(stats_cmd_table
[i
].need_admin
&& !IsOperAdmin(source_p
))
230 sendto_one(source_p
, form_str(ERR_NOPRIVS
),
231 me
.name
, source_p
->name
, "admin");
235 /* Blah, stats L needs the parameters, none of the others do.. */
236 if(statchar
== 'L' || statchar
== 'l')
237 stats_ltrace (source_p
, parc
, parv
);
239 stats_cmd_table
[i
].handler (source_p
);
243 /* Send the end of stats notice, and the stats_spy */
244 sendto_one_numeric(source_p
, RPL_ENDOFSTATS
,
245 form_str(RPL_ENDOFSTATS
), statchar
);
251 stats_dns_servers (struct Client
*source_p
)
253 report_dns_servers (source_p
);
257 stats_delay(struct Client
*source_p
)
260 struct DictionaryIter iter
;
262 DICTIONARY_FOREACH(nd
, &iter
, nd_dict
)
264 sendto_one_notice(source_p
, ":Delaying: %s for %ld",
265 nd
->name
, (long) nd
->expire
);
270 stats_hash(struct Client
*source_p
)
272 hash_stats(source_p
);
276 stats_connect(struct Client
*source_p
)
279 struct server_conf
*server_p
;
283 if((ConfigFileEntry
.stats_c_oper_only
||
284 (ConfigServerHide
.flatten_links
&& !IsExemptShide(source_p
))) &&
287 sendto_one_numeric(source_p
, ERR_NOPRIVILEGES
,
288 form_str(ERR_NOPRIVILEGES
));
292 RB_DLINK_FOREACH(ptr
, server_conf_list
.head
)
294 server_p
= ptr
->data
;
296 if(ServerConfIllegal(server_p
))
304 if(ServerConfAutoconn(server_p
))
306 if(ServerConfSSL(server_p
))
308 if(ServerConfTb(server_p
))
310 if(ServerConfCompressed(server_p
))
319 sendto_one_numeric(source_p
, RPL_STATSCLINE
,
320 form_str(RPL_STATSCLINE
),
323 server_p
->port
, server_p
->class_name
);
329 * input - client to report to
331 * side effects - client is given temp dline list.
334 stats_tdeny (struct Client
*source_p
)
336 char *host
, *pass
, *user
, *oper_reason
;
337 struct AddressRec
*arec
;
338 struct ConfItem
*aconf
;
341 for (i
= 0; i
< ATABLE_SIZE
; i
++)
343 for (arec
= atable
[i
]; arec
; arec
= arec
->next
)
345 if(arec
->type
== CONF_DLINE
)
349 if(!(aconf
->flags
& CONF_FLAGS_TEMPORARY
))
352 get_printable_kline(source_p
, aconf
, &host
, &pass
, &user
, &oper_reason
);
354 sendto_one_numeric(source_p
, RPL_STATSDLINE
,
355 form_str (RPL_STATSDLINE
),
357 oper_reason
? "|" : "",
358 oper_reason
? oper_reason
: "");
366 * input - client to report to
368 * side effects - client is given dline list.
371 stats_deny (struct Client
*source_p
)
373 char *host
, *pass
, *user
, *oper_reason
;
374 struct AddressRec
*arec
;
375 struct ConfItem
*aconf
;
378 for (i
= 0; i
< ATABLE_SIZE
; i
++)
380 for (arec
= atable
[i
]; arec
; arec
= arec
->next
)
382 if(arec
->type
== CONF_DLINE
)
386 if(aconf
->flags
& CONF_FLAGS_TEMPORARY
)
389 get_printable_kline(source_p
, aconf
, &host
, &pass
, &user
, &oper_reason
);
391 sendto_one_numeric(source_p
, RPL_STATSDLINE
,
392 form_str (RPL_STATSDLINE
),
394 oper_reason
? "|" : "",
395 oper_reason
? oper_reason
: "");
404 * input - client to report to
406 * side effects - client is given list of exempt blocks
409 stats_exempt(struct Client
*source_p
)
411 char *name
, *host
, *pass
, *user
, *classname
;
412 struct AddressRec
*arec
;
413 struct ConfItem
*aconf
;
416 if(ConfigFileEntry
.stats_e_disabled
)
418 sendto_one_numeric(source_p
, ERR_DISABLED
,
419 form_str(ERR_DISABLED
), "STATS e");
423 for (i
= 0; i
< ATABLE_SIZE
; i
++)
425 for (arec
= atable
[i
]; arec
; arec
= arec
->next
)
427 if(arec
->type
== CONF_EXEMPTDLINE
)
430 get_printable_conf (aconf
, &name
, &host
, &pass
,
431 &user
, &port
, &classname
);
433 sendto_one_numeric(source_p
, RPL_STATSDLINE
,
434 form_str(RPL_STATSDLINE
),
435 'e', host
, pass
, "", "");
442 stats_events_cb(char *str
, void *ptr
)
444 sendto_one_numeric(ptr
, RPL_STATSDEBUG
, "E :%s", str
);
448 stats_events (struct Client
*source_p
)
450 rb_dump_events(stats_events_cb
, source_p
);
454 stats_hubleaf(struct Client
*source_p
)
456 struct remote_conf
*hub_p
;
459 if((ConfigFileEntry
.stats_h_oper_only
||
460 (ConfigServerHide
.flatten_links
&& !IsExemptShide(source_p
))) &&
463 sendto_one_numeric(source_p
, ERR_NOPRIVILEGES
,
464 form_str (ERR_NOPRIVILEGES
));
468 RB_DLINK_FOREACH(ptr
, hubleaf_conf_list
.head
)
472 if(hub_p
->flags
& CONF_HUB
)
473 sendto_one_numeric(source_p
, RPL_STATSHLINE
,
474 form_str(RPL_STATSHLINE
),
475 hub_p
->host
, hub_p
->server
);
477 sendto_one_numeric(source_p
, RPL_STATSLLINE
,
478 form_str(RPL_STATSLLINE
),
479 hub_p
->host
, hub_p
->server
);
485 stats_auth (struct Client
*source_p
)
487 /* Oper only, if unopered, return ERR_NOPRIVS */
488 if((ConfigFileEntry
.stats_i_oper_only
== 2) && !IsOper (source_p
))
489 sendto_one_numeric(source_p
, ERR_NOPRIVILEGES
,
490 form_str (ERR_NOPRIVILEGES
));
492 /* If unopered, Only return matching auth blocks */
493 else if((ConfigFileEntry
.stats_i_oper_only
== 1) && !IsOper (source_p
))
495 struct ConfItem
*aconf
;
496 char *name
, *host
, *pass
= "*", *user
, *classname
;
499 if(MyConnect (source_p
))
500 aconf
= find_conf_by_address (source_p
->host
, source_p
->sockhost
, NULL
,
501 (struct sockaddr
*)&source_p
->localClient
->ip
,
503 source_p
->localClient
->ip
.ss_family
,
504 source_p
->username
, NULL
);
506 aconf
= find_conf_by_address (source_p
->host
, NULL
, NULL
, NULL
, CONF_CLIENT
,
507 0, source_p
->username
, NULL
);
512 get_printable_conf (aconf
, &name
, &host
, &pass
, &user
, &port
, &classname
);
513 if(!EmptyString(aconf
->spasswd
))
514 pass
= aconf
->spasswd
;
516 sendto_one_numeric(source_p
, RPL_STATSILINE
, form_str(RPL_STATSILINE
),
517 name
, pass
, show_iline_prefix(source_p
, aconf
, user
),
518 host
, port
, classname
);
521 /* Theyre opered, or allowed to see all auth blocks */
523 report_auth (source_p
);
528 stats_tklines(struct Client
*source_p
)
530 /* Oper only, if unopered, return ERR_NOPRIVS */
531 if((ConfigFileEntry
.stats_k_oper_only
== 2) && !IsOper (source_p
))
532 sendto_one_numeric(source_p
, ERR_NOPRIVILEGES
,
533 form_str (ERR_NOPRIVILEGES
));
535 /* If unopered, Only return matching klines */
536 else if((ConfigFileEntry
.stats_k_oper_only
== 1) && !IsOper (source_p
))
538 struct ConfItem
*aconf
;
539 char *host
, *pass
, *user
, *oper_reason
;
541 if(MyConnect (source_p
))
542 aconf
= find_conf_by_address (source_p
->host
, source_p
->sockhost
, NULL
,
543 (struct sockaddr
*)&source_p
->localClient
->ip
,
545 source_p
->localClient
->ip
.ss_family
,
546 source_p
->username
, NULL
);
548 aconf
= find_conf_by_address (source_p
->host
, NULL
, NULL
, NULL
, CONF_KILL
,
549 0, source_p
->username
, NULL
);
554 /* dont report a permanent kline as a tkline */
555 if((aconf
->flags
& CONF_FLAGS_TEMPORARY
) == 0)
558 get_printable_kline(source_p
, aconf
, &host
, &pass
, &user
, &oper_reason
);
560 sendto_one_numeric(source_p
, RPL_STATSKLINE
,
561 form_str(RPL_STATSKLINE
), aconf
->flags
& CONF_FLAGS_TEMPORARY
? 'k' : 'K',
562 host
, user
, pass
, oper_reason
? "|" : "",
563 oper_reason
? oper_reason
: "");
565 /* Theyre opered, or allowed to see all klines */
568 struct ConfItem
*aconf
;
571 char *user
, *host
, *pass
, *oper_reason
;
573 for(i
= 0; i
< LAST_TEMP_TYPE
; i
++)
575 RB_DLINK_FOREACH(ptr
, temp_klines
[i
].head
)
579 get_printable_kline(source_p
, aconf
, &host
, &pass
,
580 &user
, &oper_reason
);
582 sendto_one_numeric(source_p
, RPL_STATSKLINE
,
583 form_str(RPL_STATSKLINE
),
584 'k', host
, user
, pass
,
585 oper_reason
? "|" : "",
586 oper_reason
? oper_reason
: "");
593 stats_klines(struct Client
*source_p
)
595 /* Oper only, if unopered, return ERR_NOPRIVS */
596 if((ConfigFileEntry
.stats_k_oper_only
== 2) && !IsOper (source_p
))
597 sendto_one_numeric(source_p
, ERR_NOPRIVILEGES
,
598 form_str (ERR_NOPRIVILEGES
));
600 /* If unopered, Only return matching klines */
601 else if((ConfigFileEntry
.stats_k_oper_only
== 1) && !IsOper (source_p
))
603 struct ConfItem
*aconf
;
604 char *host
, *pass
, *user
, *oper_reason
;
606 /* search for a kline */
607 if(MyConnect (source_p
))
608 aconf
= find_conf_by_address (source_p
->host
, source_p
->sockhost
, NULL
,
609 (struct sockaddr
*)&source_p
->localClient
->ip
,
611 source_p
->localClient
->ip
.ss_family
,
612 source_p
->username
, NULL
);
614 aconf
= find_conf_by_address (source_p
->host
, NULL
, NULL
, NULL
, CONF_KILL
,
615 0, source_p
->username
, NULL
);
620 get_printable_kline(source_p
, aconf
, &host
, &pass
, &user
, &oper_reason
);
622 sendto_one_numeric(source_p
, RPL_STATSKLINE
, form_str(RPL_STATSKLINE
),
623 aconf
->flags
& CONF_FLAGS_TEMPORARY
? 'k' : 'K',
624 host
, user
, pass
, oper_reason
? "|" : "",
625 oper_reason
? oper_reason
: "");
627 /* Theyre opered, or allowed to see all klines */
629 report_Klines (source_p
);
633 stats_messages(struct Client
*source_p
)
635 report_messages(source_p
);
639 stats_dnsbl(struct Client
*source_p
)
642 struct Blacklist
*blptr
;
644 RB_DLINK_FOREACH(ptr
, blacklist_list
.head
)
648 /* use RPL_STATSDEBUG for now -- jilles */
649 sendto_one_numeric(source_p
, RPL_STATSDEBUG
, "n :%d %s %s (%d)",
652 blptr
->status
& CONF_ILLEGAL
? "disabled" : "active",
658 stats_oper(struct Client
*source_p
)
660 struct oper_conf
*oper_p
;
663 if(!IsOper(source_p
) && ConfigFileEntry
.stats_o_oper_only
)
665 sendto_one_numeric(source_p
, ERR_NOPRIVILEGES
,
666 form_str (ERR_NOPRIVILEGES
));
670 RB_DLINK_FOREACH(ptr
, oper_conf_list
.head
)
674 sendto_one_numeric(source_p
, RPL_STATSOLINE
,
675 form_str(RPL_STATSOLINE
),
676 oper_p
->username
, oper_p
->host
, oper_p
->name
,
677 IsOper(source_p
) ? oper_p
->privset
->name
: "0", "-1");
684 * input - client pointer
686 * side effects - client is shown a list of active opers
689 stats_operedup (struct Client
*source_p
)
691 struct Client
*target_p
;
692 rb_dlink_node
*oper_ptr
;
693 unsigned int count
= 0;
695 RB_DLINK_FOREACH (oper_ptr
, oper_list
.head
)
697 target_p
= oper_ptr
->data
;
699 if(IsOperInvis(target_p
) && !IsOper(source_p
))
702 if(target_p
->user
->away
)
707 sendto_one_numeric(source_p
, RPL_STATSDEBUG
,
709 target_p
->name
, target_p
->username
,
713 sendto_one_numeric(source_p
, RPL_STATSDEBUG
,
714 "p :%u staff members", count
);
716 stats_p_spy (source_p
);
720 stats_ports (struct Client
*source_p
)
722 if(!IsOper (source_p
) && ConfigFileEntry
.stats_P_oper_only
)
723 sendto_one_numeric(source_p
, ERR_NOPRIVILEGES
,
724 form_str (ERR_NOPRIVILEGES
));
726 show_ports (source_p
);
730 stats_tresv(struct Client
*source_p
)
732 struct ConfItem
*aconf
;
736 RB_DLINK_FOREACH(ptr
, resv_conf_list
.head
)
740 sendto_one_numeric(source_p
, RPL_STATSQLINE
,
741 form_str(RPL_STATSQLINE
),
742 'q', aconf
->port
, aconf
->name
, aconf
->passwd
);
745 HASH_WALK(i
, R_MAX
, ptr
, resvTable
)
749 sendto_one_numeric(source_p
, RPL_STATSQLINE
,
750 form_str(RPL_STATSQLINE
),
751 'q', aconf
->port
, aconf
->name
, aconf
->passwd
);
758 stats_resv(struct Client
*source_p
)
760 struct ConfItem
*aconf
;
764 RB_DLINK_FOREACH(ptr
, resv_conf_list
.head
)
768 sendto_one_numeric(source_p
, RPL_STATSQLINE
,
769 form_str(RPL_STATSQLINE
),
770 'Q', aconf
->port
, aconf
->name
, aconf
->passwd
);
773 HASH_WALK(i
, R_MAX
, ptr
, resvTable
)
777 sendto_one_numeric(source_p
, RPL_STATSQLINE
,
778 form_str(RPL_STATSQLINE
),
779 'Q', aconf
->port
, aconf
->name
, aconf
->passwd
);
785 stats_usage (struct Client
*source_p
)
800 if(getrusage(RUSAGE_SELF
, &rus
) == -1)
802 sendto_one_notice(source_p
, ":Getruseage error: %s.",
806 secs
= rus
.ru_utime
.tv_sec
+ rus
.ru_stime
.tv_sec
;
810 rup
= (rb_current_time() - startup_time
) * hzz
;
814 sendto_one_numeric(source_p
, RPL_STATSDEBUG
,
815 "R :CPU Secs %d:%d User %d:%d System %d:%d",
816 (int) (secs
/ 60), (int) (secs
% 60),
817 (int) (rus
.ru_utime
.tv_sec
/ 60),
818 (int) (rus
.ru_utime
.tv_sec
% 60),
819 (int) (rus
.ru_stime
.tv_sec
/ 60),
820 (int) (rus
.ru_stime
.tv_sec
% 60));
821 sendto_one_numeric(source_p
, RPL_STATSDEBUG
,
822 "R :RSS %ld ShMem %ld Data %ld Stack %ld",
823 rus
.ru_maxrss
, (rus
.ru_ixrss
/ rup
),
824 (rus
.ru_idrss
/ rup
), (rus
.ru_isrss
/ rup
));
825 sendto_one_numeric(source_p
, RPL_STATSDEBUG
,
826 "R :Swaps %d Reclaims %d Faults %d",
827 (int) rus
.ru_nswap
, (int) rus
.ru_minflt
, (int) rus
.ru_majflt
);
828 sendto_one_numeric(source_p
, RPL_STATSDEBUG
,
829 "R :Block in %d out %d",
830 (int) rus
.ru_inblock
, (int) rus
.ru_oublock
);
831 sendto_one_numeric(source_p
, RPL_STATSDEBUG
,
832 "R :Msg Rcv %d Send %d",
833 (int) rus
.ru_msgrcv
, (int) rus
.ru_msgsnd
);
834 sendto_one_numeric(source_p
, RPL_STATSDEBUG
,
835 "R :Signals %d Context Vol. %d Invol %d",
836 (int) rus
.ru_nsignals
, (int) rus
.ru_nvcsw
,
837 (int) rus
.ru_nivcsw
);
841 stats_tstats (struct Client
*source_p
)
843 struct Client
*target_p
;
844 struct ServerStatistics sp
;
847 memcpy(&sp
, &ServerStats
, sizeof(struct ServerStatistics
));
849 RB_DLINK_FOREACH(ptr
, serv_list
.head
)
851 target_p
= ptr
->data
;
853 sp
.is_sbs
+= target_p
->localClient
->sendB
;
854 sp
.is_sbr
+= target_p
->localClient
->receiveB
;
855 sp
.is_sti
+= (unsigned long long)(rb_current_time() - target_p
->localClient
->firsttime
);
859 RB_DLINK_FOREACH(ptr
, lclient_list
.head
)
861 target_p
= ptr
->data
;
863 sp
.is_cbs
+= target_p
->localClient
->sendB
;
864 sp
.is_cbr
+= target_p
->localClient
->receiveB
;
865 sp
.is_cti
+= (unsigned long long)(rb_current_time() - target_p
->localClient
->firsttime
);
869 RB_DLINK_FOREACH(ptr
, unknown_list
.head
)
874 sendto_one_numeric(source_p
, RPL_STATSDEBUG
,
875 "T :accepts %u refused %u", sp
.is_ac
, sp
.is_ref
);
876 sendto_one_numeric(source_p
, RPL_STATSDEBUG
,
877 "T :rejected %u delaying %lu",
878 sp
.is_rej
, delay_exit_length());
879 sendto_one_numeric(source_p
, RPL_STATSDEBUG
,
880 "T :throttled refused %u throttle list size %lu", sp
.is_thr
, throttle_size());
881 sendto_one_numeric(source_p
, RPL_STATSDEBUG
,
882 "T :nicks being delayed %lu",
884 sendto_one_numeric(source_p
, RPL_STATSDEBUG
,
885 "T :unknown commands %u prefixes %u",
886 sp
.is_unco
, sp
.is_unpf
);
887 sendto_one_numeric(source_p
, RPL_STATSDEBUG
,
888 "T :nick collisions %u saves %u unknown closes %u",
889 sp
.is_kill
, sp
.is_save
, sp
.is_ni
);
890 sendto_one_numeric(source_p
, RPL_STATSDEBUG
,
891 "T :wrong direction %u empty %u",
892 sp
.is_wrdi
, sp
.is_empt
);
893 sendto_one_numeric(source_p
, RPL_STATSDEBUG
,
894 "T :numerics seen %u", sp
.is_num
);
895 sendto_one_numeric(source_p
, RPL_STATSDEBUG
,
896 "T :tgchange blocked msgs %u restricted addrs %lu",
897 sp
.is_tgch
, rb_dlink_list_length(&tgchange_list
));
898 sendto_one_numeric(source_p
, RPL_STATSDEBUG
,
899 "T :auth successes %u fails %u",
900 sp
.is_asuc
, sp
.is_abad
);
901 sendto_one_numeric(source_p
, RPL_STATSDEBUG
,
902 "T :sasl successes %u fails %u",
903 sp
.is_ssuc
, sp
.is_sbad
);
904 sendto_one_numeric(source_p
, RPL_STATSDEBUG
, "T :Client Server");
905 sendto_one_numeric(source_p
, RPL_STATSDEBUG
,
906 "T :connected %u %u", sp
.is_cl
, sp
.is_sv
);
907 sendto_one_numeric(source_p
, RPL_STATSDEBUG
,
908 "T :bytes sent %lluK %lluK",
911 sendto_one_numeric(source_p
, RPL_STATSDEBUG
,
912 "T :bytes recv %lluK %lluK",
915 sendto_one_numeric(source_p
, RPL_STATSDEBUG
,
916 "T :time connected %llu %llu",
917 sp
.is_cti
, sp
.is_sti
);
921 stats_uptime (struct Client
*source_p
)
925 now
= rb_current_time() - startup_time
;
926 sendto_one_numeric(source_p
, RPL_STATSUPTIME
,
927 form_str (RPL_STATSUPTIME
),
928 now
/ 86400, (now
/ 3600) % 24,
929 (now
/ 60) % 60, now
% 60);
930 sendto_one_numeric(source_p
, RPL_STATSCONN
,
931 form_str (RPL_STATSCONN
),
932 MaxConnectionCount
, MaxClientCount
,
933 Count
.totalrestartcount
);
941 static struct shared_flags shared_flagtable
[] =
943 { SHARED_PKLINE
, 'K' },
944 { SHARED_TKLINE
, 'k' },
945 { SHARED_UNKLINE
, 'U' },
946 { SHARED_PXLINE
, 'X' },
947 { SHARED_TXLINE
, 'x' },
948 { SHARED_UNXLINE
, 'Y' },
949 { SHARED_PRESV
, 'Q' },
950 { SHARED_TRESV
, 'q' },
951 { SHARED_UNRESV
, 'R' },
952 { SHARED_LOCOPS
, 'L' },
953 { SHARED_REHASH
, 'H' },
954 { SHARED_TDLINE
, 'd' },
955 { SHARED_PDLINE
, 'D' },
956 { SHARED_UNDLINE
, 'E' },
962 stats_shared (struct Client
*source_p
)
964 struct remote_conf
*shared_p
;
966 char buf
[sizeof(shared_flagtable
)/sizeof(shared_flagtable
[0])];
970 RB_DLINK_FOREACH(ptr
, shared_conf_list
.head
)
972 shared_p
= ptr
->data
;
978 for(i
= 0; shared_flagtable
[i
].flag
!= 0; i
++)
980 if(shared_p
->flags
& shared_flagtable
[i
].flag
)
981 *p
++ = shared_flagtable
[i
].letter
;
986 sendto_one_numeric(source_p
, RPL_STATSULINE
,
987 form_str(RPL_STATSULINE
),
988 shared_p
->server
, shared_p
->username
,
989 shared_p
->host
, buf
);
992 RB_DLINK_FOREACH(ptr
, cluster_conf_list
.head
)
994 shared_p
= ptr
->data
;
1000 for(i
= 0; shared_flagtable
[i
].flag
!= 0; i
++)
1002 if(shared_p
->flags
& shared_flagtable
[i
].flag
)
1003 *p
++ = shared_flagtable
[i
].letter
;
1008 sendto_one_numeric(source_p
, RPL_STATSULINE
,
1009 form_str(RPL_STATSULINE
),
1010 shared_p
->server
, "*", "*", buf
);
1016 * input - client pointer
1018 * side effects - client is shown lists of who connected servers
1021 stats_servers (struct Client
*source_p
)
1023 struct Client
*target_p
;
1026 int days
, hours
, minutes
;
1029 if(ConfigServerHide
.flatten_links
&& !IsOper(source_p
) &&
1030 !IsExemptShide(source_p
))
1032 sendto_one_numeric(source_p
, ERR_NOPRIVILEGES
,
1033 form_str (ERR_NOPRIVILEGES
));
1037 RB_DLINK_FOREACH (ptr
, serv_list
.head
)
1039 target_p
= ptr
->data
;
1042 seconds
= rb_current_time() - target_p
->localClient
->firsttime
;
1044 days
= (int) (seconds
/ 86400);
1046 hours
= (int) (seconds
/ 3600);
1048 minutes
= (int) (seconds
/ 60);
1051 sendto_one_numeric(source_p
, RPL_STATSDEBUG
,
1052 "V :%s (%s!*@*) Idle: %d SendQ: %d "
1053 "Connected: %d day%s, %d:%02d:%02d",
1055 (target_p
->serv
->by
[0] ? target_p
->serv
->by
: "Remote."),
1056 (int) (rb_current_time() - target_p
->localClient
->lasttime
),
1057 (int) rb_linebuf_len (&target_p
->localClient
->buf_sendq
),
1058 days
, (days
== 1) ? "" : "s", hours
, minutes
,
1062 sendto_one_numeric(source_p
, RPL_STATSDEBUG
,
1063 "V :%d Server(s)", j
);
1067 stats_tgecos(struct Client
*source_p
)
1069 struct ConfItem
*aconf
;
1072 RB_DLINK_FOREACH(ptr
, xline_conf_list
.head
)
1077 sendto_one_numeric(source_p
, RPL_STATSXLINE
,
1078 form_str(RPL_STATSXLINE
),
1079 'x', aconf
->port
, aconf
->name
,
1085 stats_gecos(struct Client
*source_p
)
1087 struct ConfItem
*aconf
;
1090 RB_DLINK_FOREACH(ptr
, xline_conf_list
.head
)
1095 sendto_one_numeric(source_p
, RPL_STATSXLINE
,
1096 form_str(RPL_STATSXLINE
),
1097 'X', aconf
->port
, aconf
->name
,
1103 stats_class(struct Client
*source_p
)
1105 if(ConfigFileEntry
.stats_y_oper_only
&& !IsOper(source_p
))
1106 sendto_one_numeric(source_p
, ERR_NOPRIVILEGES
,
1107 form_str (ERR_NOPRIVILEGES
));
1109 report_classes(source_p
);
1113 stats_memory (struct Client
*source_p
)
1115 struct Client
*target_p
;
1116 struct Channel
*chptr
;
1117 struct Ban
*actualBan
;
1118 rb_dlink_node
*rb_dlink
;
1120 int channel_count
= 0;
1121 int local_client_conf_count
= 0; /* local client conf links */
1122 int users_counted
= 0; /* user structs */
1124 int channel_users
= 0;
1125 int channel_invites
= 0;
1126 int channel_bans
= 0;
1127 int channel_except
= 0;
1128 int channel_invex
= 0;
1129 int channel_quiets
= 0;
1131 int class_count
= 0; /* classes */
1132 int conf_count
= 0; /* conf lines */
1133 int users_invited_count
= 0; /* users invited */
1134 int user_channels
= 0; /* users in channels */
1135 int aways_counted
= 0;
1136 size_t number_servers_cached
; /* number of servers cached by scache */
1138 size_t channel_memory
= 0;
1139 size_t channel_ban_memory
= 0;
1140 size_t channel_except_memory
= 0;
1141 size_t channel_invex_memory
= 0;
1142 size_t channel_quiet_memory
= 0;
1144 size_t away_memory
= 0; /* memory used by aways */
1145 size_t ww
= 0; /* whowas array count */
1146 size_t wwm
= 0; /* whowas array memory used */
1147 size_t conf_memory
= 0; /* memory used by conf lines */
1148 size_t mem_servers_cached
; /* memory used by scache */
1150 size_t linebuf_count
= 0;
1151 size_t linebuf_memory_used
= 0;
1153 size_t total_channel_memory
= 0;
1156 size_t local_client_count
= 0;
1157 size_t local_client_memory_used
= 0;
1159 size_t remote_client_count
= 0;
1160 size_t remote_client_memory_used
= 0;
1162 size_t total_memory
= 0;
1164 count_whowas_memory(&ww
, &wwm
);
1166 RB_DLINK_FOREACH(ptr
, global_client_list
.head
)
1168 target_p
= ptr
->data
;
1169 if(MyConnect(target_p
))
1171 local_client_conf_count
++;
1177 users_invited_count
+= rb_dlink_list_length(&target_p
->user
->invited
);
1178 user_channels
+= rb_dlink_list_length(&target_p
->user
->channel
);
1179 if(target_p
->user
->away
)
1182 away_memory
+= (strlen(target_p
->user
->away
) + 1);
1187 /* Count up all channels, ban lists, except lists, Invex lists */
1188 RB_DLINK_FOREACH(ptr
, global_channel_list
.head
)
1192 channel_memory
+= (strlen(chptr
->chname
) + sizeof(struct Channel
));
1194 channel_users
+= rb_dlink_list_length(&chptr
->members
);
1195 channel_invites
+= rb_dlink_list_length(&chptr
->invites
);
1197 RB_DLINK_FOREACH(rb_dlink
, chptr
->banlist
.head
)
1199 actualBan
= rb_dlink
->data
;
1202 channel_ban_memory
+= sizeof(rb_dlink_node
) + sizeof(struct Ban
);
1205 RB_DLINK_FOREACH(rb_dlink
, chptr
->exceptlist
.head
)
1207 actualBan
= rb_dlink
->data
;
1210 channel_except_memory
+= (sizeof(rb_dlink_node
) + sizeof(struct Ban
));
1213 RB_DLINK_FOREACH(rb_dlink
, chptr
->invexlist
.head
)
1215 actualBan
= rb_dlink
->data
;
1218 channel_invex_memory
+= (sizeof(rb_dlink_node
) + sizeof(struct Ban
));
1221 RB_DLINK_FOREACH(rb_dlink
, chptr
->quietlist
.head
)
1223 actualBan
= rb_dlink
->data
;
1226 channel_quiet_memory
+= (sizeof(rb_dlink_node
) + sizeof(struct Ban
));
1230 /* count up all classes */
1232 class_count
= rb_dlink_list_length(&class_list
) + 1;
1234 rb_count_rb_linebuf_memory(&linebuf_count
, &linebuf_memory_used
);
1236 sendto_one_numeric(source_p
, RPL_STATSDEBUG
,
1237 "z :Users %u(%lu) Invites %u(%lu)",
1239 (unsigned long) users_counted
* sizeof(struct User
),
1240 users_invited_count
,
1241 (unsigned long) users_invited_count
* sizeof(rb_dlink_node
));
1243 sendto_one_numeric(source_p
, RPL_STATSDEBUG
,
1244 "z :User channels %u(%lu) Aways %u(%d)",
1246 (unsigned long) user_channels
* sizeof(rb_dlink_node
),
1247 aways_counted
, (int) away_memory
);
1249 sendto_one_numeric(source_p
, RPL_STATSDEBUG
,
1250 "z :Attached confs %u(%lu)",
1251 local_client_conf_count
,
1252 (unsigned long) local_client_conf_count
* sizeof(rb_dlink_node
));
1254 sendto_one_numeric(source_p
, RPL_STATSDEBUG
,
1255 "z :Conflines %u(%d)", conf_count
, (int) conf_memory
);
1257 sendto_one_numeric(source_p
, RPL_STATSDEBUG
,
1258 "z :Classes %u(%lu)",
1260 (unsigned long) class_count
* sizeof(struct Class
));
1262 sendto_one_numeric(source_p
, RPL_STATSDEBUG
,
1263 "z :Channels %u(%d)",
1264 channel_count
, (int) channel_memory
);
1266 sendto_one_numeric(source_p
, RPL_STATSDEBUG
,
1267 "z :Bans %u(%d) Exceptions %u(%d) Invex %u(%d) Quiets %u(%d)",
1268 channel_bans
, (int) channel_ban_memory
,
1269 channel_except
, (int) channel_except_memory
,
1270 channel_invex
, (int) channel_invex_memory
,
1271 channel_quiets
, (int) channel_quiet_memory
);
1273 sendto_one_numeric(source_p
, RPL_STATSDEBUG
,
1274 "z :Channel members %u(%lu) invite %u(%lu)",
1276 (unsigned long) channel_users
* sizeof(rb_dlink_node
),
1278 (unsigned long) channel_invites
* sizeof(rb_dlink_node
));
1280 total_channel_memory
= channel_memory
+
1281 channel_ban_memory
+
1282 channel_users
* sizeof(rb_dlink_node
) + channel_invites
* sizeof(rb_dlink_node
);
1284 sendto_one_numeric(source_p
, RPL_STATSDEBUG
,
1285 "z :Whowas array %ld(%ld)",
1286 (long)ww
, (long)wwm
);
1290 sendto_one_numeric(source_p
, RPL_STATSDEBUG
,
1291 "z :Hash: client %u(%ld) chan %u(%ld)",
1292 U_MAX
, (long)(U_MAX
* sizeof(rb_dlink_list
)),
1293 CH_MAX
, (long)(CH_MAX
* sizeof(rb_dlink_list
)));
1295 sendto_one_numeric(source_p
, RPL_STATSDEBUG
,
1296 "z :linebuf %ld(%ld)",
1297 (long)linebuf_count
, (long)linebuf_memory_used
);
1299 count_scache(&number_servers_cached
, &mem_servers_cached
);
1301 sendto_one_numeric(source_p
, RPL_STATSDEBUG
,
1302 "z :scache %ld(%ld)",
1303 (long)number_servers_cached
, (long)mem_servers_cached
);
1305 sendto_one_numeric(source_p
, RPL_STATSDEBUG
,
1306 "z :hostname hash %d(%ld)",
1307 HOST_MAX
, (long)HOST_MAX
* sizeof(rb_dlink_list
));
1309 total_memory
= totww
+ total_channel_memory
+ conf_memory
+
1310 class_count
* sizeof(struct Class
);
1312 total_memory
+= mem_servers_cached
;
1313 sendto_one_numeric(source_p
, RPL_STATSDEBUG
,
1314 "z :Total: whowas %d channel %d conf %d",
1315 (int) totww
, (int) total_channel_memory
,
1318 count_local_client_memory(&local_client_count
, &local_client_memory_used
);
1319 total_memory
+= local_client_memory_used
;
1321 sendto_one_numeric(source_p
, RPL_STATSDEBUG
,
1322 "z :Local client Memory in use: %ld(%ld)",
1323 (long)local_client_count
, (long)local_client_memory_used
);
1326 count_remote_client_memory(&remote_client_count
, &remote_client_memory_used
);
1327 total_memory
+= remote_client_memory_used
;
1329 sendto_one_numeric(source_p
, RPL_STATSDEBUG
,
1330 "z :Remote client Memory in use: %ld(%ld)",
1331 (long)remote_client_count
,
1332 (long)remote_client_memory_used
);
1336 stats_ziplinks (struct Client
*source_p
)
1339 struct Client
*target_p
;
1340 struct ZipStats
*zipstats
;
1342 char buf
[128], buf1
[128];
1343 RB_DLINK_FOREACH (ptr
, serv_list
.head
)
1345 target_p
= ptr
->data
;
1346 if(IsCapable (target_p
, CAP_ZIP
))
1348 zipstats
= target_p
->localClient
->zipstats
;
1349 sprintf(buf
, "%.2f%%", zipstats
->out_ratio
);
1350 sprintf(buf1
, "%.2f%%", zipstats
->in_ratio
);
1351 sendto_one_numeric(source_p
, RPL_STATSDEBUG
,
1352 "Z :ZipLinks stats for %s send[%s compression "
1353 "(%llu kB data/%llu kB wire)] recv[%s compression "
1354 "(%llu kB data/%llu kB wire)]",
1356 buf
, zipstats
->out
>> 10,
1357 zipstats
->out_wire
>> 10, buf1
,
1358 zipstats
->in
>> 10, zipstats
->in_wire
>> 10);
1363 sendto_one_numeric(source_p
, RPL_STATSDEBUG
,
1364 "Z :%u ziplink(s)", sent_data
);
1368 stats_servlinks (struct Client
*source_p
)
1370 static char Sformat
[] = ":%s %d %s %s %u %u %u %u %u :%u %u %s";
1371 long uptime
, sendK
, receiveK
;
1372 struct Client
*target_p
;
1377 if(ConfigServerHide
.flatten_links
&& !IsOper (source_p
) &&
1378 !IsExemptShide(source_p
))
1380 sendto_one_numeric(source_p
, ERR_NOPRIVILEGES
,
1381 form_str (ERR_NOPRIVILEGES
));
1385 sendK
= receiveK
= 0;
1387 RB_DLINK_FOREACH (ptr
, serv_list
.head
)
1389 target_p
= ptr
->data
;
1392 sendK
+= target_p
->localClient
->sendK
;
1393 receiveK
+= target_p
->localClient
->receiveK
;
1395 sendto_one(source_p
, Sformat
,
1396 get_id(&me
, source_p
), RPL_STATSLINKINFO
, get_id(source_p
, source_p
),
1398 (int) rb_linebuf_len (&target_p
->localClient
->buf_sendq
),
1399 (int) target_p
->localClient
->sendM
,
1400 (int) target_p
->localClient
->sendK
,
1401 (int) target_p
->localClient
->receiveM
,
1402 (int) target_p
->localClient
->receiveK
,
1403 rb_current_time() - target_p
->localClient
->firsttime
,
1404 (rb_current_time() > target_p
->localClient
->lasttime
) ?
1405 (rb_current_time() - target_p
->localClient
->lasttime
) : 0,
1406 IsOper (source_p
) ? show_capabilities (target_p
) : "TS");
1409 sendto_one_numeric(source_p
, RPL_STATSDEBUG
,
1410 "? :%u total server(s)", j
);
1412 snprintf(buf
, sizeof buf
, "%7.2f", _GMKv ((sendK
)));
1413 sendto_one_numeric(source_p
, RPL_STATSDEBUG
,
1414 "? :Sent total : %s %s",
1415 buf
, _GMKs (sendK
));
1416 snprintf(buf
, sizeof buf
, "%7.2f", _GMKv ((receiveK
)));
1417 sendto_one_numeric(source_p
, RPL_STATSDEBUG
,
1418 "? :Recv total : %s %s",
1419 buf
, _GMKs (receiveK
));
1421 uptime
= (rb_current_time() - startup_time
);
1422 snprintf(buf
, sizeof buf
, "%7.2f %s (%4.1f K/s)",
1423 _GMKv (me
.localClient
->sendK
),
1424 _GMKs (me
.localClient
->sendK
),
1425 (float) ((float) me
.localClient
->sendK
/ (float) uptime
));
1426 sendto_one_numeric(source_p
, RPL_STATSDEBUG
, "? :Server send: %s", buf
);
1427 snprintf(buf
, sizeof buf
, "%7.2f %s (%4.1f K/s)",
1428 _GMKv (me
.localClient
->receiveK
),
1429 _GMKs (me
.localClient
->receiveK
),
1430 (float) ((float) me
.localClient
->receiveK
/ (float) uptime
));
1431 sendto_one_numeric(source_p
, RPL_STATSDEBUG
, "? :Server recv: %s", buf
);
1435 stats_ltrace(struct Client
*source_p
, int parc
, const char *parv
[])
1440 char statchar
= parv
[1][0];
1442 /* this is def targeted at us somehow.. */
1443 if(parc
> 2 && !EmptyString(parv
[2]))
1445 /* directed at us generically? */
1446 if(match(parv
[2], me
.name
) ||
1447 (!MyClient(source_p
) && !irccmp(parv
[2], me
.id
)))
1455 wilds
= strchr(name
, '*') || strchr(name
, '?');
1458 /* must be directed at a specific person thats not us */
1459 if(!doall
&& !wilds
)
1461 struct Client
*target_p
;
1463 if(MyClient(source_p
))
1464 target_p
= find_named_person(name
);
1466 target_p
= find_person(name
);
1468 if(target_p
!= NULL
)
1470 stats_spy(source_p
, statchar
, target_p
->name
);
1471 stats_l_client(source_p
, target_p
, statchar
);
1474 sendto_one_numeric(source_p
, ERR_NOSUCHSERVER
,
1475 form_str(ERR_NOSUCHSERVER
),
1487 stats_spy(source_p
, statchar
, name
);
1491 /* local opers get everyone */
1492 if(MyOper(source_p
))
1494 stats_l_list(source_p
, name
, doall
, wilds
, &unknown_list
, statchar
);
1495 stats_l_list(source_p
, name
, doall
, wilds
, &lclient_list
, statchar
);
1499 /* they still need themselves if theyre local.. */
1500 if(MyClient(source_p
))
1501 stats_l_client(source_p
, source_p
, statchar
);
1503 stats_l_list(source_p
, name
, doall
, wilds
, &local_oper_list
, statchar
);
1506 if (!ConfigServerHide
.flatten_links
|| IsOper(source_p
) ||
1507 IsExemptShide(source_p
))
1508 stats_l_list(source_p
, name
, doall
, wilds
, &serv_list
, statchar
);
1513 /* ok, at this point theyre looking for a specific client whos on
1514 * our server.. but it contains a wildcard. --fl
1516 stats_l_list(source_p
, name
, doall
, wilds
, &lclient_list
, statchar
);
1523 stats_l_list(struct Client
*source_p
, const char *name
, int doall
, int wilds
,
1524 rb_dlink_list
* list
, char statchar
)
1527 struct Client
*target_p
;
1529 /* send information about connections which match. note, we
1530 * dont need tests for IsInvisible(), because non-opers will
1531 * never get here for normal clients --fl
1533 RB_DLINK_FOREACH(ptr
, list
->head
)
1535 target_p
= ptr
->data
;
1537 if(!doall
&& wilds
&& !match(name
, target_p
->name
))
1540 stats_l_client(source_p
, target_p
, statchar
);
1545 stats_l_client(struct Client
*source_p
, struct Client
*target_p
,
1548 if(IsAnyServer(target_p
))
1550 sendto_one_numeric(source_p
, RPL_STATSLINKINFO
, Lformat
,
1552 (int) rb_linebuf_len(&target_p
->localClient
->buf_sendq
),
1553 (int) target_p
->localClient
->sendM
,
1554 (int) target_p
->localClient
->sendK
,
1555 (int) target_p
->localClient
->receiveM
,
1556 (int) target_p
->localClient
->receiveK
,
1557 rb_current_time() - target_p
->localClient
->firsttime
,
1558 (rb_current_time() > target_p
->localClient
->lasttime
) ?
1559 (rb_current_time() - target_p
->localClient
->lasttime
) : 0,
1560 IsOper(source_p
) ? show_capabilities(target_p
) : "-");
1565 sendto_one_numeric(source_p
, RPL_STATSLINKINFO
, Lformat
,
1566 show_ip(source_p
, target_p
) ?
1567 (IsUpper(statchar
) ?
1568 get_client_name(target_p
, SHOW_IP
) :
1569 get_client_name(target_p
, HIDE_IP
)) :
1570 get_client_name(target_p
, MASK_IP
),
1571 (int) rb_linebuf_len(&target_p
->localClient
->buf_sendq
),
1572 (int) target_p
->localClient
->sendM
,
1573 (int) target_p
->localClient
->sendK
,
1574 (int) target_p
->localClient
->receiveM
,
1575 (int) target_p
->localClient
->receiveK
,
1576 rb_current_time() - target_p
->localClient
->firsttime
,
1577 (rb_current_time() > target_p
->localClient
->lasttime
) ?
1578 (rb_current_time() - target_p
->localClient
->lasttime
) : 0,
1584 rb_dump_fd_callback(int fd
, const char *desc
, void *data
)
1586 struct Client
*source_p
= data
;
1587 sendto_one_numeric(source_p
, RPL_STATSDEBUG
, "F :fd %-3d desc '%s'", fd
, desc
);
1591 stats_comm(struct Client
*source_p
)
1593 rb_dump_fd(rb_dump_fd_callback
, source_p
);
1599 * inputs - pointer to client doing the /stats
1600 * - char letter they are doing /stats on
1603 * This little helper function reports to opers if configured.
1604 * personally, I don't see why opers need to see stats requests
1605 * at all. They are just "noise" to an oper, and users can't do
1606 * any damage with stats requests now anyway. So, why show them?
1610 stats_spy(struct Client
*source_p
, char statchar
, const char *name
)
1614 data
.client
= source_p
;
1616 data
.arg2
= (int) statchar
;
1618 call_hook(doing_stats_hook
, &data
);
1623 * input - pointer to client doing stats
1625 * side effects - call hook doing_stats_p
1628 stats_p_spy (struct Client
*source_p
)
1632 data
.client
= source_p
;
1633 data
.arg1
= data
.arg2
= NULL
;
1635 call_hook(doing_stats_p_hook
, &data
);