Automatic CDR Retrieval
This procedure describes how to configure the ProSBC to send its Call Detail Records (CDR) files to a remote server automatically and perform daily (or monthly) file archives.
Overview
The tbcopycdr script supports the following features:
Move cdr files from TMG_CDR_DIR to TMG_TEMP_DIR
Send files to a remote server
Move sucessfully sent files (rename to .sent.gz) from TMG_TEMP_DIR to TMG_ARCHIVE_DIR (ARCHIVE=true)
Rename sucessfully sent files (.sent.gz) in TMG_TEMP_DIR (ARCHIVE=false; ERASE_AFTER_SEND=false)
Delete sucessfully sent files from TMG_TEMP_DIR (ARCHIVE=false; ERASE_AFTER_SEND=true)
If a file failed to be sent to remote server, it is kept in TMG_TEMP_DIR until it is successfully sent
The tbarchivecdr script creates a gzip tar archive with all gz files copied by tbcopycdr in TMG_ARCHIVE_DIR
Change directory to TMG_ARCHIVE_DIR
Create a temporary folder with the current date (for example: 2016-01-30)
Sleep for 90 second
Move all *.gz files and $TMG_TEMP_DIR/$LOG_FILE to this folder
Archive the folder in a gzipped tar file (cdr_2016_01_30_$hostname.tgz)
Configuration
The script is configured with user variables.
CONFIG_FILE: Configuration file name and location. By default, it is set to /root/tbcopycdr.cfg
tbcopycdr.cfg file example:
The configuration file can redefine any of the following user variables. To see the default variables:
TMG_CDR_DIR: Tmedia directory where the CDR are located. Default is /lib/tb/toolpack/setup/12358/cdr_logs
REMOTE_HOST : Remote hostname or Ip address. Remote host copy is disabled by default.
REMOTE_PORT : Remote host ssh port.
REMOTE_DIR : Remote directory where to copy the backup files (/root/backup by default)
REMOTE_USER : Remote host login user.
CONNECT_TIMEOUT : scp connection timeout
ARCHIVE: true or false. If set to true, move successfully sent files (rename to .sent.gz) from TMG_TEMP_DIR to TMG_ARCHIVE_DIR. Default is false.
TMG_ARCHIVE_DIR: Directory where the cdrs are moved if ARCHIVE=true
ARCHIVE_MAX_DAYS: Define how many days the archive file (.tgz) should be kept in TMG_ARCHIVE_DIR. This user variable is used by tbarchivecdr only.
ERASE_AFTER_SEND: Take effect only if ARCHIVE is false. If ERASE_AFTER_SEND is true, erase file from TMG_TEMP_DIR, else, rename and keep files in working directory.
Note: If you set ERASE_AFTER_SEND to false, the CDR text file will be available in the /home/telcobridges/cdr/ directory and renamed *.gz.already_send.
Remote Server Copy
You must create an SSH key pair and copy it to the remote server, if the remote server copy is configured. This will enable copy the backup files to the remote host without asking for a password. Follow the instructions here:
Troubleshooting
Test
Run the tbcopycdr script with the -v option
If no errors are seen in the shell, your configuration is correct. In addition, you should have a hello_world.log file on the remote host.
Log File
Transfer results are written in $TMG_TEMP_DIR/$LOG_FILE
Schedule the Scripts
Create a new crontab on the Tmedia
Add new lines with the cron configuration
tbcopycdr:
Every 10 minutes
*/10 * * * * /usr/bin/tbcopycdr > /dev/null 2>&1
hourly (top of the hour)
0 * * * * /usr/bin/tbcopycdr > /dev/null 2>&1
daily (midnight)
0 0 * * * /usr/bin/tbcopycdr > /dev/null 2>&1
tbarchivecdr:
daily@23h59
59 23 * * * /usr/bin/tbarchivecdr > /dev/null 2>&1
weekly (sunday@23h59)
59 23 * 7 * /usr/bin/tbarchivecdr > /dev/null 2>&1
Cron table example for a cdr copy to an external server every 10 minutes with a daily archive of all the transmitted files:
Last updated
Was this helpful?