Changeset

11608:b2610460d9ab

mod_c2s,mod_s2s: Collect stats on TLS versions and ciphers
author Kim Alvefur <zash@zash.se>
date Wed, 16 Jun 2021 00:00:17 +0200
parents 11607:03eb4c0dca27
children 11609:6dcc45a2e3bc
files plugins/mod_c2s.lua plugins/mod_s2s.lua
diffstat 2 files changed, 13 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/plugins/mod_c2s.lua	Sat Jun 12 18:06:37 2021 +0200
+++ b/plugins/mod_c2s.lua	Wed Jun 16 00:00:17 2021 +0200
@@ -39,6 +39,12 @@
 local listener = {};
 local runner_callbacks = {};
 
+local m_tls_params = module:metric(
+	"counter", "encrypted", "",
+	"Encrypted connections",
+	{"protocol"; "cipher"}
+);
+
 module:hook("stats-update", function ()
 	-- for push backends, avoid sending out updates for each increment of
 	-- the metric below.
@@ -115,6 +121,7 @@
 			local info = sock:info();
 			(session.log or log)("info", "Stream encrypted (%s with %s)", info.protocol, info.cipher);
 			session.compressed = info.compression;
+			m_tls_params:with_labels(info.protocol, info.cipher):add(1)
 		else
 			(session.log or log)("info", "Stream encrypted");
 		end
--- a/plugins/mod_s2s.lua	Sat Jun 12 18:06:37 2021 +0200
+++ b/plugins/mod_s2s.lua	Wed Jun 16 00:00:17 2021 +0200
@@ -71,6 +71,11 @@
 	"Closed connections",
 	{"host", "direction", "error"}
 );
+local m_tls_params = module:metric(
+	"counter", "encrypted", "",
+	"Encrypted connections",
+	{"protocol"; "cipher"}
+);
 
 local sessions = module:shared("sessions");
 
@@ -384,6 +389,7 @@
 			local info = sock:info();
 			(session.log or log)("info", "Stream encrypted (%s with %s)", info.protocol, info.cipher);
 			session.compressed = info.compression;
+			m_tls_params:with_labels(info.protocol, info.cipher):add(1)
 		else
 			(session.log or log)("info", "Stream encrypted");
 		end