|
|
6dacf3 |
commit 3b78790b2575daf0e8b3c2822a7e160273df20bd
|
|
|
6dacf3 |
Author: Tomas Korbar <tkorbar@redhat.com>
|
|
|
6dacf3 |
Date: Tue May 19 08:35:29 2020 +0200
|
|
|
6dacf3 |
|
|
|
6dacf3 |
Include ssl errors in the stats
|
|
|
6dacf3 |
|
|
|
6dacf3 |
diff --git a/doc/protocol.txt b/doc/protocol.txt
|
|
|
6dacf3 |
index abe70b2..55479b7 100644
|
|
|
6dacf3 |
--- a/doc/protocol.txt
|
|
|
6dacf3 |
+++ b/doc/protocol.txt
|
|
|
6dacf3 |
@@ -1509,6 +1509,23 @@ The value of the "state" stat may be one of the following:
|
|
|
6dacf3 |
| | sending back multiple lines of response data). |
|
|
|
6dacf3 |
|----------------+-----------------------------------------------------------|
|
|
|
6dacf3 |
|
|
|
6dacf3 |
+TLS statistics
|
|
|
6dacf3 |
+--------------
|
|
|
6dacf3 |
+
|
|
|
6dacf3 |
+TLS is a compile-time opt-in feature available in versions 1.5.13 and later.
|
|
|
6dacf3 |
+When compiled with TLS support and TLS termination is enabled at runtime, the
|
|
|
6dacf3 |
+following additional statistics are available via the "stats" command.
|
|
|
6dacf3 |
+
|
|
|
6dacf3 |
+|--------------------------------+----------+--------------------------------|
|
|
|
6dacf3 |
+| Name | Type | Meaning |
|
|
|
6dacf3 |
+|--------------------------------+----------+--------------------------------|
|
|
|
6dacf3 |
+| ssl_handshake_errors | 64u | Number of times the server has |
|
|
|
6dacf3 |
+| | | encountered an OpenSSL error |
|
|
|
6dacf3 |
+| | | during handshake (SSL_accept). |
|
|
|
6dacf3 |
+| time_since_server_cert_refresh | 32u | Number of seconds that have |
|
|
|
6dacf3 |
+| | | elapsed since the last time |
|
|
|
6dacf3 |
+| | | certs were reloaded from disk. |
|
|
|
6dacf3 |
+|--------------------------------+----------+--------------------------------|
|
|
|
6dacf3 |
|
|
|
6dacf3 |
|
|
|
6dacf3 |
Other commands
|
|
|
6dacf3 |
diff --git a/memcached.c b/memcached.c
|
|
|
6dacf3 |
index d81a71f..d769b4a 100644
|
|
|
6dacf3 |
--- a/memcached.c
|
|
|
6dacf3 |
+++ b/memcached.c
|
|
|
6dacf3 |
@@ -3428,6 +3428,7 @@ static void server_stats(ADD_STAT add_stats, conn *c) {
|
|
|
6dacf3 |
#endif
|
|
|
6dacf3 |
#ifdef TLS
|
|
|
6dacf3 |
if (settings.ssl_enabled) {
|
|
|
6dacf3 |
+ APPEND_STAT("ssl_handshake_errors", "%llu", (unsigned long long)stats.ssl_handshake_errors);
|
|
|
6dacf3 |
APPEND_STAT("time_since_server_cert_refresh", "%u", now - settings.ssl_last_cert_refresh_time);
|
|
|
6dacf3 |
}
|
|
|
6dacf3 |
#endif
|
|
|
6dacf3 |
@@ -6779,6 +6780,9 @@ static void drive_machine(conn *c) {
|
|
|
6dacf3 |
}
|
|
|
6dacf3 |
SSL_free(ssl);
|
|
|
6dacf3 |
close(sfd);
|
|
|
6dacf3 |
+ STATS_LOCK();
|
|
|
6dacf3 |
+ stats.ssl_handshake_errors++;
|
|
|
6dacf3 |
+ STATS_UNLOCK();
|
|
|
6dacf3 |
break;
|
|
|
6dacf3 |
}
|
|
|
6dacf3 |
}
|
|
|
6dacf3 |
diff --git a/memcached.h b/memcached.h
|
|
|
6dacf3 |
index 795ea8f..6b1fe4a 100644
|
|
|
6dacf3 |
--- a/memcached.h
|
|
|
6dacf3 |
+++ b/memcached.h
|
|
|
6dacf3 |
@@ -357,6 +357,9 @@ struct stats {
|
|
|
6dacf3 |
uint64_t extstore_compact_lost; /* items lost because they were locked */
|
|
|
6dacf3 |
uint64_t extstore_compact_rescues; /* items re-written during compaction */
|
|
|
6dacf3 |
uint64_t extstore_compact_skipped; /* unhit items skipped during compaction */
|
|
|
6dacf3 |
+#endif
|
|
|
6dacf3 |
+#ifdef TLS
|
|
|
6dacf3 |
+ uint64_t ssl_handshake_errors; /* TLS failures at accept/handshake time */
|
|
|
6dacf3 |
#endif
|
|
|
6dacf3 |
struct timeval maxconns_entered; /* last time maxconns entered */
|
|
|
6dacf3 |
};
|
|
|
6dacf3 |
diff --git a/t/stats.t b/t/stats.t
|
|
|
6dacf3 |
index 028a60a..f1dcd54 100755
|
|
|
6dacf3 |
--- a/t/stats.t
|
|
|
6dacf3 |
+++ b/t/stats.t
|
|
|
6dacf3 |
@@ -26,7 +26,7 @@ my $stats = mem_stats($sock);
|
|
|
6dacf3 |
# Test number of keys
|
|
|
6dacf3 |
if (MemcachedTest::enabled_tls_testing()) {
|
|
|
6dacf3 |
# when TLS is enabled, stats contains time_since_server_cert_refresh
|
|
|
6dacf3 |
- is(scalar(keys(%$stats)), 72, "expected count of stats values");
|
|
|
6dacf3 |
+ is(scalar(keys(%$stats)), 73, "expected count of stats values");
|
|
|
6dacf3 |
} else {
|
|
|
6dacf3 |
is(scalar(keys(%$stats)), 71, "expected count of stats values");
|
|
|
6dacf3 |
}
|