[freeside-commits] freeside/bin cdr-opensips.import,1.4,1.4.2.1
Ivan,,,
ivan at wavetail.420.am
Wed Jan 11 01:57:55 PST 2012
Update of /home/cvs/cvsroot/freeside/bin
In directory wavetail.420.am:/tmp/cvs-serv15615
Modified Files:
Tag: FREESIDE_2_3_BRANCH
cdr-opensips.import
Log Message:
fix OpenSIPS import for +1 style numbers, add -c cdrtypenum RT#16019
Index: cdr-opensips.import
===================================================================
RCS file: /home/cvs/cvsroot/freeside/bin/cdr-opensips.import,v
retrieving revision 1.4
retrieving revision 1.4.2.1
diff -u -w -d -r1.4 -r1.4.2.1
--- cdr-opensips.import 6 Apr 2011 23:40:39 -0000 1.4
+++ cdr-opensips.import 11 Jan 2012 09:57:53 -0000 1.4.2.1
@@ -10,7 +10,7 @@
use Getopt::Std;
my %opt;
-getopts('H:U:P:D:T:s:e:', \%opt);
+getopts('H:U:P:D:T:s:e:c:', \%opt);
my $user = shift or die &usage;
my $dsn = 'dbi:mysql';
@@ -79,8 +79,21 @@
warn $row->{'time'} . ": no callid, skipped.\n";
next;
}
- my ($src) = $row->{'caller_id'} =~ /^sip:(\d+)@/;
- my ($dst) = $row->{'callee_id'} =~ /^sip:(\d+)@/;
+
+ #i guess now we're NANPA-centric, but at least we warn on non-numeric numbers
+ my $src = '';
+ if ( $row->{'caller_id'} =~ /^sip:(\+1)?(\d+)@/ ) {
+ $src = $2;
+ } else {
+ warn "unparseable caller_id ". $row->{'caller_id'}. "\n";
+ }
+
+ my $dst = '';
+ if ( $row->{'callee_id'} =~ /^sip:(\+1)?(\d+)@/ ) {
+ $dst = $2;
+ } else {
+ warn "unparseable callee_id ". $row->{'callee_id'}. "\n";
+ }
my $cdr = $cdrs{$callid};
if ( !$cdr ) {
@@ -88,6 +101,7 @@
uniqueid => $callid,
cdrbatchnum => $cdrbatchnum,
});
+ $cdr->cdrtypenum($opt{c}) if $opt{c};
}
my $date = str2time($row->{'time'});
if ( $row->{'method'} eq 'INVITE' ) {
@@ -132,7 +146,7 @@
$mysql->disconnect;
sub usage {
- "Usage: \n cdr-opensips.import\n\t[ -H host ]\n\t-D database\n\t-U user\n\t-P password\n\t[ -s start ] [ -e end ]\n\tfreesideuser\n";
+ "Usage: \n cdr-opensips.import\n\t[ -H host ]\n\t-D database\n\t-U user\n\t-P password\n\t[ -s start ] [ -e end ] [ -c cdrtypenum ] \n\tfreesideuser\n";
}
sub check_cdr {
More information about the freeside-commits
mailing list