Skip to content

Commit

Permalink
Improved Infinera Groove discovery (#9913)
Browse files Browse the repository at this point in the history
* Improvements for infinera groove
- add support for 3.0.1 and prior versions
- add support for subports and fibre-channel
- fix bug relating to OS version detection
- updated unit test snmprec
  • Loading branch information
nickhilliard authored and PipoCanaja committed Mar 10, 2019
1 parent eb82a15 commit 8d67bb7
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 26 deletions.
7 changes: 7 additions & 0 deletions includes/definitions/infinera-groove.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -50,3 +50,10 @@ over:
discovery:
- sysObjectID:
- .1.3.6.1.4.1.42229.1.2
- sysObjectID:
- .1.3.6.1.4.1.8072.3.2.10
snmpget:
oid: CORIANT-GROOVE-MIB::softwareloadSwloadProduct.1
mib_dir: infinera
op: 'contains'
value: 'Groove'
10 changes: 9 additions & 1 deletion includes/polling/os/infinera-groove.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,20 @@

$oid_list = [
'neType.0',
'softwareloadSwloadState.1',
'softwareloadSwloadState.2',
'softwareloadSwloadVersion.1',
'softwareloadSwloadVersion.2',
'inventoryManufacturerNumber.shelf.1.0.0.0',
];

$data = snmp_get_multi($device, $oid_list, '-OUQs', 'CORIANT-GROOVE-MIB');

$version = $data[1]['softwareloadSwloadVersion'];
foreach (array_keys($data) as $dkey) {
if (isset($data[$dkey]['softwareloadSwloadState']) && $data[$dkey]['softwareloadSwloadState'] == 'active') {
$version = $data[$dkey]['softwareloadSwloadVersion'];
break;
}
}
$hardware = $data[0]['neType'];
$serial = $data['shelf.1.0.0.0']['inventoryManufacturerNumber'];
55 changes: 30 additions & 25 deletions includes/polling/ports/infinera-groove.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,41 +26,46 @@

echo 'Port types:';

foreach (array ('100', '40', '10') as $infineratype) {
if (!is_array($cg_stats)) {
echo ' eth'.$infineratype.'g';
$cg_stats = snmpwalk_cache_multi_oid($device, 'eth'.$infineratype.'gEntry', $cg_stats, 'CORIANT-GROOVE-MIB');
$cg_stats = snmpwalk_cache_multi_oid($device, 'eth'.$infineratype.'gStatistics', $cg_stats, 'CORIANT-GROOVE-MIB');
}
foreach (array ('eth100g', 'eth40g', 'eth10g', 'fc16g', 'fc8g') as $infineratype) {
echo ' '.$infineratype;
preg_match('/[a-z]+(\d+)g/i', $infineratype, $matches);
$infspeed = $matches[1];

$cg_stats = snmpwalk_cache_multi_oid($device, $infineratype.'Entry', $cg_stats, 'CORIANT-GROOVE-MIB');
$cg_stats = snmpwalk_cache_multi_oid($device, $infineratype.'Statistics', $cg_stats, 'CORIANT-GROOVE-MIB');

$required = array(
'ifAlias' => 'eth'.$infineratype.'gAliasName',
'ifAdminStatus' => 'eth'.$infineratype.'gAdminStatus',
'ifOperStatus' => 'eth'.$infineratype.'gOperStatus',
'ifAlias' => $infineratype.'AliasName',
'ifAdminStatus' => $infineratype.'AdminStatus',
'ifOperStatus' => $infineratype.'OperStatus',
'ifType' => 'Ethernet',
'ifHCInBroadcastPkts' => 'eth'.$infineratype.'gStatisticsEntryInBroadcastPackets',
'ifHCInMulticastPkts' => 'eth'.$infineratype.'gStatisticsEntryInMulticastPackets',
'ifHCInOctets' => 'eth'.$infineratype.'gStatisticsEntryInOctets',
'ifHCInUcastPkts' => 'eth'.$infineratype.'gStatisticsEntryInPackets',
'ifHCOutBroadcastPkts' => 'eth'.$infineratype.'gStatisticsEntryOutBroadcastPackets',
'ifHCOutMulticastPkts' => 'eth'.$infineratype.'gStatisticsEntryOutMulticastPackets',
'ifHCOutOctets' => 'eth'.$infineratype.'gStatisticsEntryOutOctets',
'ifHCOutUcastPkts' => 'eth'.$infineratype.'gStatisticsEntryOutPackets',
'ifHighSpeed' => $infineratype*1000,
'ifHCInBroadcastPkts' => $infineratype.'StatisticsEntryInBroadcastPackets',
'ifHCInMulticastPkts' => $infineratype.'StatisticsEntryInMulticastPackets',
'ifHCInOctets' => $infineratype.'StatisticsEntryInOctets',
'ifHCInUcastPkts' => $infineratype.'StatisticsEntryInPackets',
'ifHCOutBroadcastPkts' => $infineratype.'StatisticsEntryOutBroadcastPackets',
'ifHCOutMulticastPkts' => $infineratype.'StatisticsEntryOutMulticastPackets',
'ifHCOutOctets' => $infineratype.'StatisticsEntryOutOctets',
'ifHCOutUcastPkts' => $infineratype.'StatisticsEntryOutPackets',
'ifHighSpeed' => $infspeed * 1000,
);

foreach ($cg_stats as $index => $tmp_stats) {
$indexids = explode('.', $index);

if (!isset($cg_stats[$index]['eth'.$infineratype.'gAdminStatus'])) {
if (!isset($cg_stats[$index][$infineratype.'AdminStatus'])) {
continue;
}

// 100g ports use shelfId, slotId, portId
// 40g and 10g ports use shelfId, slotId, portId, subportId
$descr = $infineratype.'gbe-'.$indexids[0].'/'.$indexids[1].'/'.$indexids[3];
if ($infineratype != 100) {
$descr .= '/'.$indexids[4];
// The CLI port name is not available in SNMP
$descr = ( strpos($infineratype, 'eth') === false ) ? $infineratype : $infspeed.'gbe';

// 100g and 40g ports use shelfId, slotId, portId
// 10g, fc16g and fc8g ports append the subportId with '.'
$descr .= '-'.$indexids[0].'/'.$indexids[1].'/'.$indexids[3];

if ($infspeed < 40) {
$descr .= '.'.$indexids[4];
}

// librenms expects the index to be bigint(20) => we grab 3 decimal
Expand All @@ -78,7 +83,7 @@

foreach ($required as $normaloid => $infineraoid) {
// this is a bit hacky
if (preg_match('/^eth/', $required[$normaloid])) {
if (preg_match('/^(eth|fc)\d+/i', $required[$normaloid])) {
$port_stats[$lindex][$normaloid] = $cg_stats[$index][$infineraoid];
} else {
$port_stats[$lindex][$normaloid] = $required[$normaloid];
Expand Down
3 changes: 3 additions & 0 deletions tests/snmpsim/infinera-groove.snmprec
Original file line number Diff line number Diff line change
Expand Up @@ -595,4 +595,7 @@
1.3.6.1.4.1.42229.1.2.4.1.35.1.1.38.1.1.0.4.0|4|0
1.3.6.1.4.1.42229.1.2.4.1.35.1.1.38.1.1.0.5.0|4|2380132734405
1.3.6.1.4.1.42229.1.2.4.1.35.1.1.38.1.1.0.6.0|4|185727261573
1.3.6.1.4.1.42229.1.2.9.2.1.1.2.1|2|1
1.3.6.1.4.1.42229.1.2.9.2.1.1.2.2|2|2
1.3.6.1.4.1.42229.1.2.9.2.1.1.3.1|4|FP3.0.3
1.3.6.1.4.1.42229.1.2.9.2.1.1.3.2|4|FP3.0.1

0 comments on commit 8d67bb7

Please sign in to comment.