ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/svn/ircd-hybrid/src/s_stats.c
Revision: 65
Committed: Mon Oct 3 23:33:16 2005 UTC (20 years, 10 months ago) by adx
Content type: text/x-csrc
File size: 4060 byte(s)
Log Message:
- removed external references from libio/misc
- imported s_misc.c to libio, moved CurrentTime there

File Contents

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

Properties

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