line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package FusionInventory::Agent::Task::Inventory::Win32::Controllers; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
60193454
|
use strict; |
|
1
|
|
|
|
|
8
|
|
|
1
|
|
|
|
|
80
|
|
4
|
1
|
|
|
1
|
|
6
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
74
|
|
5
|
|
|
|
|
|
|
|
6
|
1
|
|
|
1
|
|
671
|
use FusionInventory::Agent::Tools::Generic; |
|
1
|
|
|
|
|
21
|
|
|
1
|
|
|
|
|
102
|
|
7
|
1
|
|
|
1
|
|
654
|
use FusionInventory::Agent::Tools::Win32; |
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
645
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
sub isEnabled { |
10
|
0
|
|
|
0
|
0
|
|
my (%params) = @_; |
11
|
0
|
0
|
|
|
|
|
return 0 if $params{no_category}->{controller}; |
12
|
0
|
|
|
|
|
|
return 1; |
13
|
|
|
|
|
|
|
} |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
sub doInventory { |
16
|
0
|
|
|
0
|
0
|
|
my (%params) = @_; |
17
|
|
|
|
|
|
|
|
18
|
0
|
|
|
|
|
|
my $inventory = $params{inventory}; |
19
|
|
|
|
|
|
|
|
20
|
0
|
|
|
|
|
|
foreach my $controller (_getControllers( |
21
|
|
|
|
|
|
|
logger => $params{logger}, |
22
|
|
|
|
|
|
|
datadir => $params{datadir} |
23
|
|
|
|
|
|
|
)) { |
24
|
0
|
|
|
|
|
|
$inventory->addEntry( |
25
|
|
|
|
|
|
|
section => 'CONTROLLERS', |
26
|
|
|
|
|
|
|
entry => $controller |
27
|
|
|
|
|
|
|
); |
28
|
|
|
|
|
|
|
} |
29
|
|
|
|
|
|
|
} |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
sub _getControllers { |
32
|
0
|
|
|
0
|
|
|
my @controllers; |
33
|
|
|
|
|
|
|
my %seen; |
34
|
|
|
|
|
|
|
|
35
|
0
|
|
|
|
|
|
foreach my $controller (_getControllersFromWMI(@_)) { |
36
|
|
|
|
|
|
|
|
37
|
0
|
0
|
|
|
|
|
if ($controller->{deviceid} =~ /PCI\\VEN_(\S{4})&DEV_(\S{4})/) { |
38
|
0
|
|
|
|
|
|
$controller->{VENDORID} = lc($1); |
39
|
0
|
|
|
|
|
|
$controller->{PRODUCTID} = lc($2); |
40
|
|
|
|
|
|
|
} |
41
|
|
|
|
|
|
|
|
42
|
0
|
0
|
|
|
|
|
if ($controller->{deviceid} =~ /&SUBSYS_(\S{4})(\S{4})/) { |
43
|
0
|
|
|
|
|
|
$controller->{PCISUBSYSTEMID} = lc($2 . ':' . $1); |
44
|
|
|
|
|
|
|
} |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
# only devices with a PCIID sounds resonable |
47
|
0
|
0
|
0
|
|
|
|
next unless $controller->{VENDORID} && $controller->{PRODUCTID}; |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
# avoid duplicates |
50
|
0
|
0
|
|
|
|
|
next if $seen{$controller->{VENDORID}}->{$controller->{PRODUCTID}}++; |
51
|
|
|
|
|
|
|
|
52
|
0
|
|
|
|
|
|
delete $controller->{deviceid}; |
53
|
|
|
|
|
|
|
|
54
|
0
|
|
|
|
|
|
my $vendor_id = lc($controller->{VENDORID}); |
55
|
0
|
|
|
|
|
|
my $device_id = lc($controller->{PRODUCTID}); |
56
|
0
|
|
|
|
|
|
my $subdevice_id = lc($controller->{PCISUBSYSTEMID}); |
57
|
|
|
|
|
|
|
|
58
|
0
|
|
|
|
|
|
my $vendor = getPCIDeviceVendor(id => $vendor_id, @_); |
59
|
0
|
0
|
|
|
|
|
if ($vendor) { |
60
|
0
|
|
|
|
|
|
$controller->{MANUFACTURER} = $vendor->{name}; |
61
|
|
|
|
|
|
|
|
62
|
0
|
0
|
|
|
|
|
if ($vendor->{devices}->{$device_id}) { |
63
|
0
|
|
|
|
|
|
my $entry = $vendor->{devices}->{$device_id}; |
64
|
0
|
|
|
|
|
|
$controller->{CAPTION} = $entry->{name}; |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
$controller->{NAME} = |
67
|
|
|
|
|
|
|
$subdevice_id && $entry->{subdevices}->{$subdevice_id} ? |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
$entry->{subdevices}->{$subdevice_id}->{name} : |
70
|
0
|
0
|
0
|
|
|
|
$entry->{name}; |
71
|
|
|
|
|
|
|
} |
72
|
|
|
|
|
|
|
} |
73
|
|
|
|
|
|
|
|
74
|
0
|
|
|
|
|
|
push @controllers, $controller; |
75
|
|
|
|
|
|
|
} |
76
|
|
|
|
|
|
|
|
77
|
0
|
|
|
|
|
|
return @controllers; |
78
|
|
|
|
|
|
|
} |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
sub _getControllersFromWMI { |
81
|
0
|
|
|
0
|
|
|
my @controllers; |
82
|
|
|
|
|
|
|
|
83
|
0
|
|
|
|
|
|
foreach my $class (qw/ |
84
|
|
|
|
|
|
|
Win32_FloppyController Win32_IDEController Win32_SCSIController |
85
|
|
|
|
|
|
|
Win32_VideoController Win32_InfraredDevice Win32_USBController |
86
|
|
|
|
|
|
|
Win32_1394Controller Win32_PCMCIAController CIM_LogicalDevice |
87
|
|
|
|
|
|
|
/) { |
88
|
|
|
|
|
|
|
|
89
|
0
|
|
|
|
|
|
foreach my $object (getWMIObjects( |
90
|
|
|
|
|
|
|
class => $class, |
91
|
|
|
|
|
|
|
properties => [ qw/ |
92
|
|
|
|
|
|
|
Name Manufacturer Caption DeviceID |
93
|
|
|
|
|
|
|
/] |
94
|
|
|
|
|
|
|
)) { |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
push @controllers, { |
97
|
|
|
|
|
|
|
NAME => $object->{Name}, |
98
|
|
|
|
|
|
|
MANUFACTURER => $object->{Manufacturer}, |
99
|
|
|
|
|
|
|
CAPTION => $object->{Caption}, |
100
|
|
|
|
|
|
|
TYPE => $object->{Caption}, |
101
|
|
|
|
|
|
|
deviceid => $object->{DeviceID}, |
102
|
0
|
|
|
|
|
|
}; |
103
|
|
|
|
|
|
|
} |
104
|
|
|
|
|
|
|
} |
105
|
|
|
|
|
|
|
|
106
|
0
|
|
|
|
|
|
return @controllers; |
107
|
|
|
|
|
|
|
} |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
1; |