Files
librenms-librenms/includes/polling/os/junos.inc.php
Martijn Schmidt 49f206f58e 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
2019-02-04 08:55:31 -06:00

48 lines
1.7 KiB
PHP

<?php
use LibreNMS\RRD\RrdDefinition;
$oid_list = 'jnxJsSPUMonitoringCurrentFlowSession.0';
$srx_sess_data = snmp_get_multi($device, $oid_list, '-OUQs', 'JUNIPER-SRX5000-SPU-MONITORING-MIB');
if (is_numeric($srx_sess_data[0]['jnxJsSPUMonitoringCurrentFlowSession'])) {
$tags = array(
'rrd_def' => RrdDefinition::make()->addDataset('spu_flow_sessions', 'GAUGE', 0),
);
$fields = array(
'spu_flow_sessions' => $srx_sess_data[0]['jnxJsSPUMonitoringCurrentFlowSession'],
);
data_update($device, 'junos_jsrx_spu_sessions', $tags, $fields);
$graphs['junos_jsrx_spu_sessions'] = true;
echo ' Flow Sessions';
unset($srx_sess_data);
}
$version = snmp_get($device, 'jnxVirtualChassisMemberSWVersion.0', '-Oqv', 'JUNIPER-VIRTUALCHASSIS-MIB');
if (empty($version)) {
preg_match('/kernel JUNOS (\S+),/', $device['sysDescr'], $jun_ver);
$version = $jun_ver[1];
}
if (empty($version)) {
preg_match('/\[(.+)\]/', snmp_get($device, '.1.3.6.1.2.1.25.6.3.1.2.2', '-Oqv', 'HOST-RESOURCES-MIB'), $jun_ver);
$version = $jun_ver[1];
}
if (strpos($device['sysDescr'], 'olive')) {
$hardware = 'Olive';
$serial = '';
} else {
$boxDescr = snmp_get($device, 'jnxBoxDescr.0', '-Oqv', 'JUNIPER-MIB');
if (!empty($boxDescr) && $boxDescr != "Juniper Virtual Chassis Switch") {
$hardware = $boxDescr;
} else {
$hardware = snmp_translate($device['sysObjectID'], 'Juniper-Products-MIB:JUNIPER-CHASSIS-DEFINES-MIB', 'junos');
$hardware = 'Juniper '.rewrite_junos_hardware($hardware);
}
$serial = snmp_get($device, '.1.3.6.1.4.1.2636.3.1.3.0', '-OQv', '+JUNIPER-MIB', 'junos');
}
$features = '';