Unifix knowledge database - The original one

Dashboard - News - Search - List - About - Admin


Automatic DNS check of apache virtualhosts

Author:mike - Tue Feb 1 11:13:00 2005

#!/usr/bin/perl

$space=65;
$myip="212.242.77.75";      # Domains with this ip gets "working" stamp
open(fh, "/usr/local/apache2/conf/httpd.conf");
while ($dat=<fh>)
{
        if ($dat=~ /servername/i)
        {
                $dat =~ s/ //g;chop($dat);
                if ( lc ( substr($dat,0,10)) eq "servername")
                {
                        $domain=substr($dat,10,length($dat));
                        print $domain;
                        $res = `host -t a $domain`;

                        $i=length($domain); while ($i<40) {print " "; $i++;}

                        @ip=split(" ",$res);

                        if ($res =~ /NXDOMAIN/)                 {print "Not working(No A)";}
                        elsif ($res =~ /SERVFAIL/)              {print "Not working(No NS)";}
                        elsif ($res =~ /is an alias/)           {
                                                                        if (@ip[9] eq $myip) { print "Working";}
                                                                        else { print "CNAME ".@ip[5]."=>".@ip[9]; }
                                                                }
                        elsif ($res =~ /has address/)           {
                                                                        if (@ip[3] eq $myip) { print "Working"; }
                                                                        else { print @ip[3];}
                                                                }
                        else {print "Not working";}
                        print "\n";
                }
        }
}
close(fh);
Copyright(c) Unifix.org 2002-2011


Dashboard - News - Search - List - About - Admin
 
Powered by Mikjaer Consulting Solutions - Hosted by Specialhosting.dk