New OS: Ekinops (#12088)

* Initial push

* renamed mib files

* adding eki mgmt event trap handler

* Adding handler to config/snmptraps.php

* added slot state monitoring

* Ekinops port discovery script

* cleanup

* moved ifDescr change from discovery to poller

* simplified port poller script

* fixed poller array

* add Mgnt2TrapNMSEvent handler

* Adding nms alarm handler

* adding handler to snmptrap.php

* Updated handler names, exapanded event traphandler

* beginning tests and cleanup

* adding snmpsim data

* making tests

* finished trap tests

* fixed ekinops.yaml

* style and lint pass

* new snmpsim data and fixes

* adding correct snmpsim

* fixed test data

* Update ekinops.svg

* Update ekinops.svg

* Update ekinops.yaml

* new os discovery method

* remove unneeded precache line

* removing unneccesary pre-cache script

* styleci fixes

* few more style fixes

* trim whitespace in discovery

* remove unused mibs

Co-authored-by: Tony Murray <murraytony@gmail.com>
This commit is contained in:
Heath Barnhart 2020-09-23 11:23:57 -05:00 committed by GitHub
parent 0e0e80c827
commit 8a921567ba
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
18 changed files with 19288 additions and 0 deletions

65
LibreNMS/OS/Ekinops.php Normal file
View File

@ -0,0 +1,65 @@
<?php
/**
* Ekinops.php
*
* Ekinops Optical Network
*
* 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/>.
*
* @link http://librenms.org
* @copyright KanREN, Inc 2020
* @author Heath Barnhart <hbarnhart@kanren.net>
*/
namespace LibreNMS\OS;
use App\Models\Device;
use LibreNMS\Interfaces\Discovery\OSDiscovery;
use LibreNMS\OS;
class Ekinops extends OS implements OSDiscovery
{
public function discoverOS(Device $device): void
{
$sysDescr = $device->sysDescr;
$info = explode(',', $sysDescr);
$device->hardware = trim($info[1]);
$device->version = trim($info[2]);
$mgmtCard = snmp_get($this->getDeviceArray(), 'mgnt2RinvHwPlatform.0', '-OQv', 'EKINOPS-MGNT2-MIB');
$mgmtInfo = self::ekinopsInfo($mgmtCard);
$device->serial = $mgmtInfo['Serial Number'];
}
/**
* Parses Ekinops inventory returned in a tabular format within a single OID
* @param string $ekiInfo
* @return array $inv
*/
public static function ekinopsInfo($ekiInfo)
{
$info = explode("\n", $ekiInfo);
unset($info[0]);
$inv = [];
foreach ($info as $line) {
[$attr, $value] = explode(':', $line);
$attr = trim($attr);
$value = trim($value);
$inv[$attr] = $value;
}
return $inv;
}
}

View File

@ -0,0 +1,98 @@
<?php
/**
* Mgnt2TrapNMSEvent.php
*
* -Description-
*
* Ekinops managment module alarms
*
* 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/>.
*
* @link http://librenms.org
* @copyright 2020 KanREN, Inc.
* @author Heath Barnhart <hbarnhart@kanren.net>
*/
namespace LibreNMS\Snmptrap\Handlers;
use App\Models\Device;
use LibreNMS\Interfaces\SnmptrapHandler;
use LibreNMS\Snmptrap\Trap;
use Log;
class Mgnt2TrapNmsAlarm implements SnmptrapHandler
{
/**
* Handle snmptrap.
* Data is pre-parsed and delivered as a Trap.
*
* @param Device $device
* @param Trap $trap
* @return void
*/
public function handle(Device $device, Trap $trap)
{
$alarmObj = $trap->getOidData($trap->findOid('EKINOPS-MGNT2-NMS-MIB::mgnt2AlmLogObjectClassIdentifier'));
$sourcePm = $trap->getOidData($trap->findOid('EKINOPS-MGNT2-NMS-MIB::mgnt2AlmLogSourcePm'));
$slot = $trap->getOidData($trap->findOid('EKINOPS-MGNT2-NMS-MIB::mgnt2AlmLogBoardNumber'));
$portType = $trap->getOidData($trap->findOid('EKINOPS-MGNT2-NMS-MIB::mgnt2AlmLogSourcePortType'));
$portNum = $trap->getOidData($trap->findOid('EKINOPS-MGNT2-NMS-MIB::mgnt2AlmLogSourcePortNumber'));
$probCause = $trap->getOidData($trap->findOid('EKINOPS-MGNT2-NMS-MIB::mgnt2AlmLogProbableCause'));
$probSpecific = $trap->getOidData($trap->findOid('EKINOPS-MGNT2-NMS-MIB::mgnt2AlmLogSpecificProblem'));
$probAdd = $trap->getOidData($trap->findOid('EKINOPS-MGNT2-NMS-MIB::mgnt2AlmLogAdditionalText'));
$alarmSeverity = $trap->getOidData($trap->findOid('EKINOPS-MGNT2-NMS-MIB::mgnt2AlmLogSeverity'));
// Adding additional info if it exists.
if (! empty($probAdd)) {
$probSpecific = "$probSpecific Additional info: $probAdd";
}
// Changing other to unknown
if ($probCause == 'other') {
$probCause = 'Unknown';
}
if ($alarmObj == 'port') {
$msg = "Alarm on slot $slot, $sourcePm Port: $portType $portNum Issue: $probSpecific Possible Cause: $probCause";
} else {
$msg = "Alarm on slot $slot, $sourcePm Issue: $probSpecific Possible Cause: $probCause";
}
switch ($alarmSeverity) {
case 'cleared':
$severity = 1;
break;
case 'critical':
$severity = 5;
break;
case 'major':
$severity = 5;
break;
case 'minor':
$severity = 4;
break;
case 'warning':
$severity = 4;
break;
case 'indeterminate':
$severity = 0;
break;
default:
$severity = 2;
break;
}
Log::event($msg, $device->device_id, 'trap', $severity);
}
}

View File

@ -0,0 +1,66 @@
<?php
/**
* Mgnt2TrapNMSEvent.php
*
* -Description-
*
* Ekinops managment module events
*
* 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/>.
*
* @link http://librenms.org
* @copyright 2020 KanREN, Inc.
* @author Heath Barnhart <hbarnhart@kanren.net>
*/
namespace LibreNMS\Snmptrap\Handlers;
use App\Models\Device;
use LibreNMS\Interfaces\SnmptrapHandler;
use LibreNMS\Snmptrap\Trap;
use Log;
class Mgnt2TrapNmsEvent implements SnmptrapHandler
{
/**
* Handle snmptrap.
* Data is pre-parsed and delivered as a Trap.
*
* @param Device $device
* @param Trap $trap
* @return void
*/
public function handle(Device $device, Trap $trap)
{
$eventObj = $trap->getOidData($trap->findOid('EKINOPS-MGNT2-NMS-MIB::mgnt2EventLogObjectClassIdentifier'));
$sourcePm = $trap->getOidData($trap->findOid('EKINOPS-MGNT2-NMS-MIB::mgnt2EventLogSourcePm'));
$slot = $trap->getOidData($trap->findOid('EKINOPS-MGNT2-NMS-MIB::mgnt2EventLogBoardNumber'));
$portType = $trap->getOidData($trap->findOid('EKINOPS-MGNT2-NMS-MIB::mgnt2EventLogSourcePortType'));
$portNum = $trap->getOidData($trap->findOid('EKINOPS-MGNT2-NMS-MIB::mgnt2EventLogSourcePortNumber'));
$logReason = $trap->getOidData($trap->findOid('EKINOPS-MGNT2-NMS-MIB::mgnt2EventLogReason'));
$logAdd = $trap->getOidData($trap->findOid('EKINOPS-MGNT2-NMS-MIB::mgnt2EventLogAdditionalText'));
// Adding additional info if it exists.
if (! empty($logAdd)) {
$logReason = "$logReason Additional info: $logAdd";
}
if ($eventObj == 'port') {
$msg = "Event on slot $slot, $sourcePm Port: $portType $portNum. Reason: $logReason";
} else {
$msg = "Event on slot $slot, $sourcePm Reason: $logReason";
}
Log::event($msg, $device->device_id, 'trap', 2);
}
}

View File

@ -46,6 +46,8 @@ return [
'CPS-MIB::upsStartBatteryTest' => \LibreNMS\Snmptrap\Handlers\CpUpsStartBatteryTest::class,
'CPS-MIB::upsTurnedOff' => \LibreNMS\Snmptrap\Handlers\CpUpsTurnedOff::class,
'CPS-MIB::upsWokeUp' => \LibreNMS\Snmptrap\Handlers\CpUpsWokeUp::class,
'EKINOPS-MGNT2-NMS-MIB::mgnt2TrapNMSEvent' => \LibreNMS\Snmptrap\Handlers\Mgnt2TrapNmsEvent::class,
'EKINOPS-MGNT2-NMS-MIB::mgnt2TrapNMSAlarm' => \LibreNMS\Snmptrap\Handlers\Mgnt2TrapNmsAlarm::class,
'ENTITY-MIB::entConfigChange' => \LibreNMS\Snmptrap\Handlers\EntityDatabaseConfigChanged::class,
'EQUIPMENT-MIB::equipStatusTrap' => \LibreNMS\Snmptrap\Handlers\EquipStatusTrap::class,
'FORTINET-CORE-MIB::fnTrapMemThreshold' => \LibreNMS\Snmptrap\Handlers\FnTrapMemThreshold::class,

File diff suppressed because one or more lines are too long

After

Width:  |  Height:  |  Size: 8.5 KiB

View File

@ -0,0 +1 @@
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 13.537 13.603"><path d="M6.785 6.892c-.253-.288.382-.173.576-.195h4.15c.254.29-.381.174-.575.195h-4.15zM13.535 6.803c.037.679-.904 1.061-1.351.548-.492-.454-.104-1.371.565-1.335a.79.79 0 01.786.787z" fill="#f15a29"/><path d="M10.25 10.106l-3.018-3.03c.574.23 1.144.48 1.722.7.254-.227-.328-.298-.496-.407-.46-.19-.92-.378-1.381-.567l1.918-.804c.123-.364-.419-.013-.606.043l-1.146.48 3.037-3.027c-.111-.416-.634.465-.873.595L7.071 6.418l.706-1.735c-.171-.343-.304.288-.397.46l-.47 1.154V2.01c-.289-.254-.174.381-.195.575V6.27c-.312-.48-.379-1.53-.85-1.667.126.55.604 1.413.638 1.742l-3-3.011c-.383.023.147.393.269.545l2.64 2.652-1.702-.697c-.344.17.287.305.459.398l1.135.465H2.036c-.254.288.381.173.575.194H6.36l-1.716.716c-.137.365.396.026.572-.027l1.186-.495C5.392 8.092 4.38 9.1 3.369 10.106c.11.437.623-.46.863-.585l2.299-2.29-.678 1.672c.156.358.3-.265.382-.425l.48-1.183v4.272c.288.254.173-.381.194-.575V7.278c.244.578.449 1.179.718 1.742.312-.268-.317-1.017-.4-1.473-.293-.558.062-.133.272.072l2.613 2.624c.087.092.23-.05.137-.137zM3.349 11.049c.037.68-.905 1.062-1.352.548-.491-.454-.104-1.37.565-1.335a.79.79 0 01.787.787z" fill="#3b6e8f"/><path d="M4.35 8.168c.036.679-.905 1.061-1.352.548-.491-.454-.104-1.37.565-1.335a.79.79 0 01.786.787zM11.87 2.557c.036.679-.906 1.061-1.352.548-.492-.455-.104-1.371.564-1.335a.79.79 0 01.787.787zM10.868 5.438c.037.679-.904 1.06-1.35.548-.492-.455-.105-1.37.564-1.335a.79.79 0 01.786.787zM11.855 11.062c.037.68-.904 1.062-1.351.549-.492-.455-.104-1.371.564-1.336a.79.79 0 01.787.787zM8.974 10.062c.037.68-.905 1.062-1.351.548-.492-.454-.104-1.37.564-1.335a.79.79 0 01.787.787zM3.363 2.543c.037.68-.905 1.062-1.352.548-.491-.454-.104-1.371.565-1.335a.79.79 0 01.787.787zM6.244 3.543c.037.68-.905 1.062-1.351.549-.492-.455-.104-1.371.564-1.335a.79.79 0 01.787.786zM7.6 12.817c.036.68-.906 1.062-1.352.549-.492-.455-.104-1.372.564-1.336a.79.79 0 01.787.787zM6.27 10.073c.036.679-.905 1.061-1.352.548-.492-.454-.104-1.371.564-1.335a.79.79 0 01.787.787zM7.619.788c.037.679-.905 1.061-1.351.548-.492-.454-.104-1.37.564-1.335a.79.79 0 01.787.787zM8.949 3.533c.037.68-.905 1.062-1.352.548-.491-.454-.104-1.37.565-1.335a.79.79 0 01.787.787zM10.879 8.142c.037.68-.905 1.062-1.351.549-.492-.455-.104-1.371.564-1.335a.79.79 0 01.787.786zM1.573 6.793c.037.68-.905 1.061-1.352.548C-.27 6.887.118 5.97.786 6.006a.79.79 0 01.787.787zM4.339 5.463c.036.679-.905 1.061-1.351.548-.492-.454-.104-1.37.564-1.335a.79.79 0 01.787.787z" fill="#3b6e8f"/></svg>

After

Width:  |  Height:  |  Size: 2.5 KiB

View File

@ -0,0 +1,20 @@
mib: EKINOPS-MGNT2-MIB
modules:
sensors:
state:
data:
-
oid: mgnt2GigmBoardTable
value: mgnt2SlotStatus
num_oid: '.1.3.6.1.4.1.20044.7.1.2.1.1.10.{{ $index }}'
descr: mgnt2Name
index: 'mgnt2IndexBoards.{{ $index }}'
state_name: Mgnt2SlotStatus
states:
- { value: 0, generic: 0, graph: 1, descr: 'slot open' }
- { value: 1, generic: 0, graph: 1, descr: 'pmReady' }
- { value: 2, generic: 2, graph: 1, descr: 'pmReset' }
- { value: 3, generic: 1, graph: 1, descr: 'pmLoad' }
- { value: 4, generic: 0, graph: 1, descr: 'pmPassive' }
- { value: 5, generic: 3, graph: 1, descr: 'pmUnknown' }
- { value: 6, generic: 1, graph: 1, descr: 'pmNotReady' }

View File

@ -0,0 +1,9 @@
os: ekinops
text: 'Ekinops Optical'
type: network
icon: ekinops
group: ekinops
discovery:
- sysObjectID:
- .1.3.6.1.4.1.20044
mib_dir: ekinops

View File

@ -49,6 +49,11 @@ if ($device['os'] == 'fabos') {
require_once 'ports/brocade.inc.php';
}
//Shorten Ekinops Interfaces
if ($device['os'] == 'ekinops') {
require_once 'ports/ekinops.inc.php';
}
// New interface detection
foreach ($port_stats as $ifIndex => $snmp_data) {
$snmp_data['ifIndex'] = $ifIndex; // Store ifIndex in port entry

View File

@ -0,0 +1,54 @@
<?php
/**
* ekinops.inc.php
*
* -Description-
*
* The Ekinops interface naming scheme is overly verbose (see example).
* The ifDescr and ifName returned by the device are the same. This
* script reduces ifDescr to slot/card type/interface and sets ifAlias
* to the user defined description found on the interface's configuration
* on the Ekinops shelf.
*
* Example:
* ifName: EKINOPS/C600HC/13/PM_10010-MR/S10-Client10(PORT_Number 10)
* ifDescr: 13/PM_10010-MR/S10-Client10
* ifAlias: PORT_Number 10
*
* 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/>.
*
* Traps when Adva objects are created. This includes Remote User Login object,
* Flow Creation object, and LAG Creation object.
*
* @link http://librenms.org
* @copyright 2020 KanREN, Inc
* @author Heath Barnhart <hbarnhart@kanren.net>
*/
foreach ($port_stats as $index => $port) {
/*
* Split up ifName and drop the EKIPS/Chassis
*/
$intName = preg_split("/[\/,\(,\)]/", $port['ifName']);
// Make ifDescr slot/card/int
$ifDescr = $intName[2] . '/' . $intName[3] . '/' . $intName[4];
// Make ifAlias descr
$ifAlias = $intName[5];
$port_stats[$index]['ifAlias'] = $ifAlias;
$port_stats[$index]['ifDescr'] = $ifDescr;
}

View File

@ -0,0 +1,54 @@
<?php
/**
* ekinops.inc.php
*
* -Description-
*
* The Ekinops interface naming scheme is overly verbose (see example).
* The ifDescr and ifName returned by the device are the same. This
* script reduces ifDescr to slot/card type/interface and sets ifAlias
* to the user defined description found on the interface's configuration
* on the Ekinops shelf.
*
* Example:
* ifName: EKINOPS/C600HC/13/PM_10010-MR/S10-Client10(PORT_Number 10)
* ifDescr: 13/PM_10010-MR/S10-Client10
* ifAlias: PORT_Number 10
*
* 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/>.
*
* Traps when Adva objects are created. This includes Remote User Login object,
* Flow Creation object, and LAG Creation object.
*
* @link http://librenms.org
* @copyright 2020 KanREN, Inc
* @author Heath Barnhart <hbarnhart@kanren.net>
*/
foreach ($port_stats as $index => $port) {
/*
* Split up ifName and drop the EKIPS/Chassis
*/
$intName = preg_split("/[\/,\(,\)]/", $port['ifName']);
// Make ifDescr slot/card/int
$ifDescr = $intName[2] . '/' . $intName[3] . '/' . $intName[4];
// Make ifAlias descr
$ifAlias = $intName[5];
$port_stats[$index]['ifAlias'] = $ifAlias;
$port_stats[$index]['ifDescr'] = $ifDescr;
}

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

167
mibs/ekinops/EKINOPS-MIB Normal file
View File

@ -0,0 +1,167 @@
-- *****************************************************************
-- EKINOPS.TXT: MIB
--
--MIB Part Number:3MI02000AHAA
--MIB Version:01
--
-- Copyright (c) 2006 by Ekinops
-- All rights reserved.
--
-- *****************************************************************
EKINOPS-MIB DEFINITIONS ::= BEGIN
IMPORTS
MODULE-IDENTITY,
enterprises
FROM SNMPv2-SMI
TEXTUAL-CONVENTION
FROM SNMPv2-TC;
ekinops MODULE-IDENTITY
LAST-UPDATED "200903160000Z"
ORGANIZATION "Ekinops"
CONTACT-INFO
"Ekinops
11, rue Louis de Broglie
F-22300 Lannion / FRANCE
Tel : +33 (0)2 96 05 00 30
Fax : +33 (0)2 96 48 62 39
E-mail: support@ekinops.fr"
DESCRIPTION
"Initial version of this MIB module."
REVISION "200408180000Z"
DESCRIPTION
"Initial Version."
REVISION "200504040000Z"
DESCRIPTION
"Add the EkiMode type"
REVISION "200506080000Z"
DESCRIPTION
"Add the EkiSynchroMode type"
REVISION "200601190000Z"
DESCRIPTION
"Add the EkiLineProtocol type"
REVISION "200610260000Z"
DESCRIPTION
"Add the EkiStmProtocol type"
REVISION "200705240000Z"
DESCRIPTION
"Only one textual convention for all protocols"
REVISION "200903160000Z"
DESCRIPTION
"Clear Channel Protocol insertion"
::= { enterprises 20044 }
--- #####################################################
--- SYMBOLIC NAMES DEFINITION
--- #####################################################
EkiState ::= TEXTUAL-CONVENTION
STATUS current
DESCRIPTION "states for flags"
SYNTAX INTEGER {
disabled(1),
enabled(2)
}
EkiOnOff ::= TEXTUAL-CONVENTION
STATUS current
DESCRIPTION "states for flags"
SYNTAX INTEGER {
off(1),
on(2)
}
EkiProtocol ::= TEXTUAL-CONVENTION
STATUS current
DESCRIPTION "Differents protocols on the SFP or XFP"
SYNTAX INTEGER {
protGBE(1),
prot1GFC(2),
prot2GFC(3),
protOC48(4),
protclearchannel(6),
prot10GBE(8),
protOC192(9),
protStm1(10),
protStm4(11),
prot2GBE(12),
prot4GFC(13),
protEscon(14),
protFastEth(15)
}
EkiMode ::= TEXTUAL-CONVENTION
STATUS current
DESCRIPTION "mode for flags"
SYNTAX INTEGER {
auto(1),
manual(2)
}
EkiSynchroMode ::= TEXTUAL-CONVENTION
STATUS current
DESCRIPTION "Synchronization sources description"
SYNTAX INTEGER {
internal(1),
external(2)
}
EkiApiState ::= TEXTUAL-CONVENTION
STATUS current
DESCRIPTION "Api errors descriptions"
SYNTAX INTEGER {
moduleNotResponding(128),
messageFormatError(129),
cmdExecutionError(130),
unknownArticleError(132),
unknownMessageError(133)
}
EkiMeasureType ::= TEXTUAL-CONVENTION
STATUS current
DESCRIPTION "Measure type identifier"
SYNTAX INTEGER (0..15)
EkiLoadGWSW ::= TEXTUAL-CONVENTION
STATUS current
DESCRIPTION "Types of article files"
SYNTAX INTEGER {
gW(1),
sW(2)
}
EkiLoadState ::= TEXTUAL-CONVENTION
STATUS current
DESCRIPTION "Current state of the article file"
SYNTAX INTEGER {
idle(1),
downloading(2)
}
EkiLoadPermutMethod ::= TEXTUAL-CONVENTION
STATUS current
DESCRIPTION "Permutation method for the current article"
SYNTAX INTEGER {
manual(0),
autoImmediate(1),
autoScheduled(2)
}
EkiLoadPermutMode ::= TEXTUAL-CONVENTION
STATUS current
DESCRIPTION "Permutation mode for the current article"
SYNTAX INTEGER {
coldReset(0),
warmReset(1)
}
END

View File

@ -0,0 +1,165 @@
<?php
/**
* MgmtTrapNmsAlarmTest.php
*
* -Description-
*
* Tests NMS Alarm Traps sent by Ekinops Optical Networking products.
*
* 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/>.
*
*
* Tests JnxVpnPwDown and JnxVpnPwUp traps from Juniper devices.
*
* @link http://librenms.org
* @copyright 2020 KanREN, Inc
* @author Heath Barnhart <hbarnhart@kanren.net>
*/
namespace LibreNMS\Tests\Feature\SnmpTraps;
use App\Models\Device;
use LibreNMS\Snmptrap\Dispatcher;
use LibreNMS\Snmptrap\Trap;
class MgmtTrapNmsAlarmTest extends SnmpTrapTestCase
{
public function testAlarmClear()
{
$device = factory(Device::class)->create();
$alarm = self::genEkiAlarm();
$slotNum = $alarm['slotNum'];
$srcPm = $alarm['srcPm'];
$specific = $alarm['specific'];
$trapText = "$device->hostname
UDP: [$device->ip]:60057->[192.168.1.100]:162
DISMAN-EVENT-MIB::sysUpTimeInstance 168:19:32:11.62
SNMPv2-MIB::snmpTrapOID.0 EKINOPS-MGNT2-NMS-MIB::mgnt2TrapNMSAlarm
EKINOPS-MGNT2-NMS-MIB::mgnt2AlmLogNotificationId 566098
EKINOPS-MGNT2-NMS-MIB::mgnt2AlmLogObjectClassIdentifier module
EKINOPS-MGNT2-NMS-MIB::mgnt2AlmLogSourcePm $srcPm
EKINOPS-MGNT2-NMS-MIB::mgnt2AlmLogBoardNumber $slotNum
EKINOPS-MGNT2-NMS-MIB::mgnt2AlmLogSourcePortType Other
EKINOPS-MGNT2-NMS-MIB::mgnt2AlmLogSourcePortNumber 0
EKINOPS-MGNT2-NMS-MIB::mgnt2AlmLogProbableCause other
EKINOPS-MGNT2-NMS-MIB::mgnt2AlmLogSeverity cleared
EKINOPS-MGNT2-NMS-MIB::mgnt2AlmLogSpecificProblem $specific
EKINOPS-MGNT2-NMS-MIB::mgnt2AlmLogAdditionalText
EKINOPS-MGNT2-NMS-MIB::mgnt2AlmLogAlarmType synthesisAlarm
EKINOPS-MGNT2-NMS-MIB::mgnt2AlmLogTime 2020-8-19,14:21:2.0
EKINOPS-MGNT2-NMS-MIB::mgnt2AlmLogNodeControllerIpAddress 0.0.0.0
EKINOPS-MGNT2-NMS-MIB::mgnt2AlmLogChassisId $device->ip";
$trap = new Trap($trapText);
$msg = "Alarm on slot $slotNum, $srcPm Issue: $specific Possible Cause: Unknown";
\Log::shouldReceive('event')->once()->with($msg, $device->device_id, 'trap', 1);
$this->assertTrue(Dispatcher::handle($trap), 'Could not handle mgnt2TrapNMSAlarm trap CLEARED');
}
//Test alarm with addtional text supplied.
public function testAlarmAddText()
{
$device = factory(Device::class)->create();
$alarm = self::genEkiAlarm();
$slotNum = $alarm['slotNum'];
$srcPm = $alarm['srcPm'];
$specific = $alarm['specific'];
$add = $alarm['addText'];
$trapText = "$device->hostname
UDP: [$device->ip]:60057->[192.168.1.100]:162
DISMAN-EVENT-MIB::sysUpTimeInstance 168:19:32:11.62
SNMPv2-MIB::snmpTrapOID.0 EKINOPS-MGNT2-NMS-MIB::mgnt2TrapNMSAlarm
EKINOPS-MGNT2-NMS-MIB::mgnt2AlmLogNotificationId 566098
EKINOPS-MGNT2-NMS-MIB::mgnt2AlmLogObjectClassIdentifier module
EKINOPS-MGNT2-NMS-MIB::mgnt2AlmLogSourcePm $srcPm
EKINOPS-MGNT2-NMS-MIB::mgnt2AlmLogBoardNumber $slotNum
EKINOPS-MGNT2-NMS-MIB::mgnt2AlmLogSourcePortType Other
EKINOPS-MGNT2-NMS-MIB::mgnt2AlmLogSourcePortNumber 0
EKINOPS-MGNT2-NMS-MIB::mgnt2AlmLogProbableCause other
EKINOPS-MGNT2-NMS-MIB::mgnt2AlmLogSeverity cleared
EKINOPS-MGNT2-NMS-MIB::mgnt2AlmLogSpecificProblem $specific
EKINOPS-MGNT2-NMS-MIB::mgnt2AlmLogAdditionalText $add
EKINOPS-MGNT2-NMS-MIB::mgnt2AlmLogAlarmType synthesisAlarm
EKINOPS-MGNT2-NMS-MIB::mgnt2AlmLogTime 2020-8-19,14:21:2.0
EKINOPS-MGNT2-NMS-MIB::mgnt2AlmLogNodeControllerIpAddress 0.0.0.0
EKINOPS-MGNT2-NMS-MIB::mgnt2AlmLogChassisId $device->ip";
$trap = new Trap($trapText);
$msg = "Alarm on slot $slotNum, $srcPm Issue: $specific Additional info: $add Possible Cause: Unknown";
\Log::shouldReceive('event')->once()->with($msg, $device->device_id, 'trap', 1);
$this->assertTrue(Dispatcher::handle($trap), 'Could not handle mgnt2TrapNMSAlarm trap with additional text');
}
//Alarm is on a specific port
public function testAlarmPort()
{
$device = factory(Device::class)->create();
$alarm = self::genEkiAlarm();
$slotNum = $alarm['slotNum'];
$srcPm = $alarm['srcPm'];
$specific = $alarm['specific'];
$probCause = $alarm['probCause'];
$portType = $alarm['portType'];
$portNum = $alarm['portNum'];
$add = $alarm['addText'];
$trapText = "$device->hostname
UDP: [$device->ip]:60057->[192.168.1.100]:162
DISMAN-EVENT-MIB::sysUpTimeInstance 168:19:32:03.51
SNMPv2-MIB::snmpTrapOID.0 EKINOPS-MGNT2-NMS-MIB::mgnt2TrapNMSAlarm
EKINOPS-MGNT2-NMS-MIB::mgnt2AlmLogNotificationId 566097
EKINOPS-MGNT2-NMS-MIB::mgnt2AlmLogObjectClassIdentifier port
EKINOPS-MGNT2-NMS-MIB::mgnt2AlmLogSourcePm $srcPm
EKINOPS-MGNT2-NMS-MIB::mgnt2AlmLogBoardNumber $slotNum
EKINOPS-MGNT2-NMS-MIB::mgnt2AlmLogSourcePortType $portType
EKINOPS-MGNT2-NMS-MIB::mgnt2AlmLogSourcePortNumber $portNum
EKINOPS-MGNT2-NMS-MIB::mgnt2AlmLogProbableCause $probCause
EKINOPS-MGNT2-NMS-MIB::mgnt2AlmLogSeverity critical
EKINOPS-MGNT2-NMS-MIB::mgnt2AlmLogSpecificProblem $specific
EKINOPS-MGNT2-NMS-MIB::mgnt2AlmLogAdditionalText
EKINOPS-MGNT2-NMS-MIB::mgnt2AlmLogAlarmType integrityViolation
EKINOPS-MGNT2-NMS-MIB::mgnt2AlmLogTime 2020-8-19,14:20:54.0
EKINOPS-MGNT2-NMS-MIB::mgnt2AlmLogNodeControllerIpAddress 0.0.0.0
EKINOPS-MGNT2-NMS-MIB::mgnt2AlmLogChassisId $device->ip";
$trap = new Trap($trapText);
$msg = "Alarm on slot $slotNum, $srcPm Port: $portType $portNum Issue: $specific Possible Cause: $probCause";
\Log::shouldReceive('event')->once()->with($msg, $device->device_id, 'trap', 5);
$this->assertTrue(Dispatcher::handle($trap), 'Could not handle mgnt2TrapNMSAlarm trap with additional text');
}
public static function genEkiAlarm()
{
$alarm['slotNum'] = rand(1, 32);
$alarm['srcPm'] = str_shuffle('0123456789abcdefg');
$alarm['specific'] = str_shuffle('0123456789abcdefg');
$alarm['portType'] = str_shuffle('0123456789abcdefg');
$alarm['probCause'] = str_shuffle('0123456789abcdefg');
$alarm['portNum'] = rand(1, 32);
$alarm['addText'] = str_shuffle('0123456789abcdefg');
return $alarm;
}
}

View File

@ -0,0 +1,160 @@
<?php
/**
* MgmtTrapNmsEventTest.php
*
* -Description-
*
* Tests NMS Event Traps sent by Ekinops Optical Networking products.
*
* 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/>.
*
*
* Tests JnxVpnPwDown and JnxVpnPwUp traps from Juniper devices.
*
* @link http://librenms.org
* @copyright 2020 KanREN, Inc
* @author Heath Barnhart <hbarnhart@kanren.net>
*/
namespace LibreNMS\Tests\Feature\SnmpTraps;
use App\Models\Device;
use LibreNMS\Snmptrap\Dispatcher;
use LibreNMS\Snmptrap\Trap;
class MgmtTrapNmsEventTest extends SnmpTrapTestCase
{
public function testEvent()
{
$device = factory(Device::class)->create();
$alarm = self::genEkiEvent();
$slotNum = $alarm['slotNum'];
$srcPm = $alarm['srcPm'];
$reason = $alarm['reason'];
$trapText = "$device->hostname
UDP: [$device->ip]:60057->[10.0.0.1]:162
DISMAN-EVENT-MIB::sysUpTimeInstance 159:19:33:14.42
SNMPv2-MIB::snmpTrapOID.0 EKINOPS-MGNT2-NMS-MIB::mgnt2TrapNMSEvent
EKINOPS-MGNT2-NMS-MIB::mgnt2EventLogNotificationId 132
EKINOPS-MGNT2-NMS-MIB::mgnt2EventLogObjectClassIdentifier chassis
EKINOPS-MGNT2-NMS-MIB::mgnt2EventLogSourcePm $srcPm
EKINOPS-MGNT2-NMS-MIB::mgnt2EventLogBoardNumber $slotNum
EKINOPS-MGNT2-NMS-MIB::mgnt2EventLogSourcePortType None
EKINOPS-MGNT2-NMS-MIB::mgnt2EventLogSourcePortNumber 0
EKINOPS-MGNT2-NMS-MIB::mgnt2EventLogEventType activityLog
EKINOPS-MGNT2-NMS-MIB::mgnt2EventLogSourceType event
EKINOPS-MGNT2-NMS-MIB::mgnt2EventLogReason $reason
EKINOPS-MGNT2-NMS-MIB::mgnt2EventLogAdditionalText
EKINOPS-MGNT2-NMS-MIB::mgnt2EventLogTime 2020-8-10,14:22:5
EKINOPS-MGNT2-NMS-MIB::mgnt2EventLogNodeControllerIpAddress 0.0.0.0
EKINOPS-MGNT2-NMS-MIB::mgnt2EventLogChassisId $device->ip";
$trap = new Trap($trapText);
$msg = "Event on slot $slotNum, $srcPm Reason: $reason";
\Log::shouldReceive('event')->once()->with($msg, $device->device_id, 'trap', 2);
$this->assertTrue(Dispatcher::handle($trap), 'Could not handle mgnt2TrapNMSEvent trap');
}
//Test alarm with addtional text supplied.
public function testEventAddText()
{
$device = factory(Device::class)->create();
$alarm = self::genEkiEvent();
$slotNum = $alarm['slotNum'];
$srcPm = $alarm['srcPm'];
$reason = $alarm['reason'];
$add = $alarm['addText'];
$trapText = "$device->hostname
UDP: [$device->ip]:60057->[10.0.0.1]:162
DISMAN-EVENT-MIB::sysUpTimeInstance 159:19:33:14.42
SNMPv2-MIB::snmpTrapOID.0 EKINOPS-MGNT2-NMS-MIB::mgnt2TrapNMSEvent
EKINOPS-MGNT2-NMS-MIB::mgnt2EventLogNotificationId 132
EKINOPS-MGNT2-NMS-MIB::mgnt2EventLogObjectClassIdentifier chassis
EKINOPS-MGNT2-NMS-MIB::mgnt2EventLogSourcePm $srcPm
EKINOPS-MGNT2-NMS-MIB::mgnt2EventLogBoardNumber $slotNum
EKINOPS-MGNT2-NMS-MIB::mgnt2EventLogSourcePortType None
EKINOPS-MGNT2-NMS-MIB::mgnt2EventLogSourcePortNumber 0
EKINOPS-MGNT2-NMS-MIB::mgnt2EventLogEventType activityLog
EKINOPS-MGNT2-NMS-MIB::mgnt2EventLogSourceType event
EKINOPS-MGNT2-NMS-MIB::mgnt2EventLogReason $reason
EKINOPS-MGNT2-NMS-MIB::mgnt2EventLogAdditionalText $add
EKINOPS-MGNT2-NMS-MIB::mgnt2EventLogTime 2020-8-10,14:22:5
EKINOPS-MGNT2-NMS-MIB::mgnt2EventLogNodeControllerIpAddress 0.0.0.0
EKINOPS-MGNT2-NMS-MIB::mgnt2EventLogChassisId $device->ip";
$trap = new Trap($trapText);
$msg = "Event on slot $slotNum, $srcPm Reason: $reason Additional info: $add";
\Log::shouldReceive('event')->once()->with($msg, $device->device_id, 'trap', 2);
$this->assertTrue(Dispatcher::handle($trap), 'Could not handle mgnt2TrapNMSEvent trap with additional text');
}
//Event trap on a specific port
public function testEventPort()
{
$device = factory(Device::class)->create();
$alarm = self::genEkiEvent();
$slotNum = $alarm['slotNum'];
$srcPm = $alarm['srcPm'];
$reason = $alarm['reason'];
$add = $alarm['addText'];
$portType = $alarm['portType'];
$portNum = $alarm['portNum'];
$trapText = "$device->hostname
UDP: [$device->ip]:60057->[10.0.0.1]:162
DISMAN-EVENT-MIB::sysUpTimeInstance 159:19:33:14.42
SNMPv2-MIB::snmpTrapOID.0 EKINOPS-MGNT2-NMS-MIB::mgnt2TrapNMSEvent
EKINOPS-MGNT2-NMS-MIB::mgnt2EventLogNotificationId 132
EKINOPS-MGNT2-NMS-MIB::mgnt2EventLogObjectClassIdentifier port
EKINOPS-MGNT2-NMS-MIB::mgnt2EventLogSourcePm $srcPm
EKINOPS-MGNT2-NMS-MIB::mgnt2EventLogBoardNumber $slotNum
EKINOPS-MGNT2-NMS-MIB::mgnt2EventLogSourcePortType $portType
EKINOPS-MGNT2-NMS-MIB::mgnt2EventLogSourcePortNumber $portNum
EKINOPS-MGNT2-NMS-MIB::mgnt2EventLogEventType activityLog
EKINOPS-MGNT2-NMS-MIB::mgnt2EventLogSourceType event
EKINOPS-MGNT2-NMS-MIB::mgnt2EventLogReason $reason
EKINOPS-MGNT2-NMS-MIB::mgnt2EventLogAdditionalText
EKINOPS-MGNT2-NMS-MIB::mgnt2EventLogTime 2020-8-10,14:22:5
EKINOPS-MGNT2-NMS-MIB::mgnt2EventLogNodeControllerIpAddress 0.0.0.0
EKINOPS-MGNT2-NMS-MIB::mgnt2EventLogChassisId $device->ip";
$trap = new Trap($trapText);
$msg = "Event on slot $slotNum, $srcPm Port: $portType $portNum. Reason: $reason";
\Log::shouldReceive('event')->once()->with($msg, $device->device_id, 'trap', 2);
$this->assertTrue(Dispatcher::handle($trap), 'Could not handle mgnt2TrapNMSEvent trap with a specficied port');
}
public static function genEkiEvent()
{
$alarm['slotNum'] = rand(1, 32);
$alarm['srcPm'] = str_shuffle('0123456789abcdefg');
$alarm['reason'] = str_shuffle('0123456789abcdefg');
$alarm['portType'] = str_shuffle('0123456789abcdefg');
$alarm['portNum'] = rand(1, 32);
$alarm['addText'] = str_shuffle('0123456789abcdefg');
return $alarm;
}
}

10572
tests/data/ekinops.json Normal file

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff