Solaris 10 Agent doesn´t report virtual IP

Bug #552763 reported by Emengao
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
OCS Inventory: Unified Unix Agent
Fix Released
Medium
mortheres

Bug Description

If you have virtual IP in your network device, the agent doesn´t report theses information.
I have changed this file above to enable the Virtual IP information, and identify which "zone" use each IP.

FILE: Ocsinventory-Agent-1.1.2\lib\Ocsinventory\Agent\Backend\OS\Solaris\Networks.pm

package Ocsinventory::Agent::Backend::OS::Solaris::Networks;
use strict;
sub check {
  can_run("ifconfig") && can_run("netstat") && can_load ("Net::IP qw(:PROC)")
}
sub run {
 my $params = shift;
 my $inventory = $params->{inventory};
 my $description;
 my $ipaddress;
 my $ipgateway;
 my $ipmask;
 my $ipsubnet;
 my $macaddr;
 my $status;
 my $type;
 foreach (`netstat -rn`){
  $ipgateway=$1 if /^default\s+(\S+)/i;
 }
 my $zone;
 my $cont=1;
 my $iface;
 my @interface;
 sub GetInterface {
  my $inter = "";
  my $count = 0;
  my @interface_list = ();
  foreach (`ifconfig -a`){
   if (/^(\S+):/i){
    if ($count != 0){
     push(@interface_list, $inter);
    }
    $count = 1;
    $inter = "";
    $inter = $inter . $_;
   }else{
    $inter = $inter . $_;
   }
  }
  push(@interface_list, $inter);
  return @interface_list
 }
 @interface = GetInterface();
 foreach (@interface){
  $description = $1 if /^(\S+):/; # Interface name
  $status = 1 if /<UP,/;
  $ipaddress = $1 if /inet\s+(\S+)/i;
  $ipmask = $1 if /\S*netmask\s+(\S+)/i;

  if (/ether\s+(\S+)/i) {
   $macaddr = sprintf "%02x:%02x:%02x:%02x:%02x:%02x" ,
   map hex, split /\:/, $1;
  }
  if (/zone\s+(\S+)/i) {
   $zone = $1;
   $macaddr = "zone: ".$zone;
  }
  if($description && $ipmask ){
   $cont = 0;
   #HEX TO DEC TO BIN TO IP
   $ipmask = hex($ipmask);
   $ipmask = sprintf("%d", $ipmask);
   $ipmask = unpack("B*", pack("N", $ipmask));
   $ipmask = ip_bintoip($ipmask,4);
   my $binip = &ip_iptobin ($ipaddress ,4);
   my $binmask = &ip_iptobin ($ipmask ,4);
   my $binsubnet = $binip & $binmask;
   $ipsubnet = ip_bintoip($binsubnet,4);
   $inventory->addNetwork({
    DESCRIPTION => $description,
    IPADDRESS => $ipaddress,
    IPGATEWAY => $ipgateway,
    IPMASK => $ipmask,
    IPSUBNET => $ipsubnet,
    MACADDR => $macaddr,
    STATUS => $status?"Up":"Down",
    TYPE => $type,
   });
   $description = $ipaddress = $ipmask = $ipsubnet = $macaddr = $status = $type = $zone = undef;
  }
 }
}
1;

Emengao (emengao)
Changed in ocsinventory-unix-agent:
assignee: nobody → mortheres (mortheres)
mortheres (mortheres)
Changed in ocsinventory-unix-agent:
importance: Undecided → Medium
Frank (frank-bourdeau)
Changed in ocsinventory-unix-agent:
status: New → Fix Committed
mortheres (mortheres)
Changed in ocsinventory-unix-agent:
milestone: none → 2.1rc1
Frank (frank-bourdeau)
Changed in ocsinventory-unix-agent:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.