root / plugins / senderbase / senderbase @ 2c09bd7d
Historique | Voir | Annoter | Télécharger (2,53 ko)
| 1 |
#!/bin/sh |
|---|---|
| 2 |
|
| 3 |
: << =cut |
| 4 |
|
| 5 |
=head1 NAME |
| 6 |
|
| 7 |
senderbase - Gives the current SenderBase reputation for a mail host. |
| 8 |
|
| 9 |
SenderBase is a mail server reputation service run by Cisco. It's |
| 10 |
basically a measure of how likely or unlikely they think it is for the |
| 11 |
server in question to be sending spam, rated on a scale of -10 (near-100% |
| 12 |
chance of spam) to 10 (near-0% chance of spam). The SenderBase score for |
| 13 |
a server is one of several criteria that may be used when doing spam |
| 14 |
filtering; consequently, it's useful for the operator of a mail server to |
| 15 |
track their current reputation score. |
| 16 |
|
| 17 |
=head1 CONFIGURATION |
| 18 |
|
| 19 |
By default, the script will use the first IP address returned by |
| 20 |
C<hostname -I>. If that's not the right address to use, set the |
| 21 |
C<ip_address> environment variable to the appropriate value. (Note that |
| 22 |
if a host has multiple IP addresses, there's no guaranteed ordering for |
| 23 |
C<hostname -I>, so you should set the address explicitly in that case.) |
| 24 |
|
| 25 |
[senderbase] |
| 26 |
env.ip_address 8.8.8.8 |
| 27 |
|
| 28 |
=head1 AUTHOR |
| 29 |
|
| 30 |
Phil! Gold <phil_g@pobox.com> |
| 31 |
|
| 32 |
=head1 LICENSE |
| 33 |
|
| 34 |
This plugin is made available under a CC0 waiver: |
| 35 |
|
| 36 |
https://creativecommons.org/publicdomain/zero/1.0/ |
| 37 |
|
| 38 |
=head1 MAGIC MARKERS |
| 39 |
|
| 40 |
#%# family=auto |
| 41 |
#%# capabilities=autoconf |
| 42 |
|
| 43 |
=cut |
| 44 |
|
| 45 |
if which dig >/dev/null; then |
| 46 |
query_program=dig |
| 47 |
do_query () {
|
| 48 |
hostname=$1 |
| 49 |
dig +short $hostname TXT | sed 's/"//g' | head -1 |
| 50 |
} |
| 51 |
elif which host >/dev/null; then |
| 52 |
query_program=host |
| 53 |
do_query () {
|
| 54 |
hostname=$1 |
| 55 |
host -t TXT $hostname | grep -m 1 'descriptive text' | cut -d\" -f2 |
| 56 |
} |
| 57 |
else |
| 58 |
query_program= |
| 59 |
do_query () {
|
| 60 |
true |
| 61 |
} |
| 62 |
fi |
| 63 |
|
| 64 |
real_ip_address="${ip_address:-$(hostname -I | awk '{print $1}')}"
|
| 65 |
ip_reversed="$(echo $real_ip_address | sed -re 's/^([0-9]+)\.([0-9]+)\.([0-9]+)\.([0-9]+)$/\4.\3.\2.\1/')" |
| 66 |
query_host="${ip_reversed}.rf.senderbase.org"
|
| 67 |
|
| 68 |
if [ "$1" = "autoconf" ]; then |
| 69 |
if [ -z "$query_program" ]; then |
| 70 |
echo 'no (No "dig" or "host" executable found.)' |
| 71 |
elif [ -z "$(do_query "$query_host")" ]; then |
| 72 |
echo "no (No SenderBase reputation for IP address ${ip_address}.)"
|
| 73 |
else |
| 74 |
echo 'yes' |
| 75 |
fi |
| 76 |
exit 0 |
| 77 |
fi |
| 78 |
|
| 79 |
if [ "$1" = "config" ]; then |
| 80 |
cat <<EOF |
| 81 |
graph_category mail |
| 82 |
graph_title SenderBase Reputation for $real_ip_address |
| 83 |
graph_info Current reputation from senderbase.org. Ranges from -10 (very poor) through 0 (neutral) to 10 (very good). |
| 84 |
graph_args --lower-limit -10 --upper-limit 10 |
| 85 |
reputation.label Reputation |
| 86 |
reputation.warning 0: |
| 87 |
reputation.critical -5: |
| 88 |
EOF |
| 89 |
exit 0 |
| 90 |
fi |
| 91 |
|
| 92 |
value="$(do_query "$query_host")" |
| 93 |
echo reputation.value "${value:-U}"
|
