diff --git a/AUTHORS.md b/AUTHORS.md index 8416c5e15..ac6443655 100644 --- a/AUTHORS.md +++ b/AUTHORS.md @@ -23,7 +23,7 @@ Contributors to LibreNMS: - Stuart Henderson (sthen) - Filippo Giunchedi (filippog) - Lasse Leegaard (lasseleegaard) -- Mickael Marchand (mmarchand) +- Mickael Marchand (mmarchand) - Mohammad Al-Shami (mohshami) - Rudy Hardeman (zarya) - Arjit Chaudhary (arjit.c@gmail.com) (arjitc) diff --git a/includes/discovery/cisco-entity-sensor.inc.php b/includes/discovery/cisco-entity-sensor.inc.php index 881c6dd36..e7053a20d 100644 --- a/includes/discovery/cisco-entity-sensor.inc.php +++ b/includes/discovery/cisco-entity-sensor.inc.php @@ -163,8 +163,21 @@ if ($device['os_group'] == 'cisco') { } //end if if ($ok) { - // echo("\n".$valid['sensor'].", $type, $device, $oid, $index, 'cisco-entity-sensor', $descr, $divisor, $multiplier, $limit_low, $warn_limit_low, $warn_limit, $limit, $current"); discover_sensor($valid['sensor'], $type, $device, $oid, $index, 'cisco-entity-sensor', $descr, $divisor, $multiplier, $limit_low, $warn_limit_low, $warn_limit, $limit, $current, 'snmp', $entPhysicalIndex, $entry['entSensorMeasuredEntity']); + #Cisco IOS-XR : add a fake sensor to graph as dbm + if ($type == "power" and $device['os'] == "iosxr" and preg_match ("/Transceiver (R|T)x/i", $descr) ) { + // convert Watts to dbm + $type = "dbm"; + $limit_low = 10 * log10($limit_low*1000); + $warn_limit_low = 10 * log10($warn_limit_low*1000); + $warn_limit = 10 * log10($warn_limit*1000); + $limit = 10 * log10($limit*1000); + $current = round(10 * log10($current*1000),3); + $multiplier = 1; + $divisor = 1; + //echo("\n".$valid['sensor'].", $type, $device, $oid, $index, 'cisco-entity-sensor', $descr, $divisor, $multiplier, $limit_low, $warn_limit_low, $warn_limit, $limit, $current"); + discover_sensor($valid['sensor'], $type, $device, $oid, $index, 'cisco-entity-sensor', $descr, $divisor, $multiplier, $limit_low, $warn_limit_low, $warn_limit, $limit, $current, 'snmp', $entPhysicalIndex, $entry['entSensorMeasuredEntity']); + } } $cisco_entity_temperature = 1; diff --git a/includes/polling/functions.inc.php b/includes/polling/functions.inc.php index 4eb12609b..d148fa021 100644 --- a/includes/polling/functions.inc.php +++ b/includes/polling/functions.inc.php @@ -44,6 +44,13 @@ function poll_sensor($device, $class, $unit) { else if ($class == 'state') { $sensor_value = trim(str_replace('"', '', snmp_walk($device, $sensor['sensor_oid'], '-Oevq', 'SNMPv2-MIB'))); } + else if ($class == 'dbm') { + $sensor_value = trim(str_replace('"', '', snmp_get($device, $sensor['sensor_oid'], '-OUqnv', "SNMPv2-MIB$mib"))); + //iosxr does not expose dbm values through SNMP so we convert Watts to dbm to have a nice graph to show + if ($device['os'] == "iosxr") { + $sensor_value = round(10*log10($sensor_value/1000),3); + } + } else { if ($sensor['sensor_type'] == 'apc') { $sensor_value = trim(str_replace('"', '', snmp_walk($device, $sensor['sensor_oid'], '-OUqnv', "SNMPv2-MIB:PowerNet-MIB$mib")));