Rev 69 | Rev 244 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | Download | RSS feed
#!/usr/bin/env perl
use warnings;
use strict;
# Description: Gets PCI information on Unix systems if lspci installed
our $VERSION = '1.2';
# pci information for sysinfo client
# Author: R. W. Rodolico
# Date: 2016-04-08
# gets information on pci information assuming lspci is installed
# I really don't remember how I wrote this originally, so I just put everything
# into the hash (as done in v2), then print the hash. Unneccessarily wasteful of memory
BEGIN {
push @INC, shift;
}
use library;
my $command = &validCommandOnSystem('pciconf');
exit 1 unless $command;
exit 1 unless &getOperatingSystem() =~ m/bsd/i;
my $CATEGORY = 'pci';
my @pciInfo = qx($command -lv);
my %returnValue;
chomp @pciInfo;
my $slot = '';
while ( my $line = shift( @pciInfo ) ) {
if ( $line =~ m/^([^@]+)\@([^ ]+)\s+class=([^ ]+)\s+card=([^ ]+)\s+chip=([^ ]+)\s+rev=([^ ]+)\s+hdr=(.+)$/ ) {
$slot = $2;
$returnValue{$slot}{'driver'} = $1;
$returnValue{$slot}{'class'} = $3;
$returnValue{$slot}{'card'} = $4;
$returnValue{$slot}{'chip'} = $5;
$returnValue{$slot}{'revision'} = $6;
$returnValue{$slot}{'header'} = $7;
} else {
my ($key, $value ) = split( '=', $line );
$returnValue{$slot}{&cleanUp( ' ', $key )} = &cleanUp( ' ', $value );
}
}
foreach my $key ( sort keys %returnValue ) {
my $temp = $returnValue{$key};
foreach my $info ( keys %$temp ) {
print "$CATEGORY\t$key\t$info\t" . $$temp{$info} . "\n";
}
}
Generated by GNU Enscript 1.6.5.90.