Didn't get proper output of check_bind9_stats_new.sh

Support forum for Nagios Core, Nagios Plugins, NCPA, NRPE, NSCA, NDOUtils and more. Engage with the community of users including those using the open source solutions.
shamimreza
Posts: 6
Joined: Thu Sep 03, 2015 5:18 am

Didn't get proper output of check_bind9_stats_new.sh

Post by shamimreza »

Hi there.

I want to check DNS service queries on my Nagios Monitoring system...
So that as per official tutorials i have deployed the server, clients and also configure the agent on the client machine...

by-default plugin "check_dns" is working but new plugin for BIND 9.10 "check_bind9_stats_new.sh" is given the below output...

===================================================================================================================
[root@auth plugins]# ./check_bind9_stats_new.sh -H localhost

syntax error at line 1, column 0, byte 0 at /usr/lib64/perl5/XML/Parser.pm line 187 at /usr/bin/xml_grep line 167
syntax error at line 1, column 0, byte 0 at /usr/lib64/perl5/XML/Parser.pm line 187 at /usr/bin/xml_grep line 167
syntax error at line 1, column 0, byte 0 at /usr/lib64/perl5/XML/Parser.pm line 187 at /usr/bin/xml_grep line 167
syntax error at line 1, column 0, byte 0 at /usr/lib64/perl5/XML/Parser.pm line 187 at /usr/bin/xml_grep line 167
syntax error at line 1, column 0, byte 0 at /usr/lib64/perl5/XML/Parser.pm line 187 at /usr/bin/xml_grep line 167
syntax error at line 1, column 0, byte 0 at /usr/lib64/perl5/XML/Parser.pm line 187 at /usr/bin/xml_grep line 167
syntax error at line 1, column 0, byte 0 at /usr/lib64/perl5/XML/Parser.pm line 187 at /usr/bin/xml_grep line 167

OK: Bind 9 Stats Collected | total_queries=c QryRTT_10=c QryRTT_100=c QryRTT_500=c QryRTT_800=c QryRTT_1600=c QryRTT_Over1600=c
====================================================================================================================

for more information below is the scripts details of the plugin...

==================================================================================================

Code: Select all

#!/bin/bash
#set -xv
: '
Script to fetch server(xml) statistics from Bind 9.10(and above?) servers
No WARNING or CRITICAL thresholds, only for perfdata.
Requires curl and xml_grep
Also requires this config in Bind(change x.x.x.x to "Nagios" src IP:
statistics-channels {
   inet * port 8080 allow { 192.168.0.5; 127.0.0.1; };
};
'

# Nagios return codes
STATE_OK=0
STATE_WARNING=1
STATE_CRITICAL=2
STATE_UNKNOWN=3
TIMEOUT=20

# Plugin variable description
PROGRAMDESCRIPTION="Check Bind9 Statistics(new format)"
PROGNAME=$(basename $0)
RELEASE="Revision 0.1"
AUTHOR="bjorn@frostberg.net"

# Functions plugin usage
print_release() {
    echo "$RELEASE $AUTHOR"
}

print_usage() {
        echo ""
        echo "$PROGNAME $RELEASE - $PROGRAMDESCRIPTION"
        echo ""
echo "Usage: $PROGNAME [-H | --hostaddress ]"
        echo ""
        echo "    -h  Show this page"
        echo "    -H  Host address"
  echo ""
}

print_help() {
                print_usage
        echo ""
        print_release $PROGNAME $RELEASE
        echo ""
        echo ""
                exit 0
}

# Make sure the correct number of command line arguments have been supplied
if [ $# -lt 1 ]; then
    print_usage
    exit $STATE_UNKNOWN
fi

# Grab the command line arguments
while [ $# -gt 0 ]; do
    case "$1" in
        -h | --help)
            print_help
            exit $STATE_OK
            ;;
        -H | --hostaddress)
                shift
                HOSTADDRESS=$1
                ;;
        *)  echo "Unknown argument: $1"
            print_usage
            exit $STATE_UNKNOWN
            ;;
        esac
