Hi!
We've also hit this problem, the patch looks good on our tests but we also
hit the warning problem, it looks like that problem was already there as the
dhclient.leases string doesn't have a parameter, so the $if that we are
using on sprintf with it seems wrong, I have rewritten that a bit and now it
shouldn't give you the warnings.
Alberto, can you test with this new patch?
Thanks.
--- a/lib/Ocsinventory/Agent/Backend/OS/Linux/Network/IPv4.pm
+++ b/lib/Ocsinventory/Agent/Backend/OS/Linux/Network/IPv4.pm
@@ -11,7 +11,7 @@
my $common = $params->{common};
my @ip;
foreach (`ifconfig`){
- if(/^\s*inet add?r\s*:\s*(\S+)/){
+ if(/^\s*inet (?add?r\s*:\s*)?(\S+)/){
($1=~/127.+/)?next:push @ip, $1
};
}
--- a/lib/Ocsinventory/Agent/Backend/OS/Linux/Network/Networks.pm
+++ b/lib/Ocsinventory/Agent/Backend/OS/Linux/Network/Networks.pm
@@ -22,13 +22,13 @@
"/var/lib/dhcp3/dhclient.%s.leases",
"/var/lib/dhcp3/dhclient.%s.leases",
"/var/lib/dhcp/dhclient.%s.leases",
- "/var/lib/dhcp/dhclient.leases",
"/var/lib/dhcp/dhclient-%s.leases",
"/var/lib/dhclient/dhclient-%s.leases", ) {
$leasepath = sprintf($_,$if);
last if (-e $leasepath);
}
+ $leasepath = "/var/lib/dhcp/dhclient.leases" unless -e $leasepath;
return undef unless -e $leasepath;
if (open DHCP, $leasepath) {
@@ -158,12 +158,12 @@
} else { # In a section
- $description = $1 if $line =~ /^(\S+)/; # Interface name
- $ipaddress = $1 if $line =~ /inet addr:(\S+)/i;
- $ipmask = $1 if $line =~ /\S*mask:(\S+)/i;
- $macaddr = $1 if $line =~
/hwadd?r\s+(\w{2}:\w{2}:\w{2}:\w{2}:\w{2}:\w{2})/i;
- $status = 1 if $line =~ /^\s+UP\s/;
- $type = $1 if $line =~ /link encap:(\S+)/i;
+ $description = $1 if $line =~ /^([^ :]+)[: ]/; # Interface name
+ $ipaddress = $1 if $line =~ /inet (?:addr:)?(\S+)/i;
+ $ipmask = $1 if $line =~ /\S*mask[: ](\S+)/i;
+ $macaddr = $1 if $line =~
/(?:hwadd?r|ether)\s+(\w{2}:\w{2}:\w{2}:\w{2}:\w{2}:\w{2})/i;
+ $status = 1 if $line =~ /(?:^\s+|<)UP(?:\s|,)/;
+ $type = $1 if $line =~ /(?:link encap:|txqueuelen\s+\d+\s+)\(?([^)
]+)\)?/i;
}
Regards.
--
Manty/BestiaTester -> http://manty.net