line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package FusionInventory::Agent::Task::Inventory::Win32::Drives; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
49303109
|
use strict; |
|
1
|
|
|
|
|
5
|
|
|
1
|
|
|
|
|
67
|
|
4
|
1
|
|
|
1
|
|
5
|
use warnings; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
65
|
|
5
|
|
|
|
|
|
|
|
6
|
1
|
|
|
1
|
|
437
|
use FusionInventory::Agent::Tools::Win32; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
500
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
my @type = ( |
9
|
|
|
|
|
|
|
'Unknown', |
10
|
|
|
|
|
|
|
'No Root Directory', |
11
|
|
|
|
|
|
|
'Removable Disk', |
12
|
|
|
|
|
|
|
'Local Disk', |
13
|
|
|
|
|
|
|
'Network Drive', |
14
|
|
|
|
|
|
|
'Compact Disc', |
15
|
|
|
|
|
|
|
'RAM Disk' |
16
|
|
|
|
|
|
|
); |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
sub isEnabled { |
19
|
0
|
|
|
0
|
0
|
|
my (%params) = @_; |
20
|
0
|
0
|
|
|
|
|
return 0 if $params{no_category}->{drive}; |
21
|
0
|
|
|
|
|
|
return 1; |
22
|
|
|
|
|
|
|
} |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
sub doInventory { |
25
|
0
|
|
|
0
|
0
|
|
my (%params) = @_; |
26
|
|
|
|
|
|
|
|
27
|
0
|
|
|
|
|
|
my $inventory = $params{inventory}; |
28
|
|
|
|
|
|
|
|
29
|
0
|
|
|
|
|
|
foreach my $drive (_getDrives( |
30
|
|
|
|
|
|
|
logger => $params{logger}, |
31
|
|
|
|
|
|
|
)) { |
32
|
0
|
|
|
|
|
|
$inventory->addEntry( |
33
|
|
|
|
|
|
|
section => 'DRIVES', |
34
|
|
|
|
|
|
|
entry => $drive |
35
|
|
|
|
|
|
|
); |
36
|
|
|
|
|
|
|
} |
37
|
|
|
|
|
|
|
} |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
sub _getDrives { |
40
|
0
|
|
|
0
|
|
|
my (%params) = @_; |
41
|
|
|
|
|
|
|
|
42
|
0
|
|
|
|
|
|
my $systemDrive; |
43
|
0
|
|
|
|
|
|
foreach my $object (getWMIObjects( |
44
|
|
|
|
|
|
|
class => 'Win32_OperatingSystem', |
45
|
|
|
|
|
|
|
properties => [ qw/SystemDrive/ ] |
46
|
|
|
|
|
|
|
)) { |
47
|
0
|
|
|
|
|
|
$systemDrive = lc($object->{SystemDrive}); |
48
|
|
|
|
|
|
|
} |
49
|
|
|
|
|
|
|
|
50
|
0
|
|
|
|
|
|
my @drives; |
51
|
|
|
|
|
|
|
|
52
|
0
|
|
|
|
|
|
foreach my $object (getWMIObjects( |
53
|
|
|
|
|
|
|
class => 'Win32_LogicalDisk', |
54
|
|
|
|
|
|
|
properties => [ qw/ |
55
|
|
|
|
|
|
|
InstallDate Description FreeSpace FileSystem VolumeName Caption |
56
|
|
|
|
|
|
|
VolumeSerialNumber DeviceID Size DriveType VolumeName ProviderName |
57
|
|
|
|
|
|
|
/ ] |
58
|
|
|
|
|
|
|
)) { |
59
|
|
|
|
|
|
|
|
60
|
0
|
0
|
|
|
|
|
$object->{FreeSpace} = int($object->{FreeSpace} / (1024 * 1024)) |
61
|
|
|
|
|
|
|
if $object->{FreeSpace}; |
62
|
|
|
|
|
|
|
|
63
|
0
|
0
|
|
|
|
|
$object->{Size} = int($object->{Size} / (1024 * 1024)) |
64
|
|
|
|
|
|
|
if $object->{Size}; |
65
|
|
|
|
|
|
|
|
66
|
0
|
|
|
|
|
|
my $filesystem = $object->{FileSystem}; |
67
|
0
|
0
|
0
|
|
|
|
if ($object->{DriveType} == 4 && $object->{ProviderName}) { |
68
|
0
|
0
|
0
|
|
|
|
if ($object->{ProviderName} =~ /\\DavWWWRoot\\/) { |
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
69
|
0
|
|
|
|
|
|
$filesystem = "WebDav"; |
70
|
|
|
|
|
|
|
} elsif ($object->{ProviderName} =~ /^\\\\vmware-host\\/) { |
71
|
0
|
|
|
|
|
|
$filesystem = "HGFS"; |
72
|
|
|
|
|
|
|
} elsif (!$object->{FileSystem} || $object->{FileSystem} ne 'NFS') { |
73
|
0
|
|
|
|
|
|
$filesystem = "CIFS"; |
74
|
|
|
|
|
|
|
} |
75
|
|
|
|
|
|
|
} |
76
|
|
|
|
|
|
|
|
77
|
0
|
|
0
|
|
|
|
push @drives, { |
78
|
|
|
|
|
|
|
CREATEDATE => $object->{InstallDate}, |
79
|
|
|
|
|
|
|
DESCRIPTION => $object->{Description}, |
80
|
|
|
|
|
|
|
FREE => $object->{FreeSpace}, |
81
|
|
|
|
|
|
|
FILESYSTEM => $filesystem, |
82
|
|
|
|
|
|
|
LABEL => $object->{VolumeName}, |
83
|
|
|
|
|
|
|
LETTER => $object->{DeviceID} || $object->{Caption}, |
84
|
|
|
|
|
|
|
SERIAL => $object->{VolumeSerialNumber}, |
85
|
|
|
|
|
|
|
SYSTEMDRIVE => (lc($object->{DeviceID}) eq $systemDrive), |
86
|
|
|
|
|
|
|
TOTAL => $object->{Size}, |
87
|
|
|
|
|
|
|
TYPE => $type[$object->{DriveType}], |
88
|
|
|
|
|
|
|
VOLUMN => $object->{VolumeName}, |
89
|
|
|
|
|
|
|
}; |
90
|
|
|
|
|
|
|
} |
91
|
|
|
|
|
|
|
|
92
|
0
|
|
|
|
|
|
return @drives; |
93
|
|
|
|
|
|
|
} |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
1; |