shift
done
RESULT=`curl -S http://$HOSTADDRESS:8080/xml/v3/server --max-time $TIMEOUT 2>/dev/null`
QUERIES=`echo "$RESULT" | xml_grep '*[@type="qtype"]' 2>/dev/null | grep "counter name" | sed 's/</\"/g' | sed 's/>/\"/g'`
OUT_QUERIES=`echo "$RESULT" | xml_grep '*[@type="resqtype"]' 2>/dev/null | grep "counter name" | sed 's/</\"/g' | sed 's/>/\"/g'`
QryRTT10=`echo "$RESULT" | xml_grep -t '*[@name="QryRTT10"]' | head -1`
QryRTT100=`echo "$RESULT" | xml_grep -t '*[@name="QryRTT100"]' | head -1`
QryRTT500=`echo "$RESULT" | xml_grep -t '*[@name="QryRTT500"]' | head -1`
QryRTT800=`echo "$RESULT" | xml_grep -t '*[@name="QryRTT800"]' | head -1`
QryRTT1600=`echo "$RESULT" | xml_grep -t '*[@name="QryRTT1600"]' | head -1`
QryRTTOver1600=`echo "$RESULT" | xml_grep -t '*[@name="QryRTT1600+"]' | head -1`
TOTAL_QUERIES=`echo "$RESULT" | xml_grep -t '*[@name="QUERY"]' | head -1`

if [ -z "$RESULT" ]
then
        "Stats collection failed"
        exit $STATE_UNKNOWN
fi

echo -n "OK: Bind 9 Stats Collected | "
echo -n "total_queries=$TOTAL_QUERIES""c "

IFS=$'\n'
for line in `echo "$QUERIES"`
do
        IFS=$'\"' read ignore ingore TYPE ignore COUNTER ignore ignore ignore value <<< "$line"
        echo "query_$TYPE=$COUNTER""c " | tr -d '\n'
done
for line in `echo "$OUT_QUERIES"`
do
        IFS=$'\"' read ignore ingore TYPE ignore COUNTER ignore ignore ignore value <<< "$line"
        echo "query-out_$TYPE=$COUNTER""c " | tr -d '\n'
done
echo -n "QryRTT_10=$QryRTT10""c QryRTT_100=$QryRTT100""c QryRTT_500=$QryRTT500""c QryRTT_800=$QryRTT800""c QryRTT_1600=$QryRTT1600""c QryRTT_Over1600=$QryRTTOver1600""c"
echo
exit $STATE_OK
================================================================================================================================

Already searched Google but didnt get any solution, hints to solve the problem, out there.

It would be great to have some help....

Thanks in advance...
Last edited by shamimreza on Tue Sep 08, 2015 12:55 pm, edited 2 times in total.
jolson
Attack Rabbit
Posts: 2560
Joined: Thu Feb 12, 2015 12:40 pm

Re: Didn't get proper output of check_bind9_stats_new.sh

Post by jolson »

You'll need to install a perl module that will allow you to run the xml_grep command:

Code: Select all

yum install perl-XML-Twig
After installing the perl module, attempt to re-run the check command.
Twits Blog
Show me a man who lives alone and has a perpetually clean kitchen, and 8 times out of 9 I'll show you a man with detestable spiritual qualities.
shamimreza
Posts: 6
Joined: Thu Sep 03, 2015 5:18 am

Re: Didn't get proper output of check_bind9_stats_new.sh

Post by shamimreza »

Sorry for late reply...
"perl-XML-Twig" package has already been installed and the problem is same....
tmcdonald
Posts: 9117
Joined: Mon Sep 23, 2013 8:40 am

Re: Didn't get proper output of check_bind9_stats_new.sh

Post by tmcdonald »

