Ad Widget

Collapse

bind9 statistics: statistics-channels

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • fisher
    Junior Member
    • Oct 2008
    • 27

    #1

    bind9 statistics: statistics-channels

    I recently added a bind9 monitoring way I have not seen before. Starting from 9.5(?) you can create a statistics channel in bind:

    statistics-channels {
    [ inet ( ip_addr | * ) [ port ip_port ] [allow { address_match_list } ]; ]
    [ inet ...; ]
    };


    It creates a http server and outputs nothing but an xml file. For example to get the bind9 memory allocation (channel bound to localhost:8099):

    wget --quiet --output-document=- http://127.0.0.1:8099|grep TotalUse | sed -e 's/<[^>]*>//g')


    Now it is easy to add to the zabbix-agentd.conf and put into the monitoring process.

    I use the "xml2" package to convert the xml format to text, but php or perl experts probably can develop much better solutions.
  • fisher
    Junior Member
    • Oct 2008
    • 27

    #2
    The default config for bind is (/etc/bind9/named.conf.local):

    statistics-channels {
    inet 127.0.0.1 port 8053 allow { 127.0.0.1; };
    };

    Zabbix agentd config:

    UserParameter=bind9.queries,/usr/local/bind9getstats/bin/bind9getqueries.sh
    UserParameter=bind9.memuse,/usr/local/bind9getstats/bin/bind9memuse.sh

    The scripts are in a svn repo:
    cd /usr/local && svn co http://svn.fisher.hu/bind9getstats

    The usernameass is guest:guest

    I attached a exported template. I believe all of these workin. At least for me
    Attached Files

    Comment

    • Frederico
      Junior Member
      • Jun 2010
      • 9

      #3
      bind9memuse.sh Unit

      the script bind9memuse.sh returns in Kbytes the use of memory ?? what is the unit ?

      tanks

      Comment

      • fisher
        Junior Member
        • Oct 2008
        • 27

        #4
        Regarding my experiences it returns the allocated memory in bytes.

        Comment

        • nated
          Junior Member
          • Apr 2009
          • 5

          #5
          Thanks for the info. I ended up doing this with some custom UserParameters that are similar to that script.

          zabbix_agentd.conf:

          UserParameter=bind.queries.in[*],curl http://localhost:8053/ 2>/dev/null | xml2 | grep -A1 "/isc/bind/statistics/server/queries-in/rdtype/name=$1$" | tail -1 | cut -d= -f2
          UserParameter=bind.queries.out[*],curl http://localhost:8053/ 2>/dev/null | xml2 | grep -A1 "/isc/bind/statistics/views/view/rdtype/name=$1$" | tail -1 | cut -d= -f2

          Then setup item keys like:

          bind.queries.in[A]
          bind.queries.in[PTR]
          bind.queries.out[A]

          etc.
          Last edited by nated; 16-03-2011, 17:41.

          Comment

          • aigars
            Member
            • Apr 2010
            • 55

            #6
            I'm using bind 9.7.3 and this script "bind9getqueries.sh" constantly returning zero results. Sorry, but I'm dummy with linux systems.

            Comment

            • aigars
              Member
              • Apr 2010
              • 55

              #7
              Stupid! Forgot to install xml2 libraries.

              Comment

              • Ori0n
                Member
                • Dec 2010
                • 35

                #8
                Old thread, I know....

                I wrote a couple of bash one-liners that don't require xml2

                This one is for per-zone statistics and expects variable 1 = domain and variable 2 = stat type (QrySuccess, QryNXDOMAIN, etc):
                Code:
                UserParameter=bind.stat[*],curl -s http://localhost:8053 | sed -e '/>$1/,/\/counters/!d' | sed -e 's/ //g' | grep '<$2>' | sed -e 's/.*>\(.*\)<.*/\1/'
                This one is for total query stats per record type and expects variable 1 = stat type (A, AAAA or PTR):
                Code:
                UserParameter=bind.stat.queriesin[*],curl -s http://localhost:8053 |  sed -e '/<queries-in>/,/<\/queries-in>/!d' | grep -A1 '<name>$1</name>' | tail -1 | sed -e 's/ //g' | sed -e 's/.*>\(.*\)<.*/\1/'

                Comment

                • fisher
                  Junior Member
                  • Oct 2008
                  • 27

                  #9
                  Thank you
                  \o/

                  Comment

                  • fisher
                    Junior Member
                    • Oct 2008
                    • 27

                    #10
                    Recently I had to use the following line (bind 9.7):

                    $1: domain
                    $2: qry type like A, PTR, MX, AAAA, etc.

                    UserParameter=bind.stat[*],curl -s http://localhost:8053 | sed -e '/>$1/,/\/resstat/!d' -e '/>$2</,/\/counter/!d' -e 's/<[^>]*>//g' -e '1,1 d'

                    Comment

                    • fisher
                      Junior Member
                      • Oct 2008
                      • 27

                      #11
                      ATM it looks there is no per domain stast available. I keep researching if the stats format is changed or what.

                      Comment

                      • fisher
                        Junior Member
                        • Oct 2008
                        • 27

                        #12
                        I have updated the oneliner:

                        UserParameter=bind.stat[*],curl -s http://localhost:8053 | sed -e '/>$1/,/\/counters/!d' -e /$2/\!d -e 's/.*>\([0-9]*\)<.*/\1/g'


                        It is one sed no grep or else.

                        Comment

                        Working...