Subversion Repositories camp_sysinfo_client_3

Rev

Rev 57 | Rev 87 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
29 rodolico 1
#!/usr/bin/env perl
2
use warnings;
31 rodolico 3
use strict;
29 rodolico 4
 
37 rodolico 5
# Description: Get IPMI network information
29 rodolico 6
 
57 rodolico 7
our $VERSION = '1.2';
37 rodolico 8
 
29 rodolico 9
# IPMI network module for sysinfo client
10
# Author: R. W. Rodolico
11
# Date:   2016-09-17 
12
 
57 rodolico 13
# 20171124 RWR
14
# Fixed where STDERR now goes to /dev/null
15
#
29 rodolico 16
# module to get network interface information for ipmi
17
# requires ipmitool (runs ipmitool lan print)
18
# NOTE: this takes the ipmitool output and parses it, so changes to 
19
#       this output invalidates this module
20
 
21
BEGIN {
22
   push @INC, shift;
23
}
24
 
25
use library;
26
 
27
my $command = &validCommandOnSystem('ipmitool');
28
 
29
exit 1 unless $command;
30
 
31
my %storage = ( 
32
                'address' => { 'key' => 'IP Address' }, 
33
                'netmask' => { 'key' => 'Subnet Mask' },
34
                'mac' => { 'key' => 'MAC Address' }
35
              );
36
 
37
my $CATEGORY = 'network';
57 rodolico 38
my @temp = qx( $command lan print 2>/dev/null );
29 rodolico 39
chomp @temp;
40
 
41
foreach my $line ( @temp ) {
42
   my ( $key, $value ) = split( /\s+:\s+/, $line );
43
   foreach my $test ( keys %storage ) {
44
      next if defined( $storage{$test}{'value'} );
45
      if ( $key eq $storage{$test}{'key'} ) {
46
         $storage{$test}{'value'} = $value;
47
         last;
48
      } # if
49
   } # foreach 
50
}
51
 
52
foreach my $key ( keys %storage ) {
53
   print "$CATEGORY\tipmi\t$key\t$storage{$key}{'value'}\n";
54
}
55
 
56
1;