5 * stats.h Structures and functions for statistics.
7 * Version: $Id: stats.h,v 1.1 2010/08/14 04:13:52 faust Exp $
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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
23 * Copyright 2005,2006,2007,2008 The FreeRADIUS server project
26 //#include <freeradius/ident.h>
27 //RCSIDH(stats_h, "$Id: stats.h,v 1.1 2010/08/14 04:13:52 faust Exp $")
29 #ifdef WITH_STATS_64BIT
30 typedef uint64_t fr_uint_t;
32 typedef uint32_t fr_uint_t;
36 typedef struct fr_stats_t {
37 fr_uint_t total_requests;
38 fr_uint_t total_invalid_requests;
39 fr_uint_t total_dup_requests;
40 fr_uint_t total_responses;
41 fr_uint_t total_access_accepts;
42 fr_uint_t total_access_rejects;
43 fr_uint_t total_access_challenges;
44 fr_uint_t total_malformed_requests;
45 fr_uint_t total_bad_authenticators;
46 fr_uint_t total_packets_dropped;
47 fr_uint_t total_no_records;
48 fr_uint_t total_unknown_types;
51 typedef struct fr_stats_ema_t {
59 extern fr_stats_t radius_auth_stats;
60 extern fr_stats_t radius_acct_stats;
62 extern fr_stats_t proxy_auth_stats;
63 extern fr_stats_t proxy_acct_stats;
66 void radius_stats_init(int flag);
67 void request_stats_final(REQUEST *request);
68 void request_stats_reply(REQUEST *request);
69 void radius_stats_ema(fr_stats_ema_t *ema,
70 struct timeval *start, struct timeval *end);
72 #define RAD_STATS_INC(_x) _x++
73 #ifdef WITH_ACCOUNTING
74 #define RAD_STATS_TYPE_INC(_listener, _x) if (_listener->type == RAD_LISTEN_AUTH) { \
75 radius_auth_stats._x++; \
76 } else if (_listener->type == RAD_LISTEN_ACCT) { \
77 radius_acct_stats._x++; } \
80 #define RAD_STATS_CLIENT_INC(_listener, _client, _x) if (_listener->type == RAD_LISTEN_AUTH) \
81 _client->auth->_x++; \
82 else if (_listener->type == RAD_LISTEN_ACCT) \
85 #else /* WITH_ACCOUNTING */
87 #define RAD_STATS_TYPE_INC(_listener, _x) { radius_auth_stats._x++; _listener->stats._x++; }
89 #define RAD_STATS_CLIENT_INC(_listener, _client, _x) _client->auth->_x++
91 #endif /* WITH_ACCOUNTING */
94 #else /* WITH_STATS */
95 #define request_stats_init(_x)
96 #define request_stats_final(_x)
98 #define RAD_STATS_INC(_x)
99 #define RAD_STATS_TYPE_INC(_listener, _x)
100 #define RAD_STATS_CLIENT_INC(_listener, _client, _x)
104 #endif /* FR_STATS_H */