Ad Widget

Collapse

dns checking [named]

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • frater
    Senior Member
    • Oct 2010
    • 340

    #16
    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:
    Code:
    DNS resolve speed
    net.tcp.dnsspeed
    Numeric (unsigned)
    Interval 60
    Trigger:
    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}
    Last edited by frater; 19-01-2011, 17:23.
    Zabbix agents on Linux, FreeBSD, Windows, AVM-Fritz!box, DD-WRT and QNAP

    Comment

    • qix
      Senior Member
      Zabbix Certified SpecialistZabbix Certified Professional
      • Oct 2006
      • 423

      #17
      @Janis

      Originally posted by janis.orlovs
      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:
      Code:
      net.tcp.dns[127.0.0.1,google.com]
      For checking if a remote DNS server will resolve zabbix.com:
      Code:
      net.tcp.dns[ip.of.isp.dns,zabbix.com]
      With kind regards,

      Raymond

      Comment


      • doctorbal82
        doctorbal82 commented
        Editing a comment
        Fantastic! I was going to build a script for this but Zabbix already has the supported item type. Thanks for making this clear!
    • Rudlafik
      Senior Member
      • Nov 2018
      • 144

      #18
      Now: net.dns.record[<ip>,name,<type>,<timeout>,<count>,<protocol>]

      Comment

      Working...