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