Community Forums
Connect with us on LinkedIn
+ Reply to Thread
Page 1 of 2 1 2 LastLast
Results 1 to 15 of 17
  1. #1
    Member
    Join Date
    Jun 2003
    Posts
    90

    Default Easy way to check for dead domains?

    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. #2
    Member bvierra's Avatar
    Join Date
    Jul 2006
    Location
    Southern California
    Posts
    55

    Default

    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. #3
    cPanel Partner NOC cPanel Partner NOC Badge
    Join Date
    Apr 2003
    Location
    Houston, TX
    Posts
    378
    cPanel/Enkompass Access Level

    Root Administrator

    Default

    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. #4
    Member
    Join Date
    Jun 2003
    Posts
    90

    Default

    Excellent bvierra!

    Cheers

  5. #5
    Member
    Join Date
    Oct 2005
    Posts
    125

    Default

    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. #6
    Member
    Join Date
    Jun 2003
    Location
    Minnesota, USA
    Posts
    95

    Default

    Yes, this no longer works. Does anyone have an alternative?

    Quote Originally Posted by Serra View Post
    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.
    Gertie

  7. #7
    Member
    Join Date
    Oct 2005
    Posts
    125

    Default

    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. #8
    Member
    Join Date
    Jun 2003
    Location
    Minnesota, USA
    Posts
    95

    Default

    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:

    Greetings,

    Unfortunately, as this is not a cPanel script, I can't assist with any code-related issues that this script might be facing. I would suggest that if you need such a script, that it be created using API2, which is actively supported in all versions of cPanel:

    cPanel API2 Documentation

    You can also continue to use the CSV file, as this script does, but we are not able to support third-party scripts.
    Quote Originally Posted by Serra View Post
    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.
    Gertie

  9. #9
    Member
    Join Date
    Oct 2005
    Posts
    125

    Default

    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. #10
    cPanel Partner NOC cPanel Partner NOC Badge rking's Avatar
    Join Date
    Aug 2005
    Posts
    192

    Default

    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. #11
    cPanel Partner NOC cPanel Partner NOC Badge rking's Avatar
    Join Date
    Aug 2005
    Posts
    192

    Default

    Lol, I should add that this was before I learned regex. In case you can't tell.

  12. #12
    Member
    Join Date
    Jun 2003
    Location
    Minnesota, USA
    Posts
    95

    Default

    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.
    Quote Originally Posted by rking View Post
    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.
    Gertie

  13. #13
    cPanel Partner NOC cPanel Partner NOC Badge rking's Avatar
    Join Date
    Aug 2005
    Posts
    192

    Default

    Sorry, this script is written in PHP.

    Running:

    Code:
    php scriptname.php
    should do it once you've modified $mainIP.

  14. #14
    cPanel Development cpanelkenneth's Avatar
    Join Date
    Apr 2006
    Posts
    3,788
    cPanel/Enkompass Access Level

    Root Administrator

    Default

    Quote Originally Posted by rking View Post
    It will pull the rest of the IPs from /etc/ips.
    Please note that /etc/ips will not be populated on all servers. In particular Virtuozzo servers will have an empty /etc/ips file.
    Kenneth
    Product Manager
    cPanel, Inc.

  15. #15
    cPanel Development cpanelkenneth's Avatar
    Join Date
    Apr 2006
    Posts
    3,788
    cPanel/Enkompass Access Level

    Root Administrator

    Default

    Quote Originally Posted by bvierra View Post
    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
    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.
    Kenneth
    Product Manager
    cPanel, Inc.

Similar Threads & Tags
Similar threads

  1. List ALL domains - an easy way ?
    By 4u123 in forum cPanel and WHM Discussions
    Replies: 4
    Last Post: 09-21-2009, 02:26 PM
  2. is there an easy way to check bandwith.
    By Kelvin_n in forum cPanel and WHM Discussions
    Replies: 1
    Last Post: 08-18-2006, 03:13 PM
  3. Subdomains fine, Addon domains dead
    By Winkie in forum cPanel and WHM Discussions
    Replies: 1
    Last Post: 08-10-2004, 11:42 AM
  4. Is there a easy way to check if you have php seux set up or not?
    By DWHS.net in forum cPanel and WHM Discussions
    Replies: 4
    Last Post: 03-02-2004, 06:28 PM
Linkedin       Facebook       Twitter       RSS       Flickr       YouTube