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.
(cherry picked from commit
2690dc48d357c85c59f0d72063d7a799e9d03bc0)
SET_SOCKSTATDESC(unixactive, "Unix domain sockets active",
"UnixActive");
SET_SOCKSTATDESC(rawactive, "Raw sockets active", "RawActive");
+ SET_SOCKSTATDESC(tcp4clients, "TCP/IPv4 clients currently connected",
+ "TCP4Clients");
+ SET_SOCKSTATDESC(tcp6clients, "TCP/IPv6 clients currently connected",
+ "TCP6Clients");
+
INSIST(i == isc_sockstatscounter_max);
/* Initialize DNSSEC statistics */
isc_sockstatscounter_rawrecvfail = 60,
isc_sockstatscounter_rawactive = 61,
- isc_sockstatscounter_max = 62
+ isc_sockstatscounter_tcp4clients = 62,
+ isc_sockstatscounter_tcp6clients = 63,
+
+ isc_sockstatscounter_max = 64
};
ISC_LANG_BEGINDECLS
STATID_SENDFAIL = 8,
STATID_RECVFAIL = 9,
STATID_ACTIVE = 10,
- STATID_MAX = 11,
+ STATID_CLIENTS = 11,
+ STATID_MAX = 12,
} isc__nm_statid_t;
#if HAVE_LIBNGHTTP2
-1,
isc_sockstatscounter_udp4sendfail,
isc_sockstatscounter_udp4recvfail,
- isc_sockstatscounter_udp4active
+ isc_sockstatscounter_udp4active,
+ -1,
};
static const isc_statscounter_t udp6statsindex[] = {
-1,
isc_sockstatscounter_udp6sendfail,
isc_sockstatscounter_udp6recvfail,
- isc_sockstatscounter_udp6active
+ isc_sockstatscounter_udp6active,
+ -1,
};
static const isc_statscounter_t tcp4statsindex[] = {
isc_sockstatscounter_tcp4connectfail, isc_sockstatscounter_tcp4connect,
isc_sockstatscounter_tcp4acceptfail, isc_sockstatscounter_tcp4accept,
isc_sockstatscounter_tcp4sendfail, isc_sockstatscounter_tcp4recvfail,
- isc_sockstatscounter_tcp4active
+ isc_sockstatscounter_tcp4active, isc_sockstatscounter_tcp4clients,
};
static const isc_statscounter_t tcp6statsindex[] = {
isc_sockstatscounter_tcp6connectfail, isc_sockstatscounter_tcp6connect,
isc_sockstatscounter_tcp6acceptfail, isc_sockstatscounter_tcp6accept,
isc_sockstatscounter_tcp6sendfail, isc_sockstatscounter_tcp6recvfail,
- isc_sockstatscounter_tcp6active
+ isc_sockstatscounter_tcp6active, isc_sockstatscounter_tcp6clients,
};
#if 0
* chance to be executed.
*/
if (sock->quota != NULL) {
+ isc__nm_decstats(sock, STATID_CLIENTS);
isc_quota_detach(&sock->quota);
}
}
UV_RUNTIME_CHECK(uv_timer_init, r);
uv_handle_set_data((uv_handle_t *)&csock->read_timer, csock);
+ isc__nm_incstats(csock, STATID_CLIENTS);
+
r = uv_accept(&ssock->uv_handle.stream, &csock->uv_handle.stream);
if (r != 0) {
result = isc__nm_uverr2result(r);
REQUIRE(atomic_load(&sock->closing));
if (sock->quota != NULL) {
+ isc__nm_decstats(sock, STATID_CLIENTS);
isc_quota_detach(&sock->quota);
}
* had a chance to be executed.
*/
if (sock->quota != NULL) {
+ isc__nm_decstats(sock, STATID_CLIENTS);
isc_quota_detach(&sock->quota);
}
}
UV_RUNTIME_CHECK(uv_timer_init, r);
uv_handle_set_data((uv_handle_t *)&csock->read_timer, csock);
+ isc__nm_incstats(csock, STATID_CLIENTS);
+
r = uv_accept(&ssock->uv_handle.stream, &csock->uv_handle.stream);
if (r != 0) {
result = isc__nm_uverr2result(r);
REQUIRE(sock->tls.pending_req == NULL);
if (sock->quota != NULL) {
+ isc__nm_decstats(sock, STATID_CLIENTS);
isc_quota_detach(&sock->quota);
}