[OpenSIPS-Users] OpenSIPs-CP CDRviewer question

Brett Nemeroff brett at nemeroff.com
Wed Mar 24 22:31:56 CET 2010


Christian,
To make this work, there are a number of changes you need to make. This is
what I did:
1. ACC module params:
modparam("acc", "db_extra", "from_did=$avp(s:from_did);
to_did=$avp(s:to_did)")
of course, you'll need to set from_did and to_did in your script

2. Update stored procedure:
CREATE PROCEDURE opensips_cdrs_1_6()
BEGIN
  DECLARE done INT DEFAULT 0;
  DECLARE bye_record INT DEFAULT 0;
  DECLARE v_callid,v_from_tag, v_to_tag,v_from_did,v_to_did VARCHAR(64);
  DECLARE v_inv_time, v_bye_time DATETIME;
  DECLARE inv_cursor CURSOR FOR SELECT time, callid, from_tag,
to_tag,from_did,to_did 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,
v_from_did, v_to_did;
    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
(from_did,to_did,call_start_time,duration,sip_call_id,sip_from_tag,sip_to_tag,created)
VALUES
(v_from_did,v_to_did,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
//
DELIMITER ;
~
(notice we pull from_did/to_did from acc table)

3. Add from_did/to_did fields to acc table
4. Add from_did/to_did fields to cdrs tables
5. Update cdrviewer configuration
 // what fields to show
 $show_field[0]['from_did'] = "Caller" ;
 $show_field[1]['to_did'] = "Callee" ;
 $show_field[2]['call_start_time'] = "Call Start Time";
 $show_field[3]['duration'] = "Duration";
 $show_field[4]['leg_type'] = "Leg Type";

I don't really know what Leg Type is. I'd probably stuff something in there
like inbound/outbound/interstate/local/LD/TF/etc/etc/etc.

-Brett


Now a cavet here.. I just got this working.. however I'm getting multiple
CDR records for each call.. for example, for one call I'll see 2 x 6 second
calls and 1x36 second call. So I'm not entirely sure how that is happening
yet.. I think it's because I'm logging ACKs and early media. (pretty sure
actually).

On the other hand... Despite all the criticism out there regarding the
generation of CDR from a proxy, I'd really like to see this done at the
dialog level. After all, if you are going to piece together ACC recs to form
a dialog based CDR, this really should be done in the dialog module. Rather
than trying to replicate this kind of logic in a stored proc (blah!).



On Wed, Mar 24, 2010 at 3:49 PM, Christian Vo <cvo at nvidia.com> wrote:

>
>
> Thx Bogdan,
>
>
> Seems to be correct though:
>
> // what fields to show
>  $show_field[0]['caller_id'] = "Caller" ;
>  $show_field[1]['callee_id'] = "Callee" ;
>  $show_field[2]['call_start_time'] = "Call Start Time";
>  $show_field[3]['duration'] = "Duration";
>  $show_field[4]['leg_type'] = "Leg Type";
>
>
>
> I don't know what "leg_type" corresponds to,  (no entry in the acc table
> afaik), but I do see caller_id and callee_id...
> but the CDRviewer is showing my call entry with these fields blanked out...
>
>
>
> -----Original Message-----
> From: users-bounces at lists.opensips.org [mailto:
> users-bounces at lists.opensips.org] On Behalf Of Bogdan-Andrei Iancu
> Sent: Wednesday, March 24, 2010 12:24 PM
> To: OpenSIPS users mailling list
> Subject: Re: [OpenSIPS-Users] OpenSIPs-CP CDRviewer question
>
> Hi Christian,
>
> you need to go into opensips-cp > trunk > config > tools > system >
> cdrviewer > local.inc.php file and configure the $show_field array to
> show you whatever columns you need. Probably by mistake, it is
> configured to show some columns that does not exists.
>
> Regards,
> Bogdan
>
>
> Christian Vo wrote:
> > Hello,
> > So I realized I didn't have accounting to database enabled properly,
> > And added the following lines to my opensips.cfg:
> > modparam("acc", "db_url", "mysql://<user>:<passwd>@localhost/opensips")
> > modparam("acc", "db_extra", "caller_id=$fu; callee_id=$tu")
> > now I see there is an entry into the "acc" table:
> > mysql> select * from acc;
> >
> +----+--------+----------------------------------+----------+------------------------------------------+----------+------------+---------------------+--------+---------+---------+---------------------+---------------+------+--------+----------+--------------+------------+-------------+----------+---------------------+---------------+---------+
> > | id | method | from_tag | to_tag | callid | sip_code | sip_reason |
> > time | cdr_id | src_uri | dst_uri | caller_id | caller_domain | rpid |
> > src_ip | src_port | sip_proxy_ip | user_agent | accountcode | amaflags
> > | callee_id | callee_domain | contact |
> >
> +----+--------+----------------------------------+----------+------------------------------------------+----------+------------+---------------------+--------+---------+---------+---------------------+---------------+------+--------+----------+--------------+------------+-------------+----------+---------------------+---------------+---------+
> > | 1 | INVITE | 1BB69EB7976D43D1FA7F0A976BCFF582 | 9b522302 |
> > E06F4B164B33933E42E1DC53B510F59D1133C657 | 200 | OK | 2010-03-24
> > 11:20:03 | 0 | | | sip:1000 at 10.32.0.97 <sip%3A1000 at 10.32.0.97> | | | | |
> | | | |
> > sip:1003 at 10.32.0.97 <sip%3A1003 at 10.32.0.97> | | NULL |
> > | 2 | ACK | 1BB69EB7976D43D1FA7F0A976BCFF582 | 9b522302 |
> > E06F4B164B33933E42E1DC53B510F59D1133C657 | 200 | OK | 2010-03-24
> > 11:20:03 | 0 | | | sip:1000 at 10.32.0.97 <sip%3A1000 at 10.32.0.97> | | | | |
> | | | |
> > sip:1003 at 10.32.0.97 <sip%3A1003 at 10.32.0.97> | | NULL |
> > | 3 | BYE | 1BB69EB7976D43D1FA7F0A976BCFF582 | 9b522302 |
> > E06F4B164B33933E42E1DC53B510F59D1133C657 | 200 | OK | 2010-03-24
> > 11:20:26 | 0 | | | sip:1000 at 10.32.0.97 <sip%3A1000 at 10.32.0.97> | | | | |
> | | | |
> > sip:1003 at 10.32.0.97 <sip%3A1003 at 10.32.0.97> | | NULL |
> >
> +----+--------+----------------------------------+----------+------------------------------------------+----------+------------+---------------------+--------+---------+---------+---------------------+---------------+------+--------+----------+--------------+------------+-------------+----------+---------------------+---------------+---------+
> > However, when I view from CDRViewer, the
> > Caller, Callee , and Leg Type fields for this entry are blank.
> > Is this expected behavior?
> > ------------------------------------------------------------------------
> > This email message is for the sole use of the intended recipient(s)
> > and may contain confidential information. Any unauthorized review,
> > use, disclosure or distribution is prohibited. If you are not the
> > intended recipient, please contact the sender by reply email and
> > destroy all copies of the original message.
> > ------------------------------------------------------------------------
> > ------------------------------------------------------------------------
> >
> > _______________________________________________
> > Users mailing list
> > Users at lists.opensips.org
> > http://lists.opensips.org/cgi-bin/mailman/listinfo/users
> >
>
>
> --
> Bogdan-Andrei Iancu
> www.voice-system.ro
>
>
> _______________________________________________
> Users mailing list
> Users at lists.opensips.org
> http://lists.opensips.org/cgi-bin/mailman/listinfo/users
>
> _______________________________________________
> Users mailing list
> Users at lists.opensips.org
> http://lists.opensips.org/cgi-bin/mailman/listinfo/users
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.opensips.org/pipermail/users/attachments/20100324/f5ab90ed/attachment.htm 


More information about the Users mailing list