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