Skip to content

Commit 962e828

Browse files
authored
Better handle issues with ipmitool/freeipmi so we try other types as … (librenms#17066)
* Better handle issues with ipmitool/freeipmi so we try other types as needed. * Correct StyleCI Requirement * Fix code style
1 parent 8217fcc commit 962e828

File tree

1 file changed

+15
-8
lines changed

1 file changed

+15
-8
lines changed

includes/discovery/sensors/ipmi.inc.php

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
<?php
22

3+
use Illuminate\Support\Facades\Log;
34
use Illuminate\Support\Str;
45
use LibreNMS\Config;
56

@@ -21,16 +22,22 @@
2122
}
2223

2324
foreach (Config::get('ipmi.type', []) as $ipmi_type) {
24-
$results = explode(PHP_EOL, external_exec(array_merge($cmd, ['-I', $ipmi_type, 'sensor'])));
25+
// Check if the IPMI type is available, catch segfaults of ipmitool/freeipmi.
26+
try {
27+
Log::debug('Trying IPMI type: ' . $ipmi_type);
28+
$results = explode(PHP_EOL, external_exec(array_merge($cmd, ['-I', $ipmi_type, 'sensor'])));
2529

26-
$results = array_values(array_filter($results, function ($line) {
27-
return ! Str::contains($line, 'discrete');
28-
}));
30+
$results = array_values(array_filter($results, function ($line) {
31+
return ! Str::contains($line, 'discrete');
32+
}));
2933

30-
if (! empty($results)) {
31-
set_dev_attrib($device, 'ipmi_type', $ipmi_type);
32-
echo "$ipmi_type ";
33-
break;
34+
if (! empty($results)) {
35+
set_dev_attrib($device, 'ipmi_type', $ipmi_type);
36+
echo "$ipmi_type ";
37+
break;
38+
}
39+
} catch (\Exception $e) {
40+
Log::error('IPMI Discovery error occurred: ' . $e->getMessage());
3441
}
3542
}
3643

0 commit comments

Comments
 (0)