Skip to content

Commit

Permalink
tm: provide clustering statistics for sent/recv messages
Browse files Browse the repository at this point in the history
  • Loading branch information
razvancrainea committed Aug 16, 2022
1 parent ce19581 commit b82d4e6
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 1 deletion.
21 changes: 20 additions & 1 deletion modules/tm/cluster.c
Expand Up @@ -21,6 +21,7 @@
#include "cluster.h"
#include "t_lookup.h"
#include "t_fwd.h"
#include "t_stats.h"
#include "../../ut.h"
#include "../../receive.h"
#include "../../socket_info.h"
Expand Down Expand Up @@ -208,12 +209,21 @@ static void receive_tm_repl(bin_packet_t *packet)
TM_BIN_POP(str, &tmp, "message");

/* only auto-CANCEL is treated differently */
if (packet->type == TM_CLUSTER_AUTO_CANCEL) {
switch (packet->type) {
case TM_CLUSTER_AUTO_CANCEL:
if_update_stat(tm_enable_stats, tm_cluster_cancel_rx , 1);
if (tm_repl_auto_cancel) {
tm_repl_cancel(packet, &tmp, &ri);
return;
}
LM_WARN("auto-CANCEL handling is disabled, but got one auto-CANCEL here!\n");
break;
case TM_CLUSTER_REQUEST:
if_update_stat(tm_enable_stats, tm_cluster_request_rx , 1);
break;
case TM_CLUSTER_REPLY:
if_update_stat(tm_enable_stats, tm_cluster_reply_rx , 1);
break;
}
receive_msg(tmp.s, tmp.len, &ri, NULL, FL_TM_REPLICATED);
}
Expand Down Expand Up @@ -370,6 +380,9 @@ static void *tm_replicate_cancel(struct sip_msg *msg)
LM_ERR("Error sending message to cluster: %d\n",
tm_repl_cluster);
break;
case CLUSTERER_SEND_SUCCESS:
if_update_stat(tm_enable_stats, tm_cluster_cancel_tx , 1);
break;
}
bin_free_packet(&packet);
return NULL; /* dummy return to comply with TM_BIN_PUSH() */
Expand Down Expand Up @@ -399,6 +412,9 @@ static void tm_replicate_reply(struct sip_msg *msg, int cid)
LM_ERR("Error sending message to %d in cluster: %d\n", cid,
tm_repl_cluster);
break;
case CLUSTERER_SEND_SUCCESS:
if_update_stat(tm_enable_stats, tm_cluster_reply_tx , 1);
break;
}
bin_free_packet(packet);
}
Expand Down Expand Up @@ -429,6 +445,9 @@ static int tm_replicate_broadcast(struct sip_msg *msg)
LM_ERR("Error sending message to cluster: %d\n",
tm_repl_cluster);
break;
case CLUSTERER_SEND_SUCCESS:
if_update_stat(tm_enable_stats, tm_cluster_request_tx , 1);
break;
}
bin_free_packet(packet);
return 0;
Expand Down
7 changes: 7 additions & 0 deletions modules/tm/t_stats.h
Expand Up @@ -46,6 +46,13 @@ extern stat_var *tm_trans_5xx;
extern stat_var *tm_trans_6xx;
extern stat_var *tm_trans_inuse;

extern stat_var *tm_cluster_reply_tx;
extern stat_var *tm_cluster_request_tx;
extern stat_var *tm_cluster_cancel_tx;
extern stat_var *tm_cluster_reply_rx;
extern stat_var *tm_cluster_request_rx;
extern stat_var *tm_cluster_cancel_rx;


#ifdef STATISTICS
/* update the statistics regading the final codes of the transactions
Expand Down
13 changes: 13 additions & 0 deletions modules/tm/tm.c
Expand Up @@ -175,6 +175,13 @@ stat_var *tm_trans_5xx;
stat_var *tm_trans_6xx;
stat_var *tm_trans_inuse;

stat_var *tm_cluster_reply_tx;
stat_var *tm_cluster_request_tx;
stat_var *tm_cluster_cancel_tx;
stat_var *tm_cluster_reply_rx;
stat_var *tm_cluster_request_rx;
stat_var *tm_cluster_cancel_rx;

static dep_export_t deps = {
{ /* OpenSIPS module dependencies */
{ MOD_TYPE_NULL, NULL, 0 },
Expand Down Expand Up @@ -330,6 +337,12 @@ static stat_export_t mod_stats[] = {
{"5xx_transactions" , 0, &tm_trans_5xx },
{"6xx_transactions" , 0, &tm_trans_6xx },
{"inuse_transactions" , STAT_NO_RESET, &tm_trans_inuse },
{"cluster_reply_sent" , 0, &tm_cluster_reply_tx },
{"cluster_request_sent" ,0, &tm_cluster_request_tx },
{"cluster_cancel_sent" , 0, &tm_cluster_cancel_tx },
{"cluster_reply_recv" , 0, &tm_cluster_reply_rx },
{"cluster_request_recv" ,0, &tm_cluster_request_rx },
{"cluster_cancel_recv" , 0, &tm_cluster_cancel_rx },
{0,0,0}
};

Expand Down

0 comments on commit b82d4e6

Please sign in to comment.