Monitor Domain Expiration with Xymon
Usage: To check domain expiration and notify owner.
Create a file name dnsreg in /home/xymon/server/ext/dnsreg
#!/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.*:|expir.*date:" | 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 $BB $BBDISP "status+90000 $DOMAIN.dnsreg $COLOR `date` Domain $DOMAIN expires on $EXPIRESTRING " done exit 0
Save it and quit.
Check /home/xymon/server/ext/dnsreg permission
permission should be -rwxrwxr-x 1 xymon apache 920 Apr 11 16:30 dnsreg
Add dnsreg task in /home/xymon/server/etc/tasks.cfg
[dnsreg] ENVFILE /home/xymon/server/etc/xymonserver.cfg NEEDS xymond CMD $XYMONHOME/ext/dnsreg LOGFILE $XYMONSERVERLOGS/dnsreg.log INTERVAL 1d
Save and quit.
Add domain to check in /home/xymon/server/etc/hosts.cfg
page Domain Domain title Domain EXP CHECK group linuxscritpshub 0.0.0.0 linuxscriptshub.com # noconn dnsreg
Save and quit.
and restart your xymon server.
Now you can see your xymon page have dnsreg function.