Rev 237 | Blame | Last modification | View Log | Download | RSS feed
#!/usr/bin/env perl
use warnings;
use strict;
# Description: Get IPMI network information
our $VERSION = '1.3.0';
# IPMI network module for sysinfo client
# Author: R. W. Rodolico
# Date: 2016-09-17
# 20171124 RWR
# Fixed where STDERR now goes to /dev/null
#
# 20191118 RWR v1.2.1
# in some cases, ipmitool is used only to access other devices over the network
# so it will not have information. Fixed so that if @temp is empty, will just exit
#
# 20230204 RWR v1.3.0
# look for specific IPMI files to determine if the driver is installed
# better than just checking @temp afterwards
#
# module to get network interface information for ipmi
# requires ipmitool (runs ipmitool lan print)
# NOTE: this takes the ipmitool output and parses it, so changes to
# this output invalidates this module
BEGIN {
push @INC, shift;
}
use library;
my $command = &validCommandOnSystem('ipmitool');
exit 1 unless $command;
# some systems have ipmitool installed simply for managing other machines
# but do not have ipmi themselves
exit 1 unless -e '/dev/ipmi0' || -e '/dev/ipmi/0' || -e '/dev/ipmidev/0';
my %storage = (
'address' => { 'key' => 'IP Address' },
'netmask' => { 'key' => 'Subnet Mask' },
'mac' => { 'key' => 'MAC Address' }
);
my $CATEGORY = 'network';
my @temp = qx( $command lan print 2> /dev/null );
exit 2 unless @temp; # ipmitool installed, but driver not. Probably using to connect someplace else.
chomp @temp;
foreach my $line ( @temp ) {
my ( $key, $value ) = split( /\s+:\s+/, $line );
foreach my $test ( keys %storage ) {
next if defined( $storage{$test}{'value'} );
if ( $key eq $storage{$test}{'key'} ) {
$storage{$test}{'value'} = $value;
last;
} # if
} # foreach
}
foreach my $key ( keys %storage ) {
print "$CATEGORY\tipmi\t$key\t$storage{$key}{'value'}\n";
}
1;