#!/bin/sh OFFSET=2012052000 if [ ! $1 ]; then echo "SOA: Warning - No remote host specified" exit 3 fi getSerial() { #dig +short soa $1 @$2 | awk '{ print $3 }' | tail -n 1 host -W 1 -t soa $1 $2 2>/dev/null | awk '/SOA/ {print $7}' } local=`getSerial "wleiden.net" localhost` remote=`getSerial wleiden.net $1` # Get errors or timeouts if [ "$remote" = "timed" ]; then echo "DNS timed out" exit 3 fi perf=`expr $remote - $OFFSET` diff=`expr $local - $remote` if [ "$local" = "$remote" ]; then echo "SOA: OK (Serial: $local) | soa=$perf" exit 0 elif [ $diff -lt 100 ]; then echo "SOA: WARNING - Serial difference within day ($diff) (r:$remote/$local) | soa=$perf" exit 1 else echo "SOA: ERROR - Serial difference (r:$remote/l:$local) | soa=$perf" exit 2 fi