[asterisk-users] Inaccurate CDRs

Dumpolid Exeplish dumpexec at gmail.com
Thu Oct 19 00:26:19 MST 2006


This is an update on the issues of CDR inaccuracies, i hope this will help
someone in need.
In order to remove the Authenticate() function and still be able to perform
call accounting and authentication, we pass the authetication process
through an AGI. the reason beig that the Authenticate() application always
awnsers the channel first before authentication. This will cause
irregularities in terms of billing since the user will have to pay for both
the 'authentication' time and the call processing time. My authentication
Macros calls this perl script to enable authentication without awnsering the
channel.




#!/usr/bin/perl

use Asterisk::AGI;
open (PIN1,'/etc/asterisk/pinset_1');
open (PIN2,'/etc/asterisk/pinset_2');
open (PIN3,'/etc/asterisk/pinset_3');
$|=1;
$AGI = new Asterisk::AGI;

exit if $#ARGV <0;
chomp($dbid=$ARGV[0]);
#$AGI->exec("NoOp","$dbid")  ;
%input = $AGI->ReadParse();
$try = '0';
$filename = 'agent-pass';
while($try < 3) {
      $pin = $AGI->get_data($filename,"2000");
      if (!defined $pin) {$try++;$filename = 'auth-incorrect';next;}
      if (length($pin)!=4) {$try++;$filename = 'auth-incorrect';next;}
      $status=check_pin($pin);

           if ($status =='1'){
           $AGI->exec("NoOp","$pin");
           $AGI->stream_file('auth-thankyou');
           #$AGI->exec('Playback','auth-thankyou','noanswer');
           $AGI->exec('SetAccount',"$pin");
           exit (0);
           }
           else {
      $try++;
      $filename = 'auth-incorrect';
      #$AGI->exec('Playback','')
      next;
      }
}
$AGI->exec('Playback','vm-goodbye');
$AGI->exec('Wait','1');
$AGI->hangup();
exit (0);



sub check_pin{
    my $pin=$_[0];
    my $file='PIN'."$dbid";
    seek ("$file",0,0);
    while (<$file>){
            if (/$pin/) {return '1';}
    }
    return '0';
}


you have to install the Asterisk::AGI module for thi script to work. i used
the authentication macros from AMP (FreePBX) to pug in this agi.
Every trunk thatrequiers authentication calls this macros. The macros is as
follows..



[macro-pinsets]
include => macro-pinsets-custom
exten => s,1,GotoIf(${ARG2} = 1?cdr,1)
exten => cdr,1,AGI(auth.agi|${ARG1})

; end of [macro-pinsets]



i hope this will be of use to someone



On 10/18/06, Dumpolid Exeplish <dumpexec at gmail.com> wrote:
>
> I have found the problem.
> Before calls leave our network, thee user must supply a pin. this is a for
> of call accounting that we implemented. To do this, we had used AMP's
> Authenticate () function. This function actually and always answers the
> channel first before accepting pin entries. This was why there is always an
> answered flag on the channel. and since the channel is answered as soon as
> the call is made, there is no difference between the duration and the
> billsec. Now my problem is how do i implement an authentication AGI that
> uses DTMF ? i would be posting this question in another thread
>
> Thanks for your help
>
>
>  On 10/17/06, Dumpolid Exeplish <dumpexec at gmail.com> wrote:
> >
> > this Cdr Record if from the Primary PBX
> >
> >
> > '2006-10-17 07:11:37', 'Admin', 'XXXXXXX, 'aaaaaaaaaa', 'from-internal',
> > 'IAX2/TRUNK1 at TRUNK3-16384' , 'Zap/1-1', 'ResetCDR', 'w', 10, 0, 'BUSY',
> > 3, '', '', ''
> >
> >
> >
> > this is the CDR record from the secondsry for the same call
> >
> >
> > '2006-10-17 13:31:57', '"Admin" <XXXXX>', 'XXXXX', 'aaaaaaaaaa',
> > 'from-internal', 'SIP/401-8f0c', 'IAX2/TRUNK1-2', 'Dial',
> > 'IAX2/TRUNK1/aaaaaaaaaaa|120', 15, 15, 'ANSWERED', 3, '4147', '', ''
> >
> > in this setup, the caller dropped the call after allowing it to ring for
> > 15 seconds
> >
> >
> >
> >
> >
> >
> > On 10/17/06, Dumpolid Exeplish <dumpexec at gmail.com > wrote:
> > >
> > > Well I am using APM on the two boxes i have modified the srripts
> > > extensievely and i am sure that there is no Awnser befor a dial when Dialing
> > > through the PBX trunks
> > >
> > >
> > >
> > >
> > > On 10/17/06, Steve Davies <davies147 at gmail.com > wrote:
> > > >
> > > > On 10/17/06, Dumpolid Exeplish < dumpexec at gmail.com> wrote:
> > > > > Hello,
> > > > > i have call time irregularites in my asterisk CDR. I a currently
> > > > using a
> > > > > mysqly backent to save CDR records and use this to generate bills
> > > > at the end
> > > > > of each month. However, my users are complaining that they gety
> > > > charged for
> > > > > even uncompleted calls ( i.e. calls they make whaich have already
> > > > be setup
> > > > > but canclled). i have noticed that only 'AWNSERED' and 'Busy' show
> > > > up in my
> > > > > call disposition colume. I have also noticed that both the call
> > > > duration and
> > > > > the billsec are always equal. here is my setup below
> > > > >
> > > > > <PSTN va E1>  <========> (<Primary Asterisk>) <=====<Sip and IAX
> > > > trunks>
> > > > > <============> (<Secondary PBX>)
> > > > >
> > > > > Clients are connected to the Secondary PBX. this pbx handles
> > > > registration of
> > > > > all clents. The billing irregularities happen on the Secondary
> > > > PBX. When a
> > > > > call is maked from the Secondary and it is routed across the
> > > > trunks, call
> > > > > disposition always registeres 'AWNSERED', unless the Primary PBX
> > > > sends back
> > > > > a busy signal. the duration and billsecs are always equla. this
> > > > means that
> > > > > the user gets billed for ring time, and calls disconnected from
> > > > the
> > > > > Secondary PBX
> > > > >
> > > >
> > > > Could you provide a snippet of the dialplan used on each of the
> > > > primary and secondary boxes to complete a call?
> > > >
> > > > For example, is the primary executing an Answer() before it does the
> > > >
> > > > onward Dial() on behalf of the secondary?
> > > >
> > > > Cheers,
> > > > Steve
> > > > _______________________________________________
> > > > --Bandwidth and Colocation provided by Easynews.com<http://easynews.com/>--
> > > >
> > > > asterisk-users mailing list
> > > > To UNSUBSCRIBE or update options visit:
> > > >    http://lists.digium.com/mailman/listinfo/asterisk-users
> > > >
> > >
> > >
> >
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.digium.com/pipermail/asterisk-users/attachments/20061019/2f544185/attachment.htm


More information about the asterisk-users mailing list