Export CDR files from AsteriskNOW to External FTP/SFTP


#1

Hi All
Again i am very new to Asterisk so please don`t ridicule me for asking stupid questions. I have a new installation of Asterisk 11 ,i need to export the CDR records in a .csv format to an external SFTP/FTP server. Is this possible ? Could anyone perhaps assist me with some steps or maybe even a reference to a document ?
Thanks
Rynard


#2

Most Welcome @rcoetzee,

I think you need to create PHP Script with follwoing steps:

  1. Connect to CDR DB
  2. Your sql
  3. generate CSV
  4. connect to your external server
  5. upload CSV to server

Hope this to be helpful.


#3

Hi Ahmed
Thanks for the reply. As far as i can tell there is a way to generate the CDR files in .csv format. It is stored in /var/log/asterisk/cdr-csv/master.csv. So i guess my first question is if Asterisk will store it here by default or if i need to edit some conf file. Secondly i need to create some script that will copy this master.csv file into a custom.csv file every “XX” seconds and then that file needs to be copied to External FTP server using scp or equivalent.


#4

HI @rcoetzee,
Very good to know,

For second part I think you can but scp in bash file and use watch to run it periodically:

watch -n 10 path/to/script.sh


#5

It depends on how you configure your CDR.

https://wiki.asterisk.org/wiki/display/AST/Asterisk+14+Configuration_cdr

https://wiki.asterisk.org/wiki/display/AST/CDR+Storage+Backends

The CSV and Custom Backends both will write to csv files on the host asterisk is running on.


#6

Hi thanks for the reply ,another question ,how do i get the CSV backend registered , see below output Call Detail Record (CDR) settings

Logging: Enabled
Mode: Simple
Log unanswered calls: Yes
Log congestion: No

  • Registered Backends

    Adaptive ODBC

#7

The module name is cdr_csv.so

You can do a ‘module load cdr_csv.so’ from the console if you have compiled it.

You can add it to the modules that are loaded on startup by adjusting your modules.conf file.


#8

Awesome thanks for all the replies guys ,managed to get a bash script for this ,ended up only rewriting files if the size was more than 1mb