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?
Using the callbacks provided by dialog module is the best way to go.
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
Item 1 - Solved. Found dialog store and fetch functions.
1) if using DB persistence, the dialog values will be also saved in DB across restarts.
3) see the db_extra_bye in ACC module - http://www.opensips.org/html/docs/modules/1.9.x/acc.html#id293902
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?
Found the problem, was on file db/db_ut.c
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?
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?
How do you do accounting ? with START/STOP or with CDRs ?
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: ACC: call ended: created=1367706516;call_start_time=1367706518;duration=12;setuptime=2;method=INVITE;from_tag=13139SIPpTag001;to_tag=as1d100ada;email@example.com;code=200;reason=OK
May 4 19:28:50 s05 /sbin/opensips: NOTICE:prepaid:search_delete_call: PRE PAGO - Deleting CALL firstname.lastname@example.org
May 4 19:28:50 s05 /sbin/opensips: 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: NOTICE:prepaid:price_write_avp[b]: WRITING PRICE AVP: 0.064000[/b]
May 4 19:28:50 s05 /sbin/opensips: PRICE=0.064000
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.
Sign up for the SourceForge newsletter:
You seem to have CSS turned off.
Please don't fill out this field.