I’m trying to make a web page which lists unanswered calls from CDR. On incoming call all softphones and some mobile phones ring simultaneously. Asterisk version is 1.8.5.
Here is what gets written to CDR table for a single ANSWERED call:
╔═════════════════════╦══════╦═════════╦═════╦══════════╦═══════════════════════════╦═══════════════════════════╦═════════╦═══════════════════════╦══════════╦═════════╦═════════════╦══════════╦═════════════╦═══════════╦════════════════╦══════════╗ ║ calldate ║ clid ║ src ║ dst ║ dcontext ║ channel ║ dstchannel ║ lastapp ║ lastdata ║ duration ║ billsec ║ disposition ║ amaflags ║ accountcode ║ userfield ║ uniqueid ║ imported ║ ╠═════════════════════╬══════╬═════════╬═════╬══════════╬═══════════════════════════╬═══════════════════════════╬═════════╬═══════════════════════╬══════════╬═════════╬═════════════╬══════════╬═════════════╬═══════════╬════════════════╬══════════╣ ║ 2012-02-06 12:40:45 ║ ║ 5020971 ║ 595 ║ OUTGOING ║ Local/595@OUTGOING-5d9a;2 ║ SIP/help.desk-000000b8 ║ Dial ║ SIP/help.desk/595,,Tt ║ 8 ║ 0 ║ ANSWERED ║ 3 ║ ║ ║ 1328524845.301 ║ 0 ║ ║ 2012-02-06 12:40:45 ║ ║ 5020971 ║ 599 ║ OUTGOING ║ Local/599@OUTGOING-038b;2 ║ SIP/help.desk-000000b9 ║ Dial ║ SIP/help.desk/599,,Tt ║ 8 ║ 0 ║ NO ANSWER ║ 3 ║ ║ ║ 1328524845.303 ║ 1 ║ ║ 2012-02-06 12:40:44 ║ ║ 5020971 ║ s ║ to_tech ║ SIP/help.desk-000000b6 ║ Local/595@OUTGOING-5d9a;1 ║ Queue ║ TECH,Tt,,,300 ║ 111 ║ 110 ║ ANSWERED ║ 3 ║ ║ ║ 1328524844.298 ║ 0 ║ ╚═════════════════════╩══════╩═════════╩═════╩══════════╩═══════════════════════════╩═══════════════════════════╩═════════╩═══════════════════════╩══════════╩═════════╩═════════════╩══════════╩═════════════╩═══════════╩════════════════╩══════════╝
The SQL to get the unanswered calls is this:
SELECT * FROM cdr WHERE disposition = 'NO ANSWER' AND imported='0'
Needless to say, I’m getting false positives with calls that are actually answered. 🙂
They only link I see is that the NO ANSWER and ANSWERED lines have very short time interval between them (and they share the same src number).
Now, before I go ahead and start checking if there are some ANSWERED calls from the same number with a close time interval (like 3 seconds), I’d like to hear if someone knows a better way to solve this.
I don’t speak extensions.conf very fluently and the guys who actually put our dialplan up are long gone but I noticed this in extensions.conf:
[class1]
exten => s,n,SET(CDR(accountcode)=${UNIQUEID})
include => accounts
include => OUTGOING
If I get this straight, the exten line there is supposed to set accountcode field in the CDR table to a value of the incoming call’s uniqueid? Anyway it is not working as the accountcode field is never filled in the table.
If I am reading that output correctly, it seems that the call came in and was put into a queue, then the Queue() app transferred the call to an agent (599) who did not answer, so the call was then transferred to another agent (595), who then answered the call.
In addition, it seems that each time the call is handled by the Queue() application, it is given a new call id, so it makes it very difficult to track.
What I would suggest, for this specific issue with Queues, is to use the QueueLog functionality, which can be integrated with SQL. You can then track the call in the QueueLog table, and track each step and transfer it made in the QueueLog SQL Table.
It will then be possible to construct an SQL query to join the QueueLog table with the cdr table to see which unique calls were unanswered, as opposed to a situation like the one you currently have.
EDIT:
Step-by-step instructions can be found at : http://www.voip-info.org/wiki/view/Asterisk+queue_log+on+MySQL . Queue events will then be inserted into a table, which looks like:
You can then track the queue activity using this table.
Hope that helped.