correction for .fr
by
Vincenth,
May 31, 2015
for the errors :
ERROR:
[: 89: XXX: unexpected operator
you have to change all tests "==" by a simple "="
tested on ubuntu 12.04
here is my correction to add .fr domains (thanks to marc.lecrosnier for his original version)
My whois return "Expiry Date" not "anniversary"
Line 86 :
elif [ ${DLTYPE} == 'fr' ];
then
TYPE=afnic
WHOIS_SERVER="whois.nic.fr"
Line : 131
# for .fr domains
elif [ $TYPE = 'afnic' ];
then
day=`cat ${FILE} | awk '/Expiry Date:/' | cut -d ':' -f2 | cut -d ' ' -f2 | cut -d '/' -f1`
month=`cat ${FILE} | awk '/Expiry Date:/' | cut -d ':' -f2 | cut -d ' ' -f2 | cut -d '/' -f2`
year=$(date +%Y)
getmonth()
{
case $month in
01) echo jan ;;
02) echo feb ;;
03) echo mar ;;
04) echo apr ;;
05) echo may ;;
06) echo jun ;;
07) echo jul ;;
08) echo aug ;;
09) echo sep ;;
10) echo oct ;;
11) echo nov ;;
12) echo dec ;;
*) echo 0 ;;
esac
}
if [ $(($(date -d "$day-$(getmonth $month)-$year" +%s)-$(date +%s))) -lt 0 ];
then
year=$(($(date +%Y)+1))
fi
expiration=$day-$(getmonth $month)-$year
add whois to plugin
by
martinp,
May 31, 2015
Superb plugin, many thanks, my little contribution for .si domains :
elif [ ${DLTYPE} == 'si' ];
then
TYPE=si
WHOIS_SERVER="whois.arnes.si"
elif [ $TYPE == 'si' ];
then
expiration=`cat ${FILE} | awk '/expire:/' | cut -d ':' -f2 | cut -d ' ' -f1`
Please let me know it this code to add is ok:
elif [ ${DLTYPE} == 'it' ];
then
TYPE=italy
WHOIS_SERVER="whois.nic.it"
.
.
.
.
elif [ $TYPE == 'italy' ];
then
day=`cat ${FILE} | awk '/Expire Date:/' | cut -d ':' -f2 | cut -d ' ' -f9 | cut -d '-' -f3`
month=`cat ${FILE} | awk '/Expire Date:/' | cut -d ':' -f2 | cut -d ' ' -f9 | cut -d '-' -f2`
year=`cat ${FILE} | awk '/Expire Date:/' | cut -d ':' -f2 | cut -d ' ' -f9 | cut -d '-' -f1`
expiration=$day-$month-$year
sometimes the server responds only with te status (without expire date), but I think it depends on how many queries per hour it receives from the same source IP.
Thank you
Help .ES domains
by
senengs,
May 31, 2014
I am looking for a tool to check .es domains and thsi one don't solve my trouble.. Somebody can help me ??
I saw it for many domains but noone for .ES
Regards !
Fix for .org domain checks failing
by
kquigley,
January 31, 2014
Since the last couple of days - the .org domain checks are failing. I fixed this with the following simple edits:
Change: (from around line 100)
elif [ $TYPE == 'pir' ];
then
expiration=`cat ${FILE} | awk '/Expiration Date:/' | cut -d ':' -f2 | cut -d ' ' -f1`
To:
elif [ $TYPE == 'pir' ];
then
#Registry Expiry Date
expiration=`cat ${FILE} | awk '/Registry Expiry Date:/' | cut -d ':' -f2`
Excellent work
here is my contribution to add .fr domains :
Line 86 :
elif [ ${DLTYPE} == 'fr' ];
then
TYPE=afnic
WHOIS_SERVER="whois.nic.fr"
Line : 131
# for .fr domains
elif [ $TYPE == 'afnic' ];
then
#expiration=`cat ${FILE} | awk '/anniversary:/' | cut -d ':' -f2 | cut -d '' -f2`
day=`cat ${FILE} | awk '/anniversary:/' | cut -d ':' -f2 | cut -d ' ' -f2 | cut -d '/' -f1`
month=`cat ${FILE} | awk '/anniversary:/' | cut -d ':' -f2 | cut -d ' ' -f2 | cut -d '/' -f2`
year=$(date +%Y)
getmonth()
{
case $month in
01) echo jan ;;
02) echo feb ;;
03) echo mar ;;
04) echo apr ;;
05) echo may ;;
06) echo jun ;;
07) echo jul ;;
08) echo aug ;;
09) echo sep ;;
10) echo oct ;;
11) echo nov ;;
12) echo dec ;;
*) echo 0 ;;
esac
}
if [ $(($(date -d "$day-$(getmonth $month)-$year" +%s)-$(date +%s))) -lt 0 ];
then
year=$(($(date +%Y)+1))
fi
expiration=$day-$(getmonth $month)-$year
Marc
For anyone having issues with co.uk or any other domains, the fix is actually quite easy.
vi the script and edit this line:
elif [ $TYPE == 'nic' ];
then
expiration=`cat ${FILE} | awk '/Expiration date:/' | cut -d ':' -f2`
Change Expiration to Expiry, so it should look like this.
elif [ $TYPE == 'nic' ];
then
expiration=`cat ${FILE} | awk '/Expiry date:/' | cut -d ':' -f2`
---------
Basically, what is occurring is that when the whois record is returned, the script is looking for the string "expiration date" which no longer exists.
And this fix works for any TLD that is not working. From the same nagios server, run a whois query: ' whois DomainName ' and see what the results turn back.
Then it is as simple as altering the check_domain script to match what is returned by whois.
Hi
I have a problem for co.uk domains.
For example:
# /usr/local/nagios/libexec/check_domain -d bbc.co.uk -c 14 -w 60
UNKNOWN - cannot retrieve expiration time
It will be greatly appreciated if someone can help.
Thanks.
Great plugin
by
Kirk,
February 28, 2013
This is working great for me. I modified the output so that the number of days is always shown last, it makes it much easier to scan down the list for me.
I also created a dummy host that loops back to the nagius server (127.0.0.1) named "Domain-Expiration-Checks" then created a custom command and service checks for each domain. This requires quite a bit more typing and configuration but it keeps the domain checks under a host and not cluttering up my top level host view in Nagios.
I highly suggest that you limits on how often your whois services check to avoid whois rate control on your nagios server. I created a once daily time frame that only checks from midnight to 12:30 then used the following values in each service to get 1 check per day per domain.
normal_check_interval 30
max_check_attempts 1
check_period once-daily
I also added support for .ms and .us domains.
then
TYPE=ms
WHOIS_SERVER="whois.nic.ms"
elif [ ${DLTYPE} == 'us' ];
then
TYPE=us
WHOIS_SERVER="whois.nic.us"
else
# for .ms domains
elif [ $TYPE == 'ms' ];
then
day=`cat ${FILE} | awk '/Registry/' | cut -d ' ' -f4 | cut -d T -f1 | cut -d '-' -f3`
month=`cat ${FILE} | awk '/Registry/' | cut -d ' ' -f4 | cut -d T -f1 | cut -d '-' -f2`
getmonth()
{
case $month in
01) echo jan ;;
02) echo feb ;;
03) echo mar ;;
04) echo apr ;;
05) echo may ;;
06) echo jun ;;
07) echo jul ;;
08) echo aug ;;
09) echo sep ;;
10) echo oct ;;
11) echo nov ;;
12) echo dec ;;
*) echo 0 ;;
esac
}
year=`cat ${FILE} | awk '/Registry/' | cut -d ' ' -f4 | cut -d T -f1 | cut -d '-' -f1`
expiration=$day-$(getmonth ${2})-$year
# for .us domains
elif [ $TYPE == 'us' ];
then
day=`cat ${FILE} | awk '/Domain Expiration Date:/' | cut -d ' ' -f27`
month=`cat ${FILE} | awk '/Domain Expiration Date:/' | cut -d ' ' -f26`
year=`cat ${FILE} | awk '/Domain Expiration Date:/' | cut -d ' ' -f30`
expiration=$day-$month-$year
Great plugin, thanks for your efforts in writing it.
Great Script!
by
dukedar,
January 31, 2013
Does anyoone know had to differentiate between .co and .co.uk? Also any idea how to get the expiration for .be domains? They do not seem to provide it.
Great script! I managed to add .tw, .asia, and .cn. Fixed .ca and .ru as well.
Found a nice list of WHOIS serers here:
http://www.nirsoft.net/whois_servers_list.html
Fix for .ru domains
by
nickmob,
November 30, 2012
Great plugin! If you want to check all .ru domains (not only registered with Ru-center), change 2 lines: whois.nic.ru replace with whois.ripn.net, line with "year=`cat ${FILE} | awk '/paid-till:/' | cut -d ':' -f2 | cut -d ' ' -f5 | cut -d '.' -f1`"
replace with "year=`cat ${FILE} | awk '/paid-till:/' | cut -d ':' -f2 | cut -d ' ' -f6 | cut -d '.' -f1`" (difference is -f6 instead of -f5)
Doesn't work in Opsview Core
by
Cipher-0,
October 31, 2012
I had a similar issue to mr.o below.
In the Opsview Core host, the plig-in works perfectly.
In Opsview from the console, it returns this:
$ /usr/local/nagios/libexec/check_domain -d mit.edu -c 14 -w 60
RETURN CODE: 3 (UNKNOWN)
OUTPUT:
We do not support this domain (not integrated). Sorry.
ERROR:
[: 89: edu: unexpected operator
[: 89: edu: unexpected operator
[: 89: edu: unexpected operator
[: 89: edu: unexpected operator
[: 89: edu: unexpected operator
[: 89: edu: unexpected operator
[: 89: edu: unexpected operator
[: 89: edu: unexpected operator
[: 89: edu: unexpected operator
[: 89: edu: unexpected operator
I was unable to get it functioning.
great plugin. here is .ca patch
by
vclark,
May 31, 2012
--- scripts/nagios/check_domain (revision 109964)
+++ scripts/nagios/check_domain (working copy)
@@ -83,6 +83,10 @@
then
TYPE=dk-hostmaster
WHOIS_SERVER="whois.dk-hostmaster.dk"
+elif [ ${DLTYPE} == 'ca' ];
+then
+ TYPE=ca
+ WHOIS_SERVER="whois.cira.ca"
else
echo "We do not support this domain (not integrated). Sorry."
exit $STATE_UNKNOWN
@@ -124,6 +128,10 @@
elif [ $TYPE == 'afilias' ];
then
expiration=`cat ${FILE} | awk '/Expiration Date:/' | cut -d ':' -f2 | cut -d ' ' -f1`
+# for .ca domains
+elif [ $TYPE == 'ca' ];
+then
+expiration=`cat ${FILE} | awk '/Expiry date:/' | cut -d ':' -f2`
#for .ru domains
elif [ $TYPE == 'russia' ];
then
problem
by
mr.o,
March 31, 2012
Hi
I have a strange problem, I can manually perform the script in CLI:t $ ./check_domain -d exemple.com it works great.
But when I let Nagios run the script i only get UNKNOWN "We do not support this domain (not integrated). Sorry" as result.
define command{
command_name check_domain
command_line $USER1$/check_domain -d $ARG1$
}
define service {
use generic-service
host_name exemple.com
service_description DNS-Expire date
check_command check_domain!exemple.com
}
Domains .pt
by
carekapt,
January 31, 2012
I'm gonna try to change the script for my self, but could you include .pt domains on the next version of the script?
Best regards,
carekaPT