Heray-Was-Here
Server : Apache
System : Linux vps103298.mylogin.co 4.18.0-513.11.1.el8_9.x86_64 #1 SMP Wed Jan 17 02:00:40 EST 2024 x86_64
User : calvet ( 273824)
PHP Version : 7.4.33
Disable Function : NONE
Directory :  /proc/thread-self/root/usr/share/perl5/vendor_perl/Ocsinventory/Agent/Backend/OS/Solaris/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : //proc/thread-self/root/usr/share/perl5/vendor_perl/Ocsinventory/Agent/Backend/OS/Solaris/IPv4.pm
package Ocsinventory::Agent::Backend::OS::Solaris::IPv4;

sub check { 
    my $params = shift;
    my $common = $params->{common};
    $common->can_run ("ifconfig") 
}

# Initialise the distro entry
sub run {
    my $params = shift;
    my $common = $params->{common};
    my %ip;
    my $ip;
    my $hostn;

    #Looking for ip addresses with ifconfig, except loopback
    # Solaris need -a option
    for (`ifconfig -a`){#ifconfig in the path
        #Solarisligne inet
       if (/^\s*inet\s+(\S+).*/){($1=~/^127.+/)?next:($ip{$1}=1)};
    }

    # Ok. Now, we have the list of IP addresses configured
    # We could have too many addresses to list them in HW
    # (details will be sent in Networks instead)
    # 
    #  How could we choose ?
    # 
    # Let's try to resolve the name of our server
    #  

    chomp( $hostn = `uname -n` );
    if ($hostn) {
      my $aip;
      foreach (`ping -s $hostn 10 1`) {
        unless ( $ip ) {
          if( /^.*\((\d+\.\d+\.\d+\.\d+)\):.*/ ) {
            $aip = $1;
            $ip = $aip  if( exists($ip{$aip}) );
          }
        }
      }
    }
    $common->setHardware({IPADDR => $ip});
}

1;

Hry