3. CDR - Call Detail Records
CDR contains information about calls that have
passed through Asterisk system
Asterisk assumes that you want to store CDR
information
CDR is store in CSV (Comma-Separated Value)
format
Asterisk CDR (1/4)
4. By default, Asterisk creates a CDR file named
Master.csv in the folder
/var/log/asterisk/cdr-csv
and call information is stored in this file
To the naked eye, Master.csv file’s content
looks like a bit of a mess. If, however, you
separate each line according to the commas,
you will find that each line contains information
about a particular call.
Asterisk CDR (2/4)
5. A Comma-Separated Values (CSV) file is a
common method of formatting database-type
information in a text file
You can open CSV files with a text editor, but
most spreadsheet(likes Microsoft Excel) and
database programs will also read them and
properly parse them into rows and columns
Asterisk CDR (3/4)
6. By default, Asterisk will simply add to the files
until the storage (hard drive or other non-valotile
storage) is full
In Asterisk 1.4
Basic call (2-way) generates 245 ~ 247 bytes of CDR
content
Conference call (3-way) generates around 494 bytes
of CDR content
Asterisk CDR (4/4)
7. Linux provides utilities to handle the rotation of
log files
So that no single file becomes too large
Also, the deletion of older logfiles (which will prevent
the system from getting clogged with log files)
logrotate is a tool to do “log rotation” :
Regular (daily, weekly, monthly, etc) moving of an
existing log file to some other file name and starting
fresh with an empty log file
After a period the old log files get thrown away
Logrotate (1/2)
8. logrotate tool is often run on a cron job, which
has the effect of fully automatic log rotation
One of downloadable site for source :
https://fedorahosted.org/logrotate/
Logrotate (2/2)
9. cron is a job scheduling facility in Linux/Unix
system.
The cron system is managed by cron daemone,
crond
It gets information about which program and when
they should run
At system startup cron daemon is invoked
Cron (1/7)
10. cron daemone searches following target every
minute
/etc/cron.d folder
/etc/crontab file(cron table)
/var/spool/cron folder
Under /etc/cron.d and /var/spool/cron folder
there have shell script files named after accounts in
/etc/passpwd file and
are executed by cron daemone when it is time to do
scheduled job
Cron (2/7)
11. On system using Vixie cron, jobs that occure
hourly, daily, weekly and monthly are kept in
separate directories in /etc:
/etc/cron.hourly
/etc/cron.daily
/etc/cron.weekly
/etc/cron.monthly
/etc/crontab stores these folders as table
entries
Cron (3/7)
12. Vixie cron uses the program run-parts
to run shell scripts in each folder listed in
/etc/crontab
Cron (4/7)
13. On CentOS 6, Vixie cron uses the program
run-parts to run shell scripts in each folder listed
in /etc/anacrontab
Cron (5/7)
15. Note:
In MS-Windows environment, there has a built-in tool
functioning as Cron named
Windows Task Scheduler
http://en.wikipedia.org/wiki/Windows_Task_Scheduler
Cron (7/7)
16. To do Asterisk CDR log rotation, it needs to
configure cron job using lograte tool
Create a folder named logrotate.d in /etc
Create a logrotate configuration file named asterisk
in /etc/logrotate.d and place following content in this
file (here setting maximum size of CDR file to 70K
bytes for example)
Put All Together (1/3)
/var/log/asterisk/cdr-csv/Master.csv {
daily
missingok
size 70k
rotate 2
copytruncate
}
17. Create a shell script named logrotate in
/etc/cron.daily and its content is as below (assume
logrotate could be invoked from directory
/usr/sbin):
Put All Together (2/3)
#!/bin/sh
/usr/sbin/logrotate /etc/logrotate.d/asterisk
EXITVALUE=$?
if [ $EXITVALUE != 0 ]; then
/usr/bin/logger -t logrotate "ALERT exited abnormally with
[$EXITVALUE]"
fi
exit 0
18. To see the status of execution of logrotate
/var/lib/ logrotate.status
How often does system do CDR log rotation?
Depening on call traffic volume, e.g the speed of
size increasing of Master.csv
Put All Together (3/3)
19. Asterisk CDR log rotation
http://www.voip-info.org/wiki/view/logrotate
http://www.voip-info.org/wiki/view/logrotate+Chinese
More information about the usage of logrotate
configuration file
http://www.thegeekstuff.com/2010/07/logrotate-
examples/
http://linuxconfig.org/logrotate
http://www-
uxsup.csx.cam.ac.uk/~jw35/courses/apache/html/x167
0.htm
Reference