Subversion Repositories camp_sysinfo_client_3

Rev

Go to most recent revision | Details | 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
 
37 rodolico 7
our $VERSION = '1.1';
8
 
29 rodolico 9
# IPMI network module for sysinfo client
10
# Author: R. W. Rodolico
11
# Date:   2016-09-17 
12
 
13
# module to get network interface information for ipmi
14
# requires ipmitool (runs ipmitool lan print)
15
# NOTE: this takes the ipmitool output and parses it, so changes to 
16
#       this output invalidates this module
17
 
18
BEGIN {
19
   push @INC, shift;
20
}
21
 
22
use library;
23
 
24
my $command = &validCommandOnSystem('ipmitool');
25
 
26
exit 1 unless $command;
27
 
28
my %storage = ( 
29
                'address' => { 'key' => 'IP Address' }, 
30
                'netmask' => { 'key' => 'Subnet Mask' },
31
                'mac' => { 'key' => 'MAC Address' }
32
              );
33
 
34
my $CATEGORY = 'network';
35
my @temp = qx/$command lan print/;
36
chomp @temp;
37
 
38
foreach my $line ( @temp ) {
39
   my ( $key, $value ) = split( /\s+:\s+/, $line );
40
   foreach my $test ( keys %storage ) {
41
      next if defined( $storage{$test}{'value'} );
42
      if ( $key eq $storage{$test}{'key'} ) {
43
         $storage{$test}{'value'} = $value;
44
         last;
45
      } # if
46
   } # foreach 
47
}
48
 
49
foreach my $key ( keys %storage ) {
50
   print "$CATEGORY\tipmi\t$key\t$storage{$key}{'value'}\n";
51
}
52
 
53
1;