Jump to content



Recommended Posts


I just tested the implementation of CDRs in a MySQL database via PHP script available here: http://wiki.pbxnsip.com/index.php?title=JSON_CDR and everything works well. Each call is recorded in the database.
But I have trouble reading the data and understand them.
Indeed, for one call there may be three entries and the type is both O and I
My goal is to make a script statistics (number of incoming calls, number of outgoing calls, average length, etc ...), can you help me to understand these values ​​and how to use them.
Thank you.
Link to comment
Share on other sites

You have to keep in mind that those CDR are call leg CDR. That means you typically get two records for each telephone call. They contain the same Call-ID, so that you can group them together if you want.


Most users want to see only the CDR for the trunks for billing purposes. When then trunk is empty, those users can just discard the record.

Link to comment
Share on other sites

thx for your reply


so what the difference between "primarycallid" and "callid" ? because for one call, there are 3 entries with the same "primarycallid" but 3 different "callid", and sometimes primarycallid = callid.


If i check where trunk is not empty i could have 2 entries, one with type O and one with type I


but i think it will be when snomONE call cellphone extension (type O)


hard to do script in this condition :wacko:

Link to comment
Share on other sites

Indeed, the result seems correct


but all call to cellphone when you have your cellphone in "Accounts / Redirection / Cell Phone Number" and "Include the cell phone in calls to extension" is set to "Immediatly" are recorded.


I have to find a better request :angry:


Thx for your help

Link to comment
Share on other sites



after more tests, the best request i found was :


SELECT * FROM `cdr` WHERE trunkid > 0 and extension = ''


and i have to look after "remoteparty" field to know for Outbound Call the callee and for Inbound Call the caller


If during the call, there was a lot of : hold, transfer, *52 for cellphone, etc... the results will be the summary of the call but the "from" and "to" field will be not correct afterall, so i check the "remoteparty".


In case of call in huntgroup or ivr node, with this request, il will not know which extension pick up the phone. In these cases, i have to do another request to have more detail.


What do you think about all this ???


i'll continue my tests and let you know if i'm good ;):P


Thx for your answers



Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...