three stacks of high society


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

apache

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

Gentoo upgrade to Apache 2.2

I upgraded my server's apache from 2.0 to 2.2 today (see Overview of new features in Apache 2.2) and it was painless except for a few minor hiccups. I like to keep my server's packages up to date with Gentoo's stable packages not just for new features but mainly to make package upgrades as easy as possible. I find that by staying up to date with upstream stable packages, upgrades are more incremental and rarely cause as much difficulty as having to upgrade from multiple major versions behind.

With Gentoo, the Apache 2.2 upgrade came with a routine:

emerge --sync
emerge -uDav world

I noticed the new Apache version, checked out the other packages listed, and then hit enter to proceed. At the end of the compilation, Gentoo reminded me there are new config files in /etc to merge. Luckily for me, I've maintained a clean separation of Apache configuration directives and VirtualHosts, so I was able to accept all of the major configuration directive changes without modification (2.2 mostly just moves around the default directives to more logical locations). Staying up to date and close to upstream shows its benefits here.

Apache restarted without complaining, but attempts to access any of my virtualhosts resulted in a 403 Forbidden:

[Sat Sep 08 13:30:55 2007] [error] [client 89.14.247.41] client denied by server configuration: /home/victor/public_html/

This was caused by Apache 2.2's /etc/apache2/modules.d/00_default_settings.conf:

<Directory />
        Options FollowSymLinks
        AllowOverride None
        Order deny,allow
        Deny from all
</Directory>

You can either override this manually in every vhost.d/*.conf file, or you can just change the "Deny from all" line to "Allow from all" and then make Deny rules manually in each vhost.d file (if you wish). I restarted apache and refreshed my test site, but there was now a new problem - .php files were being parsed as plain text, which meant Apache wasn't passing off .php files for processing.

I added "-D PHP5" to my /etc/conf.d/apache2's APACHE2_OPTS line, which tells Apache to load the PHP5 module. However, since my libphp5.so was built for my old Apache, I had to re-compile for Apache 2.2:

emerge -av php

I waited a few minutes, restarted apache, and now everything works beautifully.

Syndicate content

Recent Flickr photos

Downtown StuttgartThe CubeFeinkost Bohm and BW|BankHäussler City PlazaVolgelsangstrasseView from BismarckstrasseMy Mom's Stuttgart PaintingBefore the moversBefore the movers

Recent comments

I Approve Of

Random Flickr photos

matzah ball soup and beer0151.jpgStuttgart Moona town near innsbruckStuttgarter FrühlingsfestUmzug Neuhausen

Blame me for

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