Rev 149 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | Download | RSS feed
#!/usr/bin/env perl
use warnings;
use strict;
# Description: Get IPMI network information
our $VERSION = '1.2.1';
# 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
#
# 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;
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;