Question

I'm using Asterisk and want to collect cdr records. I searched for a while, and found that there are already modules which we can use to collect cdr records into CSV files or MySQL.

I'm wondering that whether there is already a module which let me collect cdr records by http post. So that when a call finished, Asterisk will post cdr records to a predefined URL.

Thanks in advanced.

Était-ce utile?

La solution

I don't know such a module, but you could execute an Application on Hangup.

You could use the function ${CURL(url[,post-data])}:

exten => h,n,Set(result=${CURL(http://SERVER/cdr.php?\
             cdranswer=${CDR(answer)}&exten=${EXTEN}&cidnum=${CALLERID(num)})}) 
exten => h,n,Noop(${result}) 

Another Approach is to execute a Script on Hangup:

exten => h,n,System('php -f /opt/scripts/cdr.php \
                        ${CallerID(num)} ${EXTEN} "${CDR(answer)}" ${EPOCH}');

Maybe you could also use ${CDR(billsec)}.

Autres conseils

Another option would be to use a CRON job to run a Ruby or PHP script every few minutes to extract and HTTP POST all of the CDRs since the last time the script was run. I've done that for a customer and it works reasonably well.

That said, what I've found is that if I need to have CDRs accessible "off machine", the easiest way to do it over the long haul is set up MySQL replication; write the CDRs to the PBX machine, read them from the replicated copy on the reports machine. It's a bit more set-up intensive at the beginning, but makes everything else a heck of a lot easier later on.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top