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

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

Copyt trusty code

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