Subversion Repositories camp_sysinfo_client_3

Rev

Rev 69 | 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;
197 rodolico 26
exit 1 unless &getOperatingSystem() =~ m/bsd/i;
48 rodolico 27
 
28
 
29
my $CATEGORY = 'pci';
30
 
31
my @pciInfo =  qx($command -lv);
32
 
33
my %returnValue;
34
 
35
chomp @pciInfo;
36
my $slot = '';
37
while ( my $line = shift( @pciInfo ) ) {
38
   if ( $line =~ m/^([^@]+)\@([^ ]+)\s+class=([^ ]+)\s+card=([^ ]+)\s+chip=([^ ]+)\s+rev=([^ ]+)\s+hdr=(.+)$/ ) {
39
      $slot = $2;
40
      $returnValue{$slot}{'driver'} = $1;
41
      $returnValue{$slot}{'class'} = $3;
42
      $returnValue{$slot}{'card'} = $4;
43
      $returnValue{$slot}{'chip'} = $5;
44
      $returnValue{$slot}{'revision'} = $6;
45
      $returnValue{$slot}{'header'} = $7;
46
   } else {
47
      my ($key, $value ) = split( '=', $line );
48
      $returnValue{$slot}{&cleanUp( ' ', $key )} = &cleanUp( ' ', $value );
49
   }
50
}
51
 
52
 
53
foreach my $key ( sort keys %returnValue ) {
54
   my $temp = $returnValue{$key};
55
   foreach my $info ( keys %$temp ) {
56
      print "$CATEGORY\t$key\t$info\t" . $$temp{$info} . "\n";
57
   }
58
}
59