three stacks of high society


Engineer and open source software advocate living and working in Austin, Texas

Using Python to monitor expiring domains

Tags:

I wanted a script that would monitor our domain names and notify the proper people when the time came to renew. I came across this, but it:

  • requires modification when we add or delete domain names (which we do very often)
  • doesn't differentiate its output based on the expiration date, resulting in lots of noise

So I decided to write a Python-based script that would scan Apache's vhost directory, pull out unique domain names based on the vhost files, figures out how long until each domain expires, and then only emails you the domains that are expiring within a set number of days. This alleviates the need for someone to modify the script when a new domain is added and reduces email noise.

To use, download and modify the script to suit your needs. Make sure you change the "To" email address, days_ahead you want notified, vhost file regex, and possibly vhost_path. Then run it on cron every two weeks or so.

The output looks something like this:

From: apache
To: victor
Subject: Expiring domains

yahoo.com expires in 1401 days
cnn.com expires in 551 days

AttachmentSize
check_domain_expiration.py.txt1.82 KB

Post new comment

The content of this field is kept private and will not be shown publicly.
  • Insert Flickr images: [flickr-photo:id=230452326,size=s] or [flickr-photoset:id=72157594262419167,size=m].
  • You may post code using <code>...</code> (generic) or <?php ... ?> (highlighted PHP) tags.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Lines and paragraphs break automatically.
  • Web page addresses and e-mail addresses turn into links automatically.

More information about formatting options

CAPTCHA
This question is for testing whether you are a human visitor and to prevent automated spam submissions.

Random Flickr photos

jacksonpollock.org0153.jpgNürburgringSudsKoenigseestuttgart sunset

Blame me for

ClemsonTALK - Clemson's largest forum
Clemson Wiki Project - Clemson oriented Wiki