[Xymon] dnsreg script question

J.C. Cleaver cleaver at terabithia.org
Tue Mar 24 21:09:48 CET 2015


On Tue, March 24, 2015 11:50 am, John Tullis wrote:
> Apologies for resurrecting an old thread.
>
> I added the sleep to the command because I'm running bbcmd on a few
> hundred domains. The script failed to run and I'm not sure why.
>
> My other issue is that there are a few domains that I want to run
> individually instead of it running the script on all the domains. Is there
> a way to kick off a test for a single host?
> I tried using "bbcmd hobbitd_alert --test domain.com dnsreg" but that only
> told me what alert rules applied to this but didn't update anything. Is
> there some command where I can tell a specific domain to do a fresh
> dnsreg?
>
> John Tullis
>

John,

There's no direct way to tell xymon to "re-run" a test, primarily because
there's no central scheduling/dispatch mechanism. (In the parlance of some
other monitoring systems, everything is a 'passive test'.)

In this case, the script is running 'xymongrep dnsreg' and looping over
the results, so if you wanted to hack a single host run out of this you'd
want to edit that line to read something like this instead:

> /home/xymon/server/bin/xymongrep dnsreg | grep domain.com | while read L

Save a copy, then run it as you had before: bbcmd /path/to/your/dnsreg/script

Running xymond_alert that way is unnecessary since, as you discovered,
that simply runs a test against the alerting config :)

A key point is that running the original script is sufficient to send a
xymon message back in to your system, regardless if it's running against
your entire config file or just a single server. As long as the rest of
your system is up, xymond will receive the message and send it off to
xymond_alert just like normal.



(Side note: Given how common xymongrep usage is in server-side scripts,
this is something that might be helped by allowing an environment variable
override to force an additional filter to be applied. It probably wouldn't
be too difficult to put in, and it would make "one-off" runs of server
scripts using that template much easier.)


Hope this helps!

-jc



> ________________________________
>
>
> Ok let me tweak it around. What does this line do anyhow? I keep seeing
>
> that pop up and then the error about command being not found
>
>
>
> thanks
>
>
>
>
>
>
>
> "status+90000 $DOMAIN.dnsreg $COLOR `date`
>
>
>
> From: Dugan, Darin D [EIT] [mailto:dddugan at
> iastate.edu<http://lists.xymon.com/mailman/listinfo/xymon>]
>
> Sent: Friday, September 21, 2012 10:50 AM
>
> To: Russell Blumenthal; xymon at
> xymon.com<http://lists.xymon.com/mailman/listinfo/xymon>
>
> Subject: RE: dnsreg script question
>
>
>
>
>
>
>
> Rereading your message, it seems perhaps $XYMON or $XYMDISP are not
>
> populated. Are you running this under xymoncmd to set the environment? I
>
> run from cron daily with:
>
>
>
>
>
>
>
> /home/xymon/server/bin/xymoncmd
>
> --env=/home/xymon/server/etc/xymonserver.cfg
>
> /home/xymon/server/ext/dnsreg
>
>
>
>
>
>
>
> A few other differences in my script:
>
>
>
> 1.       I'm using $XYMSRV instead of $XYMDISP. Hmm...I don't have a
>
> $XYMDISP anywhere, maybe $BBDISP wasn't updated to $XYMSRV properly?
>
>
>
> 2.       Added a "sleep 60" command before "done". Whois seems to get
>
> angry with me if I query a bunch of domains in quick succession.
>
>
>
> 3.       Had to modify the sed commands for EXPIRESTRING:
>
> EXPIRESTRING="`whois $DOMAIN | egrep -i
>
> "Expires.*:|Expiration.*:|Renewal.*:" | head -n 1 | cut -d: -f2 | sed
>
> -e's/^\s*//' | sed -e's/\s.*//'`"
>
>
>
>
>
>
>
> Cheers.
>
>
>
>
>
>
>
> From: Russell Blumenthal [mailto:rblumenthal at
> telmar.com<http://lists.xymon.com/mailman/listinfo/xymon>]
>
> Sent: Friday, September 21, 2012 8:09 AM
>
> To: Dugan, Darin D [EIT]; xymon at
> xymon.com<http://lists.xymon.com/mailman/listinfo/xymon>
>
> Subject: RE: dnsreg script question
>
>
>
>
>
>
>
> I installed  'whois' and I am able to do a manual query 'whois
>
> domain.com'. but unable to run the script manually to test it.
>
>
>
> From: Dugan, Darin D [EIT] [mailto:dddugan at
> iastate.edu<http://lists.xymon.com/mailman/listinfo/xymon>]
>
> Sent: Friday, September 21, 2012 9:05 AM
>
> To: Russell Blumenthal; xymon at
> xymon.com<http://lists.xymon.com/mailman/listinfo/xymon>
>
> Subject: RE: dnsreg script question
>
>
>
>
>
>
>
> I'm guessing you don't have 'whois' available or in the path.
>
>
>
>
>
>
>
> From: xymon-bounces at
> xymon.com<http://lists.xymon.com/mailman/listinfo/xymon>
> [mailto:xymon-bounces at
> xymon.com<http://lists.xymon.com/mailman/listinfo/xymon>] On Behalf
>
> Of Russell Blumenthal
>
> Sent: Thursday, September 20, 2012 4:30 PM
>
> To: xymon at xymon.com<http://lists.xymon.com/mailman/listinfo/xymon>
>
> Subject: [Xymon] dnsreg script question
>
>
>
>
>
>
>
> I am having an issue trying to get the dnsreg script working. I install
>
> it and all and when I go to test it I get this (I took out my domain).
>
> Any help would be appreciated.
>
>
>
>
>
>
>
> Thanks
>
>
>
>
>
>
>
>
>
>
>
> ./dnsreg.sh: line 31: status+90000 mydomain.com.dnsreg red Thu Sep 20
>
> 17:27:42 EDT 2012
>
>
>
>
>
>
>
> Domain mydomain.com expires on
>
>
>
> : command not found
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
> The script looks like this:
>
>
>
>
>
>
>
>
>
>
>
> #!/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.
>
>
>
>
>
>
>
> NOW=`date "+%s"`
>
>
>
> WARNTIME=`expr $NOW + 864000`        # 10 days
>
>
>
> ALARMTIME=`expr $NOW + 432000`       # 5 day
>
>
>
>
>
>
>
> /home/xymon/server/bin/xymongrep dnsreg | while read L
>
>
>
> do
>
>
>
>       set $L
>
>
>
>       DOMAIN=$2
>
>
>
>
>
>
>
>       EXPIRESTRING="`whois $DOMAIN | egrep -i
>
> "Expires.*:|Expiration.*:|Renewal.*:" | head -n 1 | cut -d: -f2 | sed
>
> -e's/^[     ]*//'`"
>
>
>
>       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
>
>
>
>
>
>
>
>       $XYMON $XYMDISP "status+90000 $DOMAIN.dnsreg $COLOR `date`
>
>
>
>
>
>
>
> Domain $DOMAIN expires on $EXPIRESTRING
>
>
>
> "
>
>
>
> done
>
>
>
> -------------- next part --------------
>
> An HTML attachment was scrubbed...
>
> URL:
> <http://lists.xymon.com/pipermail/xymon/attachments/20120921/592d8e9b/attachment.html>
>
> _______________________________________________
> Xymon mailing list
> Xymon at xymon.com
> http://lists.xymon.com/mailman/listinfo/xymon
>





More information about the Xymon mailing list