mirror of
https://github.com/librenms/librenms.git
synced 2024-09-22 02:48:37 +00:00
fad0bffc43
hopefully doesn't break anything Mostly issues with snmp oids and options containing spaces. Try to remove all of those. DO NOT DELETE THIS TEXT #### Please note > Please read this information carefully. You can run `./scripts/pre-commit.php` to check your code before submitting. - [x] Have you followed our [code guidelines?](http://docs.librenms.org/Developing/Code-Guidelines/) #### Testers If you would like to test this pull request then please run: `./scripts/github-apply <pr_id>`, i.e `./scripts/github-apply 5926` After you are done testing, you can remove the changes with `./scripts/github-remove`. If there are schema changes, you can ask on discord how to revert.
68 lines
2.3 KiB
PHP
68 lines
2.3 KiB
PHP
<?php
|
|
|
|
use LibreNMS\Config;
|
|
|
|
// IPMI - We can discover this on poll!
|
|
if ($ipmi['host'] = get_dev_attrib($device, 'ipmi_hostname')) {
|
|
echo 'IPMI : ';
|
|
|
|
$ipmi['user'] = get_dev_attrib($device, 'ipmi_username');
|
|
$ipmi['password'] = get_dev_attrib($device, 'ipmi_password');
|
|
|
|
$cmd = [Config::get('ipmitool', 'ipmitool')];
|
|
if (Config::get('own_hostname') != $device['hostname'] || $ipmi['host'] != 'localhost') {
|
|
array_push($cmd, '-H', $ipmi['host'], '-U', $ipmi['user'], '-P', $ipmi['password'], '-L', 'USER');
|
|
}
|
|
|
|
foreach (Config::get('ipmi.type', []) as $ipmi_type) {
|
|
$results = explode(PHP_EOL, external_exec(array_merge($cmd, ['-I', $ipmi_type, 'sensor'])));
|
|
|
|
array_filter($results, function ($line) {
|
|
return !str_contains($line, 'discrete');
|
|
});
|
|
|
|
if (!empty($results)) {
|
|
set_dev_attrib($device, 'ipmi_type', $ipmi_type);
|
|
echo "$ipmi_type ";
|
|
break;
|
|
}
|
|
}
|
|
|
|
$index = 0;
|
|
|
|
sort($results);
|
|
foreach ($results as $sensor) {
|
|
// BB +1.1V IOH | 1.089 | Volts | ok | na | 1.027 | 1.054 | 1.146 | 1.177 | na
|
|
$values = array_map('trim', explode('|', $sensor));
|
|
list($desc,$current,$unit,$state,$low_nonrecoverable,$low_limit,$low_warn,$high_warn,$high_limit,$high_nonrecoverable) = $values;
|
|
|
|
$index++;
|
|
if ($current != 'na' && Config::has("ipmi_unit.$unit")) {
|
|
discover_sensor(
|
|
$valid['sensor'],
|
|
Config::get("ipmi_unit.$unit"),
|
|
$device,
|
|
$desc,
|
|
$index,
|
|
'ipmi',
|
|
$desc,
|
|
'1',
|
|
'1',
|
|
$low_limit == 'na' ? null : $low_limit,
|
|
$low_warn == 'na' ? null : $low_warn,
|
|
$high_warn == 'na' ? null : $high_warn,
|
|
$high_limit == 'na' ? null : $high_limit,
|
|
$current,
|
|
'ipmi'
|
|
);
|
|
}
|
|
}
|
|
|
|
echo "\n";
|
|
}
|
|
|
|
check_valid_sensors($device, 'voltage', $valid['sensor'], 'ipmi');
|
|
check_valid_sensors($device, 'temperature', $valid['sensor'], 'ipmi');
|
|
check_valid_sensors($device, 'fanspeed', $valid['sensor'], 'ipmi');
|
|
check_valid_sensors($device, 'power', $valid['sensor'], 'ipmi');
|