Please run the plugins as the nagios user from the command line like so:

Code: Select all

su nagios
bash +x /usr/local/nagios/libexec/check_bind9_stats_new.sh > /tmp/output.txt
and send us the /tmp/output.txt file.
Former Nagios employee
shamimreza
Posts: 6
Joined: Thu Sep 03, 2015 5:18 am

Re: Didn't get proper output of check_bind9_stats_new.sh

Post by shamimreza »

thanks for you guys response....
but may be i need to stop to use this plugins... cause the output is same as before...

# su nagios
# bash +x /usr/lib64/nagios/plugins/check_bind9_stats_new.sh > /tmp/output.txt
# vim /tmp/output.txt
OK: Bind 9 Stats Collected | total_queries=c QryRTT_10=c QryRTT_100=c QryRTT_500=c QryRTT_800=c QryRTT_1600=c QryRTT_Over1600=c
tmcdonald
Posts: 9117
Joined: Mon Sep 23, 2013 8:40 am

Re: Didn't get proper output of check_bind9_stats_new.sh

Post by tmcdonald »

Sorry, I was one key off and missed a few others in my command. The correct command is:

bash -x /usr/local/nagios/libexec/check_bind9_stats_new.sh > /tmp/output.txt 2>&1

Sorry for the mixup.
Former Nagios employee
shamimreza
Posts: 6
Joined: Thu Sep 03, 2015 5:18 am

Re: Didn't get proper output of check_bind9_stats_new.sh

Post by shamimreza »

Its OK... and thanks for your help...

but the output is same as before .. no change at all.. :(
tmcdonald
Posts: 9117
Joined: Mon Sep 23, 2013 8:40 am

Re: Didn't get proper output of check_bind9_stats_new.sh

Post by tmcdonald »

There should definitely be something in that output file now, we're interested in that and not just the final output.
Former Nagios employee
shamimreza
Posts: 6
Joined: Thu Sep 03, 2015 5:18 am

Re: Didn't get proper output of check_bind9_stats_new.sh

Post by shamimreza »

As per your instruction i was expecting so... but here is the output ->

syntax error at line 1, column 0, byte 0 at /usr/lib64/perl5/XML/Parser.pm line 187 at /usr/bin/xml_grep line 167
syntax error at line 1, column 0, byte 0 at /usr/lib64/perl5/XML/Parser.pm line 187 at /usr/bin/xml_grep line 167
syntax error at line 1, column 0, byte 0 at /usr/lib64/perl5/XML/Parser.pm line 187 at /usr/bin/xml_grep line 167
syntax error at line 1, column 0, byte 0 at /usr/lib64/perl5/XML/Parser.pm line 187 at /usr/bin/xml_grep line 167
syntax error at line 1, column 0, byte 0 at /usr/lib64/perl5/XML/Parser.pm line 187 at /usr/bin/xml_grep line 167
syntax error at line 1, column 0, byte 0 at /usr/lib64/perl5/XML/Parser.pm line 187 at /usr/bin/xml_grep line 167
syntax error at line 1, column 0, byte 0 at /usr/lib64/perl5/XML/Parser.pm line 187 at /usr/bin/xml_grep line 167
OK: Bind 9 Stats Collected | total_queries=c QryRTT_10=c QryRTT_100=c QryRTT_500=c QryRTT_800=c QryRTT_1600=c QryRTT_Over1600=c

I didnt understand why there isnt any log or something, from which it can be find-out the problem to troubleshoot...

I have never face this sort of situation before.. :( and now i m thinking not to use this plugin and gonna search for new one... !!!
tmcdonald
Posts: 9117
Joined: Mon Sep 23, 2013 8:40 am

Re: Didn't get proper output of check_bind9_stats_new.sh

Post by tmcdonald »

We can certainly help troubleshoot this one, but if you are going to search for another anyway can we close up this thread and have you open another for the new plugin if needed?
Former Nagios employee
Locked