mirror of
https://github.com/librenms/librenms.git
synced 2024-10-07 16:52:45 +00:00
APC: Add support for Battery Recommended Days Remaining (#14653)
* APC: Add support for Battery Recommended Days Remaining * Extract number from string later during polling Odd that this is different from the discovery process * wip * wip * Apply fixes from StyleCI * wip * wip * Apply fixes from StyleCI --------- Co-authored-by: Tony Murray <murraytony@gmail.com>
This commit is contained in:
@@ -24,6 +24,7 @@ use LibreNMS\Exceptions\InvalidIpException;
|
||||
use LibreNMS\OS;
|
||||
use LibreNMS\Util\IP;
|
||||
use LibreNMS\Util\IPv6;
|
||||
use LibreNMS\Util\UserFuncHelper;
|
||||
|
||||
function discover_new_device($hostname, $device = [], $method = '', $interface = '')
|
||||
{
|
||||
@@ -943,8 +944,12 @@ function discovery_process(&$valid, $os, $sensor_class, $pre_cache)
|
||||
if (is_numeric($$limit)) {
|
||||
$$limit = ($$limit / $divisor) * $multiplier;
|
||||
}
|
||||
if (is_numeric($$limit) && isset($user_function) && is_callable($user_function)) {
|
||||
$$limit = $user_function($$limit);
|
||||
if (is_numeric($$limit) && isset($user_function)) {
|
||||
if (is_callable($user_function)) {
|
||||
$$limit = $user_function($$limit);
|
||||
} else {
|
||||
$$limit = (new UserFuncHelper($$limit))->{$user_function}();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -964,8 +969,12 @@ function discovery_process(&$valid, $os, $sensor_class, $pre_cache)
|
||||
$entPhysicalIndex_measured = isset($data['entPhysicalIndex_measured']) ? $data['entPhysicalIndex_measured'] : null;
|
||||
|
||||
//user_func must be applied after divisor/multiplier
|
||||
if (isset($user_function) && is_callable($user_function)) {
|
||||
$value = $user_function($value);
|
||||
if (isset($user_function)) {
|
||||
if (is_callable($user_function)) {
|
||||
$value = $user_function($value);
|
||||
} else {
|
||||
$value = (new UserFuncHelper($value, $snmp_data[$data['value']], $data))->{$user_function}();
|
||||
}
|
||||
}
|
||||
|
||||
$uindex = $index;
|
||||
|
Reference in New Issue
Block a user