Multiple CDR records Asterisk 13 - asterisk

Running Asterisk 13.12.1, FreePBX 13.0.192.19.
We had to install new server and since we previously used much older asterisk, there were some fixes applied. We DIDN'T update previous, but we made clean install, just copied dialplans, sip config etc.
The problem is that we are now having multiple CDR records per call. We previously had NOCDR lines for local contexts, and we tried I have tried to change those to exten => _X!,1,Set(CDR_PROP(disable)=1) but that didn't work at all.
Here is the example:
[main context]
exten => remote-mon-1,1,Dial(SIP/lokal300&SIP/lokal301&Local/06xxxxxx#shift-remote-1&Local/06xxxxxx#shift-remote-2&Local/06xxxxxx#shift-remote-3&Local/06xxxxxx#shift-remote-4&Local/06xxxxxx#shift-remote-5&Local/06xxxxxx#shift-remote-6,,m(remote)M(whoanswered,remote))
[shift-remote-1]
exten => _X!,1,Set(CDR_PROP(disable)=1)
exten => _X!,n,Dial(SIP/gsm10/${EXTEN},540)
Basically what the above does is calling two local phones (300 and 301) as well as multiple (6) remote mobile phones via gsm gateway.
1) So CDR PROP is completely ignored (I think someone said how its not working with Local context but I need confirmation). How can I fix it?
2) Any other ideas how to avoid creating multiple CDR record for each call?
Thank you!
Update: As this was flagged as a duplicate of Asterisk 13.4 cdr engine is creating 2 records per call , I need to explain that In that question the solution is applying unofficial patch, which is not something we want to do. I was looking for official approved way on why CDR_PROP is not working correctly. Furthermore (I just checked) the link to patch in that post is not working, as site is unreachable. One more reason to not flag this as duplicate.

1) use NoCDR, not forget add '/n' to local channels
pro-sip*CLI> core show application NOCDR
-= Info about application 'NoCDR' =-
[Synopsis]
Tell Asterisk to not maintain a CDR for this channel.
[Description]
This application will tell Asterisk not to maintain a CDR for the current
channel. This does *NOT* mean that information is not tracked; rather, if the
channel is hung up no CDRs will be created for that channel.
If a subsequent call to ResetCDR occurs, all non-finalized CDRs created for the
channel will be enabled.
NOTE: This application is deprecated. Please use the CDR_PROP function to
disable CDRs on a channel.
[Syntax]
NoCDR()
[Arguments]
Not available
[See Also]
ResetCDR(), CDR_PROP
2) Read /etc/asterisk/cdr.conf params.

Related

Asterisk how check if a number is busy before dialing it

As a beginner that just installed his first asterix server I came across a small issue. i want to check if a number that i dial is busy or not before actually dialing it.
So for example I would call 0904 => number busy => redirect to 0905
However I don't want it to dial 0904 first if its busy but just instantly redirect it to 0905 instead.
I have a very basic setup with just 3 users. 2 of them are in a queue "support" one of them is in the queue "admin"
I have seen and read a little about checking if a channel is available but i didn't fully understand that and I'm not sure if it could be done easier.
Here is my simple dialplan, if i call *12 my simple python script will just execute the Dial command to the 0904.
exten => *12,1,Answer()
same => n,set(PHONE_EXTEN=0904)
same => n,AGI(test-agi.py,${PHONE_EXTEN})
same => n,Hangup()
There is no way know if external number is busy.
If number is your extension, you can count calls using GROUP/GROUP_COUNT or you can check extensions states and hints, like described in docs
https://wiki.asterisk.org/wiki/display/AST/Extension+State+and+Hints
https://wiki.asterisk.org/wiki/display/AST/Device+State

execute command after asterisk confbridge recording is finished

I'm trying to find answer how to make Asterisk execute some command (my script) after confbridge's recording is finished
There is the next info in confbridge.conf:
record_conference=yes
Records the conference call starting when the first user enters the
room, and ending when the last user exits the room.
It records file well but I want it sending wav file via email.
Could anybody help me?
My config now looks like this (if it's necessary):
exten => 333,1,ConfBridge(100010,100010_bridge_profile,100010_user_profile)
Dialplan scripting is limited to events relating to each call channel. To get event info for other parts of asterisk (such as the ConfBridge application) you should hook into the Asterisk Manager Interface (AMI).
There are many libraries already created to make working with the AMI easier. (That site may be outdated. Refer to the official Asterisk Wiki whenever possible.)
The AMI event you're interested in is "ConfBridgeEnd". Docs here.
You can use h-extension after confbridge, in which you have check if confbridge still active(last user).
If yes, run your script via System call.

Asterisk ami/agi - not able to answer call

I have followed the instructions in this thread: Asterisk AMI - pickup call. However, I am still unable to answer calls via AMI. I can make the call to the extension, but corresponding phone for that extension doesn't ring. I can then run the AMI command to answer that call, it does answer, but obviously there isn't any actual response.
Dialplan (testing with extension 116):
exten => 116,1,AGI(agi:async)
Any ideas what I am doing wrong here?
Use
exten => 116,1,Answer
exten => 116,2,AGI(agi:async)
or use Answer action via ami.
http://www.voip-info.org/wiki/view/Asterisk+manager+API
You need listen event, when see agi-async event issue Answer on same channel. For example you can do playback command with answer.
Very likly you need start with AGI interface, which is much more simpler for understanding. Not use agi:async, it require understanding of asterisk internals.
Found the Answer. For those wanting to answer with API Manager you can use the following -
http://ip-address:port/asterisk/rawman?action=Originate&Channel=Local/(exten you want to answer with)#(context)&Application=Exec&Data=Pickup((exten you want to answer with)#PICKUPMARK)
I am of course using http to send my requests, if you are using something else you will need to change the format.
Or you can use the bridge command. Two channels will be created when you make a call from one extension to the other, bridge those channels and you will have better overall functionality than pickup.

How exactly does the a2billing softswitch generate call records?

I just installed Asterisk 11 and a2billing 2.01. I followed instructions for the a2billing installation and everything was OK. It works.
But... There are no call traces being recorded into the a2billing database!!!
As I understand it, it uses the "cc_call" table for call recording - but this table is empty!
I need all calls recorded, not only answered. I'm making calls via AGI using their PHP scripts. The following is my dial plan:
;For standard inbound call
[a2billing]
exten => _X.,1,NoOp(A2Billing Start)
exten => _X.,n,Agi(/usr/share/a2billing/AGI/a2billing.php,1)
exten => h,1,Hangup
This starts the IVR which tells me my account balance (how much money I have left), and then asks me to choose a number to dial.
I have a trunk for the call, created as has been recommended. After the call my balance is decreased; i.e., the call has been charged. But I cannot see any call records inserted into the database.
My questions are: How exactly does a2billing generate CDR's? What do I need to do to have the calls recorded?
As mentioned by arheops, A2billing store CDRs in it's own Mysql Database, within a table called cc_call, the table is very similar to the Asterisk CDR table but contains extra fields to store the buy/sell rates, cost of calls and relation to the rate/callplan tables.
When you send a call to the AGI, A2Billing will try first to authenticate the users, if it succeed then the outbound call will be saved.
A2Billing create cdrs via by agi script. You can got it in cc_call table.
For record calls you have change agi-confX and set key for recording(in config section of web)

Collect Asterisk cdr records by http post

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.
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)}.
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.

Resources