1NAME
2 Net::DNSBL::Statistics - gather DNSBL Statistics
3
4SYNOPSIS
5 use Net::DNSBL::Statistics qw(
6 run
7 plaintxt
8 htmltxt
9 );
10
11 %dnsblcounts=run(\%config,$NonBlockSock,$sockaddr_in);
12 $text = plaintxt(\%config,\%dnsblscounts);
13 $html = htmltxt(\%config,\%dnsblcounts);
14
15DESCRIPTION
16 Net::DNSBL::Statistics is the Perl module that collects statistics on
17 the interrogation success for a list of IP addresses against a list of
18 DNSBL's. The module is used to implement the reproting script dnsblstat.
19
20CONFIGURATION FILE
21 With the addition of a few elements, the configuration file for
22 dnsblstat shares a common format with the Mail::SpamCannibal
23 sc_BLcheck.pl script, facilitating common maintenance of DNSBL's for
24 your MTA installation.
25
26 The sample configuration file statistics.conf.sample is heavily
27 commented with the details for each configuration element.
28
29SYSTEM SIGNALS
30 dnsblstat responds to the following system signals:
31
32 * TERM
33 Script is terminated.
34
35PERL MODULE DESCRIPTION - Script Implementation
36 Net::DNSBL::Statistics provides most of the functions that implement
37 dnsblstat which is a script that collects statistics from a list of IP
38 address interrogations against a list of DNSBL's
39
40dnsblstat usage
41 How to use dnsblstat
42
43 Syntax: dnsblstat path/to/config.file
44 or
45 dnsblstat -t path/to/config.file
46 dnsblstat -w path/to/config.file
47
48 Normally dnsblstat prints a sorted list (by count) of the DNSBL's
49 interrogated with their reply count, percentage of the total count, and
50 any comments from the DNSBL's 'comment' key field in the config file.
51 The 'comment' field may contain html markup text.
52
53 i.e.
54 44 100.0% TOTAL IP's interrogated
55 41 93.2% UNION of all results
56 34 77.3% dnsbl.sorbs.net comment
57 ........
58
59 The -t switch will print a start and stop time.
60
61 i.e.
62 # start: Fri Jan 4 17:46:44 2008
63 # stop : Fri Jan 4 17:58:21 2008
64
65 The -w switch will put the output into an HTML table without the <table>
66 statement </table>>., a commment as above and with an <a
67 href="...">dnsbl name</a> statement replacing the dnsbl name if the
68 'url' key is present in the config file.
69
70 i.e.
71 A one line example corresponding to the text line above:
72
73 34 77.3% dnsbl.sorbs.net
74
75 with a 'comment' key of: 127.0.0.2,5,7,8,9,10,12
76 and a 'url' key of: http://www.au.sorbs.net/using.shtml
77
78 <tr class=dnsbl><td align=right>34</td>
79 <td align=right>77.3%</td>
80 <td align=left><a
81 href="http://www.au.sorbs.net/using.shtml">dnsbl.sorbs.net</a></td>
82 <td align=left>127.0.0.2,5,7,8,9,10,12</td>
83 </tr>
84
85Net::DNSBL::Statistics FUNCTIONS
86 * %dnsblscounts=run(\%config,$NonBlockSock,$sockaddr_in);
87 Returns the total number of IP's interrogated (IP list less white
88 listed items) and a hash of DNSBL names and their respective SPAM
89 reply counts or equivalent for 'in-addr.arpa' and GENERIC.
90
91 input: config pointer,
92 non-blocking socket descriptor,
93 sockaddr_in for local DNS host
94
95 returns: dnsbl count hash
96
97 The dnsbl count hash will have two added keys:
98
99 TOTAL the total number of interrogations less whitelist
100 UNION the total number of spam 'hits'
101
102 HINTs: use Net::NBsocket qw( open_udbNB sockaddr_in );
103 use Net::DNS::ToolKit qw( get_ns );
104
105 my $sock = open_udpNB();
106 my $sockaddr_in = sockaddr_in(53, scalar get_ns());
107
108 * $text = plaintxt($config,\%dnsbls);
109 Generate a plain text report of the form:
110
111 44 100.0% TOTAL IP's interrogated
112 41 93.2% UNION of all results
113 34 77.3% dnsbl.sorbs.net comment
114 22 50.0% GENERIC comment
115 13 29.5% in-addr.arpa comment
116 11 25.0% cbl.abuseat.org comment
117 9 20.5% list.dsbl.org comment
118 2 4.5% dnsbl.njabl.org comment
119 1 2.3% bl.spamcannibal.org comment
120 0 0.0% dynablock.njabl.org comment
121
122 input: configuration pointer,
123 dnsbl count hash pointer
124 returns: text buffer
125
126 The 'comment' comes from the config file 'comment' key field for
127 each specified DNSBL or is blank if there is no 'comment' key.
128
129 * $html = htmltxt($config,\%dnsbls);
130 Generate a report as above but with <tr><td></td></tr> table markup.
131 The <table></table> tags are not generated. If there is a 'url' key
132 field in the respective DNSBL config entry, the DNSBL name is
133 provide with <a href="url">DNSBL</a> tags with the specified 'url'
134 as the 'href' value.
135
136 input: configuration pointer,
137 dnsbl count hash pointer
138 returns: html text buffer
139
140 A one line example corresponding to the text line above:
141
142 34 77.3% dnsbl.sorbs.net
143
144 with a 'comment' key of: 127.0.0.2,5,7,8,9,10,12
145 and a 'url' key of: http://www.au.sorbs.net/using.shtml
146
147 <tr class=dnsbl><td align=right>34</td>
148 <td align=right>77.3%</td>
149 <td align=left><a
150 href="http://www.au.sorbs.net/using.shtml">dnsbl.sorbs.net</a></td>
151 <td align=left>127.0.0.2,5,7,8,9,10,12</td>
152 </tr>
153
154Statistics Web Page HOWTO
155 Read the "contrib/HOWTO" document that describes the scripts used with
156 'cron' to auto generate web pages for the statistics reports
157
158EXPORT_OK
159 run
160 plaintxt
161 htmltxt
162
163AUTHOR
164 Michael Robinton, michael@bizsystems.com
165
166COPYRIGHT
167 Copyright 2008-2014, Michael Robinton. This program is free software;
168 you can redistribute it and/or modify it under the terms of the GNU
169 General Public License as published by the Free Software Foundation;
170 either version 2 of the License, or (at your option) any later version.
171
172 This program is distributed in the hope that it will be useful, but
173 WITHOUT ANY WARRANTY; without even the implied warranty of
174 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
175 Public License for more details.
176
177 You should have received a copy of the GNU General Public License along
178 with this program; if not, write to the Free Software Foundation, Inc.,
179 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
180
181SEE ALSO
182 the Mail::SpamCannibal manpage, the Net::DNS::Codes manpage, the
183 Net::DNS::ToolKit manpage, the Net::DNSBL::MultiDaemon manpage
184
185