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