Skip to content

Commit 5de08c5

Browse files
committed
fix: Fix Storage inventory support on FreeBSD
Closes #1050
1 parent 0b40b97 commit 5de08c5

File tree

6 files changed

+1473
-10
lines changed

6 files changed

+1473
-10
lines changed

Changes

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ inventory:
3434
* Fix additional content merged into json even when not required on partial content
3535
* Update support for Acer S240L monitors inventory
3636
* Don't inventory Surface Display as monitor on windows
37+
* fix #1050: Fix Storage inventory support on FreeBSD
3738

3839
remoteinventory:
3940
* fix RedHat RHN systemid set as WINPRODID

lib/GLPI/Agent/Task/Inventory/BSD/Storages.pm

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ sub _getStorages {
5050
if ($geom->{provider}
5151
&& $geom->{provider}->{config}
5252
&& $geom->{provider}->{config}->{descr});
53-
$device->{DISKSIZE} = $geom->{provider}->{mediasize}
53+
$device->{DISKSIZE} = getCanonicalSize($geom->{provider}->{mediasize}."bytes")
5454
if ($geom->{provider}
5555
&& defined $geom->{provider}->{mediasize});
5656
$device->{TYPE} = _retrieveDeviceTypeFromName($device->{NAME});
@@ -84,10 +84,26 @@ sub _extractDataFromDmesg {
8484

8585
my $storages = $params{storages};
8686

87-
my $dmesgLines = getAllLines(
88-
command => 'dmesg',
89-
%params
90-
);
87+
my $dmesgLines;
88+
89+
# Check if called during unittests before checking well-known system dmesg.boot file
90+
if (empty($params{file}) && has_file('/var/run/dmesg.boot')) {
91+
$dmesgLines = getAllLines(
92+
file => '/var/run/dmesg.boot',
93+
%params
94+
);
95+
}
96+
97+
# Fallback on dmesg output but it can be empty and so not reliable
98+
if (empty($dmesgLines)) {
99+
$dmesgLines = getAllLines(
100+
command => 'dmesg',
101+
%params
102+
);
103+
}
104+
105+
return if empty($dmesgLines);
106+
91107
for my $storage (@$storages) {
92108
next unless $storage->{NAME};
93109
$storage->{MODEL} = getFirstMatch(
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# extract of really required lines from /var/run/dmesg.boot file
2+
ada0 at ahcich0 bus 0 scbus0 target 0 lun 0
3+
ada0: <ST1000NM0011 SN03> ATA8-ACS SATA 3.x device
4+
ada0: Serial Number Z1N3PC1B
5+
ada0: 300.000MB/s transfers (SATA 2.x, UDMA6, PIO 8192bytes)
6+
ada0: Command Queueing enabled
7+
ada0: 953869MB (1953525168 512 byte sectors)
8+
ada1 at ahcich1 bus 0 scbus1 target 0 lun 0
9+
ada1: <ST1000NM0011 SN03> ATA8-ACS SATA 3.x device
10+
ada1: Serial Number Z1N3PN8K
11+
ada1: 300.000MB/s transfers (SATA 2.x, UDMA6, PIO 8192bytes)
12+
ada1: Command Queueing enabled
13+
ada1: 953869MB (1953525168 512 byte sectors)

resources/bsd/storages/dmesg-freebsd-14.3-empty

Whitespace-only changes.

0 commit comments

Comments
 (0)