Subversion Repositories camp_sysinfo_client_3

Rev

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

Rev Author Line No. Line
48 rodolico 1
#!/usr/bin/env perl
2
use warnings;
3
use strict;  
4
 
5
# Description: Gets PCI information on Unix systems if lspci installed
6
 
7
our $VERSION = '1.2';
8
 
9
# pci information for sysinfo client
10
# Author: R. W. Rodolico
11
# Date:   2016-04-08
12
 
13
# gets information on pci information assuming lspci is installed
14
# I really don't remember how I wrote this originally, so I just put everything
15
# into the hash (as done in v2), then print the hash. Unneccessarily wasteful of memory
16
 
17
BEGIN {
18
   push @INC, shift;
19
}
20
 
21
use library;
22
 
23
my $command = &validCommandOnSystem('pciconf');
24
 
25
exit 1 unless $command;
26
 
27
 
28
my $CATEGORY = 'pci';
29
 
30
my @pciInfo =  qx($command -lv);
31
 
32
my %returnValue;
33
 
34
chomp @pciInfo;
35
my $slot = '';
36
while ( my $line = shift( @pciInfo ) ) {
37
   if ( $line =~ m/^([^@]+)\@([^ ]+)\s+class=([^ ]+)\s+card=([^ ]+)\s+chip=([^ ]+)\s+rev=([^ ]+)\s+hdr=(.+)$/ ) {
38
      $slot = $2;
39
      $returnValue{$slot}{'driver'} = $1;
40
      $returnValue{$slot}{'class'} = $3;
41
      $returnValue{$slot}{'card'} = $4;
42
      $returnValue{$slot}{'chip'} = $5;
43
      $returnValue{$slot}{'revision'} = $6;
44
      $returnValue{$slot}{'header'} = $7;
45
   } else {
46
      my ($key, $value ) = split( '=', $line );
47
      $returnValue{$slot}{&cleanUp( ' ', $key )} = &cleanUp( ' ', $value );
48
   }
49
}
50
 
51
 
52
foreach my $key ( sort keys %returnValue ) {
53
   my $temp = $returnValue{$key};
54
   foreach my $info ( keys %$temp ) {
55
      print "$CATEGORY\t$key\t$info\t" . $$temp{$info} . "\n";
56
   }
57
}
58