/usr/share/fusioninventory/lib/FusionInventory/Agent/Task/Inventory/Linux/Videos.pm is in fusioninventory-agent 1:2.3.10.1-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 | package FusionInventory::Agent::Task::Inventory::Linux::Videos;
use strict;
use warnings;
use FusionInventory::Agent::Tools;
use FusionInventory::Agent::Tools::Unix;
sub isEnabled {
return 1;
}
sub doInventory {
my (%params) = @_;
my $inventory = $params{inventory};
my $logger = $params{logger};
my $ddcprobeData = _getDdcprobeData(
command => 'ddcprobe',
logger => $logger
);
my $xorgData;
my $xorgPid;
foreach my $process (getProcesses(logger => $logger)) {
next unless $process->{CMD} =~ m{
^
(?:
/usr/bin
|
/usr/X11R6/bin
|
/etc/X11
)
/X
}x;
$xorgPid = $process->{PID};
last;
}
if ($xorgPid) {
my $link = "/proc/$xorgPid/fd/0";
$xorgData = _parseXorgFd(file => $link) if -r $link;
}
return unless $xorgData || $ddcprobeData;
my $video = {
CHIPSET => $xorgData->{product} || $ddcprobeData->{product},
MEMORY => $xorgData->{memory} || $ddcprobeData->{memory},
NAME => $xorgData->{name} || $ddcprobeData->{oem},
RESOLUTION => $xorgData->{resolution} || $ddcprobeData->{dtiming},
PCISLOT => $xorgData->{pcislot},
};
if ($video->{MEMORY} && $video->{MEMORY} =~ s/kb$//i) {
$video->{MEMORY} = int($video->{MEMORY} / 1024);
}
if ($video->{RESOLUTION}) {
$video->{RESOLUTION} =~ s/@.*//;
}
$inventory->addEntry(
section => 'VIDEOS',
entry => $video
);
}
sub _getDdcprobeData {
my $handle = getFileHandle(@_);
return unless $handle;
my $data;
while (my $line = <$handle>) {
$line =~ s/[[:cntrl:]]//g;
$line =~ s/[^[:ascii:]]//g;
$data->{$1} = $2 if $line =~ /^(\S+):\s+(.*)/;
}
close $handle;
return $data;
}
sub _parseXorgFd {
my $handle = getFileHandle(@_);
return unless $handle;
my $data;
while (my $line = <$handle>) {
if ($line =~ /Modeline\s"(\S+?)"/) {
$data->{resolution} = $1 if !$data->{resolution};
} elsif ($line =~ /Integrated Graphics Chipset:\s+(.*)/) {
# Intel
$data->{name} = $1;
} elsif ($line =~ /Virtual screen size determined to be (\d+)\s*x\s*(\d+)/) {
# Nvidia
$data->{resolution} = "$1x$2";
} elsif ($line =~ /NVIDIA GPU\s*(.*?)\s*at/) {
$data->{name} = $1;
} elsif ($line =~ /VESA VBE OEM:\s*(.*)/) {
$data->{name} = $1;
} elsif ($line =~ /VESA VBE OEM Product:\s*(.*)/) {
$data->{product} = $1;
} elsif ($line =~ /VESA VBE Total Mem: (\d+)\s*(\w+)/i) {
$data->{memory} = $1 . $2;
} elsif ($line =~ /RADEON\(0\): Chipset: "(.*?)"/i) {
# ATI /Radeon
$data->{name} = $1;
} elsif ($line =~ /Virtual size is (\S+)/i) {
# VESA / XFree86
$data->{resolution} = $1;
} elsif ($line =~ /Primary Device is: PCI (.+)/i) {
$data->{pcislot} = $1;
# mimic lspci pci slot format
$data->{pcislot} =~ s/^00@//;
$data->{pcislot} =~ s/(\d{2}):(\d{2}):(\d)$/$1:$2.$3/;
} elsif ($line =~ /NOUVEAU\(0\): Chipset: "(.*)"/) {
# Nouveau
$data->{product} = $1;
}
}
close $handle;
return $data;
}
1;
|