CDR - Execution Time!

Hi All
I’ve asterisk running with AGI Scripts.
One before the call, to get the limit time, and one after to update the user.

All this is done based on the CDR table (myql).
My problem is that the AGI script is run before the CDR table is updated…

My AGI script is run like

exten => h,1,DEADAGI(checkAfter.agi)

I’d like it to be run after the CDR update !
If you have an idea !

Thank you

Which variables of the CDR are you trying to access? Most of the CDR variables can be read or writen with the CDR function.

If you are trying to get the duration / billsec variables they are not available during the call. It has to do with how asterisk stores this information internally. You will probably have to do some sort of post processing on your CDR (ie. cron script).


Thanks for your answer.

Yes I want to access the BillSec field.
I need to bill the call, and update a table i have created (cdrcost).
Acutally i’m doing my own Billing System.

Do you mean that I must run cron script to update my database ???
There is no way to run a script after the call is hangup ?

have you looked at DeadAGI instead of AGI for use in ‘h’ extensions ? … md+DeadAGI

Oh Yes, Sorry, i’m already using DeadAGI…
I’m gonna edit my post !

You can run a script afterr the user hangs up, that is what the ‘h’ extension is for. However, Asterisk doesn’t calculate the billsecs & duration fields until it posts the CDR.

I can think of two choices for handling this.

1.) Use Asterisk CDR and cron scripts to do post processing.
2.) Keep your own timer, so you know how long the call has been up.

You can use the variable EPOCH, which will give you the current unix timestamp, or you can do it in your AGI script.