source: ocsinventory-agent/trunk/fuentes/lib/Ocsinventory/Agent/Backend/OS/BSD/IPv4.pm @ 468

Last change on this file since 468 was 468, checked in by mabarracus, 4 years ago

Copyt trusty code

File size: 516 bytes
Line 
1package Ocsinventory::Agent::Backend::OS::BSD::IPv4;
2
3sub check {
4  my @ifconfig = `ifconfig -a 2>/dev/null`;
5  return 1 if @ifconfig;
6  return;
7}
8
9# Initialise the distro entry
10sub run {
11  my $params = shift;
12  my $common = $params->{common};
13  my @ip;
14
15  # Looking for ip addresses with ifconfig, except loopback
16  # *BSD need -a option
17  foreach (`ifconfig -a`){
18    if(/^\s*inet\s+(\S+)/){
19      ($1=~/127.+/)?next:push @ip, $1
20    };
21  }
22
23  my $ip=join "/", @ip;
24
25  $common->setHardware({IPADDR => $ip});
26}
27
281;
Note: See TracBrowser for help on using the repository browser.