Przeglądaj źródła

Merge pull request #442 from smititelu/KAMAILIO-30

Better counting of received_replies counter
Stefan Mititelu 9 lat temu
rodzic
commit
09be0ae191

+ 9 - 6
modules/tm/t_reply.c

@@ -554,8 +554,8 @@ static int _reply_light( struct cell *trans, char* buf, unsigned int len,
 	/* t_update_timers_after_sending_reply( rb ); */
 	update_reply_stats( code );
 	trans->relayed_reply_branch=-2;
-	t_stats_replied_locally();
-	t_stats_replied_total();
+	t_stats_relayed_locally();
+	t_stats_relayed_total();
 	if (lock) UNLOCK_REPLIES( trans );
 
 	/* do UAC cleanup procedures in case we generated
@@ -1867,7 +1867,7 @@ enum rps relay_reply( struct cell *t, struct sip_msg *p_msg, int branch,
 			}
 		}
 		update_reply_stats( relayed_code );
-		t_stats_replied_total();
+		t_stats_relayed_total();
 		if (!buf) {
 			LOG(L_ERR, "ERROR: relay_reply: "
 				"no mem for outbound reply buffer\n");
@@ -1890,7 +1890,7 @@ enum rps relay_reply( struct cell *t, struct sip_msg *p_msg, int branch,
 		memcpy( uas_rb->buffer, buf, res_len );
 		if (relayed_msg==FAKED_REPLY) { /* to-tags for local replies */
 			update_local_tags(t, &bm, uas_rb->buffer, buf);
-			t_stats_replied_locally();
+			t_stats_relayed_locally();
 		}
 
 		/* update the status ... */
