diff options
Diffstat (limited to 'SiteSummary.pm')
-rw-r--r-- | SiteSummary.pm | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/SiteSummary.pm b/SiteSummary.pm index 53b3c50..c8fa9c7 100644 --- a/SiteSummary.pm +++ b/SiteSummary.pm @@ -24,6 +24,7 @@ our @EXPORT = qw( get_macaddresses get_primary_ip_address get_primary_macaddress + get_unique_ether_id get_site get_sitegroup is_laptop @@ -198,6 +199,30 @@ sub get_primary_macaddress { } # +# Given the output from 'ifconfig -a', return the unique host ID used +# by sitesummary. +# Use like this: +# get_unique_ether_id(get_file_string($hostid, "/system/ifconfig-a")) +# +sub get_unique_ether_id { + my $ifconfigoutput = shift; + my $eth0mac; + my $eth1mac; + my $eth2mac; + open(IFCONFIG, $ifconfigoutput) || return undef; + while (<IFCONFIG>) { + chomp; + $eth0mac = $1 if (m/^eth0\s+Link encap:Ethernet HWaddr (\S+)/); + $eth1mac = $1 if (m/^eth1\s+Link encap:Ethernet HWaddr (\S+)/); + $eth2mac = $1 if (m/^eth2\s+Link encap:Ethernet HWaddr (\S+)/); + } + close (IFCONFIG); + #print STDERR "MAC: $eth0mac\n"; + my $mac = $eth0mac || $eth1mac || $eth2mac || "unknown"; + return lc("ether-$mac"); +} + +# # Return the hostname string # sub get_hostname { |