Arista EOS: Added groups and better sensor names (#11990)

* Arista EOS: Added groups and better sensor names

* Changed few sensors naming to remove redundancy

* Test files

* Better naming v2

* More rewriting and grouping

* And more grouping/rewritting

* Update arista_eos_vrf.json

* Minor code format fix

Co-authored-by: Tony Murray <murraytony@gmail.com>
This commit is contained in:
TheGreatDoc
2020-08-18 15:36:14 +02:00
committed by GitHub
parent 29dae9cbbe
commit 29b09c8845
5 changed files with 11096 additions and 386 deletions

View File

@@ -71,7 +71,17 @@ if (!empty($entity_oids)) {
if ($descr) {
$descr = rewrite_entity_descr($descr);
} else {
$descr = $entity_array[$index]['entPhysicalDescr'];
// Better sensor names for Arista EOS. Remove some redundancy and improve them so they reflect to which unit they belong.
if ($device['os'] === 'arista_eos') {
$descr = $entity_array[$index]['entPhysicalDescr'];
if (preg_match("/(Input|Output) (voltage|current) sensor/i", $descr) || Str::startsWith($descr, 'Power supply') || preg_match('/^(Power Supply|Hotspot|Inlet|Board)/i', $descr)) {
$descr = ucwords($entity_array[substr_replace($index, '000', -3)]['entPhysicalDescr']) . " " . preg_replace('/(Voltage|Current|Power Supply) Sensor$/i', '', ucwords($entity_array[$index]['entPhysicalDescr']));
}
if (preg_match('/(temp|temperature) sensor$/i', $descr)) {
$descr = preg_replace('/(temp|temperature) sensor$/i', '', $descr);
}
}
// End better sensor names for Arista EOS.
$descr = rewrite_entity_descr($descr);
}
$valid_sensor = check_entity_sensor($descr, $device);
@@ -183,8 +193,30 @@ if (!empty($entity_oids)) {
$high_limit = $entry['aristaEntSensorThresholdHighCritical'] / $divisor;
}
}
// Grouping sensors
$group = null;
if (preg_match("/DOM /i", $descr)) {
$group = "SFPs";
} elseif (preg_match('/PwrCon/', $descr)) {
$string = explode(' ', $descr);
if (preg_match('/PwrCon[0-9]/', $string[0])) {
$group = $string[0];
} else {
$group = preg_replace('/PwrCon/i', '', $string[0]);
}
$descr = preg_replace('/^.*?(PwrCon)[0-9]*/i', '', $descr);
} elseif (preg_match("/^(Trident.*|Jericho[0-9]|FM6000)/i", $descr)) {
// I only know replies for Trident|Jericho|FM6000 platform. If you have another please add to the preg_match
$group = "Platform";
} elseif (preg_match("/^(Power|PSU)/i", $descr)) {
$group = "PSUs";
} else {
$group = "System";
$descr = Str::replaceLast('temp sensor', '', $descr);
}
// End grouping sensors
}
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']);
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'], null, $group);
}
}//end if
}//end foreach

View File

@@ -36,6 +36,7 @@ function rewrite_entity_descr($descr)
$descr = str_replace('PMOD', 'PSU', $descr);
$descr = preg_replace('/^temperatures /', '', $descr);
$descr = preg_replace('/^voltages /', '', $descr);
$descr = str_replace('PowerSupply', 'PSU ', $descr);
return $descr;
}