<div>This is an update on the issues of CDR inaccuracies, i hope this will help someone in need. </div>
<div>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.
</div>
<div>&nbsp;</div>
<div>&nbsp;</div>
<div>&nbsp;</div>
<p>#!/usr/bin/perl</p>
<p>use Asterisk::AGI;<br>open (PIN1,'/etc/asterisk/pinset_1');<br>open (PIN2,'/etc/asterisk/pinset_2');<br>open (PIN3,'/etc/asterisk/pinset_3');<br>$|=1;<br>$AGI = new Asterisk::AGI;</p>
<p>exit if $#ARGV &lt;0;<br>chomp($dbid=$ARGV[0]);<br>#$AGI-&gt;exec(&quot;NoOp&quot;,&quot;$dbid&quot;)&nbsp; ;<br>%input = $AGI-&gt;ReadParse();<br>$try = '0';<br>$filename = 'agent-pass';<br>while($try &lt; 3) {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $pin = $AGI-&gt;get_data($filename,&quot;2000&quot;);
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (!defined $pin) {$try++;$filename = 'auth-incorrect';next;}<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (length($pin)!=4) {$try++;$filename = 'auth-incorrect';next;}<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $status=check_pin($pin);&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if ($status =='1'){<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $AGI-&gt;exec(&quot;NoOp&quot;,&quot;$pin&quot;);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $AGI-&gt;stream_file('auth-thankyou');<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; #$AGI-&gt;exec('Playback','auth-thankyou','noanswer');<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $AGI-&gt;exec('SetAccount',&quot;$pin&quot;);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; exit (0);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; else {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $try++;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $filename = 'auth-incorrect';<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; #$AGI-&gt;exec('Playback','')<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; next;
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br>}<br>$AGI-&gt;exec('Playback','vm-goodbye');<br>$AGI-&gt;exec('Wait','1');<br>$AGI-&gt;hangup();<br>exit (0);</p>
<p>&nbsp;</p>
<p>sub check_pin{<br>&nbsp;&nbsp;&nbsp; my $pin=$_[0];<br>&nbsp;&nbsp;&nbsp; my $file='PIN'.&quot;$dbid&quot;;<br>&nbsp;&nbsp;&nbsp; seek (&quot;$file&quot;,0,0);<br>&nbsp;&nbsp;&nbsp; while (&lt;$file&gt;){<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (/$pin/) {return '1';}<br>&nbsp;&nbsp;&nbsp; }<br>&nbsp;&nbsp;&nbsp; return '0';<br>
}</p>
<p>&nbsp;</p>
<div>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. </div>
<div>Every trunk thatrequiers authentication calls this macros. The macros is as follows..</div>
<div>&nbsp;</div>
<div>&nbsp;</div>
<div>
<p>[macro-pinsets]<br>include =&gt; macro-pinsets-custom<br>exten =&gt; s,1,GotoIf(${ARG2} = 1?cdr,1)<br>exten =&gt; cdr,1,AGI(auth.agi|${ARG1})</p>
<p>; end of [macro-pinsets]</p>
<p>&nbsp;</p>
<p>i hope this will be of use to someone<br></p><br><br>&nbsp;</div>
<div><span class="gmail_quote">On 10/18/06, <b class="gmail_sendername">Dumpolid Exeplish</b> &lt;<a href="mailto:dumpexec@gmail.com">dumpexec@gmail.com</a>&gt; wrote:</span>
<blockquote class="gmail_quote" style="PADDING-LEFT: 1ex; MARGIN: 0px 0px 0px 0.8ex; BORDER-LEFT: #ccc 1px solid">
<div>I have found the problem. </div>
<div>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 
</div>
<div>&nbsp;</div>
<div>Thanks for your help<br><br>&nbsp;</div>
<div><span class="e" id="q_10e5a5c1b2da509e_1">
<div><span class="gmail_quote">On 10/17/06, <b class="gmail_sendername">Dumpolid Exeplish</b> &lt;<a onclick="return top.js.OpenExtLink(window,event,this)" href="mailto:dumpexec@gmail.com" target="_blank">dumpexec@gmail.com
</a>&gt; wrote:</span> 
<blockquote class="gmail_quote" style="PADDING-LEFT: 1ex; MARGIN: 0px 0px 0px 0.8ex; BORDER-LEFT: #ccc 1px solid">
<div>this Cdr Record if from the Primary PBX</div>
<div>&nbsp;</div>
<div><br>'2006-10-17 07:11:37', 'Admin', 'XXXXXXX, 'aaaaaaaaaa', 'from-internal', <a onclick="return top.js.OpenExtLink(window,event,this)" href="mailto:'IAX2/TRUNK1@TRUNK3-16384'" target="_blank">'IAX2/TRUNK1@TRUNK3-16384' 
</a>, 'Zap/1-1', 'ResetCDR', 'w', 10, 0, 'BUSY', 3, '', '', ''</div>
<div>&nbsp;</div>
<div>&nbsp;</div>
<div>&nbsp;</div>
<div>this is the CDR record from the secondsry for the same call</div>
<div>&nbsp;</div>
<div>&nbsp;</div>
<div>'2006-10-17 13:31:57', '&quot;Admin&quot; &lt;XXXXX&gt;', 'XXXXX', 'aaaaaaaaaa', 'from-internal', 'SIP/401-8f0c', 'IAX2/TRUNK1-2', 'Dial', 'IAX2/TRUNK1/aaaaaaaaaaa|120', 15, 15, 'ANSWERED', 3, '4147', '', ''</div>
<div>&nbsp;</div>
<div>in this setup, the caller dropped the call after allowing it to ring for 15 seconds</div>
<div><span>
<div>&nbsp;</div>
<div>&nbsp;</div>
<div>&nbsp;</div>
<div>&nbsp;</div>
<div><br>&nbsp;</div>
<div><span class="gmail_quote">On 10/17/06, <b class="gmail_sendername">Dumpolid Exeplish</b> &lt;<a onclick="return top.js.OpenExtLink(window,event,this)" href="mailto:dumpexec@gmail.com" target="_blank">dumpexec@gmail.com 
</a>&gt; wrote:</span> 
<blockquote class="gmail_quote" style="PADDING-LEFT: 1ex; MARGIN: 0px 0px 0px 0.8ex; BORDER-LEFT: #ccc 1px solid">
<div>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</div>
<div><span>
<div>&nbsp;</div>
<div><br><br>&nbsp;</div>
<div><span class="gmail_quote">On 10/17/06, <b class="gmail_sendername">Steve Davies</b> &lt;<a onclick="return top.js.OpenExtLink(window,event,this)" href="mailto:davies147@gmail.com" target="_blank">davies147@gmail.com 
</a>&gt; wrote:</span> 
<blockquote class="gmail_quote" style="PADDING-LEFT: 1ex; MARGIN: 0px 0px 0px 0.8ex; BORDER-LEFT: #ccc 1px solid">On 10/17/06, Dumpolid Exeplish &lt;<a onclick="return top.js.OpenExtLink(window,event,this)" href="mailto:dumpexec@gmail.com" target="_blank">
 dumpexec@gmail.com</a>&gt; wrote:<br>&gt; Hello,<br>&gt; i have call time irregularites in my asterisk CDR. I a currently using a<br>&gt; mysqly backent to save CDR records and use this to generate bills at the end<br>&gt; of each month. However, my users are complaining that they gety charged for 
