add metrics to monitor

This commit is contained in:
jeka committed 2026-03-07 19:01:14 +03:00
1 parent fbd1128bf1
commit b1c8ba7e90
7 files changed
+268 -8

No files matched your search

+8
View File
@@ -753,6 +753,12 @@ static void send_metrics(struct control_server* server, struct control_client* c
rsp->etcp.retrans_timer_active = (conn->retrans_timer != NULL) ? 1 : 0;
rsp->etcp.ack_resp_timer_active = (conn->ack_resp_timer != NULL) ? 1 : 0;
/* Connection IDs */
rsp->etcp.next_tx_id = conn->next_tx_id;
rsp->etcp.last_rx_id = conn->last_rx_id;
rsp->etcp.last_delivered_id = conn->last_delivered_id;
rsp->etcp.rx_ack_till = conn->rx_ack_till;
/* Fill TUN metrics */
if (instance->tun) {
rsp->tun.bytes_read = instance->tun->bytes_read;
@@ -784,6 +790,8 @@ static void send_metrics(struct control_server* server, struct control_client* c
link_info[i].init_timer_active = (link->init_timer != NULL) ? 1 : 0;
link_info[i].keepalive_timer_active = (link->keepalive_timer != NULL) ? 1 : 0;
link_info[i].shaper_timer_active = (link->shaper_timer != NULL) ? 1 : 0;
link_info[i].keepalive_sent = (uint32_t)link->keepalive_sent_count;
link_info[i].keepalive_recv = (uint32_t)link->keepalive_recv_count;
link = link->next;
}
+1 -1
View File
@@ -103,7 +103,7 @@ struct ETCP_CONN {
uint32_t last_rx_id; // Last received ID
uint32_t last_delivered_id; // Last delivered to output_queue
uint32_t rx_ack_till;// из ack пакета - по какой пакет получено и собрано на уданенной стороне
uint32_t rx_ack_till;// из ack пакета - по какой пакет получено и собрано на удаленной стороне
// Metrics (RTT, jitter, etc.)
// uint16_t retrans_delay; // Not used
+10 -1
View File
@@ -140,6 +140,8 @@ static void etcp_link_send_keepalive(struct ETCP_LINK* link) {
DEBUG_DEBUG(DEBUG_CATEGORY_CONNECTION, "[%s] Sending keepalive on link %p (local_id=%d)",
link->etcp->log_name, link, link->local_link_id);
link->keepalive_sent_count++;
etcp_encrypt_send(dgram);
u_free(dgram);
}
@@ -572,6 +574,8 @@ struct ETCP_LINK* etcp_link_new(struct ETCP_CONN* etcp, struct ETCP_SOCKET* conn
link->keepalive_timeout = 2000; // Default 2 seconds
link->keepalive_interval = 200; // Default 0.2 s
}
link->keepalive_sent_count = 0;
link->keepalive_recv_count = 0;
// Выделяем свободный local_link_id
int free_id = etcp_find_free_local_link_id(etcp);
@@ -1006,7 +1010,12 @@ process_decrypted:
DEBUG_INFO(DEBUG_CATEGORY_CONNECTION, "[%s] Link %p (local_id=%d) status changed to UP - packet received",
link->etcp->log_name, link, link->local_link_id);
}
// Count received keepalive packets (empty packets with no payload)
if (pkt->data_len == 0) {
link->keepalive_recv_count++;
}
// Cancel all init timers - link is alive, no need for recovery
etcp_cancel_all_init_timers(link->etcp);
+2
View File
@@ -111,6 +111,8 @@ struct ETCP_LINK {
void* keepalive_timer; // Таймер для отправки keepalive пакетов
uint32_t keepalive_timeout; // таймаут (ms)
uint8_t pkt_sent_since_keepalive; // Флаг: был ли отправлен пакет с последнего keepalive тика
uint32_t keepalive_sent_count; // Счётчик отправленных keepalive
uint32_t keepalive_recv_count; // Счётчик полученных keepalive
};
// INITIALIZATION (создаёт listen-сокеты и подключения из конфига)