mirror of
https://github.com/librenms/librenms.git
synced 2024-10-07 16:52:45 +00:00
newdevice: Updated Arista entity-physical support to use high/low values from device (#7156)
* fix: Fixed the high/low thresholds for Arista devices * final updates * push threshold changes * more updates * another update * updated entity-sensor for current value calc * hoping final update
This commit is contained in:
committed by
Tony Murray
parent
fea2f37f20
commit
f7e14df90e
@@ -1691,7 +1691,11 @@ function uw_to_dbm($value)
|
||||
*/
|
||||
function set_null($value, $default = null, $min = null)
|
||||
{
|
||||
if (!is_numeric($value)) {
|
||||
if (is_nan($value)) {
|
||||
return $default;
|
||||
} elseif (is_infinite($value)) {
|
||||
return $default;
|
||||
} elseif (!is_numeric($value)) {
|
||||
return $default;
|
||||
} elseif (isset($min) && $value < $min) {
|
||||
return $default;
|
||||
@@ -1705,7 +1709,11 @@ function set_null($value, $default = null, $min = null)
|
||||
*/
|
||||
function set_numeric($value, $default = 0)
|
||||
{
|
||||
if (!isset($value) || !is_numeric($value)) {
|
||||
if (is_nan($value) ||
|
||||
is_infinite($value) ||
|
||||
!isset($value) ||
|
||||
!is_numeric($value)
|
||||
) {
|
||||
$value = $default;
|
||||
}
|
||||
return $value;
|
||||
|
||||
@@ -1,9 +1,6 @@
|
||||
<?php
|
||||
|
||||
echo ' ENTITY-SENSOR: ';
|
||||
|
||||
echo 'Caching OIDs:';
|
||||
|
||||
if (!is_array($entity_array)) {
|
||||
$entity_array = array();
|
||||
echo ' entPhysicalDescr';
|
||||
@@ -11,7 +8,6 @@ if (!is_array($entity_array)) {
|
||||
echo ' entPhysicalName';
|
||||
$entity_array = snmpwalk_cache_multi_oid($device, 'entPhysicalName', $entity_array, 'CISCO-ENTITY-SENSOR-MIB');
|
||||
}
|
||||
|
||||
$oids = array();
|
||||
echo ' entPhySensorType';
|
||||
$oids = snmpwalk_cache_multi_oid($device, 'entPhySensorType', $oids, 'ENTITY-SENSOR-MIB');
|
||||
@@ -21,7 +17,9 @@ echo ' entPhySensorPrecision';
|
||||
$oids = snmpwalk_cache_multi_oid($device, 'entPhySensorPrecision', $oids, 'ENTITY-SENSOR-MIB');
|
||||
echo ' entPhySensorValue';
|
||||
$oids = snmpwalk_cache_multi_oid($device, 'entPhySensorValue', $oids, 'ENTITY-SENSOR-MIB');
|
||||
|
||||
if ($device['os'] === 'arista_eos') {
|
||||
require 'includes/discovery/sensors/misc/arista-eos-limits.inc.php';
|
||||
}
|
||||
$entitysensor['voltsDC'] = 'voltage';
|
||||
$entitysensor['voltsAC'] = 'voltage';
|
||||
$entitysensor['amperes'] = 'current';
|
||||
@@ -31,9 +29,13 @@ $entitysensor['percentRH'] = 'humidity';
|
||||
$entitysensor['rpm'] = 'fanspeed';
|
||||
$entitysensor['celsius'] = 'temperature';
|
||||
$entitysensor['dBm'] = 'dbm';
|
||||
|
||||
if (is_array($oids)) {
|
||||
foreach ($oids as $index => $entry) {
|
||||
$low_limit = null;
|
||||
$low_warn_limit = null;
|
||||
$warn_limit = null;
|
||||
$high_limit = null;
|
||||
|
||||
// Fix for Cisco ASR920, 15.5(2)S
|
||||
if ($entry['entPhySensorType'] == 'other' && str_contains($entity_array[$index]['entPhysicalName'], array('Rx Power Sensor', 'Tx Power Sensor'))) {
|
||||
$entitysensor['other'] = 'dbm';
|
||||
@@ -51,64 +53,59 @@ if (is_array($oids)) {
|
||||
$descr = $entity_array[$index]['entPhysicalDescr'];
|
||||
$descr = rewrite_entity_descr($descr);
|
||||
}
|
||||
|
||||
$valid_sensor = check_entity_sensor($descr, $device);
|
||||
|
||||
$type = $entitysensor[$entry['entPhySensorType']];
|
||||
|
||||
// FIXME this stuff is foul
|
||||
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'] == 'yocto') {
|
||||
$divisor = '1';
|
||||
$multiplier = '1';
|
||||
}
|
||||
|
||||
if (is_numeric($entry['entPhySensorPrecision']) && $entry['entPhySensorPrecision'] > '0') {
|
||||
$divisor = $divisor.str_pad('', $entry['entPhySensorPrecision'], '0');
|
||||
}
|
||||
|
||||
$current = ($current * $multiplier / $divisor);
|
||||
if ($device['os'] === 'arista_eos') {
|
||||
if ($entry['entPhySensorScale'] == 'milli' && $entry['entPhySensorType'] == 'amperes') {
|
||||
$divisor = '1';
|
||||
$multiplier = '1';
|
||||
}
|
||||
}
|
||||
|
||||
$current = ($current * $multiplier / $divisor);
|
||||
if ($type == 'temperature') {
|
||||
if ($current > '200') {
|
||||
$valid_sensor = false;
|
||||
} $descr = preg_replace('/[T|t]emperature[|s]/', '', $descr);
|
||||
}
|
||||
$descr = preg_replace('/[T|t]emperature[|s]/', '', $descr);
|
||||
}
|
||||
|
||||
if ($device['os'] == 'rittal-lcp') {
|
||||
if ($type == 'voltage') {
|
||||
$divisor = 1000;
|
||||
@@ -123,12 +120,10 @@ if (is_array($oids)) {
|
||||
$valid_sensor = false;
|
||||
}
|
||||
}
|
||||
|
||||
// echo($descr . "|" . $index . "|" .$current . "|" . $multiplier . "|" . $divisor ."|" . $entry['entPhySensorScale'] . "|" . $entry['entPhySensorPrecision'] . "\n");
|
||||
if ($current == '-127' || ($device['os'] == 'asa' && str_contains($device['hardware'], 'sc'))) {
|
||||
$valid_sensor = false;
|
||||
}
|
||||
|
||||
if ($valid_sensor && dbFetchCell("SELECT COUNT(*) FROM `sensors` WHERE device_id = ? AND `sensor_class` = ? AND `sensor_type` = 'cisco-entity-sensor' AND `sensor_index` = ?", array($device['device_id'], $type, $index)) == '0') {
|
||||
// Check to make sure we've not already seen this sensor via cisco's entity sensor mib
|
||||
if ($type == "power" && $device['os'] == "arista_eos" && preg_match("/DOM (R|T)x Power/i", $descr)) {
|
||||
@@ -136,10 +131,43 @@ if (is_array($oids)) {
|
||||
$current = round(10 * log10($entry['entPhySensorValue'] / 10000), 3);
|
||||
$multiplier = 1;
|
||||
$divisor = 1;
|
||||
discover_sensor($valid['sensor'], $type, $device, $oid, $index, 'entity-sensor', $descr, $divisor, $multiplier, null, null, null, null, $current, 'snmp', $entPhysicalIndex, $entry['entSensorMeasuredEntity']);
|
||||
} else {
|
||||
discover_sensor($valid['sensor'], $type, $device, $oid, $index, 'entity-sensor', $descr, $divisor, $multiplier, null, null, null, null, $current);
|
||||
}
|
||||
|
||||
if ($device['os'] === 'arista_eos') {
|
||||
if ($entry['aristaEntSensorThresholdLowWarning'] != '-1000000000') {
|
||||
if ($entry['entPhySensorScale'] == 'milli' && $entry['entPhySensorType'] == 'watts') {
|
||||
$temp_low_warn_limit = $entry['aristaEntSensorThresholdLowWarning'] / 10000;
|
||||
$low_warn_limit = round(10 * log10($temp_low_warn_limit), 2);
|
||||
} else {
|
||||
$low_warn_limit = $entry['aristaEntSensorThresholdLowWarning'] / $divisor;
|
||||
}
|
||||
}
|
||||
if ($entry['aristaEntSensorThresholdLowCritical'] != '-1000000000') {
|
||||
if ($entry['entPhySensorScale'] == 'milli' && $entry['entPhySensorType'] == 'watts') {
|
||||
$temp_low_limit = $entry['aristaEntSensorThresholdLowCritical'] / 10000;
|
||||
$low_limit = round(10 * log10($temp_low_limit), 2);
|
||||
} else {
|
||||
$low_limit = $entry['aristaEntSensorThresholdLowCritical'] / $divisor;
|
||||
}
|
||||
}
|
||||
if ($entry['aristaEntSensorThresholdHighWarning'] != '1000000000') {
|
||||
if ($entry['entPhySensorScale'] == 'milli' && $entry['entPhySensorType'] == 'watts') {
|
||||
$temp_warn_limit = $entry['aristaEntSensorThresholdHighWarning'] / 10000;
|
||||
$warn_limit = round(10 * log10($temp_warn_limit), 2);
|
||||
} else {
|
||||
$warn_limit = $entry['aristaEntSensorThresholdHighWarning'] / $divisor;
|
||||
}
|
||||
}
|
||||
if ($entry['aristaEntSensorThresholdHighCritical'] != '1000000000') {
|
||||
if ($entry['entPhySensorScale'] == 'milli' && $entry['entPhySensorType'] == 'watts') {
|
||||
$temp_high_limit = $entry['aristaEntSensorThresholdHighCritical'] / 10000;
|
||||
$high_limit = round(10 * log10($temp_high_limit), 2);
|
||||
} else {
|
||||
$high_limit = $entry['aristaEntSensorThresholdHighCritical'] / $divisor;
|
||||
}
|
||||
}
|
||||
}
|
||||
discover_sensor($valid['sensor'], $type, $device, $oid, $index, 'entity-sensor', $descr, $divisor, $multiplier, $low_limit, $low_warn_limit, $warn_limit, $high_limit, $current, 'snmp', $entPhysicalIndex, $entry['entSensorMeasuredEntity']);
|
||||
}
|
||||
}//end if
|
||||
}//end foreach
|
||||
@@ -147,5 +175,4 @@ if (is_array($oids)) {
|
||||
$entity_array
|
||||
);
|
||||
}//end if
|
||||
|
||||
echo "\n";
|
||||
|
||||
26
includes/discovery/sensors/misc/arista-eos-limits.inc.php
Normal file
26
includes/discovery/sensors/misc/arista-eos-limits.inc.php
Normal file
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
/**
|
||||
* arista-eos-limits.inc.php
|
||||
*
|
||||
* LibreNMS Arista EOS sensor limits
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* @package LibreNMS
|
||||
* @link http://librenms.org
|
||||
* @copyright 2017 Neil Lathwood
|
||||
* @author Neil Lathwood <neil@lathwood.co.uk>
|
||||
*/
|
||||
|
||||
$oids = snmpwalk_cache_oid($device, 'aristaEntSensorThresholdTable', $oids, 'ARISTA-ENTITY-SENSOR-MIB');
|
||||
@@ -61,6 +61,7 @@ function poll_sensor($device, $class)
|
||||
$mibdir = null;
|
||||
|
||||
$sensor_value = trim(str_replace('"', '', $snmp_data[$sensor['sensor_oid']]));
|
||||
echo "HERE $sensor_value END".PHP_EOL;
|
||||
|
||||
if (file_exists('includes/polling/sensors/'. $class .'/'. $device['os'] .'.inc.php')) {
|
||||
require 'includes/polling/sensors/'. $class .'/'. $device['os'] .'.inc.php';
|
||||
|
||||
199
mibs/arista/ARISTA-ENTITY-SENSOR-MIB
Normal file
199
mibs/arista/ARISTA-ENTITY-SENSOR-MIB
Normal file
@@ -0,0 +1,199 @@
|
||||
ARISTA-ENTITY-SENSOR-MIB DEFINITIONS ::= BEGIN
|
||||
|
||||
IMPORTS
|
||||
MODULE-IDENTITY, OBJECT-TYPE,
|
||||
NOTIFICATION-TYPE FROM SNMPv2-SMI
|
||||
MODULE-COMPLIANCE, OBJECT-GROUP,
|
||||
NOTIFICATION-GROUP FROM SNMPv2-CONF
|
||||
entPhysicalIndex, entPhysicalDescr FROM ENTITY-MIB
|
||||
entStateAlarm FROM ENTITY-STATE-MIB
|
||||
EntitySensorValue, entPhySensorValue
|
||||
FROM ENTITY-SENSOR-MIB
|
||||
SnmpAdminString FROM SNMP-FRAMEWORK-MIB
|
||||
aristaMibs FROM ARISTA-SMI-MIB;
|
||||
|
||||
|
||||
aristaEntSensorMIB MODULE-IDENTITY
|
||||
LAST-UPDATED "201408150000Z"
|
||||
ORGANIZATION "Arista Networks, Inc."
|
||||
CONTACT-INFO
|
||||
"Arista Networks, Inc.
|
||||
|
||||
Postal: 5453 Great America Parkway
|
||||
Santa Clara, CA 95054
|
||||
|
||||
Tel: +1 408 547-5500
|
||||
|
||||
E-mail: snmp@arista.com"
|
||||
DESCRIPTION
|
||||
"This MIB module augments the entPhySensorTable of
|
||||
ENTITY-SENSOR-MIB to provide threshold information for
|
||||
various sensors in the system. For example, a given device
|
||||
may have several voltage sensors as well as temperature
|
||||
sensors each with appropriate threshold support to help
|
||||
NMS systems detect and alert appropriately.
|
||||
|
||||
In addition, on systems where it is supported, if the
|
||||
sensor value crosses the supported threshold value the system
|
||||
can generate appropriate notification as well."
|
||||
REVISION "201408150000Z"
|
||||
DESCRIPTION "Updated postal and e-mail addresses."
|
||||
REVISION "201305090950Z"
|
||||
DESCRIPTION "Initial version of this MIB module."
|
||||
::= { aristaMibs 12 }
|
||||
|
||||
-- Textual Conventions --
|
||||
|
||||
aristaEntSensorMibNotifications OBJECT IDENTIFIER
|
||||
::= { aristaEntSensorMIB 0 }
|
||||
|
||||
aristaEntSensorMibObjects OBJECT IDENTIFIER
|
||||
::= { aristaEntSensorMIB 1 }
|
||||
|
||||
aristaEntSensorMibConformance OBJECT IDENTIFIER
|
||||
::= { aristaEntSensorMIB 2 }
|
||||
|
||||
-- entity threshold table --
|
||||
|
||||
aristaEntSensorThresholdTable OBJECT-TYPE
|
||||
SYNTAX SEQUENCE OF AristaEntSensorThresholdEntry
|
||||
MAX-ACCESS not-accessible
|
||||
STATUS current
|
||||
DESCRIPTION
|
||||
"This table contains threshold information for the
|
||||
various sensors in the system."
|
||||
::= { aristaEntSensorMibObjects 1 }
|
||||
|
||||
aristaEntSensorThresholdEntry OBJECT-TYPE
|
||||
SYNTAX AristaEntSensorThresholdEntry
|
||||
MAX-ACCESS not-accessible
|
||||
STATUS current
|
||||
DESCRIPTION
|
||||
"A single row containing threshold information for a
|
||||
sensor. Threshold values are reported using the unit
|
||||
of EntitySensorValue. If a sensor does not support threshold
|
||||
data, then an underflow/overflow value is returned.
|
||||
All the other relevant information for the given sensor can be
|
||||
obtained from the entPhySensorTable itself."
|
||||
INDEX { entPhysicalIndex }
|
||||
::= { aristaEntSensorThresholdTable 1 }
|
||||
|
||||
AristaEntSensorThresholdEntry ::= SEQUENCE {
|
||||
aristaEntSensorThresholdLowWarning EntitySensorValue,
|
||||
aristaEntSensorThresholdLowCritical EntitySensorValue,
|
||||
aristaEntSensorThresholdHighWarning EntitySensorValue,
|
||||
aristaEntSensorThresholdHighCritical EntitySensorValue,
|
||||
aristaEntSensorStatusDescr SnmpAdminString
|
||||
}
|
||||
|
||||
aristaEntSensorThresholdLowWarning OBJECT-TYPE
|
||||
SYNTAX EntitySensorValue
|
||||
MAX-ACCESS read-only
|
||||
STATUS current
|
||||
DESCRIPTION
|
||||
"The low thresold value for the given sensor at which point
|
||||
the entity's alarm status is set to warning."
|
||||
::= { aristaEntSensorThresholdEntry 1 }
|
||||
|
||||
aristaEntSensorThresholdLowCritical OBJECT-TYPE
|
||||
SYNTAX EntitySensorValue
|
||||
MAX-ACCESS read-only
|
||||
STATUS current
|
||||
DESCRIPTION
|
||||
"The low critical value for the given sensor at which point
|
||||
the entity's alarm status is set to critical."
|
||||
::= { aristaEntSensorThresholdEntry 2 }
|
||||
|
||||
aristaEntSensorThresholdHighWarning OBJECT-TYPE
|
||||
SYNTAX EntitySensorValue
|
||||
MAX-ACCESS read-only
|
||||
STATUS current
|
||||
DESCRIPTION
|
||||
"The high thresold value for the given sensor at which point
|
||||
the entity's alarm status is set to warning."
|
||||
::= { aristaEntSensorThresholdEntry 3 }
|
||||
|
||||
aristaEntSensorThresholdHighCritical OBJECT-TYPE
|
||||
SYNTAX EntitySensorValue
|
||||
MAX-ACCESS read-only
|
||||
STATUS current
|
||||
DESCRIPTION
|
||||
"The high critical value for the given sensor at which point
|
||||
the entity's alarm status is set to critical."
|
||||
::= { aristaEntSensorThresholdEntry 4 }
|
||||
|
||||
aristaEntSensorStatusDescr OBJECT-TYPE
|
||||
SYNTAX SnmpAdminString
|
||||
MAX-ACCESS read-only
|
||||
STATUS current
|
||||
DESCRIPTION
|
||||
"A textual description of the current status of the sensor.
|
||||
It serves as a human-readable representation of the operating
|
||||
status including any threshold alerts."
|
||||
::= { aristaEntSensorThresholdEntry 5 }
|
||||
|
||||
|
||||
-- Notifications --
|
||||
|
||||
aristaEntSensorAlarm NOTIFICATION-TYPE
|
||||
OBJECTS {
|
||||
entPhysicalDescr, entPhySensorValue, entStateAlarm
|
||||
}
|
||||
STATUS current
|
||||
DESCRIPTION
|
||||
"This notification is generated under 2 conditions:
|
||||
a) When the value of the sensor value crosses a supported
|
||||
low or high threshold into warning or critical status.
|
||||
b) If previously the sensor value was in a warning or
|
||||
critical status but returns back to a normal status."
|
||||
::= { aristaEntSensorMibNotifications 1 }
|
||||
|
||||
|
||||
-- Conformance and Compliance
|
||||
|
||||
aristaEntSensorMibCompliances OBJECT IDENTIFIER
|
||||
::= { aristaEntSensorMibConformance 1 }
|
||||
|
||||
aristaEntSensorMibGroups OBJECT IDENTIFIER
|
||||
::= { aristaEntSensorMibConformance 2 }
|
||||
|
||||
aristaEntSensorMibCompliance MODULE-COMPLIANCE
|
||||
STATUS current
|
||||
DESCRIPTION
|
||||
"The compliance statement for Arista switches that implement
|
||||
the ARISTA-ENTITY-SENSOR-MIB."
|
||||
MODULE -- this module
|
||||
MANDATORY-GROUPS {
|
||||
aristaEntSensorThresholdGroup,
|
||||
aristaEntSensorNotificationsGroup
|
||||
}
|
||||
::= { aristaEntSensorMibCompliances 1 }
|
||||
|
||||
aristaEntSensorThresholdGroup OBJECT-GROUP
|
||||
OBJECTS {
|
||||
aristaEntSensorThresholdLowWarning,
|
||||
aristaEntSensorThresholdLowCritical,
|
||||
aristaEntSensorThresholdHighWarning,
|
||||
aristaEntSensorThresholdHighCritical,
|
||||
aristaEntSensorStatusDescr
|
||||
}
|
||||
STATUS current
|
||||
DESCRIPTION
|
||||
"The collection of objects that provide threshold
|
||||
information for the sensors in the system."
|
||||
::= { aristaEntSensorMibGroups 1 }
|
||||
|
||||
aristaEntSensorNotificationsGroup NOTIFICATION-GROUP
|
||||
NOTIFICATIONS {
|
||||
aristaEntSensorAlarm
|
||||
}
|
||||
STATUS current
|
||||
DESCRIPTION
|
||||
"The collection of notifications generated by the system if
|
||||
sensor(s) change value are not within the acceptable operating
|
||||
range."
|
||||
::= { aristaEntSensorMibGroups 2 }
|
||||
|
||||
END
|
||||
|
||||
|
||||
Reference in New Issue
Block a user