Search This Blog

Wednesday, May 6, 2015

SQL CDR Pulls

I was given the task of pulling CDRs for an entire month almost 2 months ago for a fairly high call volume directory number.  If you haven't done this before, CUCM provides a CDR pull under the serviceability section.  The problem, it trunicates the results to 100 so you end up having to run 50 million pulls.  The quick and easy way to do this is to simply pull a SQL query but this can be intensive on CUCM.  Be sure to do this during off peak hours just in case you botch something and send CUCM into a spiral and need to reboot.  There are two different ways to run CDRs based on version.

Pre 8.x Version
run sql car select * from tbl_billing_data where originalcalledpartynumber like '3126'

8.x and Forward:
 run sql car select datetimestampconnect, duration, callingpartynumber, finalcalledpartynumber from tbl_billing_data where callingpartynumber = '3126'

Keep in mind the above are just examples.  You don't need all those fields if you don't want them but I included ones that I happen to use.  Make sure you set your terminal length to something like 20000 just in case some of the results go out of bounds of the window.  Once you get that information, copy and paste it into a text file.  From here, import that data into Excel via text file.  If you don't do it in this fashion, Excel will not format it for you based off of spaces or commas and you end up with a mess.

Now, here is the next kicker.  The times are not in common format so you may see something like this:


amporigination datetimest ampconnect datetimest ampdisconnect
============== ========== =========== ========== =============
56:26.0 3/2/2015 56:39.0 3/2/2015 56:41.0
16:31.0 3/2/2015 16:34.0 3/2/2015 18:47.0
44:12.0 3/2/2015 44:16.0 3/2/2015 50:16.0
03:00.0 3/2/2015 03:03.0 3/2/2015 08:19.0

What is ampconnect or amporigination in actual time?  If you click the field, the text box at the top of the sheet will show you the real time.  I believe these times are in Epoch time and need to be converted.  Just highlight all the times and format the cells to "Time" and bam, done!  An easier way to deal with all of this is to just buy a third party billing program but if you must do it the hard way, this is how it's done.



No comments:

Post a Comment