line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package FusionInventory::Agent::Task::Inventory::BSD::Storages; |
2
|
|
|
|
|
|
|
|
3
|
3
|
|
|
3
|
|
93756582
|
use strict; |
|
3
|
|
|
|
|
7
|
|
|
3
|
|
|
|
|
86
|
|
4
|
3
|
|
|
3
|
|
11
|
use warnings; |
|
3
|
|
|
|
|
4
|
|
|
3
|
|
|
|
|
105
|
|
5
|
|
|
|
|
|
|
|
6
|
3
|
|
|
3
|
|
455
|
use FusionInventory::Agent::Tools; |
|
3
|
|
|
|
|
4
|
|
|
3
|
|
|
|
|
1431
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
sub isEnabled { |
9
|
0
|
|
|
0
|
0
|
0
|
my (%params) = @_; |
10
|
0
|
0
|
|
|
|
0
|
return 0 if $params{no_category}->{storage}; |
11
|
0
|
|
|
|
|
0
|
return -r '/etc/fstab'; |
12
|
|
|
|
|
|
|
} |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
sub doInventory { |
15
|
0
|
|
|
0
|
0
|
0
|
my (%params) = @_; |
16
|
|
|
|
|
|
|
|
17
|
0
|
|
|
|
|
0
|
my $inventory = $params{inventory}; |
18
|
0
|
|
|
|
|
0
|
my $logger = $params{logger}; |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
# get a list of devices from /etc/fstab |
21
|
0
|
|
|
|
|
0
|
my @devices = _getDevicesFromFstab(logger => $logger); |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
# parse dmesg |
24
|
0
|
|
|
|
|
0
|
my @lines = getAllLines( |
25
|
|
|
|
|
|
|
command => 'dmesg' |
26
|
|
|
|
|
|
|
); |
27
|
|
|
|
|
|
|
|
28
|
0
|
|
|
|
|
0
|
foreach my $device (@devices) { |
29
|
|
|
|
|
|
|
|
30
|
0
|
|
|
|
|
0
|
foreach my $line (@lines) { |
31
|
0
|
0
|
|
|
|
0
|
if ($line =~ /^$device->{DESCRIPTION}.*<(.*)>/) { |
32
|
0
|
|
|
|
|
0
|
$device->{MODEL} = $1; |
33
|
|
|
|
|
|
|
} |
34
|
0
|
0
|
|
|
|
0
|
if ($line =~ /^$device->{DESCRIPTION}.*\s+(\d+)\s*MB/) { |
35
|
0
|
|
|
|
|
0
|
$device->{CAPACITY} = $1; |
36
|
|
|
|
|
|
|
} |
37
|
|
|
|
|
|
|
} |
38
|
|
|
|
|
|
|
|
39
|
0
|
0
|
|
|
|
0
|
if ($device->{MODEL}) { |
40
|
0
|
0
|
|
|
|
0
|
if ($device->{MODEL} =~ s/^(SGI|SONY|WDC|ASUS|LG|TEAC|SAMSUNG|PHILIPS|PIONEER|MAXTOR|PLEXTOR|SEAGATE|IBM|SUN|SGI|DEC|FUJITSU|TOSHIBA|YAMAHA|HITACHI|VERITAS)\s*//i) { |
41
|
0
|
|
|
|
|
0
|
$device->{MANUFACTURER} = $1; |
42
|
|
|
|
|
|
|
} |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
# clean up the model |
45
|
0
|
|
|
|
|
0
|
$device->{MODEL} =~ s/^(\s|,)*//; |
46
|
0
|
|
|
|
|
0
|
$device->{MODEL} =~ s/(\s|,)*$//; |
47
|
|
|
|
|
|
|
} |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
$inventory->addEntry( |
50
|
0
|
|
|
|
|
0
|
section => 'STORAGES', |
51
|
|
|
|
|
|
|
entry => $device |
52
|
|
|
|
|
|
|
); |
53
|
|
|
|
|
|
|
} |
54
|
|
|
|
|
|
|
} |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
sub _getDevicesFromFstab { |
57
|
1
|
|
|
1
|
|
10
|
my (%params) = ( |
58
|
|
|
|
|
|
|
file => '/etc/fstab', |
59
|
|
|
|
|
|
|
@_ |
60
|
|
|
|
|
|
|
); |
61
|
|
|
|
|
|
|
|
62
|
1
|
|
|
|
|
3
|
my $handle = getFileHandle(%params); |
63
|
1
|
50
|
|
|
|
3
|
return unless $handle; |
64
|
|
|
|
|
|
|
|
65
|
1
|
|
|
|
|
1
|
my (@devices, %seen); |
66
|
1
|
|
|
|
|
8
|
while (my $line = <$handle>) { |
67
|
5
|
100
|
|
|
|
14
|
next unless $line =~ m{^/dev/(\S+)}; |
68
|
4
|
50
|
|
|
|
11
|
next if $seen{$1}++; |
69
|
4
|
|
|
|
|
13
|
push @devices, { DESCRIPTION => $1 }; |
70
|
|
|
|
|
|
|
} |
71
|
1
|
|
|
|
|
6
|
close $handle; |
72
|
|
|
|
|
|
|
|
73
|
1
|
|
|
|
|
6
|
return @devices; |
74
|
|
|
|
|
|
|
} |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
1; |