ATTRIBUTE FreeRADIUS-Proxied-To 1 ipaddr
+
#
-# If you send a Status-Server packet from localhost to localhost
-# containing a FreeRADIUS-Statistics-Type attribute, the
-# response will contain relevant statistics.
-#
-# The FreeRADIUS-Statistics-Type attribute is ignored for ALL
-# other packet types, and for ALL other IP addresses. This will
-# not be changed.
-#
-# Statistics can be queried by a number of methods:
-#
-# Globally - all sockets auth/acct/proxy-auth/proxy-acct
-# By server IP/port - return auth or acct statistics for that port
-# By home server IP/port - return proxied auth and acct statistics
-# By client - send IP, return auth & acct statistics
-# By client for a server IP/port - return auth & acct statistics
-#
-# Just send FreeRADIUS-Statistics-Type, and client IP, and/or
-# server IP/port, using the attributes defined below.
-#
-# This is really a bitmask.
+# This attribute is really a bitmask.
#
ATTRIBUTE FreeRADIUS-Statistics-Type 127 integer
VALUE FreeRADIUS-Statistics-Type Accounting 2
VALUE FreeRADIUS-Statistics-Type Proxy-Authentication 4
VALUE FreeRADIUS-Statistics-Type Proxy-Accounting 8
-VALUE FreeRADIUS-Statistics-Type Request-Queue 0x10
+VALUE FreeRADIUS-Statistics-Type Internal 0x10
VALUE FreeRADIUS-Statistics-Type Client 0x20
VALUE FreeRADIUS-Statistics-Type Server 0x40
VALUE FreeRADIUS-Statistics-Type Home-Server 0x80
VALUE FreeRADIUS-Stats-Server-State Zombie 1
VALUE FreeRADIUS-Stats-Server-State Dead 2
+#
+# When a home server is marked "dead" or "alive"
+#
ATTRIBUTE FreeRADIUS-Stats-Server-Time-Of-Death 174 date
ATTRIBUTE FreeRADIUS-Stats-Server-Time-Of-Life 175 date
+#
+# When this server was started. If start == hup, it hasn't been
+# hup'd yet. This is friendlier than having hup == 0 on start.
+#
+ATTRIBUTE FreeRADIUS-Stats-Start-Time 176 date
+ATTRIBUTE FreeRADIUS-Stats-HUP-Time 177 date
END-VENDOR FreeRADIUS
extern fr_stats_t radius_auth_stats;
extern fr_stats_t radius_acct_stats;
+void radius_stats_init(int flag);
void request_stats_final(REQUEST *request);
void request_stats_reply(REQUEST *request);
#else /* WITH_STATS */
+#define request_stats_init(_x)
#define request_stats_final(_x)
#define RAD_STATS_INC(_x)
RCSID("$Id$")
#include <freeradius-devel/radiusd.h>
-#include <freeradius-devel/radius_snmp.h>
#include <freeradius-devel/modules.h>
#include <freeradius-devel/rad_assert.h>
const char *radiusd_version = "FreeRADIUS Version " RADIUSD_VERSION ", for host " HOSTINFO ", built on " __DATE__ " at " __TIME__;
-time_t time_now;
pid_t radius_pid;
static int debug_memory = 0;
exit(0);
}
+ radius_stats_init(0);
+
/*
* Process requests until HUP or exit.
*/
while ((rcode = radius_event_process()) == 0x80) {
+ radius_stats_init(1);
radlog(L_INFO, "Received HUP.");
module_hup(cf_section_sub_find(mainconfig.config, "modules"));
}
#ifdef WITH_STATS
+static struct timeval start_time;
+static struct timeval hup_time;
+
fr_stats_t radius_auth_stats = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
#ifdef WITH_ACCOUNTING
fr_stats_t radius_acct_stats = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
#endif
#endif
-#ifdef HAVE_PTHREAD_H
if ((flag->vp_integer & 0x10) != 0) {
+ vp = radius_paircreate(request, &request->reply->vps,
+ FR2ATTR(176), PW_TYPE_DATE);
+ if (vp) vp->vp_date = start_time.tv_sec;
+ vp = radius_paircreate(request, &request->reply->vps,
+ FR2ATTR(177), PW_TYPE_DATE);
+ if (vp) vp->vp_date = hup_time.tv_sec;
+
+#ifdef HAVE_PTHREAD_H
int i, array[RAD_LISTEN_MAX];
thread_pool_queue_stats(array);
if (!vp) continue;
vp->vp_integer = array[i];
}
- }
#endif
+ }
if ((flag->vp_integer & 0x20) != 0) {
fr_ipaddr_t ipaddr;
}
}
+void radius_stats_init(int flag)
+{
+ if (!flag) {
+ gettimeofday(&start_time, NULL);
+ hup_time = start_time; /* it's just nicer this way */
+ } else {
+ gettimeofday(&hup_time, NULL);
+ }
+}
+
#endif /* WITH_STATS */