Web Hosting Talk







View Full Version : CPanel chkcpaccts script can anyone help???


Snowman30
01-21-2005, 12:19 AM
chkcpaccts - Helps keep track of accounts that are no longer used, whether deleted or transfered to another server

I found this script at cpanelfaq.org (http://www.cpanelfaq.com/007/28.html) its a few months old but i thought id give it a try. Unfortunately it didnt seem to work. Anyone use it or know of a fix?

#!/usr/bin/perl
# cPlicensing.net - scripts Copyright(c) 2003 cPlicensing.net.
# All rights Reserved.
# support@cPlicensing.net http://cPlicensing.net
# Unauthorized copying is prohibited
#Version: 0.02
#
#+CHANGE LOG
#-v0.2 :: 2004-22-02 :: Now will show a catagory for domains that point to the correct ip as well.

use Socket;

$|++;
$ENV{'REMOTE_USER'} = 'root';

$acctsdb = '/var/cpanel/root.accts';
$chkuser = 'root';

if (!-e "/usr/local/cpanel") {
print "CPanel not found, Are you sure this is a CPanel box?\n";
exit;
}

print "Checking /etc/resolv.conf...";
open(RESOLVCONF,"/etc/resolv.conf") or die("Failed, Where is your resolv.conf?\n");
while(<RESOLVCONF>) {
chomp;
if((/127.0.0.1/) and ($ARGV[0] ne "--allowlocalhost")) {
print "Found 127.0.0.1 in the resolv.conf, this is a no no! Change it to the base ip of the server\n";
exit;
}
}
close(RESOLVCONF);
print "Check Complete\n";

print "Rebuilding $acctsdb...";
system("/usr/local/cpanel/whostmgr/bin/whostmgr fetchcsv > /dev/null");
if (!-e "$acctsdb") {
print "$acctsdb Not found\n";
exit;
}
print "Done\n";

print "Opening $acctsdb...";
open(DATA,"$acctsdb") or die("failed\n");
print "done\nScanning Domains....";
while(<DATA>) {
print ".";
$totaldom++;
($UNDEF,$domain,$ip,$UNDEF,$UNDEF,$UNDEF,$UNDEF,$UNDEF,$UNDEF,$UNDEF,$UNDEF,$UNDEF,$owner) = split(/,/, $_, 28);
chomp($domain,$ip,$owner);
$ip=~ s/:443//;
# if ($owner ne $chkuser) { next; }
$iaddr = gethostbyname($domain);
if (!$iaddr){ push @failedresolve, "$domain"; next; }
$domainip = inet_ntoa($iaddr);
if ($domainip ne $ip) {
push @wrongip, "$domain($ip) ---Resolves-to--> $domainip";
} else {
push @rightip, "$domain($ip) ---Resolves-to--> $domainip";
}
}
close(DATA);
print "done\n\n";

print "\n\n";
print "-------------------------------------\n";
print "- LIST OF DOMAINS THAT POINT RIGHT -\n";
print "=====================================\n";
foreach (@rightip) {
print "-->$_\n";
}
print "-------------------------------------\n";
print "- LIST OF DOMAINS THAT DONT RESOLVE -\n";
print "=====================================\n";
foreach (@failedresolve) {
print "-->$_\n";
}
print "\n\n";
print "-------------------------------------\n";
print "- LIST OF DOMAINS THAT POINT WRONG -\n";
print "=====================================\n";
foreach (@wrongip) {
print "-->$_\n";
}
print "\n\n";
print "-------------------------------------\n";
print "- SUMMARY -\n";
print "=====================================\n";
print "-->TOTAL DOMAINS IN THE DB FILE...................$totaldom\n";
print "-->TOTAL DOMAINS THAT RESOLVE TO THE CORRECT IP...".@rightip."\n";
print "-->TOTAL DOMAINS THAT DONT RESOLVE................".@failedresolve."\n";
print "-->TOTAL DOMAINS THAT POINT ELSE WHERE............".@wrongip."\n";
print "\n\n";

Dacsoft
01-21-2005, 10:38 PM
So what is it doing? Or not doing?

Snowman30
01-21-2005, 11:56 PM
Its not chekcing any of the accounts on the server on some of our servers, and on others it checks about a half a dozen

Snowman30
03-08-2005, 05:15 AM
ok i found the issue....

cpanel no longer deposits the list into root.accts

instead each site has a file in /var/cpanel/users

what i need is a way to go thru these files and do a dns lookup on the domains to see if they are currently resoling to the server or pointing elewhere

anyone know of a way to do this or is capable of modifying the perl script to do this?

ndchost
03-15-2005, 09:55 PM
The script needs to be re-written to use cpanels API. We do have plans for this in the next month or so.