diff options
author | Harald Welte <laforge@netfilter.org> | 2010-01-01 15:08:38 +0100 |
---|---|---|
committer | Harald Welte <laforge@netfilter.org> | 2010-01-01 15:08:38 +0100 |
commit | 730bc653d1197c57cdc89e9e22c06ed687749e21 (patch) | |
tree | 482ed9d8ca1952491928519310edff180bfdbe9a /openbsc/tools | |
parent | 510087752e46489b7ea61d72b3ab39540ce0d908 (diff) |
hlrstat: Print numeric MCC/MNC in case no name is available
Diffstat (limited to 'openbsc/tools')
-rwxr-xr-x | openbsc/tools/hlrstat.pl | 25 |
1 files changed, 20 insertions, 5 deletions
diff --git a/openbsc/tools/hlrstat.pl b/openbsc/tools/hlrstat.pl index a3fd2b81e..668fc9a4a 100755 --- a/openbsc/tools/hlrstat.pl +++ b/openbsc/tools/hlrstat.pl @@ -8,6 +8,18 @@ my $dbh = DBI->connect("dbi:SQLite:dbname=hlr.sqlite3","",""); my %mcc_names; my %mcc_mnc_names; +sub get_mcc_mnc_name($) +{ + my $mcc_mnc = shift; + my $ret = $mcc_mnc; + + if ($mcc_mnc_names{$mcc_mnc} ne '') { + $ret = $mcc_mnc_names{$mcc_mnc}; + } + + return $ret; +} + sub read_networks($) { my $filename = shift; @@ -37,6 +49,7 @@ read_networks("networks.tab"); my %oper_count; my %country_count; +#my $sth = $dbh->prepare("SELECT imsi FROM subscriber where authorized=1"); my $sth = $dbh->prepare("SELECT imsi FROM subscriber"); $sth->execute(); @@ -49,10 +62,12 @@ while (my $href = $sth->fetchrow_hashref) { } -foreach my $c (keys %country_count) { +foreach my $c (sort{$country_count{$b} <=> $country_count{$a}} keys %country_count) { printf("%s: %d\n", $mcc_names{$c}, $country_count{$c}); -} - foreach my $k (keys %oper_count) { - printf("\t%s: %d\n", $mcc_mnc_names{$k}, $oper_count{$k}); + + foreach my $k (sort{$oper_count{$b} <=> $oper_count{$a}} keys %oper_count) { + if ($k =~ /^$c-/) { + printf("\t%s: %d\n", get_mcc_mnc_name($k), $oper_count{$k}); + } } -#//} +} |