ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/svn/ircd-hybrid/src/s_stats.c
Revision: 69
Committed: Tue Oct 4 16:09:51 2005 UTC (19 years, 10 months ago) by adx
Content type: text/x-csrc
File size: 3977 byte(s)
Log Message:
- splitted ircd/libio, all headers connected with libio sources have been
  moved for internal use only. To use libio interface, include "libio.h"
  (which is already done in "stdinc.h")


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 "ircd.h"
29 #include "numeric.h"
30 #include "send.h"
31
32 /* stats stuff */
33 static struct ServerStatistics ircst;
34 struct ServerStatistics *ServerStats = &ircst;
35
36 void
37 init_stats(void)
38 {
39 memset(&ircst, 0, sizeof(ircst));
40 }
41
42 /* tstats()
43 *
44 * inputs - client to report to
45 * output - NONE
46 * side effects -
47 */
48 void
49 tstats(struct Client *source_p)
50 {
51 const struct Client *target_p = NULL;
52 struct ServerStatistics *sp;
53 struct ServerStatistics tmp;
54 dlink_node *ptr;
55
56 sp = &tmp;
57 memcpy(sp, ServerStats, sizeof(struct ServerStatistics));
58
59 /*
60 * must use the += operator. is_sv is not the number of currently
61 * active server connections. Note the incrementation in
62 * s_bsd.c:close_connection.
63 */
64 sp->is_sv += dlink_list_length(&serv_list);
65
66 DLINK_FOREACH(ptr, serv_list.head)
67 {
68 target_p = ptr->data;
69
70 sp->is_sbs += target_p->localClient->send.bytes;
71 sp->is_sbr += target_p->localClient->recv.bytes;
72 sp->is_sti += CurrentTime - target_p->firsttime;
73 }
74
75 sp->is_cl += dlink_list_length(&local_client_list);
76
77 DLINK_FOREACH(ptr, local_client_list.head)
78 {
79 target_p = ptr->data;
80
81 sp->is_cbs += target_p->localClient->send.bytes;
82 sp->is_cbr += target_p->localClient->recv.bytes;
83 sp->is_cti += CurrentTime - target_p->firsttime;
84 }
85
86 sp->is_ni += dlink_list_length(&unknown_list);
87
88 sendto_one(source_p, ":%s %d %s T :accepts %u refused %u",
89 me.name, RPL_STATSDEBUG, source_p->name, sp->is_ac, sp->is_ref);
90 sendto_one(source_p, ":%s %d %s T :unknown commands %u prefixes %u",
91 me.name, RPL_STATSDEBUG, source_p->name, sp->is_unco, sp->is_unpf);
92 sendto_one(source_p, ":%s %d %s T :nick collisions %u unknown closes %u",
93 me.name, RPL_STATSDEBUG, source_p->name, sp->is_kill, sp->is_ni);
94 sendto_one(source_p, ":%s %d %s T :wrong direction %u empty %u",
95 me.name, RPL_STATSDEBUG, source_p->name, sp->is_wrdi, sp->is_empt);
96 sendto_one(source_p, ":%s %d %s T :numerics seen %u",
97 me.name, RPL_STATSDEBUG, source_p->name, sp->is_num);
98 sendto_one(source_p, ":%s %d %s T :auth successes %u fails %u",
99 me.name, RPL_STATSDEBUG, source_p->name, sp->is_asuc, sp->is_abad);
100 sendto_one(source_p, ":%s %d %s T :Client Server",
101 me.name, RPL_STATSDEBUG, source_p->name);
102
103 sendto_one(source_p, ":%s %d %s T :connected %u %u",
104 me.name, RPL_STATSDEBUG, source_p->name,
105 (unsigned int)sp->is_cl,
106 (unsigned int)sp->is_sv);
107 sendto_one(source_p, ":%s %d %s T :bytes sent %llu %llu",
108 me.name, RPL_STATSDEBUG, source_p->name,
109 sp->is_cbs, sp->is_sbs);
110 sendto_one(source_p, ":%s %d %s T :bytes recv %llu %llu",
111 me.name, RPL_STATSDEBUG, source_p->name,
112 sp->is_cbr, sp->is_sbr);
113 sendto_one(source_p, ":%s %d %s T :time connected %u %u",
114 me.name, RPL_STATSDEBUG, source_p->name,
115 (unsigned int)sp->is_cti,
116 (unsigned int)sp->is_sti);
117 }

Properties

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