Module: kamailio
Branch: master
Commit: 30248b184ca169e6d348c98b0236efd230a5446e
URL:
https://github.com/kamailio/kamailio/commit/30248b184ca169e6d348c98b0236efd…
Author: Cedric Mueller <cmueller(a)sipgate.de>
Committer: Daniel-Constantin Mierla <miconda(a)gmail.com>
Date: 2024-06-17T15:48:09+02:00
tls: enable statistics
---
Modified: src/modules/tls/tls_mod.c
---
Diff:
https://github.com/kamailio/kamailio/commit/30248b184ca169e6d348c98b0236efd…
Patch:
https://github.com/kamailio/kamailio/commit/30248b184ca169e6d348c98b0236efd…
---
diff --git a/src/modules/tls/tls_mod.c b/src/modules/tls/tls_mod.c
index baa1a7c76d1..5d06e7040b5 100644
--- a/src/modules/tls/tls_mod.c
+++ b/src/modules/tls/tls_mod.c
@@ -42,6 +42,8 @@
#include "../../core/dprint.h"
#include "../../core/mod_fix.h"
#include "../../core/kemi.h"
+#include "../../core/counters.h"
+#include "../../core/tcp_info.h"
#define KSR_RTHREAD_SKIP_P
#define KSR_RTHREAD_NEED_4PP
@@ -56,6 +58,7 @@
#include "tls_mod.h"
#include "tls_cfg.h"
#include "tls_rand.h"
+#include "tls_ct_wrq.h"
#ifndef TLS_HOOKS
#error "TLS_HOOKS must be defined, or the tls module won't work"
@@ -107,6 +110,20 @@ MODULE_VERSION
#define KEY_PREFIX_LEN (strlen(KEY_PREFIX))
#endif
+#ifdef STATISTICS
+unsigned long tls_stats_connections_no(void);
+unsigned long tls_stats_max_connections(void);
+unsigned long tls_stats_ct_wq_total_bytes(void);
+
+static stat_export_t mod_stats[] = {
+ {"opened_connections", STAT_IS_FUNC,
+ (stat_var **)tls_stats_connections_no},
+ {"max_connections", STAT_IS_FUNC,
+ (stat_var **)tls_stats_max_connections},
+ {"clear_text_write_queued_bytes", STAT_IS_FUNC,
+ (stat_var **)tls_stats_ct_wq_total_bytes},
+ {0, 0, 0}};
+#endif
extern str sr_tls_event_callback;
str sr_tls_xavp_cfg = {0, 0};
@@ -360,6 +377,14 @@ static int mod_init(void)
unsigned char rand_buf[32];
int k;
+#ifdef STATISTICS
+ /* register statistics */
+ if(register_module_stats("tls", mod_stats) != 0) {
+ LM_ERR("failed to register statistics\n");
+ return -1;
+ }
+#endif
+
if(tls_disable) {
LM_WARN("tls support is disabled "
"(set enable_tls=1 in the config to enable it)\n");
@@ -929,3 +954,24 @@ EVP_PKEY *tls_engine_private_key(const char *key_id)
return pkey;
}
#endif
+
+#ifdef STATISTICS
+unsigned long tls_stats_connections_no(void)
+{
+ struct tcp_gen_info ti;
+ tcp_get_info(&ti);
+ return ti.tls_connections_no;
+}
+
+unsigned long tls_stats_max_connections(void)
+{
+ struct tcp_gen_info ti;
+ tcp_get_info(&ti);
+ return ti.tls_max_connections;
+}
+
+unsigned long tls_stats_ct_wq_total_bytes(void)
+{
+ return tls_ct_wq_total_bytes();
+}
+#endif