The Community Forums

Interact with an entire community of cPanel & WHM users!
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Easy way to check for dead domains?

Discussion in 'General Discussion' started by simonpearce, Oct 12, 2009.

  1. simonpearce

    simonpearce Well-Known Member

    Joined:
    Jun 20, 2003
    Messages:
    90
    Likes Received:
    0
    Trophy Points:
    6
    We've inherited some servers with LOTS of domains on - many, if not most are dead (ie domain no longer registered/nameservers pointing elsewhere)

    Is there an easy way to search for these in whm or using a script rather than checking each one individually?

    Cheers
     
  2. bvierra

    bvierra Well-Known Member

    Joined:
    Jul 28, 2006
    Messages:
    55
    Likes Received:
    1
    Trophy Points:
    8
    Location:
    Southern California
    The main reason this script was written was to help admins keep track of domains that still pointed to a server that they where trying to move accounts off of. This script was also found useful because it helped find mistakes. Some sales/admins forget to remove accounts of canceled customers. Basically this script scans thru a db file and resolves each domain and makes sure it points to the correct ip. If it does not point to the right ip then it will let you know.

    http://cplicensing.net/scripts.php?file=chkcpaccts
     
  3. DomineauX

    DomineauX Well-Known Member
    PartnerNOC

    Joined:
    Apr 12, 2003
    Messages:
    414
    Likes Received:
    4
    Trophy Points:
    18
    Location:
    Houston, TX
    cPanel Access Level:
    Root Administrator
    Handy utility there bvierra as are many of your other scripts.
    Doesn't appear to be much new in a long time though...hint hint :)
     
  4. simonpearce

    simonpearce Well-Known Member

    Joined:
    Jun 20, 2003
    Messages:
    90
    Likes Received:
    0
    Trophy Points:
    6
    Excellent bvierra!

    Cheers
     
  5. Serra

    Serra Well-Known Member

    Joined:
    Oct 27, 2005
    Messages:
    213
    Likes Received:
    4
    Trophy Points:
    18
    Location:
    Florida
    Of course the script just stopped working because of the changes in cPanel, so at this point it will either not work, or quickly stop working when cPanel catches up to 'release'.

    The problem with the script is that they change the whostmgr and it is no longer possible to pull domain and ip combos, so it doesn't find any domains listed.
     
  6. gertiebeth

    gertiebeth Well-Known Member

    Joined:
    Jun 4, 2003
    Messages:
    97
    Likes Received:
    0
    Trophy Points:
    6
    Location:
    Minnesota, USA
    cPanel Access Level:
    Root Administrator
    Yes, this no longer works. Does anyone have an alternative?

     
  7. Serra

    Serra Well-Known Member

    Joined:
    Oct 27, 2005
    Messages:
    213
    Likes Received:
    4
    Trophy Points:
    18
    Location:
    Florida
    I spoke with the company that wrote it at cPlicensing: cPanel Scripts.
    They gave me a half hearted reply that said it would be updated... I'm not holding my breath... It has been a week, so I'm not sure they actually intend on doing anything. I'll post if they do.

    The problem is that the script used the CSV file to determine the domain and IP address. It was a simple matter to see if the IP matched. A list of domains and a list of IPs are available, but I can't find any easy way to find a match between them.

    If they don't come up with something soon, I'll likely come up with a solution myself, I just hate to waste time working on scripting when that isn't really my area of expertise.
     
  8. gertiebeth

    gertiebeth Well-Known Member

    Joined:
    Jun 4, 2003
    Messages:
    97
    Likes Received:
    0
    Trophy Points:
    6
    Location:
    Minnesota, USA
    cPanel Access Level:
    Root Administrator
    Thank you Serra. I opened a ticket with cpanel about this (as it is big part of my business) but they said they could not help me as it is a third party script. I have a ticket open with my admin company right now to see if they can modify the script for me, and if so, how much they would charge.

    cpanel's response, for those interested:

     
  9. Serra

    Serra Well-Known Member

    Joined:
    Oct 27, 2005
    Messages:
    213
    Likes Received:
    4
    Trophy Points:
    18
    Location:
    Florida
    I took a look at the API2 stuff and while there is some interesting things there, none of it would be useful for us running a script to determine domains that point to the wrong address. One of the API2 statements does allow us to find an account's IP address, but it just doesn't seem to be that useful.


    As I said, if cPlicensing doesn't modify the script in a reasonable amount of time, I'll find a way to do it myself. Post what happens with the script.
     
  10. acenetryan

    acenetryan Well-Known Member
    PartnerNOC

    Joined:
    Aug 21, 2005
    Messages:
    197
    Likes Received:
    1
    Trophy Points:
    18
    Here's one I wrote a while back. I wrote it quick and dirty, you need to modify $mainIP to reflect the server's main IP. It will pull the rest of the IPs from /etc/ips. You need to be root to run this.

    Code:
    <?
    
    $mainIP = 'MAINIPGOESHERE';
    
    $etcips = Array();
    $serverIPs = Array();
    
    $cmd = 'cat /etc/ips';
    
    exec($cmd,$etcips);
    
    foreach($etcips as $etcip)
    {
      list($IP, $netmask, $broadcast) = split(':', $etcip);
    
      $serverIPs[] = $IP;
    }
    
    $serverIPs[] = $mainIP;
    
    $userdomains = Array();
    
    $cmd = 'cat /etc/trueuserdomains';
    
    exec($cmd,$userdomains);
    
    $resolves = 0;
    $doesnotresolve = 0;
    
    foreach($userdomains as $singleentry)
    {
      list($domain, $username) = split(':',$singleentry);
    
      if($domain != '*')
      {
        $cmd = 'host '.$domain;
    
        $result = exec($cmd);
        $lastspacepos = strrpos($result, " ");
        if($lastspacepos === false)
        {
          // Not Found
          print "Not Found\n";
        }
        else
        {
          $lastword = substr($result, $lastspacepos+1, strlen($result)-($lastspacepos+1) );
    
          if(in_array($lastword,$serverIPs))
          {
            print $domain."(".$lastword.") resolves to this server\n";
            $resolves++;
          }
          else
          {
            print $domain."(".$lastword.") does not resolve to this server\n";
            $doesnotresolve++;
          }
        }
      }
    }
    
    print $resolves." domains resolve to this server\n";
    print $doesnotresolve." domains do not resolve to this server\n";
    
    ?>
    
    I make no guarantees to the accuracy or security of the code, blah, blah, blah. Use at your own discretion.
     
  11. acenetryan

    acenetryan Well-Known Member
    PartnerNOC

    Joined:
    Aug 21, 2005
    Messages:
    197
    Likes Received:
    1
    Trophy Points:
    18
  12. gertiebeth

    gertiebeth Well-Known Member

    Joined:
    Jun 4, 2003
    Messages:
    97
    Likes Received:
    0
    Trophy Points:
    6
    Location:
    Minnesota, USA
    cPanel Access Level:
    Root Administrator
    I'm not sure how to use this. I modified the IP address and ran the script as perl scriptname and the results were:

    Code:
    Bareword found where operator expected at newdns line 11, near "$etcips as"
            (Missing operator before as?)
    Bareword found where operator expected at newdns line 29, near "$userdomains as"
            (Missing operator before as?)
    Bareword found where operator expected at newdns line 41, near "// Not"
            (Missing operator before Not?)
    syntax error at newdns line 11, near "$etcips as "
    syntax error at newdns line 15, near "[]"
    syntax error at newdns line 39, near "==="
    syntax error at newdns line 60, near "}"
    Execution of newdns aborted due to compilation errors.
     
  13. acenetryan

    acenetryan Well-Known Member
    PartnerNOC

    Joined:
    Aug 21, 2005
    Messages:
    197
    Likes Received:
    1
    Trophy Points:
    18
  14. cPanelKenneth

    cPanelKenneth cPanel Development
    Staff Member

    Joined:
    Apr 7, 2006
    Messages:
    4,461
    Likes Received:
    22
    Trophy Points:
    38
    cPanel Access Level:
    Root Administrator
    Please note that /etc/ips will not be populated on all servers. In particular Virtuozzo servers will have an empty /etc/ips file.
     
  15. cPanelKenneth

    cPanelKenneth cPanel Development
    Staff Member

    Joined:
    Apr 7, 2006
    Messages:
    4,461
    Likes Received:
    22
    Trophy Points:
    38
    cPanel Access Level:
    Root Administrator
    We overhauled the fetchcsv function in cPanel 11.25. The data it returns now contains a header row. Plus every column in the List Accounts interface is represented in the csv file.

    The script billy links to is not aware of these changes. For cPanel 11.25 servers replace this:
    Code:
    print "Retreiving CSV from whostmgr...";
    my %csv;
    foreach(qx(/usr/local/cpanel/whostmgr/bin/whostmgr fetchcsv)) {
    	chomp;
    	next unless /^,/;
    	my(undef,$domain,$ip,$user,undef) = split(",", $_, 5);
    	next unless $domain and $ip and $user;
    	$ip =~ s/:443//;
    	$csv{$user}{domain} = $domain;
    	$csv{$user}{ip} = $ip;
    }
    print "Success\n";
    
    with

    Code:
    print "Retreiving CSV from whostmgr...";
    my %csv;
    my @dataset = qx( /usr/local/cpanel/whostmgr/bin/whostmgr fetchcsv );
    foreach my $record ( @dataset) {
            chomp $record;
            next unless $record =~ /,/;
            #Domain,IP,User Name,Email,Start Date,Disk Partition,Quota,Disk Space Used,Package,Theme,Owner,Server,Unix Startdate,Disk Space Used (bytes),Quota (bytes)
            my($domain,$ip,$user, undef) = split(",", $record, 4);
            next if $domain eq 'Domain'; # skip header row
            next unless $domain and $ip and $user;
            $ip =~ s/:443//;
            $csv{$user}{'domain'} = $domain;
            $csv{$user}{'ip'} = $ip;
    }
    print "Success\n";
    
    Please note that neither I nor cPanel take any responsibility for the use of the script. Nor are any guarantees made regarding the quality of the original script or the continuing compatibility of the script or proposed code changes.
     
  16. aspardeshi

    aspardeshi Member

    Joined:
    Oct 22, 2009
    Messages:
    15
    Likes Received:
    0
    Trophy Points:
    1
    try googling rather than making research

    i would advise to try googling rather than making research on this script :confused:
     
  17. Serra

    Serra Well-Known Member

    Joined:
    Oct 27, 2005
    Messages:
    213
    Likes Received:
    4
    Trophy Points:
    18
    Location:
    Florida
    Wow, ndc more than exceed my expecations with this. They have replaced the script with a plugin:

     
Loading...

Share This Page