How to enable Asterisk Database CDR and CEL Logging on Debian 12
- 00:40 cat /etc/os-release
- 00:50 asterisk -V
- 01:00 cd /etc/asterisk
- 01:15 vim cdr.conf
- 01:31 vim cdr_custom.conf
- 02:04 ls /var/log/asterisk/cdr-custom/
- 02:20 asterisk -rvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
- 02:36 core reload
- 03:06 ls /var/log/asterisk/cdr-custom/
- 03:15 vim /var/log/asterisk/cdr-custom/Mine.csv
- 03:51 vim cel.conf
- 04:21 vim cel_custom.conf
- 05:15 ls /var/log/asterisk/cel-custom/
- 06:11 vim /var/log/asterisk/cel-custom/Minecel.csv
To Enable Asterisk Database CDR & CEL Logging On Debian 12
Introduction:
CDR (Call Detail Records) and CEL (Call Event Logs) are two types of data reports that Asterisk, a popular open-source PBX (Private Branch Exchange) software, generates to track and record phone call activity.
Procedure Steps:
Step 1: Check the OS version by using the below command.
root@linuxhelp:~# cat /etc/os-release
PRETTY_NAME="Debian GNU/Linux 12 (bookworm)"
NAME="Debian GNU/Linux"
VERSION_ID="12"
VERSION="12 (bookworm)"
VERSION_CODENAME=bookworm
ID=debian
HOME_URL="https://www.debian.org/"
SUPPORT_URL="https://www.debian.org/support"
BUG_REPORT_URL=https://bugs.debian.org/
Step 2: Check the Asterisk version by using the below command.
root@linuxhelp:~# asterisk -V
Asterisk 20.4.0
Step 3: Go to the following location by using the below command.
root@linuxhelp:~# cd /etc/asterisk
Step 4: Open cdr.conf file and make enable by using the below command.
root@linuxhelp:/etc/asterisk# vim cdr.conf
[general]
enable=yes
Step 5: Open cdr_custom.conf file and make the configuration for the cdr by using the below command.
root@linuxhelp:/etc/asterisk# vim cdr_custom.conf
[mappings]
; Our CDR log will be written to /var/log/asterisk/cdr-custom/Master.csv
; with the following schema.
Mine.csv => ${CSV_QUOTE(${CDR(clid)})},${CSV_QUOTE(${CDR(src)})},${CSV_QUOTE(${CDR(dst)})},${CSV_QUOTE(${CDR(dcontext)})},${CSV_QUOTE(${CDR(channel)})},${CSV_QUOTE(${CDR(dstchannel)})},${CSV_QUOTE(${CDR(lastapp)})},${CSV_QUOTE(${CDR(lastdata)})},${CSV_QUOTE(${CDR(start)})},${CSV_QUOTE(${CDR(answer)})},${CSV_QUOTE(${CDR(end)})},${CSV_QUOTE(${CDR(duration)})},${CSV_QUOTE(${CDR(billsec)})},${CSV_QUOTE(${CDR(disposition)})},${CSV_QUOTE(${CDR(amaflags)})},${CSV_QUOTE(${CDR(accountcode)})},${CSV_QUOTE(${CDR(uniqueid)})},${CSV_QUOTE(${CDR(userfield)})},${CDR(sequence)
Step 6: List the files with the path to check if the log file exist by using the below command.
root@linuxhelp:/etc/asterisk# ls /var/log/asterisk/cdr-custom/
Master.csv
Step 7: Login to the asterisk console by using the below command.
root@linuxhelp:~# asterisk -rvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
Asterisk 20.4.0, Copyright (C) 1999 - 2022, Sangoma Technologies Corporation and others.
Created by Mark Spencer <markster@digium.com>
Asterisk comes with ABSOLUTELY NO WARRANTY; type 'core show warranty' for details.
This is free software, with components licensed under the GNU General Public
License version 2 and other licenses; you are welcome to redistribute it under
certain conditions. Type 'core show license' for details.
=========================================================================
Connected to Asterisk 20.4.0 currently running on linuxhelp (pid = 1363)
linuxhelp*CLI>
Step 8: Reload the modules to apply the configuration changes by using the below command.
linuxhelp*CLI> core reload
-- Reloading module 'extconfig' (Configuration)
-- Reloading module 'logger' (Logger)
Asterisk Queue Logger restarted
-- Reloading module 'cdr' (CDR Engine)
[Jan 26 23:11:29] NOTICE[39953]: cdr.c:4568 cdr_toggle_runtime_options: CDR simple logging enabled.
-- Reloading module 'cel' (CEL Engine)
-- CEL logging disabled.
-- Reloading module 'dnsmgr' (DNS Manager)
-- Reloading module 'dsp' (DSP)
-- Reloading module 'enum' (ENUM Support)
-- Reloading module 'features' (Call Features)
-- Reloading module 'http' (Built-in HTTP Server)
-- Reloading module 'indications' (Indication Tone Handling)
-- Reloading module 'acl' (Named ACL system)
-- Reloading module 'manager' (Asterisk Manager Interface)
-- Reloading module 'plc' (PLC)
-- Reloading module 'udptl' (UDPTL)
-- Reloading module 'res_pjproject.so' (PJPROJECT Log and Utility Support)
-- Reloading module 'res_pjsip.so' (Basic SIP resource)
[Jan 26 23:11:29] NOTICE[6076]: sorcery.c:1348 sorcery_object_load: Type 'system' is not reloadable, maintaining previous values
-- Reloading module 'res_pjsip_authenticator_digest.so' (PJSIP authentication resource)
-- Reloading module 'res_pjsip_endpoint_identifier_ip.so' (PJSIP IP endpoint identifier)
-- Reloading module 'res_musiconhold.so' (Music On Hold Resource)
-- Reloading module 'res_rtp_asterisk.so' (Asterisk RTP Stack)
-- Reloading module 'res_pjsip_outbound_publish.so' (PJSIP Outbound Publish Support)
-- Reloading module 'res_pjsip_mwi.so' (PJSIP MWI resource)
-- Reloading module 'res_pjsip_publish_asterisk.so' (PJSIP Asterisk Event PUBLISH Support)
-- Reloading module 'res_pjsip_notify.so' (CLI/AMI PJSIP NOTIFY Support)
-- Reloading module 'res_pjsip_outbound_registration.so' (PJSIP Outbound Registration Support)
-- Reloading module 'cdr_custom.so' (Customizable Comma Separated Values CDR Backend)
-- Reloading module 'app_playback.so' (Sound File Playback Application)
-- Reloading module 'app_voicemail.so' (Comedian Mail (Voicemail System))
-- Reloading module 'pbx_config.so' (Text Extension Configuration)
-- Time to scan old dialplan and merge leftovers back into the new: 0.000004 sec
-- Time to restore hints and swap in new dialplan: 0.000002 sec
-- Time to delete the old dialplan: 0.000004 sec
-- Total time merge_contexts_delete: 0.000010 sec
-- pbx_config successfully loaded 1 contexts (enable debug for details).
-- Reloading module 'app_queue.so' (True Call Queueing)
[Jan 26 23:11:29] NOTICE[39953]: app_queue.c:9528 reload_queue_rules: queuerules.conf has not changed since it was last loaded. Not taking any action.
-- Reloading module 'cel_custom.so' (Customizable Comma Separated Values CEL Backend)
[Jan 26 23:11:29] NOTICE[39953]: cel_custom.c:92 load_config: No mappings found in cel_custom.conf. Not logging CEL to custom CSVs.
Added CEL CSV mapping for 0 files.
Step 9: Make the call by using microsip application as shown in below image.
-- Executing [110@internal:1] NoOp("PJSIP/112-00000018", "Calling 110 From Caller ") in new stack
-- Executing [110@internal:2] Answer("PJSIP/112-00000018", "") in new stack
> 0x7f614c033d20 -- Strict RTP learning after remote address set to: 192.168.6.107:4016
-- Executing [110@internal:3] Dial("PJSIP/112-00000018", "PJSIP/110,10") in new stack
-- Called PJSIP/110
-- PJSIP/110-00000019 is ringing
> 0x7f614c033d20 -- Strict RTP switching to RTP target address 192.168.6.107:4016 as source
== Spawn extension (internal, 110, 3) exited non-zero on 'PJSIP/112-00000018'
Step 10: Check the log file if exist by using the below command.
root@linuxhelp:/etc/asterisk# ls /var/log/asterisk/cdr-custom/
Master.csv Mine.csv
Step 11: If exist the log file open and check the logs by using the below command.
root@linuxhelp:/etc/asterisk# vim /var/log/asterisk/cdr-custom/Mine.csv
"""linuxhelp3"" <112>","112","110","internal","PJSIP/112-00000018","PJSIP/110-00000019","Dial","PJSIP/110,10","2024-01-26 23:11:50","2024-01-26 23:11:50","2024-01-26 23:11:53","3","3","NO ANSWER","DOCUMENTATION","","1706290910.40","",28
Step 12: Open cel.conf file and make enable by using the below command.
root@linuxhelp:/etc/asterisk# vim cel.conf
[general]
; CEL Activation
;
; Use the 'enable' keyword to turn CEL on or off.
;
; Accepted values: yes and no
; Default value: no
enable=yes
Step 13: Open cel_custom.conf file and make the configuration by using the below command.
root@linuxhelp:/etc/asterisk# vim cel_custom.conf
[mappings]
Minecel.csv => ${CSV_QUOTE(${eventtype})},${CSV_QUOTE(${eventtime})},${CSV_QUOTE(${CALLERID(name)})},${CSV_QUOTE(${CALLERID(num)})},${CSV_QUOTE(${CALLERID(ANI)})},${CSV_QUOTE(${CALLERID(RDNIS)})},${CSV_QUOTE(${CALLERID(DNID)})},${CSV_QUOTE(${CHANNEL(exten)})},${CSV_QUOTE(${CHANNEL(context)})},${CSV_QUOTE(${CHANNEL(channame)})},${CSV_QUOTE(${CHANNEL(appname)})},${CSV_QUOTE(${CHANNEL(appdata)})},${CSV_QUOTE(${CHANNEL(amaflags)})},${CSV_QUOTE(${CHANNEL(accountcode)})},${CSV_QUOTE(${CHANNEL(uniqueid)})},${CSV_QUOTE(${CHANNEL(linkedid)})},${CSV_QUOTE(${BRIDGEPEER})},${CSV_QUOTE(${CHANNEL(userfield)})},${CSV_QUOTE(${userdeftype})},${CSV_QUOTE(${eventextra})}
Step 14: list the cel log file if exist by using the below command.
root@linuxhelp:/etc/asterisk# ls /var/log/asterisk/cel-custom/
Step 15: Reload the modules to apply the configuration changes by using following command.
linuxhelp*CLI> core reload
-- Reloading module 'extconfig' (Configuration)
-- Reloading module 'logger' (Logger)
Asterisk Queue Logger restarted
-- Reloading module 'cdr' (CDR Engine)
[Jan 26 23:14:59] NOTICE[39953]: cdr.c:4568 cdr_toggle_runtime_options: CDR simple logging enabled.
-- Reloading module 'cel' (CEL Engine)
-- CEL logging enabled.
-- Reloading module 'dnsmgr' (DNS Manager)
-- Reloading module 'dsp' (DSP)
-- Reloading module 'enum' (ENUM Support)
-- Reloading module 'features' (Call Features)
-- Reloading module 'http' (Built-in HTTP Server)
-- Reloading module 'indications' (Indication Tone Handling)
-- Reloading module 'acl' (Named ACL system)
-- Reloading module 'manager' (Asterisk Manager Interface)
-- Reloading module 'plc' (PLC)
-- Reloading module 'udptl' (UDPTL)
-- Reloading module 'res_pjproject.so' (PJPROJECT Log and Utility Support)
-- Reloading module 'res_pjsip.so' (Basic SIP resource)
[Jan 26 23:14:59] NOTICE[6076]: sorcery.c:1348 sorcery_object_load: Type 'system' is not reloadable, maintaining previous values
-- Reloading module 'res_pjsip_authenticator_digest.so' (PJSIP authentication resource)
-- Reloading module 'res_pjsip_endpoint_identifier_ip.so' (PJSIP IP endpoint identifier)
-- Reloading module 'res_musiconhold.so' (Music On Hold Resource)
-- Reloading module 'res_rtp_asterisk.so' (Asterisk RTP Stack)
-- Reloading module 'res_pjsip_outbound_publish.so' (PJSIP Outbound Publish Support)
-- Reloading module 'res_pjsip_mwi.so' (PJSIP MWI resource)
-- Reloading module 'res_pjsip_publish_asterisk.so' (PJSIP Asterisk Event PUBLISH Support)
-- Reloading module 'res_pjsip_notify.so' (CLI/AMI PJSIP NOTIFY Support)
-- Reloading module 'res_pjsip_outbound_registration.so' (PJSIP Outbound Registration Support)
-- Reloading module 'cdr_custom.so' (Customizable Comma Separated Values CDR Backend)
-- Reloading module 'app_playback.so' (Sound File Playback Application)
-- Reloading module 'app_voicemail.so' (Comedian Mail (Voicemail System))
-- Reloading module 'pbx_config.so' (Text Extension Configuration)
-- Time to scan old dialplan and merge leftovers back into the new: 0.000003 sec
-- Time to restore hints and swap in new dialplan: 0.000003 sec
-- Time to delete the old dialplan: 0.000003 sec
-- Total time merge_contexts_delete: 0.000009 sec
-- pbx_config successfully loaded 1 contexts (enable debug for details).
-- Reloading module 'app_queue.so' (True Call Queueing)
[Jan 26 23:14:59] NOTICE[39953]: app_queue.c:9528 reload_queue_rules: queuerules.conf has not changed since it was last loaded. Not taking any action.
-- Reloading module 'cel_custom.so' (Customizable Comma Separated Values CEL Backend)
-- Added CEL CSV mapping for '/var/log/asterisk/cel-custom/Minecel.csv'.
Added CEL CSV mapping for 1 files.
Step 16: Make the call by using microsip application as shown in below image.
-- Executing [110@internal:1] NoOp("PJSIP/112-00000028", "Calling 110 From Caller ") in new stack
-- Executing [110@internal:2] Answer("PJSIP/112-00000028", "") in new stack
> 0x7f614c016dd0 -- Strict RTP learning after remote address set to: 192.168.6.107:4034
-- Executing [110@internal:3] Dial("PJSIP/112-00000028", "PJSIP/110,10") in new stack
-- Called PJSIP/110
> 0x7f614c016dd0 -- Strict RTP switching to RTP target address 192.168.6.107:4034 as source
-- PJSIP/110-00000029 is ringing
== Spawn extension (internal, 110, 3) exited non-zero on 'PJSIP/112-00000028'
-- Removed contact 'sip:112@192.168.6.107:63422;transport=TCP;ob' from AOR '112' due to request
== Contact 112/sip:112@192.168.6.107:63422;transport=TCP;ob has been deleted
== Endpoint 112 is now Unreachable
-- Added contact 'sip:112@192.168.6.107:64670;transport=TCP;ob' to AOR '112' with expiration of 300 seconds
== Endpoint 112 is now Reachable
-- Contact 112/sip:112@192.168.6.107:64670;transport=TCP;ob is now Reachable. RTT: 0.465 msec
Step 17: Check the log file if exist by using the below command.
root@linuxhelp:/etc/asterisk# ls /var/log/asterisk/cel-custom/
Minecel.csv
Step 18: If exist the log file open and check the logs by using the below command.
root@linuxhelp:/etc/asterisk# vim /var/log/asterisk/cel-custom/Minecel.csv
"CHAN_START","1706292128.463134","linuxhelp3","112","","","","110","internal","PJSIP/112-00000028","","","3","","1706292128.121","1706292128.121","","","",""
"ANSWER","1706292128.463483","linuxhelp3","112","112","","110","110","internal","PJSIP/112-00000028","Answer","","3","","1706292128.121","1706292128.121","","","",""
"APP_START","1706292128.464302","linuxhelp3","112","112","","110","110","internal","PJSIP/112-00000028","Dial","PJSIP/110,10","3","","1706292128.121","1706292128.121","","","",""
"CHAN_START","1706292128.464771","linuxhelp1","110","","","","s","internal","PJSIP/110-00000029","","","3","","1706292128.125","1706292128.121","","","",""
"HANGUP","1706292132.799587","linuxhelp3","112","112","","110","110","internal","PJSIP/112-00000028","","","3","","1706292128.121","1706292128.121","","","","{""hangupcause"":16,""hangupsource"":""PJSIP/112-00000028"",""dialstatus"":""CANCEL""}"
"CHAN_END","1706292132.799587","linuxhelp3","112","112","","110","110","internal","PJSIP/112-00000028","","","3","","1706292128.121","1706292128.121","","","",""
"HANGUP","1706292132.799657","linuxhelp1","110","110","","","110","internal","PJSIP/110-00000029","AppDial","(Outgoing Line)","3","","1706292128.125","1706292128.121","","","","{""hangupcause"":16,""hangupsource"":"""",""dialstatus"":""""}"
"CHAN_END","1706292132.799657","linuxhelp1","110","110","","","110","internal","PJSIP/110-00000029","AppDial","(Outgoing Line)","3","","1706292128.125","1706292128.121","","","",""
Conclusion:
We have reached the end of this article. In this guide, we have walked you through the steps required to enable Asterisk Database CDR & CEL Logging on Debian 12. Your feedback is much welcome.
Comments ( 0 )
No comments available