How to import Asterisk DB data to TNG4*.

Moderators: Leon van Heerden, Luanda_Junzi, Belinda Frick, Lee Hendricks

How to import Asterisk DB data to TNG4*.

Postby Leon van Heerden » Wed Nov 02, 2011 10:16 am

PLEASE NOTE this this should only be done on a TNG4* that has been registered. If you load calls older than the installation date on an unregistered TNG4*, it will expire.
First you need to extract the information form the DB to a CSV File.

On MySQL you need to run the following SQL statement to extract the data:
Code: Select all
mysql -u [username] -p [password] [Database Name]

select clid, src, dst, dcontext, channel, dstchannel, lastapp, lastdata, calldate, "", "", duration, billsec, disposition, amaflags, accountcode, uniqueid, userfield into outfile '/tmp/201106.csv' FIELDS TERMINATED BY ',' ENCLOSED BY '"' LINES TERMINATED BY '\n' from cdr where calldate like "2011-06-%";


This will give you all the data for the 6th month in 2011 and write it out to a CSV file in /tmp. Change the "2011-06-%" to the month you want to export and run the command again. Remember to also change the "/tmp/201106.csv" to a new name other wise it will overwrite your other file.

Now you can just change the TNG location that TNG uses to read the CSV file to this new file.
The file should almost immediately start processing.
You can check on the Call list screen, the "number of calls" on the top left of the page should be increasing until the file is completely processed.

Once you have completed loading all the files that you require, change TNG back to the original file name so that the live call details are loaded again.
The default location is usually:
Code: Select all
/var/log/asterisk/cdr-custom/Master.csv






Thanks to Emile from Clarotech for the information and testing.
----
Leon van Heerden
http://www.datatex.co.za
Leon van Heerden
 
Posts: 332
Joined: Fri Oct 29, 2010 11:21 am
Location: Cape Town

Return to Support Archive's (TNG)

Who is online

Users browsing this forum: No registered users and 1 guest

cron