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