Skip to content
Snippets Groups Projects
Commit 8a9300f8 authored by taggart's avatar taggart
Browse files

countbouncecodes, for a given domain give counts of the bounce codes

parent fb4783a1
Branches
No related tags found
No related merge requests found
#!/usr/bin/perl -w
# countbouncecodes - for a given domain, give a list of bounce codes by count
# NOTE: this script requires the current user has read access to the db
# Matt Taggart <taggart@riseup.net> 2019-09
my $listsql=q(mysql -N --batch --database=sympa --execute "select user_subscriber, bounce_subscriber from subscriber_table WHERE bounce_subscriber <> 'NULL'");
if ( ! $ARGV[0] ) {
print "usage: countbouncecodes <domain>\n";
exit 1;
}
my $target = $ARGV[0];
open(LISTDUMP, "$listsql|") or die "cannot get dump of address+bounce pairs from database\n";
while (<LISTDUMP>) {
chomp;
# match sane address and list
m/^<?(.*\@(.*?))>?\s*\t(.*) (.*) (.*) (.*)$/;
my $address=$1;
my $domain=$2;
my $firstbounce=$3;
my $lastbounce=$4;
my $bouncescore=$5;
my $bouncecode=$6;
#print "$address $domain $firstbounce $lastbounce $bouncescore $bouncecode\n";
if ( $domain eq $target ) {
# hash, key is code, value is count
$codes{$bouncecode}++;
}
}
format Foo =
@>>>> @<<<<<<<<<<<
$count, $code
.
$~= 'Foo';
$count='count';
$code='code';
print "Bounce codes for $target\n";
write;
print "-------------\n";
# sort by count
foreach $code ( sort { $codes{$b} <=> $codes{$a} } keys %codes) {
$count=$codes{$code};
write;
#if ( $count == $limit ) {last;}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment