[Freeswitch-users] Call Detail Record via Event Socket Layer

Michael Collins msc at freeswitch.org
Thu Dec 8 03:51:49 MSK 2011


well, actually it is possible because in the upcoming FS cookbook I have
this exact recipe! You'll have to buy the book to get the full monty, but
here's the example script from that recipe, which will also be freely
downloadable from Packt's web site once the CB is done:

#!/usr/bin/perl


# handle_cdr.pl


# Connect to event socket, listen for CHANNEL_HANGUP_COMPLETE events


# Uses event data to create custom CDRs


use strict;
use warnings;
use lib '/usr/src/freeswitch.git/libs/esl/perl';
use ESL;
my $host = "localhost";
my $port = "8021";
my $pass = "ClueCon";
my $con  = new ESL::ESLconnection($host, $port, $pass);
if ( ! $con ) {
    die "Unable to establish connection to FreeSWITCH.\n";
}
## Listen for events, filter in only CHANNEL_HANGUP_COMPLETE


$con->events('plain','all');
$con->filter('Event-Name','CHANNEL_HANGUP_COMPLETE');
print "Connected to FreeSWITCH $host:$port and waiting for events...\n\n";
while (1) {
my @raw_data = split "\n",$e->serialize();
    my %cdr;
    foreach my $item ( @raw_data ) {
        #print "$item\n";


        my ($header, $value) = split ': ', $item;
        $header =~ s/^variable_//;
        $cdr{$header} = $value
    }
    # %cdr contains a complete list of channel variables
    print "New CDR: ";
    print $cdr{uuid} . ', ' . $cdr{direction} . ', ';
    print $cdr{answer_epoch} . ', ' . $cdr{end_epoch} . ', ';
    print $cdr{hangup_cause} . "\n";
}


-MC

On Wed, Dec 7, 2011 at 6:15 AM, Tux Tux <tha_tux at hotmail.com> wrote:

>  Hi,
>
> Is it possible to request the CDR via a ESL event?
>
> I found the possibilities to save it to disk and/or database but not to
> get it via the ESL.
> Maybe this is because the CDR can grow large in size, but I want to be
> certain.
>
> Thanks,
> Nico
>
>
> _________________________________________________________________________
> Professional FreeSWITCH Consulting Services:
> consulting at freeswitch.org
> http://www.freeswitchsolutions.com
>
> 
> 
>
> Official FreeSWITCH Sites
> http://www.freeswitch.org
> http://wiki.freeswitch.org
> http://www.cluecon.com
>
> FreeSWITCH-users mailing list
> FreeSWITCH-users at lists.freeswitch.org
> http://lists.freeswitch.org/mailman/listinfo/freeswitch-users
> UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users
> http://www.freeswitch.org
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.freeswitch.org/pipermail/freeswitch-users/attachments/20111207/7a8b79d8/attachment.html 


Join us at ClueCon 2011 Aug 9-11, 2011
More information about the FreeSWITCH-users mailing list