[Smaug] DNS-checking cronjob script

Rick Moen rick at linuxmafia.com
Wed May 18 13:31:52 PDT 2011


I've revised that weekly prototype cronjob.  Again, volunteers are
welcome to step forward and say 'Gee, that's a really good idea.  I'll
run a Smaug-customised version of that, as a weekly cronjob on my
own machine, to help keep an eye on Smaug's DNS functionality, going
forward.'  (Also, clue:  You can also volunteer to _receive_ the weekly 
e-mailed report, and help that way instead.  The script can send to any
number of recipients.)



The cronjob now sends this slightly expanded e-mail:


Date: Wed, 18 May 2011 13:25:00 -0700
From: root <root at linuxmafia.com>
To: rick at linuxmafia.com
Subject: Domain linuxmafia.com SOA check

2010062201 on ns.primate.net, which is Aaron T. Porter
2010062201 on ns.tx.primate.net, which is Aaron T. Porter
2010062201 on ns3.linuxmafia.com, which is David Wolfskill, ns.catwhisker.org   
2010062201 on ns1.thecoop.net, which is Drew Bertola
2010062201 on ns1.linuxmafia.com, which is Rick Moen


/etc/cron.weekly/mydomains is now as follows.  Copy and adapt freely.



#!/bin/sh

# mydomains     Cron script to sanity-check my domain's SOA records at
#               all of its authoritative nameservers, as a quick and 
#               dirty way of making sure (1) they're all online and
#               (2) they're all serving up the same data (or at least
#               data with the same zonefile serial number).
#  
#               The script queries all five nameservers for their current
#               SOA value (for linuxmafia.com), and then uses awk to parse 
#               out of that verbose record just the S/N field, which is 
#               field #3.  The point is that you can visually spot offline 
#               or aberrant nameservers by their S/Ns being (respectively) 
#               missing or an out-of-step value.
#
#		Written by Rick Moen (rick at linuxmafia.com)
#		$Id: cron.weekly,v 1.02 2009/11/17 17:04:05 rick
# Copyright (C) Rick Moen, 2009.  Do anything you want with this work.

set -o errexit  #aka "set -e": exit if any line returns non-true value
set -o nounset  #aka "set -u": exit upon finding an uninitialised variable

test -x /usr/bin/mail || exit 0

{
dig -t soa linuxmafia.com. @NS.PRIMATE.NET. +short | awk '{ print $3 " on ns.primate.net, which is Aaron T. Porter" }'
dig -t soa linuxmafia.com. @NS.TX.PRIMATE.NET. +short | awk '{ print $3 " on ns.tx.primate.net, which is Aaron T. Porter" }'
dig -t soa linuxmafia.com. @NS3.LINUXMAFIA.COM. +short | awk '{ print $3 " on ns3.linuxmafia.com, which is David Wolfskill, ns.catwhisker.org" }'
dig -t soa linuxmafia.com. @NS1.THECOOP.NET. +short | awk '{ print $3 " on ns1.thecoop.net, which is Drew Bertola"}'
dig -t soa linuxmafia.com. @NS1.LINUXMAFIA.COM. +short | awk '{ print $3 " on ns1.linuxmafia.com, which is Rick Moen"}'
} |
/usr/bin/mail -s "Domain linuxmafia.com SOA check" rick at linuxmafia.com




More information about the Smaug mailing list