|
| 1 | +#!/usr/bin/perl |
| 2 | +use strict; |
| 3 | +use warnings; |
| 4 | + |
| 5 | +use Data::Dumper; |
| 6 | +$|++; |
| 7 | + |
| 8 | +use lib 'lib'; |
| 9 | +use Mail::DMARC::Report::View::CLI; |
| 10 | +my $cli = Mail::DMARC::Report::View::CLI->new; |
| 11 | + |
| 12 | +my $reports = $cli->store->retrieve; |
| 13 | +printf "%3s %20s %20s %15s\n", qw[ ID Recipient From/Sender Report-Start ]; |
| 14 | +printf " | -- %3s %32s %13s %7s %7s %20s\n\n", 'Qty','Source IP','Disposition','DKIM','SPF'; |
| 15 | + |
| 16 | +foreach my $report ( reverse @$reports) { |
| 17 | +#warn Dumper($report); |
| 18 | + printf "%3s %20s %20s %15s\n", @$report{qw/ rid rcpt_domain from_domain begin /}; |
| 19 | + my $rows = $cli->store->backend->get_row( rid => $report->{rid} )->{rows}; |
| 20 | + foreach my $row ( @$rows ) { |
| 21 | + printf " | -- %3s %32s %13s %7s %7s", @$row{qw/ count source_ip disposition dkim spf /}; |
| 22 | + foreach ( @{ $row->{reasons} } ) { |
| 23 | + print ' ' . $_->{type}; |
| 24 | + print "( $_->{comment} )" if $_->{comment}; |
| 25 | + }; |
| 26 | + print "\n"; |
| 27 | +#print Dumper($row); |
| 28 | + } |
| 29 | + print "\n"; |
| 30 | +} |
| 31 | + |
| 32 | +exit; |
| 33 | + |
| 34 | +# PODNAME: dmarc_view_reports |
| 35 | +# ABSTRACT: view DMARC reports on the command line |
| 36 | + |
| 37 | +=head1 SYNOPSIS |
| 38 | +
|
| 39 | + dmarc_view_reports | less |
| 40 | +
|
| 41 | +
|
| 42 | +=head1 DESCRIPTION |
| 43 | +
|
| 44 | +Dumps the contents of the DMARC data store to your terminal. The most recent records are show first. |
| 45 | +
|
| 46 | +
|
| 47 | +=head1 SAMPLE OUTPUT |
| 48 | +
|
| 49 | +
|
| 50 | + ID Recipient From/Sender Report-Start |
| 51 | + | -- Qty Source IP Disposition DKIM SPF |
| 52 | +
|
| 53 | + 570 theartfarm.com simerson.net 2013-05-20 09:40:50 |
| 54 | + | -- 1 75.126.200.152 quarantine fail fail |
| 55 | +
|
| 56 | + 568 yeah.net tnpi.net 2013-05-21 09:00:00 |
| 57 | + | -- 1 111.176.77.138 reject fail fail |
| 58 | +
|
| 59 | + 567 126.com tnpi.net 2013-05-21 09:00:00 |
| 60 | + | -- 1 49.73.135.125 reject fail fail |
| 61 | +
|
| 62 | + 565 google.com mesick.us 2013-05-20 17:00:00 |
| 63 | + | -- 88 208.75.177.101 none pass pass |
| 64 | +
|
| 65 | + 564 google.com theartfarm.com 2013-05-20 17:00:00 |
| 66 | + | -- 3 208.75.177.101 none pass pass |
| 67 | +
|
| 68 | + 563 google.com lynboyer.com 2013-05-20 17:00:00 |
| 69 | + | -- 1 2a00:1450:4010:c03::235 none pass fail forwarded |
| 70 | + | -- 12 208.75.177.101 none pass pass |
| 71 | + | -- 1 209.85.217.174 none pass fail forwarded |
| 72 | +
|
| 73 | + 561 google.com simerson.net 2013-05-20 17:00:00 |
| 74 | + | -- 1 208.75.177.101 none pass pass |
| 75 | +
|
| 76 | + 560 google.com tnpi.net 2013-05-20 17:00:00 |
| 77 | + | -- 1 208.75.177.101 none pass pass |
| 78 | + | -- 1 27.20.110.240 reject fail fail |
| 79 | +
|
| 80 | + 559 hotmail.com lynboyer.com 2013-05-20 20:00:00 |
| 81 | + | -- 6 208.75.177.101 none pass pass |
| 82 | +
|
| 83 | +=cut |
| 84 | + |
0 commit comments