[OpenSIPS-Users] cdrview not working correctly

gshaverdov gshaverdov at ocs.ru
Wed Sep 4 14:23:44 CEST 2013


Helo All!

I’ve a problem with collect cdrs on opensips-cp 5.0 and opensips 1.8.3
platforms.

Acc parameters 

# ----- acc params -----
/* what sepcial events should be accounted ? */
modparam("acc", "early_media", 1)
modparam("acc", "report_cancels", 1)
/* by default ww do not adjust the direct of the sequential requests.
   if you enable this parameter, be sure the enable "append_fromtag"
   in "rr" module */
modparam("acc", "detect_direction", 0)
/* account triggers (flags) */
modparam("acc", "failed_transaction_flag", 3)
modparam("acc", "log_flag", 1)
modparam("acc", "log_missed_flag", 2)
/* uncomment the following lines to enable DB accounting also */
modparam("acc", "db_flag", 2)
modparam("acc", "cdr_flag", 1)
modparam("acc", "db_missed_flag", 2)
modparam("acc", "db_table_acc", "acc")
modparam("acc", "db_url", "mysql://opensips:opensipsrw@localhost/opensips")

in route have 
{
….
# account only INVITEs
        if (is_method("INVITE")) {
        setflag(1); # do accounting
        }
….
}
Acc table has procedure :

CREATE DEFINER=`root`@`localhost` PROCEDURE `opensips_cdrs`()
BEGIN
  DECLARE done INT DEFAULT 0;
  DECLARE bye_record INT DEFAULT 0;
  DECLARE v_callid,v_from_tag, v_to_tag VARCHAR(64);
  DECLARE v_inv_time, v_bye_time DATETIME;
  DECLARE inv_cursor CURSOR FOR SELECT time, callid, from_tag, to_tag FROM
acc where method='INVITE' and cdr_id='0';
  DECLARE CONTINUE HANDLER FOR SQLSTATE '02000' SET done = 1;
  OPEN inv_cursor;
  REPEAT
    FETCH inv_cursor INTO v_inv_time, v_callid, v_from_tag, v_to_tag;
    IF NOT done THEN
      SET bye_record = 0;
      SELECT 1, time INTO bye_record, v_bye_time FROM acc WHERE method='BYE'
AND callid=v_callid AND ((from_tag=v_from_tag AND to_tag=v_to_tag) OR
(from_tag=v_to_tag AND to_tag=v_from_tag)) ORDER BY time ASC LIMIT 1;
      IF bye_record = 1 THEN
        INSERT INTO cdrs
(call_start_time,duration,sip_call_id,sip_from_tag,sip_to_tag,created)
VALUES
(v_inv_time,UNIX_TIMESTAMP(v_bye_time)-UNIX_TIMESTAMP(v_inv_time),v_callid,v_from_tag,v_to_tag,NOW());
        UPDATE acc SET cdr_id=last_insert_id() WHERE callid=v_callid AND (
(from_tag=v_from_tag AND to_tag=v_to_tag) OR (from_tag=v_to_tag AND
to_tag=v_from_tag));
      END IF;
      SET done = 0;
    END IF;
  UNTIL done END REPEAT;
END

Cdrs table exist;

Acc table fill in, and mysql log reports about. Call procedure but no any
data not inserting to cdrs table.. a was download mysql debugger and it say
me that in Select operator : Error code :1329 SQLState 02000 no data – zero
rows fetched selected or processed. Another bogus - in this procedure at "IF
bye_record = 1 THEN" statement never leg to Insert to cdrs.... and one
more... v_bye_time is never handle. 







--
View this message in context: http://opensips-open-sip-server.1449251.n2.nabble.com/cdrview-not-working-correctly-tp7587732.html
Sent from the OpenSIPS - Users mailing list archive at Nabble.com.



More information about the Users mailing list