فهرست منبع

modules/ims_charging: fixed charging stats

jaybeepee 9 سال پیش
والد
کامیت
c084e0b389
4فایلهای تغییر یافته به همراه19 افزوده شده و 3 حذف شده
  1. 2 0
      modules/ims_charging/dialog.c
  2. 8 2
      modules/ims_charging/ims_ro.c
  3. 3 0
      modules/ims_charging/mod.c
  4. 6 1
      modules/ims_charging/ro_session_hash.h

+ 2 - 0
modules/ims_charging/dialog.c

@@ -4,6 +4,7 @@
 #include "../ims_usrloc_scscf/usrloc.h"
 #include "../ims_usrloc_scscf/udomain.h"
 #include "ro_db_handler.h"
+#include "ims_charging_stats.h"
 
 struct cdp_binds cdpb;
 
@@ -11,6 +12,7 @@ extern usrloc_api_t ul;
 extern int ro_db_mode;
 extern char *domain;
 extern struct dlg_binds dlgb;
+extern struct ims_charging_counters_h ims_charging_cnts_h;
 
 void dlg_callback_received(struct dlg_cell *dlg, int type, struct dlg_cb_params *_params) {
     LM_DBG("Received dialog callback event [%d]\n", type);

+ 8 - 2
modules/ims_charging/ims_ro.c

@@ -721,6 +721,7 @@ static void resume_on_interim_ccr(int is_timeout, void *param, AAAMessage *cca,
     goto success;
 
 error:
+    counter_inc(ims_charging_cnts_h.failed_interim_ccr);  
     if (ro_cca_data)
         Ro_free_CCA(ro_cca_data);
 
@@ -904,7 +905,7 @@ void send_ccr_stop(struct ro_session *ro_session) {
     Ro_free_CCR(ro_ccr_data);
 
     counter_inc(ims_charging_cnts_h.final_ccrs);
-    counter_add(ims_charging_cnts_h.active_ro_sessions, -1);
+//    counter_add(ims_charging_cnts_h.active_ro_sessions, -1);
     return;
 
 error1:
@@ -935,6 +936,7 @@ static void resume_on_termination_ccr(int is_timeout, void *param, AAAMessage *c
 
     if (!cca) {
         LM_ERR("Error in termination CCR.\n");
+        counter_inc(ims_charging_cnts_h.failed_final_ccrs); 
         return;
     }
 
@@ -942,6 +944,7 @@ static void resume_on_termination_ccr(int is_timeout, void *param, AAAMessage *c
 
     if (ro_cca_data == NULL) {
         LM_DBG("Could not parse CCA message response.\n");
+        counter_inc(ims_charging_cnts_h.failed_final_ccrs); 
         return;
     }
 
@@ -955,6 +958,7 @@ static void resume_on_termination_ccr(int is_timeout, void *param, AAAMessage *c
     counter_inc(ims_charging_cnts_h.successful_final_ccrs);
 
 error:
+    counter_inc(ims_charging_cnts_h.failed_final_ccrs);      
     Ro_free_CCA(ro_cca_data);
     if (!is_timeout && cca) {
         cdpb.AAAFreeMessage(&cca);
@@ -1184,6 +1188,7 @@ int Ro_Send_CCR(struct sip_msg *msg, struct dlg_cell *dlg, int dir, int reservat
     }
 
     counter_inc(ims_charging_cnts_h.initial_ccrs);
+    counter_inc(ims_charging_cnts_h.active_ro_sessions);
 
     if (free_called_asserted_identity) shm_free(called_asserted_identity.s); // shm_malloc in cscf_get_public_identity_from_requri	
     return RO_RETURN_BREAK;
@@ -1305,7 +1310,6 @@ static void resume_on_initial_ccr(int is_timeout, void *param, AAAMessage *cca,
     shm_free(ssd);
 
     counter_inc(ims_charging_cnts_h.successful_initial_ccrs);
-    counter_inc(ims_charging_cnts_h.active_ro_sessions);
 
     return;
 
@@ -1314,6 +1318,8 @@ error1:
 
 error0:
     LM_DBG("Trying to reserve credit on initial INVITE failed on cdp callback\n");
+//    counter_add(ims_charging_cnts_h.active_ro_sessions, -1); /*we bumped active on the original initial ccr sent */
+    counter_inc(ims_charging_cnts_h.failed_initial_ccrs);      /* drop by one as theoretically this is failed initial ccr */
     create_cca_return_code(error_code);
 
     if (!is_timeout && cca) {

+ 3 - 0
modules/ims_charging/mod.c

@@ -21,6 +21,8 @@
 #include "../../lib/ims/ims_getters.h"
 #include "ro_db_handler.h"
 #include "ims_charging_stats.h"
+#include "ro_session_hash.h"
+#include "ims_charging_stats.h"
 
 MODULE_VERSION
 
@@ -57,6 +59,7 @@ client_ro_cfg cfg = { str_init("scscf.ims.smilecoms.com"),
     0
 };
 
+extern struct ims_charging_counters_h ims_charging_cnts_h;
 struct cdp_binds cdpb;
 struct dlg_binds dlgb;
 cdp_avp_bind_t *cdp_avp;

+ 6 - 1
modules/ims_charging/ro_session_hash.h

@@ -11,6 +11,7 @@
 #include "ro_timer.h"
 #include "../../mem/shm_mem.h"
 #include "../ims_usrloc_scscf/usrloc.h"
+#include "ims_charging_stats.h"
 #include <stdlib.h>
 
 
@@ -22,6 +23,8 @@
 
 #define MAX_PANI_LEN 100
 
+extern struct ims_charging_counters_h ims_charging_cnts_h;
+
 enum ro_session_event_type {
     pending,
     answered,
@@ -72,7 +75,7 @@ struct ro_session {
     int rating_group;
     int service_identifier;
     unsigned int is_final_allocation;
-    unsigned int billed;
+    long billed;
 };
 
 /*! entries in the main ro_session table */
@@ -163,6 +166,8 @@ static inline void unlink_unsafe_ro_session(struct ro_session_entry *ro_session_
         ro_session_entry->first = ro_session->next;
 
     ro_session->next = ro_session->prev = 0;
+    
+    counter_add(ims_charging_cnts_h.active_ro_sessions, -1);
 
     return;
 }