X-Git-Url: https://defaria.com/gitweb/?a=blobdiff_plain;f=clearadm%2Fdiscovery.pl;h=49b4b3f3c6275257df09cbcb81cbc8177126774e;hb=c8ff289be5d7e6a63d08eca398cc7be875a4978b;hp=ee4afa80ac9a12965d4163871f5844bc98419868;hpb=020a4a5ea2be725b155cae3a2cadc9aba3911b9b;p=clearscm.git diff --git a/clearadm/discovery.pl b/clearadm/discovery.pl index ee4afa8..49b4b3f 100755 --- a/clearadm/discovery.pl +++ b/clearadm/discovery.pl @@ -1,4 +1,4 @@ -#!/usr/bin/perl +#!/usr/bin/env perl =pod @@ -41,7 +41,7 @@ $Date: 2011/01/07 20:48:22 $ -broadcastA|ddr : Broadcast IP (Default: Current subnet) -broadcastT|ime : Number of sends to wait for responses to broadcast - (Default: 30 seconds) + (Default: 10 seconds) =head1 DESCRIPTION @@ -62,6 +62,7 @@ use lib "$FindBin::Bin/lib", "$FindBin::Bin/../lib"; use Clearadm; use Display; +use OSDep; use Utils; my $VERSION = '$Revision: 1.1 $'; @@ -81,14 +82,18 @@ sub discover ($) { verbose "Performing discovery (for $broadcastTime seconds)..."; while (<$broadcast>) { - if (/from (.*):/) { - my $ip = $1; - my $hostname = gethostbyaddr (inet_aton ($ip), AF_INET); - - unless ($hosts{$ip}) { - verbose "Received response from ($ip): $hostname"; - $hosts{$ip} = $hostname; - } # unless + display "Received line: $_"; + if (/from (\S+) \((.+)\)/) { + my $hostname = $1; + my $ip = $2; + + # Remove domain + $hostname =~ s/(\w+)\..*/$1/; + + unless ($hosts{$ip}) { + verbose "Received response from ($ip): $hostname"; + $hosts{$ip} = $hostname; + } # unless } # if last @@ -117,8 +122,16 @@ Usage 'Extraneous options: ' . join ' ', @ARGV # Announce ourselves verbose "$FindBin::Script V$VERSION"; -my $broadcastCmd = "ping -b $broadcastAddress 2>&1"; +my $broadcastCmd = 'ping '; +if ($ARCHITECTURE eq 'solaris') { + $broadcastCmd .= '-s '; +} else { + $broadcastCmd .= '-b '; +} # if + +$broadcastCmd .= "$broadcastAddress 2>&1"; + my $pid = open my $broadcast, '-|', $broadcastCmd or error "Unable to do $broadcastCmd", 1; @@ -179,9 +192,9 @@ L =begin html
-Clearadm
-Display
-Utils
+Clearadm
+Display
+Utils
=end html @@ -196,4 +209,4 @@ Please report problems to Andrew DeFaria . Copyright (c) 2010, ClearSCM, Inc. All rights reserved. -=cut \ No newline at end of file +=cut