Created
September 25, 2015 16:26
-
-
Save rushipkar90/936af7737275d03dc68e to your computer and use it in GitHub Desktop.
check_domains_ns.pl
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/local/cpanel/3rdparty/perl/514/bin/perl | |
#use strict; | |
use warnings; | |
use YAML::Tiny; | |
use Data::Dumper; | |
my $username = $ARGV[0]; | |
my @dnsservers = ("8.8.8.8","8.8.4.4"); | |
if (not defined $username) { | |
die "Please provide username\n"; | |
} | |
my $yaml = YAML::Tiny->read( "/var/cpanel/userdata/$username/main" ) | |
or die YAML::Tiny->errstr; | |
my $addons = $yaml->[0]{addon_domains}; | |
my $maindomain = $yaml->[0]{main_domain}; | |
my $ns = `dig NS $maindomain +short`; | |
chomp($ns); | |
$ns =~s/\n/\t/g; | |
if ($ns =~ /ns(1|2).hostpapa.com/) { | |
$status = "Good"; | |
} | |
elsif ($ns == "") { | |
$status = "Not Found"; | |
} | |
else { | |
$status = "Bad"; | |
} | |
print "Main domain:\t$maindomain\t$ns\t$status\n"; | |
foreach my $key (keys $addons) { | |
my $randomserver = $dnsservers[rand @dnsservers]; | |
my $nsaddon = `dig \@$randomserver NS $key +short`; | |
chomp($ns); | |
$nsaddon =~s/\n/\t/g; | |
if ($nsaddon =~ /ns(1|2).hostpapa.com/) { | |
$statusaddon = "Good"; | |
} | |
elsif ($nsaddon eq "") { | |
$statusaddon = "Not Found"; | |
} | |
else { | |
$statusaddon = "Bad"; | |
} | |
print "Addon domain:\t$key\t$nsaddon\t$statusaddon\n"; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment