|
|
@@ -3,14 +3,17 @@
|
|
|
int start_prometheus_server(void){
|
|
|
prom_collector_registry_default_init();
|
|
|
turn_status = prom_collector_registry_must_register_metric(prom_gauge_new("turn_status", "Represents status", 5, (const char *[]) {"realm", "user", "allocation", "status", "lifetime" }));
|
|
|
+
|
|
|
turn_traffic_rcvp = prom_collector_registry_must_register_metric(prom_gauge_new("turn_traffic_rcvp", "Represents received packets", 3, (const char *[]) {"realm", "user", "allocation" }));
|
|
|
turn_traffic_rcvb = prom_collector_registry_must_register_metric(prom_gauge_new("turn_traffic_rcvb", "Represents received bytes", 3, (const char *[]) {"realm", "user", "allocation" }));
|
|
|
turn_traffic_sentp = prom_collector_registry_must_register_metric(prom_gauge_new("turn_traffic_sentp", "Represents sent packets", 3, (const char *[]) {"realm", "user", "allocation" }));
|
|
|
turn_traffic_sentb = prom_collector_registry_must_register_metric(prom_gauge_new("turn_traffic_sentb", "Represents received bytes", 3, (const char *[]) {"realm", "user", "allocation" }));
|
|
|
+
|
|
|
turn_traffic_peer_rcvp = prom_collector_registry_must_register_metric(prom_gauge_new("turn_traffic_peer_rcvp", "Represents peer received packets", 3, (const char *[]) {"realm", "user", "allocation" }));
|
|
|
turn_traffic_peer_rcvb = prom_collector_registry_must_register_metric(prom_gauge_new("turn_traffic_peer_rcvb", "Represents peer received bytes", 3, (const char *[]) {"realm", "user", "allocation" }));
|
|
|
turn_traffic_peer_sentp = prom_collector_registry_must_register_metric(prom_gauge_new("turn_traffic_peer_sentp", "Represents peer sent packets", 3, (const char *[]) {"realm", "user", "allocation" }));
|
|
|
turn_traffic_peer_sentb = prom_collector_registry_must_register_metric(prom_gauge_new("turn_traffic_peer_sentb", "Represents peer received bytes", 3, (const char *[]) {"realm", "user", "allocation" }));
|
|
|
+
|
|
|
promhttp_set_active_collector_registry(NULL);
|
|
|
|
|
|
|
|
|
@@ -39,53 +42,20 @@ void prom_del_status(const char* realm, const char* user, unsigned long long all
|
|
|
prom_gauge_add(turn_status, 1, (const char *[]) { realm , user, allocation_chars, status, NULL });
|
|
|
|
|
|
}
|
|
|
-
|
|
|
-void prom_set_rcvp(const char* realm, const char* user, unsigned long long allocation, unsigned long rsvp){
|
|
|
+void prom_set_traffic(const char* realm, const char* user, unsigned long long allocation, unsigned long rsvp, unsigned long rsvb, unsigned long sentp, unsigned long sentb, bool peer){
|
|
|
char allocation_chars[1024];
|
|
|
snprintf(allocation_chars, sizeof(allocation_chars), "%018llu", allocation);
|
|
|
|
|
|
- prom_gauge_set(turn_traffic_rcvp, rsvp, (const char *[]) { realm , user, allocation_chars });
|
|
|
-}
|
|
|
-void prom_set_rcvb(const char* realm, const char* user, unsigned long long allocation, unsigned long rsvb){
|
|
|
- char allocation_chars[1024];
|
|
|
- snprintf(allocation_chars, sizeof(allocation_chars), "%018llu", allocation);
|
|
|
-
|
|
|
- prom_gauge_set(turn_traffic_rcvb, rsvb, (const char *[]) { realm , user, allocation_chars });
|
|
|
-}
|
|
|
-void prom_set_sentp(const char* realm, const char* user, unsigned long long allocation, unsigned long sentp){
|
|
|
- char allocation_chars[1024];
|
|
|
- snprintf(allocation_chars, sizeof(allocation_chars), "%018llu", allocation);
|
|
|
-
|
|
|
- prom_gauge_set(turn_traffic_sentp, sentp, (const char *[]) { realm , user, allocation_chars });
|
|
|
-}
|
|
|
-void prom_set_sentb(const char* realm, const char* user, unsigned long long allocation, unsigned long sentb){
|
|
|
- char allocation_chars[1024];
|
|
|
- snprintf(allocation_chars, sizeof(allocation_chars), "%018llu", allocation);
|
|
|
-
|
|
|
- prom_gauge_set(turn_traffic_sentb, sentb, (const char *[]) { realm , user, allocation_chars });
|
|
|
-}
|
|
|
-
|
|
|
-void prom_set_peer_rcvp(const char* realm, const char* user, unsigned long long allocation, unsigned long rsvp){
|
|
|
- char allocation_chars[1024];
|
|
|
- snprintf(allocation_chars, sizeof(allocation_chars), "%018llu", allocation);
|
|
|
-
|
|
|
- prom_gauge_set(turn_traffic_peer_rcvp, rsvp, (const char *[]) { realm , user, allocation_chars });
|
|
|
-}
|
|
|
-void prom_set_peer_rcvb(const char* realm, const char* user, unsigned long long allocation, unsigned long rsvb){
|
|
|
- char allocation_chars[1024];
|
|
|
- snprintf(allocation_chars, sizeof(allocation_chars), "%018llu", allocation);
|
|
|
-
|
|
|
- prom_gauge_set(turn_traffic_peer_rcvb, rsvb, (const char *[]) { realm , user, allocation_chars });
|
|
|
-}
|
|
|
-void prom_set_peer_sentp(const char* realm, const char* user, unsigned long long allocation, unsigned long sentp){
|
|
|
- char allocation_chars[1024];
|
|
|
- snprintf(allocation_chars, sizeof(allocation_chars), "%018llu", allocation);
|
|
|
-
|
|
|
- prom_gauge_set(turn_traffic_peer_sentp, sentp, (const char *[]) { realm , user, allocation_chars });
|
|
|
+ if (peer){
|
|
|
+ prom_gauge_set(turn_traffic_peer_rcvp, rsvp, (const char *[]) { realm , user, allocation_chars });
|
|
|
+ prom_gauge_set(turn_traffic_peer_rcvb, rsvb, (const char *[]) { realm , user, allocation_chars });
|
|
|
+ prom_gauge_set(turn_traffic_peer_sentp, sentp, (const char *[]) { realm , user, allocation_chars });
|
|
|
+ prom_gauge_set(turn_traffic_peer_sentb, sentb, (const char *[]) { realm , user, allocation_chars });
|
|
|
+ } else {
|
|
|
+ prom_gauge_set(turn_traffic_rcvp, rsvp, (const char *[]) { realm , user, allocation_chars });
|
|
|
+ prom_gauge_set(turn_traffic_rcvb, rsvb, (const char *[]) { realm , user, allocation_chars });
|
|
|
+ prom_gauge_set(turn_traffic_sentp, sentp, (const char *[]) { realm , user, allocation_chars });
|
|
|
+ prom_gauge_set(turn_traffic_sentb, sentb, (const char *[]) { realm , user, allocation_chars });
|
|
|
+ }
|
|
|
}
|
|
|
-void prom_set_peer_sentb(const char* realm, const char* user, unsigned long long allocation, unsigned long sentb){
|
|
|
- char allocation_chars[1024];
|
|
|
- snprintf(allocation_chars, sizeof(allocation_chars), "%018llu", allocation);
|
|
|
|
|
|
- prom_gauge_set(turn_traffic_peer_sentb, sentb, (const char *[]) { realm , user, allocation_chars });
|
|
|
-}
|