Xymon Mailing List Archive search

how to get dnsreg to work .. ?

4 messages in this thread

list Meepmeep @ Fantasya.org · Sun, 28 Feb 2010 16:46:58 +0100 ·
Hi

I tried to get dnsreg script working, and it's a complete failure ..
Here what's I've done so far :

1/ Creating dnsreg script in server/ext/dnsreg (the one from xymon.com, with
a little modification).
My version :

#!/bin/sh

# Check DNS registrations in whois and warn when they are about to expire.
#
# NOTE: Requires a "whois" command that knows what servers to query.
#       Requires GNU date.
#       Should run only once a day.

BBHTAG=dnsreg
COLUMN=$BBHTAG
NOW=`date "+%s"`
WARNTIME=`expr $NOW + 864000`        # 10 days
ALARMTIME=`expr $NOW + 432000`       # 5 day

/home/xmon/server/bin/bbhostgrep dnsreg | while read L
do
      set $L
      DOMAIN=$1

      EXPIRESTRING="`whois $DOMAIN | egrep -i
"Expires.*:|Expiration.*:|Renewal.*:" | head -n 1 | cut -d: -f2 | sed
-e's/^[     ]*//' | cut -f1 -d' '`"
      EXPIRES=`date --date="$EXPIRESTRING" "+%s"`

      if test $EXPIRES -le $ALARMTIME
      then
         COLOR=red
      elif test $EXPIRES -le $WARNTIME
      then
         COLOR=yellow
      else
         COLOR=green
      fi

      $BB $BBDISP "status+12h $DOMAIN.dnsreg $COLOR `date`

Domain $DOMAIN expires on $EXPIRESTRING
"
done

exit 0


2/ Modify "server/etc/hobbitlaunch.cfg" to add :

[dnsreg]
        ENVFILE /home/xmon/server/etc/hobbitserver.cfg
        CMD /home/xmon/server/ext/dnsreg
        LOGFILE $BBSERVERLOGS/bb-dnsreg.log
        INTERVAL 5m

3/ Modify bb-hosts to add domain with dnsreg test:

group-compress <font size="+1">Servers</font>
...
[My classic test, working great]
...

groupe-compress <font size="+1">Domains</font>
0.0.0.0 firstdomain.tld    # noconn dnsreg
0.0.0.0 second.tld        # noconn dnsreg
0.0.0.0 etc.tld        # noconn dnsreg
0.0.0.0 etcetc.tld     # noconn dnsreg

Log is still empty, I try to restart/reload hobbit.sh. Nothing show on the
website concerning the "Domains" (all others tests are still showing).
Moreover, I would like to test the script on a standalone way, but I haven't
found the way to do it (like using hobbitd_alert --test)

I'm using xymon 4.3.0.0beta2 on debian, and all other tests are working
great :)

--
Nicolas G. / meepmeep
list Meepmeep @ Fantasya.org · Sun, 28 Feb 2010 17:31:03 +0100 ·
Hi

I tried to get dnsreg script working, and it's a complete failure ..
Here what's I've done so far :

1/ Creating dnsreg script in server/ext/dnsreg (the one from xymon.com, with
a little modification).
My version :

#!/bin/sh

# Check DNS registrations in whois and warn when they are about to expire.
#
# NOTE: Requires a "whois" command that knows what servers to query.
#       Requires GNU date.
#       Should run only once a day.

BBHTAG=dnsreg
COLUMN=$BBHTAG
NOW=`date "+%s"`
WARNTIME=`expr $NOW + 864000`        # 10 days
ALARMTIME=`expr $NOW + 432000`       # 5 day

/home/xmon/server/bin/bbhostgrep dnsreg | while read L
do
      set $L
      DOMAIN=$1

      EXPIRESTRING="`whois $DOMAIN | egrep -i
