From 8f7938a374ef22e55cd88e99aa60165295f99fef Mon Sep 17 00:00:00 2001 From: Miquel Ortega Date: Tue, 28 Jul 2020 10:50:58 +0200 Subject: [PATCH 1/2] Fix peer and realm on delete --- src/apps/relay/ns_ioalib_engine_impl.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/apps/relay/ns_ioalib_engine_impl.c b/src/apps/relay/ns_ioalib_engine_impl.c index 34f01fd..4ba8bb3 100644 --- a/src/apps/relay/ns_ioalib_engine_impl.c +++ b/src/apps/relay/ns_ioalib_engine_impl.c @@ -3672,15 +3672,15 @@ void turn_report_allocation_delete(void *a) prom_del_status(ss->realm_options.name, (const char*)ss->username, (unsigned long long)ss->id, (const char *)"deleted"); // Set prometheus total traffic metrics - prom_set_total_traffic(ss->realm_options.name, (const char*)ss->username, (unsigned long long)ss->id, (unsigned long)(ss->t_received_packets), (unsigned long)(ss->t_received_bytes), (unsigned long)(ss->t_sent_packets), (unsigned long)(ss->t_sent_bytes), false); - prom_set_total_traffic(ss->realm_options.name, (const char*)ss->username, (unsigned long long)ss->id, (unsigned long)(ss->t_peer_received_packets), (unsigned long)(ss->t_peer_received_bytes), (unsigned long)(ss->t_peer_sent_packets), (unsigned long)(ss->t_peer_sent_bytes), false); + prom_set_total_traffic(ss->realm_options.name, (const char*)ss->username, (unsigned long long)ss->id, (unsigned long)(ss->t_received_packets), (unsigned long)(ss->t_received_bytes), (unsigned long)(ss->t_sent_packets), (unsigned long)(ss->t_sent_bytes), true); + prom_set_total_traffic(ss->realm_options.name, (const char*)ss->username, (unsigned long long)ss->id, (unsigned long)(ss->t_peer_received_packets), (unsigned long)(ss->t_peer_received_bytes), (unsigned long)(ss->t_peer_sent_packets), (unsigned long)(ss->t_peer_sent_bytes), true); } else { // Set prometheus del metric and update status prom_del_status(NULL, (const char*)ss->username, (unsigned long long)ss->id, (const char *)"deleted"); // Set prometheus total traffic metrics - prom_set_total_traffic(ss->realm_options.name, (const char*)ss->username, (unsigned long long)ss->id, (unsigned long)(ss->t_received_packets), (unsigned long)(ss->t_received_bytes), (unsigned long)(ss->t_sent_packets), (unsigned long)(ss->t_sent_bytes), true); - prom_set_total_traffic(ss->realm_options.name, (const char*)ss->username, (unsigned long long)ss->id, (unsigned long)(ss->t_peer_received_packets), (unsigned long)(ss->t_peer_received_bytes), (unsigned long)(ss->t_peer_sent_packets), (unsigned long)(ss->t_peer_sent_bytes), true); + prom_set_total_traffic(NULL, (const char*)ss->username, (unsigned long long)ss->id, (unsigned long)(ss->t_received_packets), (unsigned long)(ss->t_received_bytes), (unsigned long)(ss->t_sent_packets), (unsigned long)(ss->t_sent_bytes), true); + prom_set_total_traffic(NULL, (const char*)ss->username, (unsigned long long)ss->id, (unsigned long)(ss->t_peer_received_packets), (unsigned long)(ss->t_peer_received_bytes), (unsigned long)(ss->t_peer_sent_packets), (unsigned long)(ss->t_peer_sent_bytes), true); } } #endif From a2200f5c5cb57a916fb77a9b9f7a0d71a1fcf34c Mon Sep 17 00:00:00 2001 From: Miquel Ortega Date: Tue, 28 Jul 2020 11:04:06 +0200 Subject: [PATCH 2/2] Change prometheus exporter port to 9641 In order to avoid conflicts using the same port userd by redis exporter looking at the [prometheus wiki](https://github.com/prometheus/prometheus/wiki/Default-port-allocations) the port 9641 is the first FREE for allocation --- README.md | 2 +- examples/etc/turnserver.conf | 2 +- src/apps/relay/mainrelay.c | 2 +- src/apps/relay/prom_server.h | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 6831ec0..b13c8d3 100644 --- a/README.md +++ b/README.md @@ -70,7 +70,7 @@ Supported user databases (for user repository, with passwords or keys, if authen Redis can also be used for status and statistics storage and notification. -By default a [prometheus](https://prometheus.io/) exporter endpoint is enabled on port 9121 under path /metrics +By default a [prometheus](https://prometheus.io/) exporter endpoint is enabled on port 9641 under path /metrics Supported message integrity digest algorithms: diff --git a/examples/etc/turnserver.conf b/examples/etc/turnserver.conf index 743058e..adf4942 100644 --- a/examples/etc/turnserver.conf +++ b/examples/etc/turnserver.conf @@ -190,7 +190,7 @@ # By default the turnserver will expose an endpoint with stats on a prometheus format # this endpoint is on a different port to conflict with other configurations. # -# You can simply run the turnserver and access the port 9121 and path /metrics +# You can simply run the turnserver and access the port 9641 and path /metrics # # For mor info on the prometheus exporter and metrics # https://prometheus.io/docs/introduction/overview/ diff --git a/src/apps/relay/mainrelay.c b/src/apps/relay/mainrelay.c index 54d3f06..02ef9fe 100644 --- a/src/apps/relay/mainrelay.c +++ b/src/apps/relay/mainrelay.c @@ -535,7 +535,7 @@ static char Usage[] = "Usage: turnserver [options]\n" " The connection string has the same parameters as redis-userdb connection string.\n" #endif #if !defined(TURN_NO_PROMETHEUS) -" --no-prometheus Disable prometheus metrics. By default it is enabled and listening on port 9121 unther the path /metrics\n" +" --no-prometheus Disable prometheus metrics. By default it is enabled and listening on port 9641 unther the path /metrics\n" " also the path / on this port can be used as a health check\n" #endif " --use-auth-secret TURN REST API flag.\n" diff --git a/src/apps/relay/prom_server.h b/src/apps/relay/prom_server.h index fcaa975..0211038 100644 --- a/src/apps/relay/prom_server.h +++ b/src/apps/relay/prom_server.h @@ -14,7 +14,7 @@ #include #include -#define DEFAULT_PROM_SERVER_PORT (9121) +#define DEFAULT_PROM_SERVER_PORT (9641) prom_gauge_t *turn_status;