Work at SourceForge, help us to make it a better place! We have an immediate need for a Support Technician in our San Francisco or Denver office.

Close

Whats the best way to keep track of a call?

2013-04-23
2013-05-09
  • Daniel Zanutti
    Daniel Zanutti
    2013-04-23

    Hi
    I developed a billing system module for opensips long ago and now i need to re-design it due to new requirements…

    I'm looking for the best (or proper) way to keep track of a call… I need to trigger an action on the first invite, 200OK (or error) and BYE…

    Currently i use register_dlgcb of dialog module… It works but i'm not sure if it may have some unpredicted scenarios.

    At the end of the call, i need the duration of it.

    Could someone help?

    Thanks

     
  • Hello,

    Using the callbacks provided by dialog module is the best way to go.

    Regards,
    Bogdan

     
  • Daniel Zanutti
    Daniel Zanutti
    2013-04-26

    Hi Bogdan

    Thanks for helping!

    Could you help with 3 another questions?

    1) Is there any way to store some billing information of the call on Dialog module or other module and retrieve it on BYE? Or do I need to write my own "billing" structure, keep track of every running call, and store it on shm? I would like to put a callback on dialog module and just get my data i had set on initial invite…

    Also I'm concerned about opensips restarts… If there is a ready-to-go solution would be much better since dialogs are already written to DB periodically…

    2) Just to check, to get the duration of the call on Bye… DLG_lifetime is the way? I saw this o ACC module: (time(NULL)-start_time)

    3) When BYE is received, I want to calculate price and write it to custom field DB. How to send back this info to an AVPs, to ACC module write it to DB? Or there is a better way to send this info internally?

    Thank you very much

     
  • Daniel Zanutti
    Daniel Zanutti
    2013-04-28

    Item 1 - Solved. Found dialog store and fetch functions.

     
  • Daniel Zanutti
    Daniel Zanutti
    2013-04-30

    Hi Bogdan

    I done almost everything… Thanks!ls

    I'm trying to write a double data to DB (23.340293) but it's truncating to 23.34. I double checked the variable (At structure db_val_t.val.double_val) and it has the correct value. Seems that it's something deep on DB core code… Could you give me some directions where to look?

    Thanks again

     
  • Daniel Zanutti
    Daniel Zanutti
    2013-04-30

    Found the problem, was on file db/db_ut.c
    Function: db_double2str

            ret = snprintf(_s, *_l, "%-10.2f", _v);

    Only 2 decimal digits were used… I need at least 6 decimal digits so I changed to 9.6… Since it's 8 bytes, 15 digits will be still ok.

    Could you commit it to SVN tree?

    Thanks

     
  • Daniel Zanutti
    Daniel Zanutti
    2013-05-03

    Hi Bogdan!

    Almost everything is working very fine, thanks for helping.

    The only last thing that it is not working is writing back the AVP to be written to ACC. The value was written to AVP but seems that ACC has already written to DB the data and never got my info.

    Opensips is writing to AVP on dialog callback module on all failure possibilities (DLGCB_TERMINATED | DLGCB_FAILED | DLGCB_EXPIRED | DLGCB_DESTROY).

    I'm pretty sure that the data was written to AVP, but was after accounting. :(

    How to solve this?

    Thanks again

     
  • Hi Daniel,

    How do you do accounting ? with START/STOP or with CDRs ?

    Regards,
    Bogdan

     
  • Daniel Zanutti
    Daniel Zanutti
    2013-05-04

    I was using START/STOP but moved to CDRs since the doc you pointed explicit says to do it: db_extra_bye  - "Note that this parameter makes sense only when the cdr_flag is used."

    Bellow log of my test, you can see that ACC data is written first to DB, then later my AVP is written. I called my module "prepaid" =)

    May  4 19:28:50 s05 /sbin/opensips[24438]: ACC: call ended: created=1367706516;call_start_time=1367706518;duration=12;setuptime=2;method=INVITE;from_tag=13139SIPpTag001;to_tag=as1d100ada;call_id=1-13139@46.182.109.28;code=200;reason=OK
    May  4 19:28:50 s05 /sbin/opensips[24438]: NOTICE:prepaid:search_delete_call: PRE PAGO - Deleting CALL 1-13139@46.182.109.28
    May  4 19:28:50 s05 /sbin/opensips[24438]: NOTICE:prepaid:calculate_group_max_duration_plus_call: PRE PAGO - Group: 4 - Balance: 44268.832000 - Virtual Balance: 44268.832000 - Calls: 1 - Charge: 0.000000 - Novo maxtime: -1 ### Rate: 0.000000 - Connect: 0.000000 (0/0)
    May  4 19:28:50 s05 /sbin/opensips[24438]: NOTICE:prepaid:price_write_avp[b]: WRITING PRICE AVP: 0.064000[/b]
    May  4 19:28:50 s05 /sbin/opensips[24438]: PRICE=0.064000
    

    Any idea?

     
  • Daniel Zanutti
    Daniel Zanutti
    2013-05-06

    I could finish it using my previous START/STOP config. Instead of using db_extra_bye, i setup db_extra with the Price field i was needing and could get the value before acc wrote to DB.

    Thanks for all help.