"Expires.*:|Expiration.*:|Renewal.*:" | head -n 1 | cut -d: -f2 | sed
-e's/^[     ]*//' | cut -f1 -d' '`"
      EXPIRES=`date --date="$EXPIRESTRING" "+%s"`

      if test $EXPIRES -le $ALARMTIME
      then
         COLOR=red
      elif test $EXPIRES -le $WARNTIME
      then
         COLOR=yellow
      else
         COLOR=green
      fi

      $BB $BBDISP "status+12h $DOMAIN.dnsreg $COLOR `date`

Domain $DOMAIN expires on $EXPIRESTRING
"
done

exit 0


2/ Modify "server/etc/hobbitlaunch.cfg" to add :

[dnsreg]
        ENVFILE /home/xmon/server/etc/hobbitserver.cfg
        CMD /home/xmon/server/ext/dnsreg
        LOGFILE $BBSERVERLOGS/bb-dnsreg.log
        INTERVAL 5m

3/ Modify bb-hosts to add domain with dnsreg test:

group-compress <font size="+1">Servers</font>
...
[My classic test, working great]
...

groupe-compress <font size="+1">Domains</font>
0.0.0.0 firstdomain.tld    # noconn dnsreg
0.0.0.0 second.tld        # noconn dnsreg
0.0.0.0 etc.tld        # noconn dnsreg
0.0.0.0 etcetc.tld     # noconn dnsreg

Log is still empty, I try to restart/reload hobbit.sh. Nothing show on the
website concerning the "Domains" (all others tests are still showing).
Moreover, I would like to test the script on a standalone way, but I haven't
found the way to do it (like using hobbitd_alert --test)

I'm using xymon 4.3.0.0beta2 on debian, and all other tests are working
great :)

--
Nicolas G. / meepmeep
list Ralph Mitchell · Sun, 28 Feb 2010 13:08:10 -0500 ·
I see a couple of things that could be wrong.  Possibly you should be doing
"DOMAIN=$2" in the loop??  $1 is the ip address, $2 is the fully-qualified
hostname.  It seemed to work just fine when I replaced the bbhostgrep line
with

     echo "yahoo.com" | while read L

Definitely you should be converting the dots in $DOMAIN to commas.  See the
second paragraph under "XYMON MESSAGE SYNTAX" in the bb.1 manpage.  This
would do it:

   DOM=`echo $DOMAIN | sed -e 's/\./,/g'`
   echo $BB $BBDISP "status+12h $DOM.dnsreg $COLOR `date`

You can test your script using bbcmd:

   server/bin/bbcmd  server/ext/dnsreg

That kicks off the script with the same environment that Xymon gives it.
 You probably want to put a  'set -x' in at the top, to see everything
that's going on.  I generally put an "echo" in front of the $BB line when
testing, to minimize the amount of bogus reports going to the server.

Ralph Mitchell


On Sun, Feb 28, 2010 at 11:31 AM, meepmeep @ Fantasya.org <
quoted from Meepmeep @ Fantasya.org
user-f4966cdc0ebb@xymon.invalid> wrote:
Hi

I tried to get dnsreg script working, and it's a complete failure ..
Here what's I've done so far :

1/ Creating dnsreg script in server/ext/dnsreg (the one from xymon.com,
with a little modification).
My version :

#!/bin/sh

# Check DNS registrations in whois and warn when they are about to expire.
#
# NOTE: Requires a "whois" command that knows what servers to query.
#       Requires GNU date.
#       Should run only once a day.

BBHTAG=dnsreg
COLUMN=$BBHTAG
NOW=`date "+%s"`
WARNTIME=`expr $NOW + 864000`        # 10 days
ALARMTIME=`expr $NOW + 432000`       # 5 day

/home/xmon/server/bin/bbhostgrep dnsreg | while read L
do
      set $L
      DOMAIN=$1

      EXPIRESTRING="`whois $DOMAIN | egrep -i
"Expires.*:|Expiration.*:|Renewal.*:" | head -n 1 | cut -d: -f2 | sed
-e's/^[     ]*//' | cut -f1 -d' '`"
      EXPIRES=`date --date="$EXPIRESTRING" "+%s"`

      if test $EXPIRES -le $ALARMTIME
      then
         COLOR=red
      elif test $EXPIRES -le $WARNTIME
      then
         COLOR=yellow
      else
         COLOR=green
      fi

      $BB $BBDISP "status+12h $DOMAIN.dnsreg $COLOR `date`

Domain $DOMAIN expires on $EXPIRESTRING
"
done

exit 0


2/ Modify "server/etc/hobbitlaunch.cfg" to add :

[dnsreg]
        ENVFILE /home/xmon/server/etc/hobbitserver.cfg
        CMD /home/xmon/server/ext/dnsreg
        LOGFILE $BBSERVERLOGS/bb-dnsreg.log
        INTERVAL 5m

3/ Modify bb-hosts to add domain with dnsreg test:

group-compress <font size="+1">Servers</font>
...
[My classic test, working great]
...

groupe-compress <font size="+1">Domains</font>
0.0.0.0 firstdomain.tld    # noconn dnsreg
0.0.0.0 second.tld        # noconn dnsreg
0.0.0.0 etc.tld        # noconn dnsreg
0.0.0.0 etcetc.tld     # noconn dnsreg

Log is still empty, I try to restart/reload hobbit.sh. Nothing show on the
website concerning the "Domains" (all others tests are still showing).
Moreover, I would like to test the script on a standalone way, but I
haven't found the way to do it (like using hobbitd_alert --test)

I'm using xymon 4.3.0.0beta2 on debian, and all other tests are working
great :)

--
Nicolas G. / meepmeep

list Meepmeep @ Fantasya.org · Mon, 1 Mar 2010 10:19:10 +0100 ·
Thank you, it works great :)

--
Nicolas G. / meepmeep
quoted from Ralph Mitchell


On Sun, Feb 28, 2010 at 7:08 PM, Ralph Mitchell <user-00a5e44c48c0@xymon.invalid>wrote:
I see a couple of things that could be wrong.  Possibly you should be doing
"DOMAIN=$2" in the loop??  $1 is the ip address, $2 is the fully-qualified
hostname.  It seemed to work just fine when I replaced the bbhostgrep line
with

     echo "yahoo.com" | while read L

Definitely you should be converting the dots in $DOMAIN to commas.  See the
second paragraph under "XYMON MESSAGE SYNTAX" in the bb.1 manpage.  This
would do it:

   DOM=`echo $DOMAIN | sed -e 's/\./,/g'`
   echo $BB $BBDISP "status+12h $DOM.dnsreg $COLOR `date`

You can test your script using bbcmd:

   server/bin/bbcmd  server/ext/dnsreg

That kicks off the script with the same environment that Xymon gives it.
 You probably want to put a  'set -x' in at the top, to see everything
that's going on.  I generally put an "echo" in front of the $BB line when
testing, to minimize the amount of bogus reports going to the server.

Ralph Mitchell