A
Agrapha
First let me state that Tassilo v. Parseval helped me a bunch last
April. I would not have been able to complete this project without his
help. I promised last year to post a working copy of this script. It's
not perfect but it works. I'll clean it up a bit more this year.
Tassilo, would you e_mail me directly in order that I may thank you
properly? mail to: nethaniel at box201.com
Up top is the results from the script. The way this script was forged
is documented in the history of this forum. Search on "Grep Once Awk
Twice" to find it. The names and numbers here have been slightly
altered to protect the innocent.
[agrapha@f3dd43-01 scripts]$ ./triag.pl 5555554999 0127 lon1
total_calls 523 total_failures 14 access number 5555554999
success rate for dates selected: 97.3231357552581%
ErrorCodes / Totals
-------------------
31,10 / 3
31,185 / 8
33,185 / 1
75,81 / 1
75,185 / 1
PhoneNumber / TotalFail
-----------------------
5550001111 / 2
5550001118 / 2
5550001110 / 1
5550001131 / 1
5550001811 / 4
5550001114 / 1
5550001211 / 1
5550001191 / 1
5550001119 / 1
Number / Error / Totals
-----------------------
5550001110 - 75,185,75,81 - 2
5550001111 - 31,185 - 1
5550001114 - 31,185 - 2
5550001118 - 31,185 - 4
5550001119 - 31,10 - 1
5550001131 - 31,10 - 1
5550001191 - 31,10 - 1
5550001211 - 33,185 - 1
5550001811 - 31,185 - 1
triag.pl script complete
[agrapha@f3dd43-01 scripts]$ cat triag.pl
#!/usr/bin/perl -w
use strict;
#####
# This script was made possible by the excellent help
# from the people on the perl usenet forum.
# The project would not have been possible without them.
# triage.pl was designed to look up an number and gather
# info about it. We begin by making sure they enter one
# on the command line or give them an example if they
# fail to do so.
###
if (!$ARGV[0] or !$ARGV[1] or !$ARGV[2]) {
print "Syntax is \"./triag.pl accessnumber yyyymmdd mkt\"\n";
print "example: ./triag.pl 2015551212 20040101 lon1
die "Include an access number, date and market when starting
Triag\n";
}
### Variable Initialization
my %error_codes;
my %error_users;
my %err_per_usr;
my $code = 0;
my $users = 0;
my $badusr = 0;
### End Variable Init
#####
# Next we go and find all the radius log files
# the push here will push the line into @selected
# if the line matches @ARGV (the command line value)
###
my @selected=`zgrep $ARGV[0]
../radiuslog/$ARGV[1]/server.$ARGV[2].Detail.$ARGV[1].gz`;
my @badcalls= grep /,0 /, @selected;
#####
# Ok so now we have a zgrep pushed into our
# @selected array. This is because the files are gunzipped.
# That give us all the calls made to the access number.
# Next we need to sort out the calls with zero session time
# by looking for /,0_/ that is a space after the ,0
# because typically failed calls have zero browsing time
###
#####
# now with the failed calls in @badcalls we filter and sort
###
foreach (@badcalls[0..$#badcalls]) {
my @errors = split /\s+/, $_;
$code = $errors[7];
$users = $errors[3];
$error_codes{$code}++;
$error_users{$users}++;
}
#####
# ok here is a difficult part to my script.
# Thanks Tassilo,
# this script would not have been possible without him.
###
my %errorsz;
foreach (@badcalls[0..$#badcalls]) {
my ($phonez, $err_codez) = (split)[3,7];
$errorsz{ $phonez }->{ $err_codez }++;
}
#####
# So the phone-numbers are the primary keys of the hash and the
# error-codes the keys of the nested hash.
# Next we perform a little math to get and average call sucess ratio
###
my $total = @selected;
my $fail = @badcalls;
print "\ntotal_calls $total\ttotal_failures $fail\taccess number
$ARGV[0]\n";
print "success rate for dates selected: ", (100 - (($fail / $total) *
100)), "%\n";
#####
# Finally I print out the information to the screen
###
print "\nErrorCodes / Totals\n";
print "-------------------\n";
foreach my $key (keys %error_codes) {
print "$key\t\/\t$error_codes{$key}\n";
}
print "\nPhoneNumber / TotalFail\n";
print "-----------------------\n";
foreach my $key (keys %error_users) {
print "$key\t\/\t$error_users{$key}\n";
}
#####
# this one is now fixed. Adding the perfect flourish
# to my first perl program.
###
print "\nNumber / Error / Totals\n";
print "-----------------------\n";
for my $n (sort { $a <=> $b } keys %errorsz) {
# $errorsz{ $n } is now itself a reference to a hash
my %codesz = %{ $errorsz{ $n } };
# compute the total numbers of errors for this phone-number
my $qty;
for ( keys %codesz ) {
$qty += $codesz{ $_ };
}
# display the stats for a given phone-number $n
print "$n - ", join (",", keys %codesz), " - $qty\n";
}
print "\n\ntriag.pl script complete\n";
April. I would not have been able to complete this project without his
help. I promised last year to post a working copy of this script. It's
not perfect but it works. I'll clean it up a bit more this year.
Tassilo, would you e_mail me directly in order that I may thank you
properly? mail to: nethaniel at box201.com
Up top is the results from the script. The way this script was forged
is documented in the history of this forum. Search on "Grep Once Awk
Twice" to find it. The names and numbers here have been slightly
altered to protect the innocent.
[agrapha@f3dd43-01 scripts]$ ./triag.pl 5555554999 0127 lon1
total_calls 523 total_failures 14 access number 5555554999
success rate for dates selected: 97.3231357552581%
ErrorCodes / Totals
-------------------
31,10 / 3
31,185 / 8
33,185 / 1
75,81 / 1
75,185 / 1
PhoneNumber / TotalFail
-----------------------
5550001111 / 2
5550001118 / 2
5550001110 / 1
5550001131 / 1
5550001811 / 4
5550001114 / 1
5550001211 / 1
5550001191 / 1
5550001119 / 1
Number / Error / Totals
-----------------------
5550001110 - 75,185,75,81 - 2
5550001111 - 31,185 - 1
5550001114 - 31,185 - 2
5550001118 - 31,185 - 4
5550001119 - 31,10 - 1
5550001131 - 31,10 - 1
5550001191 - 31,10 - 1
5550001211 - 33,185 - 1
5550001811 - 31,185 - 1
triag.pl script complete
[agrapha@f3dd43-01 scripts]$ cat triag.pl
#!/usr/bin/perl -w
use strict;
#####
# This script was made possible by the excellent help
# from the people on the perl usenet forum.
# The project would not have been possible without them.
# triage.pl was designed to look up an number and gather
# info about it. We begin by making sure they enter one
# on the command line or give them an example if they
# fail to do so.
###
if (!$ARGV[0] or !$ARGV[1] or !$ARGV[2]) {
print "Syntax is \"./triag.pl accessnumber yyyymmdd mkt\"\n";
print "example: ./triag.pl 2015551212 20040101 lon1
die "Include an access number, date and market when starting
Triag\n";
}
### Variable Initialization
my %error_codes;
my %error_users;
my %err_per_usr;
my $code = 0;
my $users = 0;
my $badusr = 0;
### End Variable Init
#####
# Next we go and find all the radius log files
# the push here will push the line into @selected
# if the line matches @ARGV (the command line value)
###
my @selected=`zgrep $ARGV[0]
../radiuslog/$ARGV[1]/server.$ARGV[2].Detail.$ARGV[1].gz`;
my @badcalls= grep /,0 /, @selected;
#####
# Ok so now we have a zgrep pushed into our
# @selected array. This is because the files are gunzipped.
# That give us all the calls made to the access number.
# Next we need to sort out the calls with zero session time
# by looking for /,0_/ that is a space after the ,0
# because typically failed calls have zero browsing time
###
#####
# now with the failed calls in @badcalls we filter and sort
###
foreach (@badcalls[0..$#badcalls]) {
my @errors = split /\s+/, $_;
$code = $errors[7];
$users = $errors[3];
$error_codes{$code}++;
$error_users{$users}++;
}
#####
# ok here is a difficult part to my script.
# Thanks Tassilo,
# this script would not have been possible without him.
###
my %errorsz;
foreach (@badcalls[0..$#badcalls]) {
my ($phonez, $err_codez) = (split)[3,7];
$errorsz{ $phonez }->{ $err_codez }++;
}
#####
# So the phone-numbers are the primary keys of the hash and the
# error-codes the keys of the nested hash.
# Next we perform a little math to get and average call sucess ratio
###
my $total = @selected;
my $fail = @badcalls;
print "\ntotal_calls $total\ttotal_failures $fail\taccess number
$ARGV[0]\n";
print "success rate for dates selected: ", (100 - (($fail / $total) *
100)), "%\n";
#####
# Finally I print out the information to the screen
###
print "\nErrorCodes / Totals\n";
print "-------------------\n";
foreach my $key (keys %error_codes) {
print "$key\t\/\t$error_codes{$key}\n";
}
print "\nPhoneNumber / TotalFail\n";
print "-----------------------\n";
foreach my $key (keys %error_users) {
print "$key\t\/\t$error_users{$key}\n";
}
#####
# this one is now fixed. Adding the perfect flourish
# to my first perl program.
###
print "\nNumber / Error / Totals\n";
print "-----------------------\n";
for my $n (sort { $a <=> $b } keys %errorsz) {
# $errorsz{ $n } is now itself a reference to a hash
my %codesz = %{ $errorsz{ $n } };
# compute the total numbers of errors for this phone-number
my $qty;
for ( keys %codesz ) {
$qty += $codesz{ $_ };
}
# display the stats for a given phone-number $n
print "$n - ", join (",", keys %codesz), " - $qty\n";
}
print "\n\ntriag.pl script complete\n";