mirror of
https://gitlab.isc.org/isc-projects/bind9
synced 2025-08-30 14:07:59 +00:00
Expose the TCP client count in statistics channel
The statistics channel does not expose the current number of TCP clients connected, only the highwater. Therefore, users did not have an easy means to collect statistics about TCP clients served over time. This information could only be measured as a seperate mechanism via rndc by looking at the TCP quota filled. In order to expose the exact current count of connected TCP clients (tracked by the "tcp-clients" quota) as a statistics counter, an extra, dedicated Network Manager callback would need to be implemented for that purpose (a counterpart of ns__client_tcpconn() that would be run when a TCP connection is torn down), which is inefficient. Instead, track the number of currently-connected TCP clients separately for IPv4 and IPv6, as Network Manager statistics.
This commit is contained in:
@@ -611,6 +611,10 @@ init_desc(void) {
|
|||||||
SET_SOCKSTATDESC(udp6active, "UDP/IPv6 sockets active", "UDP6Active");
|
SET_SOCKSTATDESC(udp6active, "UDP/IPv6 sockets active", "UDP6Active");
|
||||||
SET_SOCKSTATDESC(tcp4active, "TCP/IPv4 sockets active", "TCP4Active");
|
SET_SOCKSTATDESC(tcp4active, "TCP/IPv4 sockets active", "TCP4Active");
|
||||||
SET_SOCKSTATDESC(tcp6active, "TCP/IPv6 sockets active", "TCP6Active");
|
SET_SOCKSTATDESC(tcp6active, "TCP/IPv6 sockets active", "TCP6Active");
|
||||||
|
SET_SOCKSTATDESC(tcp4clients, "TCP/IPv4 clients currently connected",
|
||||||
|
"TCP4Clients");
|
||||||
|
SET_SOCKSTATDESC(tcp6clients, "TCP/IPv6 clients currently connected",
|
||||||
|
"TCP6Clients");
|
||||||
INSIST(i == isc_sockstatscounter_max);
|
INSIST(i == isc_sockstatscounter_max);
|
||||||
|
|
||||||
/* Initialize DNSSEC statistics */
|
/* Initialize DNSSEC statistics */
|
||||||
|
@@ -77,6 +77,9 @@ enum {
|
|||||||
isc_sockstatscounter_tcp4active,
|
isc_sockstatscounter_tcp4active,
|
||||||
isc_sockstatscounter_tcp6active,
|
isc_sockstatscounter_tcp6active,
|
||||||
|
|
||||||
|
isc_sockstatscounter_tcp4clients,
|
||||||
|
isc_sockstatscounter_tcp6clients,
|
||||||
|
|
||||||
isc_sockstatscounter_max,
|
isc_sockstatscounter_max,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@@ -386,7 +386,8 @@ typedef enum {
|
|||||||
STATID_SENDFAIL = 8,
|
STATID_SENDFAIL = 8,
|
||||||
STATID_RECVFAIL = 9,
|
STATID_RECVFAIL = 9,
|
||||||
STATID_ACTIVE = 10,
|
STATID_ACTIVE = 10,
|
||||||
STATID_MAX = 11,
|
STATID_CLIENTS = 11,
|
||||||
|
STATID_MAX = 12,
|
||||||
} isc__nm_statid_t;
|
} isc__nm_statid_t;
|
||||||
|
|
||||||
typedef struct isc_nmsocket_tls_send_req {
|
typedef struct isc_nmsocket_tls_send_req {
|
||||||
|
@@ -63,7 +63,8 @@ static const isc_statscounter_t udp4statsindex[] = {
|
|||||||
-1,
|
-1,
|
||||||
isc_sockstatscounter_udp4sendfail,
|
isc_sockstatscounter_udp4sendfail,
|
||||||
isc_sockstatscounter_udp4recvfail,
|
isc_sockstatscounter_udp4recvfail,
|
||||||
isc_sockstatscounter_udp4active
|
isc_sockstatscounter_udp4active,
|
||||||
|
-1,
|
||||||
};
|
};
|
||||||
|
|
||||||
static const isc_statscounter_t udp6statsindex[] = {
|
static const isc_statscounter_t udp6statsindex[] = {
|
||||||
@@ -77,7 +78,8 @@ static const isc_statscounter_t udp6statsindex[] = {
|
|||||||
-1,
|
-1,
|
||||||
isc_sockstatscounter_udp6sendfail,
|
isc_sockstatscounter_udp6sendfail,
|
||||||
isc_sockstatscounter_udp6recvfail,
|
isc_sockstatscounter_udp6recvfail,
|
||||||
isc_sockstatscounter_udp6active
|
isc_sockstatscounter_udp6active,
|
||||||
|
-1,
|
||||||
};
|
};
|
||||||
|
|
||||||
static const isc_statscounter_t tcp4statsindex[] = {
|
static const isc_statscounter_t tcp4statsindex[] = {
|
||||||
@@ -86,7 +88,7 @@ static const isc_statscounter_t tcp4statsindex[] = {
|
|||||||
isc_sockstatscounter_tcp4connectfail, isc_sockstatscounter_tcp4connect,
|
isc_sockstatscounter_tcp4connectfail, isc_sockstatscounter_tcp4connect,
|
||||||
isc_sockstatscounter_tcp4acceptfail, isc_sockstatscounter_tcp4accept,
|
isc_sockstatscounter_tcp4acceptfail, isc_sockstatscounter_tcp4accept,
|
||||||
isc_sockstatscounter_tcp4sendfail, isc_sockstatscounter_tcp4recvfail,
|
isc_sockstatscounter_tcp4sendfail, isc_sockstatscounter_tcp4recvfail,
|
||||||
isc_sockstatscounter_tcp4active
|
isc_sockstatscounter_tcp4active, isc_sockstatscounter_tcp4clients,
|
||||||
};
|
};
|
||||||
|
|
||||||
static const isc_statscounter_t tcp6statsindex[] = {
|
static const isc_statscounter_t tcp6statsindex[] = {
|
||||||
@@ -95,7 +97,7 @@ static const isc_statscounter_t tcp6statsindex[] = {
|
|||||||
isc_sockstatscounter_tcp6connectfail, isc_sockstatscounter_tcp6connect,
|
isc_sockstatscounter_tcp6connectfail, isc_sockstatscounter_tcp6connect,
|
||||||
isc_sockstatscounter_tcp6acceptfail, isc_sockstatscounter_tcp6accept,
|
isc_sockstatscounter_tcp6acceptfail, isc_sockstatscounter_tcp6accept,
|
||||||
isc_sockstatscounter_tcp6sendfail, isc_sockstatscounter_tcp6recvfail,
|
isc_sockstatscounter_tcp6sendfail, isc_sockstatscounter_tcp6recvfail,
|
||||||
isc_sockstatscounter_tcp6active
|
isc_sockstatscounter_tcp6active, isc_sockstatscounter_tcp6clients,
|
||||||
};
|
};
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@@ -855,6 +855,10 @@ accept_connection(isc_nmsocket_t *csock) {
|
|||||||
UV_RUNTIME_CHECK(uv_timer_init, r);
|
UV_RUNTIME_CHECK(uv_timer_init, r);
|
||||||
uv_handle_set_data((uv_handle_t *)&csock->read_timer, csock);
|
uv_handle_set_data((uv_handle_t *)&csock->read_timer, csock);
|
||||||
|
|
||||||
|
if (csock->server->pquota != NULL) {
|
||||||
|
isc__nm_incstats(csock, STATID_CLIENTS);
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* We need to initialize the tcp and timer before failing because
|
* We need to initialize the tcp and timer before failing because
|
||||||
* isc__nm_tcp_close() can't handle uninitalized TCP nmsocket.
|
* isc__nm_tcp_close() can't handle uninitalized TCP nmsocket.
|
||||||
@@ -1105,6 +1109,7 @@ tcp_close_sock(isc_nmsocket_t *sock) {
|
|||||||
|
|
||||||
if (sock->server != NULL) {
|
if (sock->server != NULL) {
|
||||||
if (sock->server->pquota != NULL) {
|
if (sock->server->pquota != NULL) {
|
||||||
|
isc__nm_decstats(sock, STATID_CLIENTS);
|
||||||
isc_quota_release(sock->server->pquota);
|
isc_quota_release(sock->server->pquota);
|
||||||
}
|
}
|
||||||
isc__nmsocket_detach(&sock->server);
|
isc__nmsocket_detach(&sock->server);
|
||||||
|
Reference in New Issue
Block a user