Based on the info I got here, I created this script to get info about the speed of the used DNS-server.
It's supposed to find out which IP it should ask to resolve the local DNS-server.
I just finished writing it, but I'm not sure if I covered all situations.
It will always return a number.
On error this is 999999
I welcome feedback
item:
Trigger:
It's supposed to find out which IP it should ask to resolve the local DNS-server.
I just finished writing it, but I'm not sure if I covered all situations.
It will always return a number.
On error this is 999999
I welcome feedback
item:
Code:
DNS resolve speed net.tcp.dnsspeed Numeric (unsigned) Interval 60
Code:
DNS is slow on {HOSTNAME}
{Template_Linux:net.tcp.dnsspeed.max(300)}>50
Code:
DNS is not running on {HOSTNAME}
{Template_Linux:net.tcp.dnsspeed.last(0)}>5000
Code:
#!/bin/bash
#####################################################
# dnsspeed
#####################################################
#
# echo 'UserParameter=net.tcp.dnsspeed[*],/usr/local/sbin/dnsspeed "$1" "$2"' >>/etc/zabbix/zabbix_agentd.conf
#####################################################
export PATH=${PATH}:/usr/local/sbin:/sbin:/usr/sbin:/bin:/usr/bin
IP=$1
RAWZONE=$2
WAIT=4
[ -z "${RAWZONE}" ] && RAWZONE=pool.ntp.org
ZONE="`echo "${RAWZONE}" | grep '\.' | grep '[A-Za-z0-9.-]*'`"
[ "${RAWZONE}" = "${ZONE}" ] || exit 1
if [ -z "${IP}" ] ; then
IP=127.0.0.1
elif ! echo "${IP}" | grep -qE '^([0-9]{1,3}\.){3}[0-9]{1,3}$' ; then
echo 99999
exit 1
fi
ftmp1=`mktemp`
host -W${WAIT} -Tv ${ZONE} ${IP} 2>/dev/null >${ftmp1}
if [ $? -eq 0 ] && [ -s ${ftmp1} ] ; then
if grep -q NOERROR ${ftmp1} ; then
ANSWER=`grep ^Received $ftmp1 | grep -oE ' in [0-9]+ ms' | tail -n1 | awk '{print $2}'`
if [ ! -z "${ANSWER}" ] ; then
echo "${ANSWER}"
rm -f $ftmp1
exit 0
fi
fi
fi
expr ${WAIT} \* 1000 + 1000
rm -f ${ftmp1}
Comment