Skip to content

Commit

Permalink
Fixes skupperproject#1207: add counters for total active service conn…
Browse files Browse the repository at this point in the history
…ections
  • Loading branch information
kgiusti committed Sep 21, 2023
1 parent 16f321d commit 47334a3
Show file tree
Hide file tree
Showing 8 changed files with 451 additions and 76 deletions.
71 changes: 43 additions & 28 deletions python/skupper_router/management/skrouter.json
Original file line number Diff line number Diff line change
Expand Up @@ -479,41 +479,56 @@
"create": true,
"required": false
},
"addrCount": {
"type": "integer",
"description":"Number of addresses known to the router.",
"graph": true
},
"linkCount": {
"type": "integer",
"description":"Number of links attached to the router node.",
"addrCount": {
"type": "integer",
"description":"Number of addresses known to the router.",
"graph": true
},
"linkCount": {
"type": "integer",
"description":"Number of links attached to the router node.",
"graph": true
},
"blockedLinkCount": {
"type": "integer",
"description": "The number of links that are flagged as blocked. A blocked link is one in which the available credit has remained zero for more than 10 seconds.",
"graph": true
},
"nodeCount": {
"type": "integer",
"description":"Number of known peer router nodes.",
"graph": true
},
"autoLinkCount": {
"type": "integer",
"description":"Number of auto links attached to the router node.",
"graph": true
},
"connectionCount": {
"type": "integer",
"description":"Number of open connections to the router node.",
"graph": true
},
"tcpConnectionCount": {
"type": "integer",
"description":"Number of open tcp connections at this router node.",
"graph": true
},
"nodeCount": {
"type": "integer",
"description":"Number of known peer router nodes.",
"graph": true
},
"autoLinkCount": {
"type": "integer",
"description":"Number of auto links attached to the router node.",
"graph": true
},
"connectionCount": {
"type": "integer",
"description":"Total open network connections to the router node.",
"graph": true
},
"tcpServiceConnections": {
"type": "integer",
"description":"Number of open TCP protocol service connections at this router node.",
"graph": true
},
"http1ServiceConnections": {
"type": "integer",
"description":"Number of open HTTP/1.x protocol service connections at this router node.",
"graph": true
},
"http2ServiceConnections": {
"type": "integer",
"description":"Number of open HTTP/2 protocol service connections at this router node.",
"graph": true
},
"amqpConnections": {
"type": "integer",
"description":"Total open AMQP connections at this router node.",
"graph": true
},
"presettledDeliveries": {
"type": "integer",
"description":"Number of presettled deliveries handled by the router.",
Expand Down
24 changes: 24 additions & 0 deletions src/router_core/agent_router.c
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,10 @@
#define QDR_ROUTER_UPTIME_SECONDS 29
#define QDR_ROUTER_MEMORY_USAGE 30
#define QDR_ROUTER_WORKER_THREADS 31
#define QDR_ROUTER_TCP_SERVICE_CONNECTIONS 32
#define QDR_ROUTER_HTTP1_SERVICE_CONNECTIONS 33
#define QDR_ROUTER_HTTP2_SERVICE_CONNECTIONS 34
#define QDR_ROUTER_AMQP_CONNECTIONS 35

const char *qdr_router_columns[] =
{"name",
Expand Down Expand Up @@ -90,6 +94,10 @@ const char *qdr_router_columns[] =
"uptimeSeconds",
"memoryUsage",
"workerThreads",
"tcpServiceConnections",
"http1ServiceConnections",
"http2ServiceConnections",
"amqpConnections",
0};


Expand Down Expand Up @@ -155,6 +163,22 @@ static void qdr_agent_write_column_CT(qd_composed_field_t *body, int col, qdr_co
qd_compose_insert_ulong(body, DEQ_SIZE(core->open_connections));
break;

case QDR_ROUTER_TCP_SERVICE_CONNECTIONS:
qd_compose_insert_uint(body, core->tcp_connections);
break;

case QDR_ROUTER_HTTP1_SERVICE_CONNECTIONS:
qd_compose_insert_uint(body, core->http1_connections);
break;

case QDR_ROUTER_HTTP2_SERVICE_CONNECTIONS:
qd_compose_insert_uint(body, core->http2_connections);
break;

case QDR_ROUTER_AMQP_CONNECTIONS:
qd_compose_insert_uint(body, core->amqp_connections);
break;

case QDR_ROUTER_AUTO_LINK_COUNT:
qd_compose_insert_ulong(body, DEQ_SIZE(core->auto_links));
break;
Expand Down
2 changes: 1 addition & 1 deletion src/router_core/agent_router.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

#include "router_core_private.h"

#define QDR_ROUTER_COLUMN_COUNT 32
#define QDR_ROUTER_COLUMN_COUNT 36

extern const char *qdr_router_columns[QDR_ROUTER_COLUMN_COUNT + 1];

Expand Down
33 changes: 33 additions & 0 deletions src/router_core/connections.c
Original file line number Diff line number Diff line change
Expand Up @@ -1682,6 +1682,22 @@ static void qdr_connection_opened_CT(qdr_core_t *core, qdr_action_t *action, boo
}
} while (false);

const char *pname = conn->protocol_adaptor->name;
if (strcmp(pname, "amqp") == 0) {
core->amqp_connections++;
} else if (strcmp(pname, "tcp_lite") == 0 || strcmp(pname, "tcp") == 0) {
core->tcp_connections++;
} else if (strcmp(pname, "http2") == 0) {
core->http2_connections++;
} else if (strcmp(pname, "http/1.x") == 0) {
core->http1_connections++;
} else if (strcmp(pname, "reference") == 0) {
// ignore reference adaptor
} else {
// update me: unknown adaptor name
assert(false);
}

qdrc_event_conn_raise(core, QDRC_EVENT_CONN_OPENED, conn);

qdr_field_free(action->args.connection.connection_label);
Expand Down Expand Up @@ -1824,6 +1840,23 @@ static void qdr_connection_closed_CT(qdr_core_t *core, qdr_action_t *action, boo
qd_log(LOG_ROUTER_CORE, QD_LOG_INFO, "[C%" PRIu64 "] Connection Closed", conn->identity);

DEQ_REMOVE(core->open_connections, conn);

const char *pname = conn->protocol_adaptor->name;
if (strcmp(pname, "amqp") == 0) {
core->amqp_connections--;
} else if (strcmp(pname, "tcp_lite") == 0 || strcmp(pname, "tcp") == 0) {
core->tcp_connections--;
} else if (strcmp(pname, "http2") == 0) {
core->http2_connections--;
} else if (strcmp(pname, "http/1.x") == 0) {
core->http1_connections--;
} else if (strcmp(pname, "reference") == 0) {
// ignore reference adaptor
} else {
// update me: unknown adaptor name
assert(false);
}

qdr_connection_free(conn);
}

Expand Down
12 changes: 9 additions & 3 deletions src/router_core/router_core_private.h
Original file line number Diff line number Diff line change
Expand Up @@ -889,6 +889,9 @@ struct qdr_core_t {

qdr_delivery_cleanup_list_t delivery_cleanup_list; ///< List of delivery cleanup items to be processed in an IO thread

qdr_edge_conn_addr_t edge_conn_addr;
void *edge_context;

// Overall delivery counters
uint64_t presettled_deliveries;
uint64_t dropped_presettled_deliveries;
Expand All @@ -905,10 +908,13 @@ struct qdr_core_t {
uint64_t deliveries_delayed_10sec;
uint64_t deliveries_stuck;
uint64_t deliveries_redirected;
uint32_t links_blocked;

qdr_edge_conn_addr_t edge_conn_addr;
void *edge_context;
// current (not sum):
uint32_t links_blocked;
uint32_t tcp_connections;
uint32_t amqp_connections;
uint32_t http1_connections;
uint32_t http2_connections;
};

struct qdr_terminus_t {
Expand Down
Loading

0 comments on commit 47334a3

Please sign in to comment.