Fix regression in VC hardware detection for JunOS (#9772)

PR #9546 has resulted in Platform being detected as
"Juniper Virtual Chassis Switch" when a set of devices
is stacked. Hence, no more possibility to see whether
it is for example an EX2300 or EX3400 virtual-chassis.

This commit falls back to using rewrite_junos_hardware()
if the "Juniper Virtual Chassis Switch" string is detected
in boxDescr, resulting in usable hardware data.

Caveat - it's possible to build a virtual-chassis of
multiple switch models, but only for higher end hardware:

https://www.juniper.net/documentation/en_US/junos/topics/concept/virtual-chassis-ex4200-overview.html#jd0e75

Example SNMP output:
mschmidt@nlrtm1-librenms1:~$ snmpwalk -v2c -cremoved -m JUNIPER-MIB -M /opt/librenms/mibs hostname jnxBoxDescr
JUNIPER-MIB::jnxBoxDescr.0 = STRING: Juniper Virtual Chassis Switch

Also reported previously via the community forums:
https://community.librenms.org/t/pr-9546-results-in-junos-platform-detection-quirks-in-combination-with-virtual-chassis/6537
This commit is contained in:
Martijn Schmidt 2019-02-04 15:55:31 +01:00 committed by Tony Murray
parent 0b1c737659
commit 49f206f58e
2 changed files with 2 additions and 2 deletions

View File

@ -1097,7 +1097,7 @@ function discovery_process(&$valid, $device, $sensor_type, $pre_cache)
$sensor_name = $data['state_name'] ?: $data['oid'];
create_state_index($sensor_name, $data['states']);
} else {
// We default to 1 for both divisors / multipler so it should be safe to do the calculation using both.
// We default to 1 for both divisors / multipliers so it should be safe to do the calculation using both.
$value = ($value / $divisor) * $multiplier;
}

View File

@ -35,7 +35,7 @@ if (strpos($device['sysDescr'], 'olive')) {
$serial = '';
} else {
$boxDescr = snmp_get($device, 'jnxBoxDescr.0', '-Oqv', 'JUNIPER-MIB');
if (!empty($boxDescr)) {
if (!empty($boxDescr) && $boxDescr != "Juniper Virtual Chassis Switch") {
$hardware = $boxDescr;
} else {
$hardware = snmp_translate($device['sysObjectID'], 'Juniper-Products-MIB:JUNIPER-CHASSIS-DEFINES-MIB', 'junos');