mirror of
https://github.com/munin-monitoring/contrib.git
synced 2018-11-08 00:59:34 +01:00
Check SenderBase with either dig or host, depending on what's available.
This commit is contained in:
parent
5355c24b49
commit
2c09bd7de7
@ -42,20 +42,36 @@ This plugin is made available under a CC0 waiver:
|
|||||||
|
|
||||||
=cut
|
=cut
|
||||||
|
|
||||||
real_ip_address=${ip_address:-$(hostname -I | awk '{print $1}')}
|
if which dig >/dev/null; then
|
||||||
ip_reversed=$(echo $real_ip_address | sed -re 's/^([0-9]+)\.([0-9]+)\.([0-9]+)\.([0-9]+)$/\4.\3.\2.\1/')
|
query_program=dig
|
||||||
query_host=${ip_reversed}.rf.senderbase.org
|
do_query () {
|
||||||
|
hostname=$1
|
||||||
|
dig +short $hostname TXT | sed 's/"//g' | head -1
|
||||||
|
}
|
||||||
|
elif which host >/dev/null; then
|
||||||
|
query_program=host
|
||||||
|
do_query () {
|
||||||
|
hostname=$1
|
||||||
|
host -t TXT $hostname | grep -m 1 'descriptive text' | cut -d\" -f2
|
||||||
|
}
|
||||||
|
else
|
||||||
|
query_program=
|
||||||
|
do_query () {
|
||||||
|
true
|
||||||
|
}
|
||||||
|
fi
|
||||||
|
|
||||||
|
real_ip_address="${ip_address:-$(hostname -I | awk '{print $1}')}"
|
||||||
|
ip_reversed="$(echo $real_ip_address | sed -re 's/^([0-9]+)\.([0-9]+)\.([0-9]+)\.([0-9]+)$/\4.\3.\2.\1/')"
|
||||||
|
query_host="${ip_reversed}.rf.senderbase.org"
|
||||||
|
|
||||||
if [ "$1" = "autoconf" ]; then
|
if [ "$1" = "autoconf" ]; then
|
||||||
if which dig >/dev/null; then
|
if [ -z "$query_program" ]; then
|
||||||
value=$(dig +short $query_host TXT | sed 's/"//g' | head -1)
|
echo 'no (No "dig" or "host" executable found.)'
|
||||||
if [ -n "$value" ]; then
|
elif [ -z "$(do_query "$query_host")" ]; then
|
||||||
echo 'yes'
|
echo "no (No SenderBase reputation for IP address ${ip_address}.)"
|
||||||
else
|
|
||||||
echo "no (No SenderBase reputation for IP address ${ip_address}.)"
|
|
||||||
fi
|
|
||||||
else
|
else
|
||||||
echo 'no (No "dig" executable found.)'
|
echo 'yes'
|
||||||
fi
|
fi
|
||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
@ -73,5 +89,5 @@ EOF
|
|||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
value=$(dig +short $query_host TXT | sed 's/"//g' | head -1)
|
value="$(do_query "$query_host")"
|
||||||
echo reputation.value ${value:-U}
|
echo reputation.value "${value:-U}"
|
||||||
|
Loading…
Reference in New Issue
Block a user