line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package FusionInventory::Agent::Task::Inventory::Win32::Drives; |
2
|
|
|
|
|
|
|
|
3
|
2
|
|
|
2
|
|
66540984
|
use strict; |
|
2
|
|
|
|
|
8
|
|
|
2
|
|
|
|
|
123
|
|
4
|
2
|
|
|
2
|
|
14
|
use warnings; |
|
2
|
|
|
|
|
25
|
|
|
2
|
|
|
|
|
154
|
|
5
|
|
|
|
|
|
|
|
6
|
2
|
|
|
2
|
|
1704
|
use FusionInventory::Agent::Tools::Win32; |
|
2
|
|
|
|
|
8
|
|
|
2
|
|
|
|
|
1141
|
|
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
|
0
|
my (%params) = @_; |
20
|
0
|
0
|
|
|
|
0
|
return 0 if $params{no_category}->{drive}; |
21
|
0
|
|
|
|
|
0
|
return 1; |
22
|
|
|
|
|
|
|
} |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
sub doInventory { |
25
|
0
|
|
|
0
|
0
|
0
|
my (%params) = @_; |
26
|
|
|
|
|
|
|
|
27
|
0
|
|
|
|
|
0
|
my $inventory = $params{inventory}; |
28
|
|
|
|
|
|
|
|
29
|
0
|
|
|
|
|
0
|
foreach my $drive (_getDrives( |
30
|
|
|
|
|
|
|
logger => $params{logger}, |
31
|
|
|
|
|
|
|
)) { |
32
|
0
|
|
|
|
|
0
|
$inventory->addEntry( |
33
|
|
|
|
|
|
|
section => 'DRIVES', |
34
|
|
|
|
|
|
|
entry => $drive |
35
|
|
|
|
|
|
|
); |
36
|
|
|
|
|
|
|
} |
37
|
|
|
|
|
|
|
} |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
sub _getDrives { |
40
|
2
|
|
|
2
|
|
551
|
my (%params) = @_; |
41
|
|
|
|
|
|
|
|
42
|
2
|
|
|
|
|
4
|
my $systemDrive; |
43
|
2
|
|
|
|
|
14
|
foreach my $object (getWMIObjects( |
44
|
|
|
|
|
|
|
class => 'Win32_OperatingSystem', |
45
|
|
|
|
|
|
|
properties => [ qw/SystemDrive/ ] |
46
|
|
|
|
|
|
|
)) { |
47
|
2
|
|
|
|
|
5473
|
$systemDrive = lc($object->{SystemDrive}); |
48
|
|
|
|
|
|
|
} |
49
|
|
|
|
|
|
|
|
50
|
2
|
|
|
|
|
7
|
my @drives; |
51
|
|
|
|
|
|
|
|
52
|
2
|
|
|
|
|
17
|
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
|
|
|
|
|
|
|
$object->{FreeSpace} = int($object->{FreeSpace} / (1024 * 1024)) |
61
|
12
|
100
|
|
|
|
3270
|
if $object->{FreeSpace}; |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
$object->{Size} = int($object->{Size} / (1024 * 1024)) |
64
|
12
|
100
|
|
|
|
39
|
if $object->{Size}; |
65
|
|
|
|
|
|
|
|
66
|
12
|
|
|
|
|
55
|
my $filesystem = $object->{FileSystem}; |
67
|
12
|
100
|
66
|
|
|
43
|
if ($object->{DriveType} == 4 && $object->{ProviderName}) { |
68
|
5
|
50
|
33
|
|
|
46
|
if ($object->{ProviderName} =~ /\\DavWWWRoot\\/) { |
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
69
|
0
|
|
|
|
|
0
|
$filesystem = "WebDav"; |
70
|
|
|
|
|
|
|
} elsif ($object->{ProviderName} =~ /^\\\\vmware-host\\/) { |
71
|
1
|
|
|
|
|
2
|
$filesystem = "HGFS"; |
72
|
|
|
|
|
|
|
} elsif (!$object->{FileSystem} || $object->{FileSystem} ne 'NFS') { |
73
|
4
|
|
|
|
|
6
|
$filesystem = "CIFS"; |
74
|
|
|
|
|
|
|
} |
75
|
|
|
|
|
|
|
} |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
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
|
12
|
|
33
|
|
|
126
|
}; |
90
|
|
|
|
|
|
|
} |
91
|
|
|
|
|
|
|
|
92
|
2
|
|
|
|
|
26
|
return @drives; |
93
|
|
|
|
|
|
|
} |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
1; |