diff options
author | Mark Wells <mark@freeside.biz> | 2012-03-08 13:37:53 -0800 |
---|---|---|
committer | Mark Wells <mark@freeside.biz> | 2012-03-08 13:38:33 -0800 |
commit | a5fba19707ec1a01db18fa55862e742170feccdf (patch) | |
tree | 66eb6e525959474e3392c12924ba95bad98b6a6e /bin | |
parent | 2e7f1e27ead9a8837b5516e2cd2e1795d51e5ee1 (diff) |
match CDRs to services by IP address, #16723
Diffstat (limited to 'bin')
-rwxr-xr-x | bin/cdr-opensips.import | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/bin/cdr-opensips.import b/bin/cdr-opensips.import index 489fac6d6..b8169d523 100755 --- a/bin/cdr-opensips.import +++ b/bin/cdr-opensips.import @@ -82,15 +82,26 @@ while ( $row = $sth->fetchrow_hashref ) { #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+)@/ ) { + my $src_ip = ''; + if ( $row->{'caller_id'} =~ /^sip:(\+1?)?(\w+)@(.*)/ ) { $src = $2; + my $rest = $3; + if ($rest =~ /^([\d\.]{7,15})/) { + # canonicalize it so that ascii sort order works + $src_ip = sprintf('%03d.%03d.%03d.%03d', split('\.', $1)); + } } else { warn "unparseable caller_id ". $row->{'caller_id'}. "\n"; } my $dst = ''; - if ( $row->{'callee_id'} =~ /^sip:(\+1)?(\d+)@/ ) { + my $dst_ip = ''; + if ( $row->{'callee_id'} =~ /^sip:(\+1?)?(\w+)@(.*)/ ) { $dst = $2; + my $rest = $3; + if ($rest =~ /^([\d\.]{7,15})/) { + $dst_ip = sprintf('%03d.%03d.%03d.%03d', split('\.', $1)); + } } else { warn "unparseable callee_id ". $row->{'callee_id'}. "\n"; } @@ -108,6 +119,8 @@ while ( $row = $sth->fetchrow_hashref ) { $cdr->startdate($date); $cdr->src($src); $cdr->dst($dst); + $cdr->src_ip_addr($src_ip); + $cdr->dst_ip_addr($dst_ip); } elsif ( $row->{'method'} eq 'ACK' ) { $cdr->answerdate($date); |