summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorivan <ivan>2012-01-11 09:57:53 +0000
committerivan <ivan>2012-01-11 09:57:53 +0000
commita0275b02c96f00a58ae122718fa45ff65370ca3c (patch)
tree817cb94f60e8b95929140617b698d35f3c4bd5df
parentca3590aaa171f5d084367a587ab006ba9078003c (diff)
fix OpenSIPS import for +1 style numbers, add -c cdrtypenum RT#16019
-rwxr-xr-xbin/cdr-opensips.import22
1 files changed, 18 insertions, 4 deletions
diff --git a/bin/cdr-opensips.import b/bin/cdr-opensips.import
index 54f06824c..489fac6d6 100755
--- a/bin/cdr-opensips.import
+++ b/bin/cdr-opensips.import
@@ -10,7 +10,7 @@ use DBI;
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 @@ while ( $row = $sth->fetchrow_hashref ) {
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 @@ while ( $row = $sth->fetchrow_hashref ) {
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 @@ if ( keys(%cdrs) ) {
$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 {