Hardware: CBR-8-CCAP-CHASS
OS: Cisco IOS-XE X86_64_LINUX_IOSD-UNIVERSALK9-M 17.9.1y1 (Cupertino)
Error discovering sensors module for **********. DivisionByZeroError: Division by zero in /usr/opt/librenms/includes/discovery/sensors/entity-sensor.inc.php:165
Stack trace:
#0 /usr/opt/librenms/includes/discovery/sensors.inc.php(16): require()
#1 /usr/opt/librenms/includes/discovery/functions.inc.php(164): include(‘/usr/opt/libren…’)
#2 /usr/opt/librenms/discovery.php(108): discover_device(Array, true)
#3 {main}
Division by zero {“exception”:“[object] (DivisionByZeroError(code: 0): Division by zero at /usr/opt/librenms/includes/discovery/sensors/entity-sensor.inc.php:165)”}
breaking Point:
entSensorScale.25007 = peta
25007 =>
array (
‘entSensorType’ => ‘voltsDC’,
‘entSensorScale’ => ‘peta’,
‘entSensorValue’ => ‘4964’,
‘entSensorMeasuredEntity’ => ‘25000’,
‘entSensorPrecision’ => ‘0’,
),
Original GIT
https://github.com/librenms/librenms/blob/master/includes/discovery/sensors/cisco-entity-sensor.inc.php
// echo("$index : ".$entry['entSensorScale']."|");
// FIXME this stuff is foul
if ($entry['entSensorScale'] == 'nano') {
$divisor = '1000000000';
$multiplier = '1';
}
if ($entry['entSensorScale'] == 'micro') {
$divisor = '1000000';
$multiplier = '1';
}
if ($entry['entSensorScale'] == 'milli') {
$divisor = '1000';
$multiplier = '1';
}
if ($entry['entSensorScale'] == 'units') {
$divisor = '1';
$multiplier = '1';
}
if ($entry['entSensorScale'] == 'kilo') {
$divisor = '1';
$multiplier = '1000';
}
if ($entry['entSensorScale'] == 'mega') {
$divisor = '1';
$multiplier = '1000000';
}
if ($entry['entSensorScale'] == 'giga') {
$divisor = '1';
$multiplier = '1000000000';
}
→ replaces them with following prefixes:
// FIXME this stuff is foul
if ($entry['entPhySensorScale'] == 'yocto') {
$divisor = '1000000000000000000000000';
$multiplier = '1';
}
if ($entry['entPhySensorScale'] == 'zepto') {
$divisor = '1000000000000000000000';
$multiplier = '1';
}
if ($entry['entPhySensorScale'] == 'atto') {
$divisor = '1000000000000000000';
$multiplier = '1';
}
if ($entry['entPhySensorScale'] == 'femto') {
$divisor = '1000000000000000';
$multiplier = '1';
}
if ($entry['entPhySensorScale'] == 'picto') {
$divisor = '1000000000000';
$multiplier = '1';
}
if ($entry['entPhySensorScale'] == 'nano') {
$divisor = '1000000000';
$multiplier = '1';
}
if ($entry['entPhySensorScale'] == 'micro') {
$divisor = '1000000';
$multiplier = '1';
}
if ($entry['entPhySensorScale'] == 'milli') {
$divisor = '1000';
$multiplier = '1';
}
if ($entry['entPhySensorScale'] == 'units') {
$divisor = '1';
$multiplier = '1';
}
if ($entry['entPhySensorScale'] == 'kilo') {
$divisor = '1';
$multiplier = '1000';
}
if ($entry['entPhySensorScale'] == 'mega') {
$divisor = '1';
$multiplier = '1000000';
}
if ($entry['entPhySensorScale'] == 'giga') {
$divisor = '1';
$multiplier = '1000000000';
}
if ($entry['entPhySensorScale'] == 'tera') {
$divisor = '1';
$multiplier = '1000000000000';
}
if ($entry['entPhySensorScale'] == 'peta') {
$divisor = '1';
$multiplier = '1000000000000000';
}
if ($entry['entPhySensorScale'] == 'exa') {
$divisor = '1';
$multiplier = '1000000000000000000';
}
if ($entry['entPhySensorScale'] == 'zetta') {
$divisor = '1';
$multiplier = '1000000000000000000000';
}
if ($entry['entPhySensorScale'] == 'yotta') {
$divisor = '1';
$multiplier = '1000000000000000000000000';
}