
I've already written about a shell script to check / monitor domain renew / expiration date here. Now I’ve modified matt’s domain-check script to support additional C/TLDs .in, .biz, .org and .info domains. I've also added 5 seconds delay to avoid whois server rejecting query. This script checks to see if a domain has expired. It can be run in interactive and batch mode, and provides facilities to alarm if a domain is about to expire in advance.
Sample usage
Display expiration date and registrar for theos.in domain:
domain-check-2 -d {domain-name}
$ domain-check-2 -d theos.in
Output:
Domain Registrar Status Expires Days Left ----------------------------------- ----------------- -------- ----------- --------- theos.in et4India (R7-AFIN Valid 28-Oct-2009 799
You can also get an email if theos.in going to expire in 30 days
$ domain-check-2 -a -d theos.in -q -x 30 -e vivek@nixcraft.com
However most killer feature is you can read list of domain names from a file such as mydomains.txt (list each domain on a new line):
$ domain-check-2 -a -f mydomains.txt -q -x 30 -e vivek@nixcraft.com
OR
$ domain-check-2 -f mydomains.txt
Output:
Domain Registrar Status Expires Days Left ----------------------------------- ----------------- -------- ----------- --------- theos.in et4India (R7-AFIN Valid 28-Oct-2009 799 nixcraft.org oDaddy.com, Inc. Valid 13-Aug-2009 723 vivekgite.com MONIKER ONLINE SE Valid 18-aug-2010 1093 cyberciti.biz Valid 30-Jun-2009 679 nixcraft.info oDaddy.com Inc. ( Valid 26-Jun-2009 675 nixcraft.net GODADDY.COM, INC. Valid 11-dec-2009 843
Download
=> Download modified domain-check-2 script here.
Quick installation
Use wget command to download and install domain-check script:
$ wget http://www.cyberciti.biz/files/scripts/domain-check-2.txt
$ mv domain-check-2.txt domain-check
$ chmod +x domain-check
$ ./domain-check -d vivekgite.com
Make sure your run domain-check script using a cron job.
- Email this to a friend
- Printable version
- Rss Feed
- Last Updated: Oct/19/2007
{ 32 comments… read them below or add one }
but… it doesnt work with things like .co.nz domains…
Nate,
You need to modify script to work with .co.nz. I’ve modified as per my requirements. Basically you need to know whois server name for all .nz domain and date format. Let me know those thing and I can tell you the rest
realy good works thanks a lot vivek
I’ve hacked the script to work somewhat with Nagios.
Does anyone want it?
Sure post the script / url / link. If you don’t have a website just email me the script :)
This script works much better than some of the others on the net. Thanks!
I can’t get the script to work for me. I get the following error:
-bash: domain-check: command not found
kendall,
Did you renamed the script? Did you setup executable permission? Did you run script as:
thank you for your quick responce. that fixed my problem. and the script works, but it does not flag .ca domains very well. it seems to skip a few such as beelineweb.ca
what I mean by skipped, is that is says unknown, but when I look it up manualy it showes that the domain is valid
are there any additions to the script that I can put in so it e-mails out when it finds an “unknown” domain?
Its great script. does any one know similar php script?
Mark: Would love to grab a copy of your Nagios version of script! Can you post a link or something? Thanks a bundle.
dave,
I’m not sure if mark can get your message.
# Mark Says: September 4th, 2007 at 2:50 pm
I’ve hacked the script to work somewhat with Nagios.
Does anyone want it?
email me or post the url, thanks
if date format is that then script will not work
Renewal-Date: 2008/11/20
Date-Approved: 2006/11/20
Date-Modified: 2007/10/21
give falst output, how to overcome that.
i suggest you look at the perl NET::DRI package. it can be a bit of bear to install with all of its dependencies, but once you get it working, it’s quite nice. look at their example whois.pl script.
very nice script. I noticed u accidently hardcoded awk in the code instead of ${AWK} on the line that looks at “Domain Expiration Date”. You could add switches to display other info (i.e. owner, etc…) in case one would want a more detailed report. Either way, nice and easy to use! good job!
Very…Very Very nice script… but I want something more..I’m sure you can do it. The script should also show the nameservers update date..it’ll be a good idea..isn’t it?
Regards,
Tushar
Very nice script – please give me a link or email address to obtain the nagios version of it
Very nice script. Is there already an extension to do “nameserver lookups”, means looking for each domain, what nameservers are registered? would be really nice since not all are so helpful and tell us that the domain is no longer on our nameserver…
Its an awesome tool. I just checked one domain. yet to check using file. but so far it impressed me.
thanks.
Great script, but it sends no email? what i`m doing wrong?
Hi Vivek.
I just wanted to say thank you for providing this script.
It is an absolutely excellent time-saver for me and a great learning tool too!
All the best,
Neil.
Hi again.
Next question. :-) I am trying to mod it to look up .uk domains.
The whois server is whois.nic.uk and the date is output as Renewal date: dd-Mmm-YYYY
Unfortunately I am not up to speed with awk and have probably made a couple of other errors too.
Are you able to assist please?
Many thanks in advance,
Neil.
Neil,
Okai, I’ve updated the script to support .uk 2nd level TLD. Try it out and let me know…
Brilliant script, thanks.
Could anyone post their nagios version if they have it please. Many thanks!
Just repeating GM’s question.. sending email but getting error msgs “/bin/sh: /home/xcyte/file.sh/domain-check-2: No such file or directory” even though I’ve followed the instructions exactly. Anyone more experienced that wants some cash to help me get this running email me at jgrimmond00@gmail.com.. thanks
Looks nice.
Do you have to modify what register the script checks?
I could not tell where the script is requesting the data from, can you please clarify?
Thanks,
Cypher
never mind i glanced over it:
“whois.pir.org”
“whois.registry.in”
“whois.nic.uk”
“whois.neulevel.biz”
“whois.afilias.info”
“whois.jprs.jp”
You can use -s option to set another whois server
/script.name -d example.com -s whois.isp.comFor some reason this script will only output “UNKNOWN” to all fields when using a large list/batch mode. It seems that any more than 5 domains in a list cause this (at least for me). Any thoughts as to why this might be?