ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/svn/ircd-hybrid-7.2/src/s_stats.c
Revision: 34
Committed: Sun Oct 2 21:05:51 2005 UTC (18 years, 6 months ago) by lusky
Content type: text/x-csrc
File size: 4040 byte(s)
Log Message:
create 7.2 branch, we can move/rename it as needed.


File Contents

# Content
1 /*
2 * ircd-hybrid: an advanced Internet Relay Chat Daemon(ircd).
3 * s_stats.c: Statistics related functions
4 *
5 * Copyright (C) 2002 by the past and present ircd coders, and others.
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
20 * USA
21 *
22 * $Id$
23 */
24
25 #include "stdinc.h"
26 #include "s_stats.h"
27 #include "client.h"
28 #include "irc_string.h"
29 #include "ircd.h"
30 #include "numeric.h"
31 #include "s_bsd.h"
32 #include "send.h"
33 #include "memory.h"
34
35 /* stats stuff */
36 static struct ServerStatistics ircst;
37 struct ServerStatistics *ServerStats = &ircst;
38
39 void
40 init_stats(void)
41 {
42 memset(&ircst, 0, sizeof(ircst));
43 }
44
45 /* tstats()
46 *
47 * inputs - client to report to
48 * output - NONE
49 * side effects -
50 */
51 void
52 tstats(struct Client *source_p)
53 {
54 const struct Client *target_p = NULL;
55 struct ServerStatistics *sp;
56 struct ServerStatistics tmp;
57 dlink_node *ptr;
58
59 sp = &tmp;
60 memcpy(sp, ServerStats, sizeof(struct ServerStatistics));
61
62 /*
63 * must use the += operator. is_sv is not the number of currently
64 * active server connections. Note the incrementation in
65 * s_bsd.c:close_connection.
66 */
67 sp->is_sv += dlink_list_length(&serv_list);
68
69 DLINK_FOREACH(ptr, serv_list.head)
70 {
71 target_p = ptr->data;
72
73 sp->is_sbs += target_p->localClient->send.bytes;
74 sp->is_sbr += target_p->localClient->recv.bytes;
75 sp->is_sti += CurrentTime - target_p->firsttime;
76 }
77
78 sp->is_cl += dlink_list_length(&local_client_list);
79
80 DLINK_FOREACH(ptr, local_client_list.head)
81 {
82 target_p = ptr->data;
83
84 sp->is_cbs += target_p->localClient->send.bytes;
85 sp->is_cbr += target_p->localClient->recv.bytes;
86 sp->is_cti += CurrentTime - target_p->firsttime;
87 }
88
89 sp->is_ni += dlink_list_length(&unknown_list);
90
91 sendto_one(source_p, ":%s %d %s T :accepts %u refused %u",
92 me.name, RPL_STATSDEBUG, source_p->name, sp->is_ac, sp->is_ref);
93 sendto_one(source_p, ":%s %d %s T :unknown commands %u prefixes %u",
94 me.name, RPL_STATSDEBUG, source_p->name, sp->is_unco, sp->is_unpf);
95 sendto_one(source_p, ":%s %d %s T :nick collisions %u unknown closes %u",
96 me.name, RPL_STATSDEBUG, source_p->name, sp->is_kill, sp->is_ni);
97 sendto_one(source_p, ":%s %d %s T :wrong direction %u empty %u",
98 me.name, RPL_STATSDEBUG, source_p->name, sp->is_wrdi, sp->is_empt);
99 sendto_one(source_p, ":%s %d %s T :numerics seen %u",
100 me.name, RPL_STATSDEBUG, source_p->name, sp->is_num);
101 sendto_one(source_p, ":%s %d %s T :auth successes %u fails %u",
102 me.name, RPL_STATSDEBUG, source_p->name, sp->is_asuc, sp->is_abad);
103 sendto_one(source_p, ":%s %d %s T :Client Server",
104 me.name, RPL_STATSDEBUG, source_p->name);
105
106 sendto_one(source_p, ":%s %d %s T :connected %u %u",
107 me.name, RPL_STATSDEBUG, source_p->name,
108 (unsigned int)sp->is_cl,
109 (unsigned int)sp->is_sv);
110 sendto_one(source_p, ":%s %d %s T :bytes sent %llu %llu",
111 me.name, RPL_STATSDEBUG, source_p->name,
112 sp->is_cbs, sp->is_sbs);
113 sendto_one(source_p, ":%s %d %s T :bytes recv %llu %llu",
114 me.name, RPL_STATSDEBUG, source_p->name,
115 sp->is_cbr, sp->is_sbr);
116 sendto_one(source_p, ":%s %d %s T :time connected %u %u",
117 me.name, RPL_STATSDEBUG, source_p->name,
118 (unsigned int)sp->is_cti,
119 (unsigned int)sp->is_sti);
120 }

Properties

Name Value
svn:eol-style native
svn:keywords Id Revision