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
 
149 rodolico 7
our $VERSION = '1.2.1';
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
#
149 rodolico 16
# 20191118 RWR v1.2.1
17
# in some cases, ipmitool is used only to access other devices over the network
18
# so it will not have information. Fixed so that if @temp is empty, will just exit
19
#
29 rodolico 20
# module to get network interface information for ipmi
21
# requires ipmitool (runs ipmitool lan print)
22
# NOTE: this takes the ipmitool output and parses it, so changes to 
23
#       this output invalidates this module
24
 
25
BEGIN {
26
   push @INC, shift;
27
}
28
 
29
use library;
30
 
31
my $command = &validCommandOnSystem('ipmitool');
32
 
33
exit 1 unless $command;
34
 
35
my %storage = ( 
36
                'address' => { 'key' => 'IP Address' }, 
37
                'netmask' => { 'key' => 'Subnet Mask' },
38
                'mac' => { 'key' => 'MAC Address' }
39
              );
40
 
41
my $CATEGORY = 'network';
57 rodolico 42
my @temp = qx( $command lan print 2>/dev/null );
149 rodolico 43
exit 2 unless @temp; # ipmitool installed, but driver not. Probably using to connect someplace else.
29 rodolico 44
chomp @temp;
45
 
46
foreach my $line ( @temp ) {
47
   my ( $key, $value ) = split( /\s+:\s+/, $line );
48
   foreach my $test ( keys %storage ) {
49
      next if defined( $storage{$test}{'value'} );
50
      if ( $key eq $storage{$test}{'key'} ) {
51
         $storage{$test}{'value'} = $value;
52
         last;
53
      } # if
54
   } # foreach 
55
}
56
 
57
foreach my $key ( keys %storage ) {
58
   print "$CATEGORY\tipmi\t$key\t$storage{$key}{'value'}\n";
59
}
60
 
61
1;