@@ -2041,7 +2041,7 @@ enum rps local_reply( struct cell *t, struct sip_msg *p_msg, int branch,
 		winning_msg= branch==local_winner
 			? p_msg :  t->uac[local_winner].reply;
 		if (winning_msg==FAKED_REPLY) {
-			t_stats_replied_locally();
+			t_stats_relayed_locally();
 			winning_code = branch==local_winner
 				? msg_status : t->uac[local_winner].last_received;
 		} else {
@@ -2049,7 +2049,7 @@ enum rps local_reply( struct cell *t, struct sip_msg *p_msg, int branch,
 		}
 		t->uas.status = winning_code;
 		update_reply_stats( winning_code );
-		t_stats_replied_total();
+		t_stats_relayed_total();
 		if (unlikely(is_invite(t) && winning_msg!=FAKED_REPLY &&
 					 winning_code>=200 && winning_code <300 &&
 					 has_tran_tmcbs(t, TMCB_LOCAL_COMPLETED) ))  {
@@ -2143,6 +2143,9 @@ int reply_received( struct sip_msg  *p_msg )
 	if ( (t==0)||(t==T_UNDEFINED))
 		goto trans_not_found;
 
+	/* if transaction found, increment the received_replies counter */
+	t_stats_received_replies();
+
 	if (unlikely(branch==T_BR_UNDEFINED))
 		BUG("invalid branch, please report to [email protected]\n");
 	tm_ctx_set_branch_index(branch);

+ 6 - 3
modules/tm/t_stats.c

@@ -93,8 +93,9 @@ void free_tm_stats()
 		(res)->completed_5xx=(s1)->completed_5xx+(s2)->completed_5xx; \
 		(res)->completed_6xx=(s1)->completed_6xx+(s2)->completed_6xx; \
 		(res)->completed_2xx=(s1)->completed_2xx+(s2)->completed_2xx; \
-		(res)->replied_locally=(s1)->replied_locally+(s2)->replied_locally; \
-		(res)->replied_total=(s1)->replied_total+(s2)->replied_total; \
+		(res)->received_replies=(s1)->received_replies+(s2)->received_replies; \
+		(res)->relayed_locally=(s1)->relayed_locally+(s2)->relayed_locally; \
+		(res)->relayed_total=(s1)->relayed_total+(s2)->relayed_total; \
 		(res)->deleted=(s1)->deleted+(s2)->deleted; \
 	}while(0)
 
@@ -137,7 +138,9 @@ void tm_rpc_stats(rpc_t* rpc, void* c)
 										 (unsigned) waiting);
 	rpc->struct_add(st, "d", "total", (unsigned) all.transactions);
 	rpc->struct_add(st, "d", "total_local", (unsigned)all.client_transactions);
-	rpc->struct_add(st, "d", "replied_locally", (unsigned)all.replied_locally);
+	rpc->struct_add(st, "d", "received_replies", (unsigned)all.received_replies);
+	rpc->struct_add(st, "d", "relayed_locally", (unsigned)all.relayed_locally);
+	rpc->struct_add(st, "d", "relayed_total", (unsigned)all.relayed_total);
 	rpc->struct_add(st, "ddddd", 
 			"6xx", (unsigned int)all.completed_6xx,
 			"5xx", (unsigned int)all.completed_5xx,

+ 11 - 6
modules/tm/t_stats.h

@@ -43,8 +43,9 @@ struct t_proc_stats {
 	/* number of transactions which completed with this status */
 	stat_counter completed_3xx, completed_4xx, completed_5xx, 
 		completed_6xx, completed_2xx;
-	stat_counter replied_locally;
-	stat_counter replied_total;
+	stat_counter received_replies;
+	stat_counter relayed_locally;
+	stat_counter relayed_total;
 	stat_counter deleted;
 #ifdef TM_MORE_STATS
 	/* number of created transactions */
@@ -121,15 +122,19 @@ inline static void update_reply_stats( int code ) {
 	}
 }
 
+inline void static t_stats_received_replies(void)
+{
+	tm_stats[process_no].s.received_replies++;
+}
 
-inline void static t_stats_replied_locally(void)
+inline void static t_stats_relayed_locally(void)
 {
-	tm_stats[process_no].s.replied_locally++;
+	tm_stats[process_no].s.relayed_locally++;
 }
 
-inline void static t_stats_replied_total(void)
+inline void static t_stats_relayed_total(void)
 {
-	tm_stats[process_no].s.replied_total++;
+	tm_stats[process_no].s.relayed_total++;
 }
 
 

+ 51 - 18
modules/tmx/doc/tmx_admin.xml

@@ -626,72 +626,105 @@ event_route [tm:branch-failure:contact] {
 		Exported statistics are listed in the next sections. All statistics
 		except <quote>inuse_transactions</quote> can be reset.
 		</para>
-		<section>
-		<title>received_replies</title>
-			<para>
-			Total number of total replies received by TM module.
-			</para>
-		</section>
-		<section>
-		<title>relayed_replies</title>
-			<para>
-			Total number of replies received and relayed by TM module.
-			</para>
-		</section>
-		<section>
-		<title>local_replies</title>
-			<para>
-			Total number of replies local generated by TM module.
-			</para>
-		</section>
+
 		<section>
 		<title>UAS_transactions</title>
 			<para>
 			Total number of transactions created by received requests.
 			</para>
 		</section>
+
 		<section>
 		<title>UAC_transactions</title>
 			<para>
 			Total number of transactions created by local generated requests.
 			</para>
 		</section>
+
 		<section>
 		<title>2xx_transactions</title>
 			<para>
 			Total number of transactions completed with 2xx replies.
 			</para>
 		</section>
+
 		<section>
 		<title>3xx_transactions</title>
 			<para>
 			Total number of transactions completed with 3xx replies.
 			</para>
 		</section>
+
 		<section>
 		<title>4xx_transactions</title>
 			<para>
 			Total number of transactions completed with 4xx replies.
 			</para>
 		</section>
+
 		<section>
 		<title>5xx_transactions</title>
 			<para>
 			Total number of transactions completed with 5xx replies.
 			</para>
 		</section>
+
 		<section>
 		<title>6xx_transactions</title>
 			<para>
 			Total number of transactions completed with 6xx replies.
 			</para>
 		</section>
+
 		<section>
 		<title>inuse_transactions</title>
 			<para>
 			Number of transactions existing in memory at current time.
 			</para>
 		</section>
+
+		<section>
+		<title>active_transactions</title>
+			<para>
+			Number of ongoing transactions at current time.
+			</para>
+		</section>
+
+		<section>
+		<title>received_replies</title>
+			<para>
+			Total number of replies received by TM module.
+			</para>
+		</section>
+
+		<section>
+		<title>received_replies_absorbed</title>
+			<para>
+			Total number of replies received and not relayed by TM module.
+			</para>
+		</section>
+
+		<section>
+		<title>tmx:relayed_locally</title>
+			<para>
+			Total number of replies locally generated and relayed by TM module.
+			</para>
+		</section>
+
+		<section>
+		<title>relayed_received </title>
+			<para>
+			Total number of replies received and relayed by TM module.
+			</para>
+		</section>
+
+		<section>
+		<title>relayed_total</title>
+			<para>
+			Total number of replies relayed by TM module.
+			</para>
+		</section>
+
 	</section>
 </chapter>
 

+ 25 - 13
modules/tmx/tmx_mod.c

@@ -108,8 +108,10 @@ unsigned long tmx_stats_trans_6xx(void);
 unsigned long tmx_stats_trans_inuse(void);
 unsigned long tmx_stats_trans_active(void);
 unsigned long tmx_stats_rcv_rpls(void);
-unsigned long tmx_stats_rld_rpls(void);
-unsigned long tmx_stats_loc_rpls(void);
+unsigned long tmx_stats_abs_rpls(void);
+unsigned long tmx_stats_rld_rcv_rpls(void);
+unsigned long tmx_stats_rld_loc_rpls(void);
+unsigned long tmx_stats_rld_tot_rpls(void);
 
 static stat_export_t mod_stats[] = {
 	{"UAS_transactions" ,    STAT_IS_FUNC, (stat_var**)tmx_stats_uas_trans   },
@@ -122,8 +124,10 @@ static stat_export_t mod_stats[] = {
 	{"inuse_transactions" ,  STAT_IS_FUNC, (stat_var**)tmx_stats_trans_inuse },
 	{"active_transactions" , STAT_IS_FUNC, (stat_var**)tmx_stats_trans_active},
 	{"received_replies" ,    STAT_IS_FUNC, (stat_var**)tmx_stats_rcv_rpls    },
-	{"relayed_replies" ,     STAT_IS_FUNC, (stat_var**)tmx_stats_rld_rpls    },
-	{"local_replies" ,       STAT_IS_FUNC, (stat_var**)tmx_stats_loc_rpls    },
+	{"received_replies_absorbed", STAT_IS_FUNC, (stat_var**)tmx_stats_abs_rpls    },
+	{"relayed_locally" ,     STAT_IS_FUNC, (stat_var**)tmx_stats_rld_loc_rpls},
+	{"relayed_received" ,    STAT_IS_FUNC, (stat_var**)tmx_stats_rld_rcv_rpls},
+	{"relayed_total" ,       STAT_IS_FUNC, (stat_var**)tmx_stats_rld_tot_rpls},
 	{0,0,0}
 };
 #endif
@@ -810,23 +814,31 @@ unsigned long tmx_stats_trans_active(void)
 unsigned long tmx_stats_rcv_rpls(void)
 {
 	tmx_stats_update();
-	return _tmx_stats_all.completed_6xx
-		+ _tmx_stats_all.completed_5xx
-		+ _tmx_stats_all.completed_4xx
-		+ _tmx_stats_all.completed_3xx
-		+ _tmx_stats_all.completed_2xx;
+	return _tmx_stats_all.received_replies;
 }
 
-unsigned long tmx_stats_rld_rpls(void)
+unsigned long tmx_stats_abs_rpls(void)
 {
 	tmx_stats_update();
-	return _tmx_stats_all.replied_total - _tmx_stats_all.replied_locally;
+	return _tmx_stats_all.received_replies - tmx_stats_rld_rcv_rpls();
 }
 
-unsigned long tmx_stats_loc_rpls(void)
+unsigned long tmx_stats_rld_loc_rpls(void)
 {
 	tmx_stats_update();
-	return _tmx_stats_all.replied_locally;
+	return _tmx_stats_all.relayed_locally;
+}
+
+unsigned long tmx_stats_rld_tot_rpls(void)
+{
+	tmx_stats_update();
+	return _tmx_stats_all.relayed_total;
+}
+
+unsigned long tmx_stats_rld_rcv_rpls(void)
+{
+	tmx_stats_update();
+	return _tmx_stats_all.relayed_total - _tmx_stats_all.relayed_locally;
 }
 
 #endif