View Full Version : dns checking [named]
Hello all,
is there any solution how to check that dns server [named] is properly running and is answering corectly to dns querys?
diegocito
24-07-2007, 12:09
Up, please, I need this too.
Thanks
Diegocito
gescheit
24-07-2007, 13:27
Some like this if use external check.
check_dns.sh
#!/bin/bash
HOST_FOR_RESOLV="ya.ru"
DNS_SERVER=`mysql -b -D zabbix -u zabbix -ppass -e "SELECT ip FROM hosts WHERE host='$1' LIMIT 1" | cut -f 2 | grep -v ip`
if [ `nslookup $HOST_FOR_RESOLV $DNS_SERVER | grep "has address" | wc -l` -gt 0 ]; then
echo "1"
else
echo "0"
fi
To add this do: Item -> Create Item ->
Type: External check
Key check_dns.sh()
-> Save
Sure that check_dns.sh at "ExternalScripts" path.
diegocito
24-07-2007, 15:14
Ok, it seems working, but "last value" is always at "0" whereas it works and it must be at "1" (I made the test in command lines)...
Thanks for your answer
Diegocito
diegocito
26-07-2007, 10:11
Sorry but it doesn't work, but this doesn't come from your plugin, It comes from Zabbix I think.
Indeed, In command lines, it "echos" me 0 and 1 correctly, but with Zabbix, it stay always at 1 ??? I have the impression that Zabbix cannot understand the "else echo "0"" because in the zabbix_server_log file, it is written : "timeout while answering request" what is right because I unplug the network cable to test if there is no connection, but "else echo "0"" should work at this time nevetheless, no??
Thanks
Diegocito
gescheit
26-07-2007, 15:11
Use "host" instead "nslookup"
#!/usr/local/bin/bash
#DNS lookup scripts for Zabbix monitor. Conditional return
# of valid IP | 0 for failed lookup.
HOST_QUERY=$1
if [`host $HOST_QUERY | grep "has address" | wc -l` -eq 0 ]; then
#lookup failed, bad DNS lookup
echo "0"
else
#String eval returns valid IP address
LOOKUP=`host -cIN $HOST_QUERY`
echo ${LOOKUP#$HOST_QUERY has address}
fi
wyatt121
11-08-2008, 01:49
Hi,
I'm unable to get this to work. When I create this item, Zabbix makes it "Not Supported". I followed the below instructions.
Anyone have any idea what I'm doing wrong?
Regards,
Wyatt
#!/usr/local/bin/bash
#DNS lookup scripts for Zabbix monitor. Conditional return
# of valid IP | 0 for failed lookup.
HOST_QUERY=$1
if [`host $HOST_QUERY | grep "has address" | wc -l` -eq 0 ]; then
#lookup failed, bad DNS lookup
echo "0"
else
#String eval returns valid IP address
LOOKUP=`host -cIN $HOST_QUERY`
echo ${LOOKUP#$HOST_QUERY has address}
fi
Hi Wyatt,
Based on feedback (and script) from various people I developed php scripts that work more reliably. You may see them here:
http://www.zabbix.com/wiki/doku.php?id=howto:monitor_dns_and_ntp_services_on_ your_network
The thread you are reading forked somewhere and you may not be seeing the reference to my completed article on the Wiki.
I am sure you will have better luck with those instructions.
They restructured the Wiki. Now this article is at
http://www.zabbix.com/wiki/howto/monitor/services/monitor_dns_and_ntp_services_on_your_network
We use the following bash script to return the response time of a DNS server:
#!/bin/bash
dig +tcp -c CH -t TXT +noquestion +stats +time=1 @$1 hostname.bind | grep "Query\ time" | cut -d" " -f4
We configure the item to be of external check calling that script. The value is a unsigned integer. And, we set a trigger if the the return value is over some selected limit.
Hi
we are using a Nagios-plugin for DNS checks.
Add a "Nagios plugin" entry to your value maps and fill in the standard exit codes of all Nagios plugins (0 to 3).
0: OK
1: Warning
2: Critical
3: Unknown
Write a small script to call the Nagios plugin and echo the exit code at the end by
echo $?
Use this script as "external check".
The result is an integer - the exit code of the Nagios plugin.
Set the valuemap to your newly created one.
We added interpreting the output of the Nagios plugin to
send the response time via zabbix_sender, if the exit
code is 0 (OK).
HTH,
Norbert.
janis.orlovs
22-12-2010, 22:34
Can anybody help with NET.TCP.DNS key. I have problems with basic understanding of nslookup key at this point of view. Firstly question I want to use this key for testing if the DNS server is responable, but on which host I have to put this on? On nameserver or on different host which will test the nameserver working condition?
Sorry for the stupid question.
I run the check script on my Zabbix Host. This makes sense, because you want to make sure that your DNS server is responding to other hosts. Simply checking to see if named is running on the DNS server does not assure that the server is able to serve your network.
Be sure and take a look at http://www.zabbix.com/wiki/howto/monitor/services/monitor_dns_and_ntp_services_on_your_network
I don't know if anybody had mentioned it yet (to lazy to read the whole thread :D), but just a note.
Zabbix agent can now perform DNS query checks by itself,
no external script needed:
http://www.zabbix.com/documentation/1.8/manual/config/items?s[]=dns#zabbix_agent
Use net.tcp.dns[<ip>,zone] or net.tcp.dns.query[<ip>,zone,<type>]
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:
DNS resolve speed
net.tcp.dnsspeed
Numeric (unsigned)
Interval 60
Trigger:
DNS is slow on {HOSTNAME}
{Template_Linux:net.tcp.dnsspeed.max(300)}>50
DNS is not running on {HOSTNAME}
{Template_Linux:net.tcp.dnsspeed.last(0)}>5000
#!/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}
@Janis
Can anybody help with NET.TCP.DNS key. I have problems with basic understanding of nslookup key at this point of view. Firstly question I want to use this key for testing if the DNS server is responable, but on which host I have to put this on? On nameserver or on different host which will test the nameserver working condition?
Sorry for the stupid question.
You can use net.tcp.dns[<ip>,zone] on any server. The <ip> adres is the adres of the nameserver that you would like to resolv with, the zone is the zone name that you want to check.
So, for instance, to check if google.com will resolve on a local dns server do:
net.tcp.dns[127.0.0.1,google.com]
For checking if a remote DNS server will resolve zabbix.com:
net.tcp.dns[ip.of.isp.dns,zabbix.com]