<br>&gt; even uncompleted calls ( i.e. calls they make whaich have already be setup<br>&gt; but canclled). i have noticed that only 'AWNSERED' and 'Busy' show up in my<br>&gt; call disposition colume. I have also noticed that both the call duration and 
<br>&gt; the billsec are always equal. here is my setup below<br>&gt;<br>&gt; &lt;PSTN va E1&gt;&nbsp;&nbsp;&lt;========&gt; (&lt;Primary Asterisk&gt;) &lt;=====&lt;Sip and IAX trunks&gt;<br>&gt; &lt;============&gt; (&lt;Secondary PBX&gt;) 
<br>&gt;<br>&gt; Clients are connected to the Secondary PBX. this pbx handles registration of<br>&gt; all clents. The billing irregularities happen on the Secondary PBX. When a<br>&gt; call is maked from the Secondary and it is routed across the trunks, call 
<br>&gt; disposition always registeres 'AWNSERED', unless the Primary PBX sends back<br>&gt; a busy signal. the duration and billsecs are always equla. this means that<br>&gt; the user gets billed for ring time, and calls disconnected from the 
<br>&gt; Secondary PBX<br>&gt;<br><br>Could you provide a snippet of the dialplan used on each of the<br>primary and secondary boxes to complete a call?<br><br>For example, is the primary executing an Answer() before it does the 
<br>onward Dial() on behalf of the secondary?<br><br>Cheers,<br>Steve<br>_______________________________________________<br>--Bandwidth and Colocation provided by <a onclick="return top.js.OpenExtLink(window,event,this)" href="http://easynews.com/" target="_blank">
Easynews.com</a> --<br><br>asterisk-users mailing list <br>To UNSUBSCRIBE or update options visit:<br>&nbsp;&nbsp;<a onclick="return top.js.OpenExtLink(window,event,this)" href="http://lists.digium.com/mailman/listinfo/asterisk-users" target="_blank">
 http://lists.digium.com/mailman/listinfo/asterisk-users</a><br></blockquote></div><br></span></div></blockquote></div><br></span></div></blockquote></div><br></span></div></blockquote></div><br>