line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package FusionInventory::Agent::Task::Inventory::Linux::Videos; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
35033136
|
use strict; |
|
1
|
|
|
|
|
13
|
|
|
1
|
|
|
|
|
99
|
|
4
|
1
|
|
|
1
|
|
9
|
use warnings; |
|
1
|
|
|
|
|
12
|
|
|
1
|
|
|
|
|
85
|
|
5
|
|
|
|
|
|
|
|
6
|
1
|
|
|
1
|
|
612
|
use FusionInventory::Agent::Tools; |
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
224
|
|
7
|
1
|
|
|
1
|
|
820
|
use FusionInventory::Agent::Tools::Unix; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
1212
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
sub isEnabled { |
10
|
0
|
|
|
0
|
0
|
|
my (%params) = @_; |
11
|
0
|
0
|
|
|
|
|
return 0 if $params{no_category}->{video}; |
12
|
0
|
|
|
|
|
|
return 1; |
13
|
|
|
|
|
|
|
} |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
sub doInventory { |
16
|
0
|
|
|
0
|
0
|
|
my (%params) = @_; |
17
|
|
|
|
|
|
|
|
18
|
0
|
|
|
|
|
|
my $inventory = $params{inventory}; |
19
|
0
|
|
|
|
|
|
my $logger = $params{logger}; |
20
|
|
|
|
|
|
|
|
21
|
0
|
|
|
|
|
|
$logger->debug("retrieving display information:"); |
22
|
|
|
|
|
|
|
|
23
|
0
|
|
|
|
|
|
my $ddcprobeData; |
24
|
0
|
0
|
|
|
|
|
if (canRun('ddcprobe')) { |
25
|
0
|
|
|
|
|
|
$ddcprobeData = _getDdcprobeData( |
26
|
|
|
|
|
|
|
command => 'ddcprobe', |
27
|
|
|
|
|
|
|
logger => $logger |
28
|
|
|
|
|
|
|
); |
29
|
0
|
|
|
|
|
|
$logger->debug_result( |
30
|
|
|
|
|
|
|
action => 'running ddcprobe command', |
31
|
|
|
|
|
|
|
data => $ddcprobeData |
32
|
|
|
|
|
|
|
); |
33
|
|
|
|
|
|
|
} else { |
34
|
0
|
|
|
|
|
|
$logger->debug_result( |
35
|
|
|
|
|
|
|
action => 'running ddcprobe command', |
36
|
|
|
|
|
|
|
status => 'command not available' |
37
|
|
|
|
|
|
|
); |
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
|
40
|
0
|
|
|
|
|
|
my $xorgData; |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
my $xorgPid; |
43
|
0
|
|
|
|
|
|
foreach my $process (getProcesses(logger => $logger)) { |
44
|
0
|
0
|
|
|
|
|
next unless $process->{CMD} =~ m{ |
45
|
|
|
|
|
|
|
^ |
46
|
|
|
|
|
|
|
(?: |
47
|
|
|
|
|
|
|
/usr/bin |
48
|
|
|
|
|
|
|
| |
49
|
|
|
|
|
|
|
/usr/X11R6/bin |
50
|
|
|
|
|
|
|
| |
51
|
|
|
|
|
|
|
/etc/X11 |
52
|
|
|
|
|
|
|
) |
53
|
|
|
|
|
|
|
/X |
54
|
|
|
|
|
|
|
}x; |
55
|
0
|
|
|
|
|
|
$xorgPid = $process->{PID}; |
56
|
0
|
|
|
|
|
|
last; |
57
|
|
|
|
|
|
|
} |
58
|
|
|
|
|
|
|
|
59
|
0
|
0
|
|
|
|
|
if ($xorgPid) { |
60
|
0
|
|
|
|
|
|
my $link = "/proc/$xorgPid/fd/0"; |
61
|
0
|
0
|
|
|
|
|
if (-r $link) { |
62
|
0
|
|
|
|
|
|
$xorgData = _parseXorgFd(file => $link); |
63
|
0
|
|
|
|
|
|
$logger->debug_result( |
64
|
|
|
|
|
|
|
action => 'reading Xorg log file', |
65
|
|
|
|
|
|
|
data => $xorgData |
66
|
|
|
|
|
|
|
); |
67
|
|
|
|
|
|
|
} else { |
68
|
0
|
|
|
|
|
|
$logger->debug_result( |
69
|
|
|
|
|
|
|
action => 'reading Xorg log file', |
70
|
|
|
|
|
|
|
status => "non-readable link $link" |
71
|
|
|
|
|
|
|
); |
72
|
|
|
|
|
|
|
} |
73
|
|
|
|
|
|
|
} else { |
74
|
0
|
|
|
|
|
|
$logger->debug_result( |
75
|
|
|
|
|
|
|
action => 'reading Xorg log file', |
76
|
|
|
|
|
|
|
status => 'unable to get Xorg PID' |
77
|
|
|
|
|
|
|
); |
78
|
|
|
|
|
|
|
} |
79
|
|
|
|
|
|
|
|
80
|
0
|
0
|
0
|
|
|
|
return unless $xorgData || $ddcprobeData; |
81
|
|
|
|
|
|
|
|
82
|
0
|
|
0
|
|
|
|
my $video = { |
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
83
|
|
|
|
|
|
|
CHIPSET => $xorgData->{product} || $ddcprobeData->{product}, |
84
|
|
|
|
|
|
|
MEMORY => $xorgData->{memory} || $ddcprobeData->{memory}, |
85
|
|
|
|
|
|
|
NAME => $xorgData->{name} || $ddcprobeData->{oem}, |
86
|
|
|
|
|
|
|
RESOLUTION => $xorgData->{resolution} || $ddcprobeData->{dtiming}, |
87
|
|
|
|
|
|
|
PCISLOT => $xorgData->{pcislot}, |
88
|
|
|
|
|
|
|
PCIID => $xorgData->{pciid}, |
89
|
|
|
|
|
|
|
}; |
90
|
|
|
|
|
|
|
|
91
|
0
|
0
|
0
|
|
|
|
if ($video->{MEMORY} && $video->{MEMORY} =~ s/kb$//i) { |
92
|
0
|
|
|
|
|
|
$video->{MEMORY} = int($video->{MEMORY} / 1024); |
93
|
|
|
|
|
|
|
} |
94
|
0
|
0
|
|
|
|
|
if ($video->{RESOLUTION}) { |
95
|
0
|
|
|
|
|
|
$video->{RESOLUTION} =~ s/@.*//; |
96
|
|
|
|
|
|
|
} |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
$inventory->addEntry( |
99
|
0
|
|
|
|
|
|
section => 'VIDEOS', |
100
|
|
|
|
|
|
|
entry => $video |
101
|
|
|
|
|
|
|
); |
102
|
|
|
|
|
|
|
} |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
sub _getDdcprobeData { |
105
|
0
|
|
|
0
|
|
|
my $handle = getFileHandle(@_); |
106
|
0
|
0
|
|
|
|
|
return unless $handle; |
107
|
|
|
|
|
|
|
|
108
|
0
|
|
|
|
|
|
my $data; |
109
|
0
|
|
|
|
|
|
while (my $line = <$handle>) { |
110
|
0
|
|
|
|
|
|
$line =~ s/[[:cntrl:]]//g; |
111
|
0
|
|
|
|
|
|
$line =~ s/[^[:ascii:]]//g; |
112
|
0
|
0
|
|
|
|
|
$data->{$1} = $2 if $line =~ /^(\S+):\s+(.*)/; |
113
|
|
|
|
|
|
|
} |
114
|
0
|
|
|
|
|
|
close $handle; |
115
|
|
|
|
|
|
|
|
116
|
0
|
|
|
|
|
|
return $data; |
117
|
|
|
|
|
|
|
} |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
sub _parseXorgFd { |
120
|
0
|
|
|
0
|
|
|
my $handle = getFileHandle(@_); |
121
|
0
|
0
|
|
|
|
|
return unless $handle; |
122
|
|
|
|
|
|
|
|
123
|
0
|
|
|
|
|
|
my $data; |
124
|
0
|
|
|
|
|
|
while (my $line = <$handle>) { |
125
|
0
|
0
|
|
|
|
|
if ($line =~ /Modeline\s"(\S+?)"/) { |
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
126
|
0
|
0
|
|
|
|
|
$data->{resolution} = $1 if !$data->{resolution}; |
127
|
|
|
|
|
|
|
} elsif ($line =~ /Integrated Graphics Chipset:\s+(.*)/) { |
128
|
|
|
|
|
|
|
# Intel |
129
|
0
|
|
|
|
|
|
$data->{name} = $1; |
130
|
|
|
|
|
|
|
} elsif ($line =~ /Virtual screen size determined to be (\d+)\s*x\s*(\d+)/) { |
131
|
|
|
|
|
|
|
# Nvidia |
132
|
0
|
|
|
|
|
|
$data->{resolution} = "$1x$2"; |
133
|
|
|
|
|
|
|
} elsif ($line =~ /NVIDIA GPU\s*(.*?)\s*at/) { |
134
|
0
|
|
|
|
|
|
$data->{name} = $1; |
135
|
|
|
|
|
|
|
} elsif ($line =~ /VESA VBE OEM:\s*(.*)/) { |
136
|
0
|
|
|
|
|
|
$data->{name} = $1; |
137
|
|
|
|
|
|
|
} elsif ($line =~ /VESA VBE OEM Product:\s*(.*)/) { |
138
|
0
|
|
|
|
|
|
$data->{product} = $1; |
139
|
|
|
|
|
|
|
} elsif ($line =~ /VESA VBE Total Mem: (\d+)\s*(\w+)/i) { |
140
|
0
|
|
|
|
|
|
$data->{memory} = $1 . $2; |
141
|
|
|
|
|
|
|
} elsif ($line =~ /RADEON\(0\): Chipset: "(.*?)"/i) { |
142
|
|
|
|
|
|
|
# ATI /Radeon |
143
|
0
|
|
|
|
|
|
$data->{name} = $1; |
144
|
|
|
|
|
|
|
} elsif ($line =~ /Virtual size is (\S+)/i) { |
145
|
|
|
|
|
|
|
# VESA / XFree86 |
146
|
0
|
|
|
|
|
|
$data->{resolution} = $1; |
147
|
|
|
|
|
|
|
} elsif ($line =~ / |
148
|
|
|
|
|
|
|
PCI: \* \( (?:\d+:)? (\d+) : (\d+) : (\d+) \) \s |
149
|
|
|
|
|
|
|
(\w{4}:\w{4}:\w{4}:\w{4})? |
150
|
|
|
|
|
|
|
/x) { |
151
|
0
|
|
|
|
|
|
$data->{pcislot} = sprintf("%02d:%02d.%d", $1, $2, $3); |
152
|
0
|
0
|
|
|
|
|
$data->{pciid} = $4 if $4; |
153
|
|
|
|
|
|
|
} elsif ($line =~ /NOUVEAU\(0\): Chipset: "(.*)"/) { |
154
|
|
|
|
|
|
|
# Nouveau |
155
|
0
|
|
|
|
|
|
$data->{product} = $1; |
156
|
|
|
|
|
|
|
} |
157
|
|
|
|
|
|
|
} |
158
|
0
|
|
|
|
|
|
close $handle; |
159
|
|
|
|
|
|
|
|
160
|
0
|
|
|
|
|
|
return $data; |
161
|
|
|
|
|
|
|
} |
162
|
|
|
|
|
|
|
|
163
|
|
|
|
|
|
|
1; |