"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "lib/Ocsinventory/Agent/Backend/OS/Generic/Lspci/Videos.pm" between
Ocsinventory-Unix-Agent-2.6.1.tar.gz and Ocsinventory-Unix-Agent-2.8.0.tar.gz

About: Ocsinventory-Agent is a Linux agent for OCS Inventory NG.

Videos.pm  (Ocsinventory-Unix-Agent-2.6.1):Videos.pm  (Ocsinventory-Unix-Agent-2.8.0)
package Ocsinventory::Agent::Backend::OS::Generic::Lspci::Videos; package Ocsinventory::Agent::Backend::OS::Generic::Lspci::Videos;
use strict; use strict;
my $memory; my $memory;
my $resolution;
my $chipset; my $chipset;
my @resolution; my $name;
my ($ret,$handle,$i,$count,$clock,$driver_version, $nvml_version, $memtotal, $se
rial, $bios_version, $uuid, $name);
my $reso;
#sub check {
# return unless $common->can_run("xrandr");
# return 1;
#}
sub run { sub run {
my $params = shift; my $params = shift;
my $common = $params->{common}; my $common = $params->{common};
if ($common->can_run("xrandr")) { foreach(`lspci`){
if ($common->can_run("nvidia-smi")) { if(/graphics|vga|video|display/i && /^([0-9a-f][0-9a-f]:[0-9a-f][0-9a-f].
if ($common->can_load("nvidia::ml qw(:all)")){ [0-9a-f])\s([^:]+):\s*(.+?)(?:\(([^()]+)\))?$/i){
nvmlInit(); my $slot = $1;
# Retrieve driver version $chipset = $2;
($ret, $driver_version) = nvmlSystemGetDriverVersion(); $name = $3;
die nvmlErrorString($ret) unless $ret == $nividia::ml::bindings: if (defined $slot) {
:NVML_SUCCESS; my @detail = `lspci -v -s $slot 2>/dev/null`;
$memory = 0;
# Retrieve NVML version foreach my $m (@detail) {
($ret, $nvml_version) = nvmlSystemGetNVMLVersion(); if ($m =~ /.*Memory.*\s+\(.*-bit,\sprefetchable\)\s\[size=(\d
die nvmlErrorString($ret) unless $ret == $nividia::ml::bindings: *)M\]/) {
:NVML_SUCCESS; $memory += $1;
}
# How many nvidia cards are present? }
($ret, $count) = nvmlDeviceGetCount(); # Don't record zero memory
die nvmlErrorString($ret) unless $ret == $nividia::ml::bindings: $memory = undef if $memory == 0;
:NVML_SUCCESS; }
$common->addVideo({
for ($i=0; $i<$count; $i++) { 'CHIPSET' => $chipset,
($ret, $handle) = nvmlDeviceGetHandleByIndex($i); 'NAME' => $name,
next if $ret != $nvidia::ml::bindings::NVML_SUCCESS; 'MEMORY' => $memory,
});
($ret, $name) = nvmlDeviceGetName($handle); }
next if $ret != $nvidia::ml::bindings::NVML_SUCCESS; }
($ret, $memtotal) = nvmlDeviceGetMemoryInfo($handle);
next if $ret != $nvidia::ml::bindings::NVML_SUCCESS;
$memtotal = ($memtotal->{"total"} / 1024 / 1024);
($ret, $serial) = nvmlDeviceGetSerial($handle);
next if $ret != $nvidia::ml::bindings::NVML_SUCCESS;
($ret, $bios_version) = nvmlDeviceVBiosVersion($handle);
next if $ret != $nvidia::ml::bindings::NVML_SUCCESS;
($ret, $uuid) = nvmlDeviceGetUUID($handle);
next if $ret != $nvidia::ml::bindings::NVML_SUCCESS;
}
nvmlShutdown();
my @resol= `xrandr --verbose | grep *current`;
foreach my $r (@resol){
if ($r =~ /((\d{3,4})x(\d{3,4}))/){
push(@resolution,$1);
}
}
foreach my $res (@resolution){
$reso = $res;
}
$common->addVideo({
NAME => $name,
MEMORY => $memtotal,
DRVVERSION => $driver_version,
NVMLVERSION => $nvml_version,
SPEED => $clock,
SERIAL => $serial,
VBIOS => $bios_version,
UUID => $uuid,
RESOLUTION => $reso,
});
}
} else {
foreach(`lspci`){
if(/graphics|vga|video/i && /^([0-9a-f][0-9a-f]:[0-9a-f][0-9a-f]
.[0-9a-f])\s([^:]+):\s*(.+?)(?:\(([^()]+)\))?$/i){
my $slot = $1;
$chipset = $2;
$name = $3;
if (defined $slot) {
my @detail = `lspci -v -s $slot`;
$memory = 0;
foreach my $m (@detail) {
if ($m =~ /.*Memory.*\s+\(.*-bit,\sprefetchable\)\s\
[size=(\d*)M\]/) {
$memory += $1;
}
}
# Don't record zero memory
$memory = undef if $memory == 0;
}
my @resol= `xrandr --verbose | grep *current`;
foreach my $r (@resol){
if ($r =~ /((\d{3,4})x(\d{3,4}))/){
$resolution = $1;
}
}
$common->addVideo({
'CHIPSET' => $chipset,
'NAME' => $name,
'MEMORY' => $memory,
'RESOLUTION' => $resolution,
});
}
}
}
}
else {
foreach(`lspci`){
if(/graphics|vga|video/i && /^\S+\s([^:]+):\s*(.+?)(?:\(([^()]+)\))?
$/i){
$common->addVideo({
'CHIPSET' => $1,
'NAME' => $2,
});
}
}
}
} }
1; 1;
 End of changes. 3 change blocks. 
117 lines changed or deleted 26 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)