mirror of
https://github.com/librenms/librenms.git
synced 2024-10-07 16:52:45 +00:00
Juniper SNMP Trap Handlers (#10136)
* initial commit of junos handlers * added DOM alarm test, refactored handlers for DOM alarms * fixed some formating issues with last commit * Created DOM alarm handlers and unit tests * Made tests for LSP Down handler * Added trap tests for JnxVpnSes*, JnxVpnIf*, JnxVpnPw* * Added BGP4 trap handlers and tests * Fixed some variable names for codeclimate * Simplified JnxBGPM2* handlers * updated unit tests
This commit is contained in:
54
LibreNMS/Snmptrap/Handlers/JnxBgpM2BackwardTransition.php
Normal file
54
LibreNMS/Snmptrap/Handlers/JnxBgpM2BackwardTransition.php
Normal file
@@ -0,0 +1,54 @@
|
||||
<?php
|
||||
/**
|
||||
* JnxBgpM2BackwardTransition.php
|
||||
*
|
||||
* -Description-
|
||||
*
|
||||
* 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/>.
|
||||
*
|
||||
* The BGPBackwardTransition Event is generated
|
||||
* when the BGP FSM moves from a higher numbered
|
||||
* state to a lower numbered state.
|
||||
*
|
||||
* @package LibreNMS
|
||||
* @link http://librenms.org
|
||||
* @copyright 2018 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 LibreNMS\Util\IP;
|
||||
use Log;
|
||||
|
||||
class JnxBgpM2BackwardTransition 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)
|
||||
{
|
||||
$peerState = $trap->getOidData($trap->findOid('BGP4-V2-MIB-JUNIPER::jnxBgpM2PeerState'));
|
||||
$peerAddr = IP::fromHexString($trap->getOidData($trap->findOid('BGP4-V2-MIB-JUNIPER::jnxBgpM2PeerRemoteAddr.')));
|
||||
Log::event("BGP Peer $peerAddr is now in the $peerState state", $device->device_id, 'trap', 3);
|
||||
}
|
||||
}
|
51
LibreNMS/Snmptrap/Handlers/JnxBgpM2Established.php
Normal file
51
LibreNMS/Snmptrap/Handlers/JnxBgpM2Established.php
Normal file
@@ -0,0 +1,51 @@
|
||||
<?php
|
||||
/**
|
||||
* JnxBgpM2Established.php
|
||||
*
|
||||
* -Description-
|
||||
*
|
||||
* 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 2018 KanREN, Inc.
|
||||
* @author Neil Kahle <nkahle@kanren.net>
|
||||
*/
|
||||
|
||||
namespace LibreNMS\Snmptrap\Handlers;
|
||||
|
||||
use App\Models\Device;
|
||||
use LibreNMS\Interfaces\SnmptrapHandler;
|
||||
use LibreNMS\Snmptrap\Trap;
|
||||
use LibreNMS\Util\IP;
|
||||
use Log;
|
||||
|
||||
class JnxBgpM2Established 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)
|
||||
{
|
||||
|
||||
$peerState = $trap->getOidData($trap->findOid('BGP4-V2-MIB-JUNIPER::jnxBgpM2PeerState'));
|
||||
$peerAddr = IP::fromHexString($trap->getOidData($trap->findOid('BGP4-V2-MIB-JUNIPER::jnxBgpM2PeerRemoteAddr.')));
|
||||
Log::event("BGP Peer $peerAddr is now in the $peerState state", $device->device_id, 'trap', 1);
|
||||
}
|
||||
}
|
59
LibreNMS/Snmptrap/Handlers/JnxCmCfgChange.php
Normal file
59
LibreNMS/Snmptrap/Handlers/JnxCmCfgChange.php
Normal file
@@ -0,0 +1,59 @@
|
||||
<?php
|
||||
/**
|
||||
* jnxCmCfgChange.php
|
||||
*
|
||||
* -Description-
|
||||
*
|
||||
* 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/>.
|
||||
*
|
||||
* Juniper configuration change trap. Includes interface used to affect
|
||||
* the change, the user, and the system time when the change was made.
|
||||
* If a commit confirmed is rolled back the source is "other" and the
|
||||
* user is "root".
|
||||
*
|
||||
* @package LibreNMS
|
||||
* @link http://librenms.org
|
||||
* @copyright 2018 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 JnxCmCfgChange 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)
|
||||
{
|
||||
$source = $trap->getOidData($trap->findOid('JUNIPER-CFGMGMT-MIB::jnxCmCfgChgEventSource'));
|
||||
$user = $trap->getOidData($trap->findOid('JUNIPER-CFGMGMT-MIB::jnxCmCfgChgEventUser'));
|
||||
$changeTime = $trap->getOidData($trap->findOid('JUNIPER-CFGMGMT-MIB::jnxCmCfgChgEventDate'));
|
||||
if ($source=='other' && $user=='root') {
|
||||
Log::event("Config rolled back at $changeTime", $device->device_id, 'trap', 2);
|
||||
} else {
|
||||
Log::event("Config modified by $user from $source at $changeTime", $device->device_id, 'trap', 2);
|
||||
}
|
||||
}
|
||||
}
|
51
LibreNMS/Snmptrap/Handlers/JnxDomAlarmCleared.php
Normal file
51
LibreNMS/Snmptrap/Handlers/JnxDomAlarmCleared.php
Normal file
@@ -0,0 +1,51 @@
|
||||
<?php
|
||||
/**
|
||||
* JnxDomAlarmCleared.php
|
||||
*
|
||||
* -Description-
|
||||
*
|
||||
* 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 2018 KanREN, Inc.
|
||||
* @author Neil Kahle <nkahle@kanren.net>
|
||||
*/
|
||||
|
||||
namespace LibreNMS\Snmptrap\Handlers;
|
||||
|
||||
use App\Models\Device;
|
||||
use LibreNMS\Interfaces\SnmptrapHandler;
|
||||
use LibreNMS\Snmptrap\Trap;
|
||||
use LibreNMS\Snmptrap\Handlers\JnxDomAlarmId;
|
||||
use Log;
|
||||
|
||||
class JnxDomAlarmCleared 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)
|
||||
{
|
||||
$currentAlarm = $trap->getOidData($trap->findOid('JUNIPER-DOM-MIB::jnxDomCurrentAlarms'));
|
||||
$ifDescr = $trap->getOidData($trap->findOid('IF-MIB::ifDescr'));
|
||||
$alarmList = JnxDomAlarmId::getAlarms($currentAlarm);
|
||||
Log::event("DOM alarm cleared for interface $ifDescr. Cleared alarm(s): $alarmList", $device->device_id, 'trap', 1);
|
||||
}
|
||||
}
|
78
LibreNMS/Snmptrap/Handlers/JnxDomAlarmId.php
Normal file
78
LibreNMS/Snmptrap/Handlers/JnxDomAlarmId.php
Normal file
@@ -0,0 +1,78 @@
|
||||
<?php
|
||||
/**
|
||||
* JnxDomAlarmId.php
|
||||
*
|
||||
* -Description-
|
||||
*
|
||||
* 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/>.
|
||||
*
|
||||
*
|
||||
* Used covert alarm ID in the JnxDomAlarm traps from Hex to a
|
||||
* descriptive string.
|
||||
|
||||
* @package LibreNMS
|
||||
* @link http://librenms.org
|
||||
* @copyright 2019 KanREN, Inc
|
||||
* @author Heath Barnhart <hbarnhart@kanren.net>
|
||||
*/
|
||||
|
||||
namespace LibreNMS\Snmptrap\Handlers;
|
||||
|
||||
class JnxDomAlarmId
|
||||
{
|
||||
public static function getAlarms($currentAlarm)
|
||||
{
|
||||
$alarmBin = preg_split(
|
||||
"//",
|
||||
sprintf("%024s", decbin(hexdec(str_replace(" ", "", $currentAlarm)))),
|
||||
-1,
|
||||
PREG_SPLIT_NO_EMPTY
|
||||
);
|
||||
|
||||
$alarmDescr = [
|
||||
'input loss of signal',
|
||||
'input loss of lock',
|
||||
'input rx path not ready',
|
||||
'input laser power high',
|
||||
'input laser power low',
|
||||
'output laser bias current high',
|
||||
'output laser bias current low',
|
||||
'output laser power high',
|
||||
'output laser power low',
|
||||
'output data not ready',
|
||||
'output tx path not ready',
|
||||
'output laser fault',
|
||||
'output loss of lock',
|
||||
'module temperature high',
|
||||
'module temperature low',
|
||||
'module not ready',
|
||||
'module power down',
|
||||
'wire unplugged or down',
|
||||
'module unplugged or down',
|
||||
'module voltage high',
|
||||
'module voltage low',
|
||||
];
|
||||
|
||||
$index = 0;
|
||||
$descr = [];
|
||||
foreach ($alarmBin as $syntax) {
|
||||
if ($syntax == "1") {
|
||||
$descr[$index] = $alarmDescr[$index];
|
||||
}
|
||||
$index++;
|
||||
}
|
||||
$message = implode(', ', $descr);
|
||||
return $message;
|
||||
}
|
||||
}
|
51
LibreNMS/Snmptrap/Handlers/JnxDomAlarmSet.php
Normal file
51
LibreNMS/Snmptrap/Handlers/JnxDomAlarmSet.php
Normal file
@@ -0,0 +1,51 @@
|
||||
<?php
|
||||
/**
|
||||
* JnxDomAlarmSet.php
|
||||
*
|
||||
* -Description-
|
||||
*
|
||||
* 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 2018 KanREN, Inc.
|
||||
* @author Neil Kahle <nkahle@kanren.net>
|
||||
*/
|
||||
|
||||
namespace LibreNMS\Snmptrap\Handlers;
|
||||
|
||||
use App\Models\Device;
|
||||
use LibreNMS\Interfaces\SnmptrapHandler;
|
||||
use LibreNMS\Snmptrap\Trap;
|
||||
use LibreNMS\Snmptrap\Handlers\JnxDomAlarmId;
|
||||
use Log;
|
||||
|
||||
class JnxDomAlarmSet 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)
|
||||
{
|
||||
$currentAlarm = $trap->getOidData($trap->findOid('JUNIPER-DOM-MIB::jnxDomCurrentAlarms'));
|
||||
$ifDescr = $trap->getOidData($trap->findOid('IF-MIB::ifDescr'));
|
||||
$alarmList = JnxDomAlarmId::getAlarms($currentAlarm);
|
||||
Log::event("DOM alarm set for interface $ifDescr. Current alarm(s): $alarmList", $device->device_id, 'trap', 5);
|
||||
}
|
||||
}
|
61
LibreNMS/Snmptrap/Handlers/JnxDomLaneAlarmCleared.php
Normal file
61
LibreNMS/Snmptrap/Handlers/JnxDomLaneAlarmCleared.php
Normal file
@@ -0,0 +1,61 @@
|
||||
<?php
|
||||
/**
|
||||
* JnxDomLaneAlarmCleared.php
|
||||
*
|
||||
* -Description-
|
||||
*
|
||||
* 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/>.
|
||||
*
|
||||
* Trap sent when a Juniper transciever lambda reaches an alert level threshold.
|
||||
*
|
||||
* @package LibreNMS
|
||||
* @link http://librenms.org
|
||||
* @copyright 2018 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 LibreNMS\Snmptrap\Handlers\JnxDomLaneAlarmId;
|
||||
use Log;
|
||||
|
||||
class JnxDomLaneAlarmCleared 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)
|
||||
{
|
||||
$currentAlarm = $trap->getOidData($trap->findOid('JUNIPER-DOM-MIB::jnxDomCurrentLaneAlarms'));
|
||||
$lane = $trap->getOidData($trap->findOid('JUNIPER-DOM-MIB::jnxDomLaneIndex'));
|
||||
$alarmList = JnxDomLaneAlarmId::getLaneAlarms($currentAlarm);
|
||||
|
||||
$ifIndex = substr(strrchr($trap->findOid('IF-MIB::ifDescr'), '.'), 1);
|
||||
$port = $device->ports()->where('ifIndex', $ifIndex)->first();
|
||||
if (!$port) {
|
||||
Log::warning("Snmptrap JnxDomLaneAlarmCleared: Could not find port at ifIndex $port->ifIndex for device: " . $device->hostname);
|
||||
return;
|
||||
}
|
||||
|
||||
Log::event("DOM lane alarm cleared on interface $port->ifDescr lane $lane. Current alarm(s): $alarmList", $device->device_id, 'trap', 1);
|
||||
}
|
||||
}
|
65
LibreNMS/Snmptrap/Handlers/JnxDomLaneAlarmId.php
Normal file
65
LibreNMS/Snmptrap/Handlers/JnxDomLaneAlarmId.php
Normal file
@@ -0,0 +1,65 @@
|
||||
<?php
|
||||
/**
|
||||
* JnxLaneDomAlarmId.php
|
||||
*
|
||||
* -Description-
|
||||
*
|
||||
* 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/>.
|
||||
*
|
||||
*
|
||||
* Used covert alarm ID in the JnxDomLaneAlarm traps from Hex to a
|
||||
* descriptive string.
|
||||
|
||||
* @package LibreNMS
|
||||
* @link http://librenms.org
|
||||
* @copyright 2019 KanREN, Inc
|
||||
* @author Heath Barnhart <hbarnhart@kanren.net>
|
||||
*/
|
||||
|
||||
namespace LibreNMS\Snmptrap\Handlers;
|
||||
|
||||
class JnxDomLaneAlarmId
|
||||
{
|
||||
public static function getLaneAlarms($currentAlarm)
|
||||
{
|
||||
$alarmBin = preg_split(
|
||||
"//",
|
||||
sprintf("%024s", decbin(hexdec(str_replace(" ", "", $currentAlarm)))),
|
||||
-1,
|
||||
PREG_SPLIT_NO_EMPTY
|
||||
);
|
||||
|
||||
$alarmDescr = [
|
||||
'input signal high',
|
||||
'input signal low',
|
||||
'output bias high',
|
||||
'output bias low',
|
||||
'output signal high',
|
||||
'output signal low',
|
||||
'lane laser temp high',
|
||||
'lane laster temp low',
|
||||
];
|
||||
|
||||
$descr = [];
|
||||
$index = 0;
|
||||
foreach ($alarmBin as $syntax) {
|
||||
if ($syntax == "1") {
|
||||
$descr[$index] = $alarmDescr[$index];
|
||||
}
|
||||
$index++;
|
||||
}
|
||||
$message = implode(', ', $descr);
|
||||
return $message;
|
||||
}
|
||||
}
|
59
LibreNMS/Snmptrap/Handlers/JnxDomLaneAlarmSet.php
Normal file
59
LibreNMS/Snmptrap/Handlers/JnxDomLaneAlarmSet.php
Normal file
@@ -0,0 +1,59 @@
|
||||
<?php
|
||||
/**
|
||||
* JnxDomLaneAlarmSet.php
|
||||
*
|
||||
* -Description-
|
||||
*
|
||||
* 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 2018 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 LibreNMS\Snmptrap\Handlers\JnxDomLaneAlarmId;
|
||||
use Log;
|
||||
|
||||
class JnxDomLaneAlarmSet 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)
|
||||
{
|
||||
$currentAlarm = $trap->getOidData($trap->findOid('JUNIPER-DOM-MIB::jnxDomCurrentLaneAlarms'));
|
||||
$lane = $trap->getOidData($trap->findOid('JUNIPER-DOM-MIB::jnxDomLaneIndex'));
|
||||
$alarmList = JnxDomLaneAlarmId::getLaneAlarms($currentAlarm);
|
||||
|
||||
$ifIndex = substr(strrchr($trap->findOid('IF-MIB::ifDescr'), '.'), 1);
|
||||
$port = $device->ports()->where('ifIndex', $ifIndex)->first();
|
||||
if (!$port) {
|
||||
Log::warning("Snmptrap JnxDomLaneAlarmSet: Could not find port at ifIndex $port->ifIndex for device: " . $device->hostname);
|
||||
return;
|
||||
}
|
||||
|
||||
Log::event("DOM lane alarm on interface $port->ifDescr lane $lane. Current alarm(s): $alarmList", $device->device_id, 'trap', 5);
|
||||
}
|
||||
}
|
52
LibreNMS/Snmptrap/Handlers/JnxLdpLspDown.php
Normal file
52
LibreNMS/Snmptrap/Handlers/JnxLdpLspDown.php
Normal file
@@ -0,0 +1,52 @@
|
||||
<?php
|
||||
/**
|
||||
* JnxLdpLspDown.php
|
||||
*
|
||||
* -Description-
|
||||
*
|
||||
* 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 2018 KanREN, Inc.
|
||||
* @author Neil Kahle <nkahle@kanren.net>
|
||||
*/
|
||||
|
||||
namespace LibreNMS\Snmptrap\Handlers;
|
||||
|
||||
use App\Models\Device;
|
||||
use LibreNMS\Interfaces\SnmptrapHandler;
|
||||
use LibreNMS\Snmptrap\Trap;
|
||||
use Log;
|
||||
|
||||
class JnxLdpLspDown 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)
|
||||
{
|
||||
$lspForward = $trap->getOidData($trap->findOid('JUNIPER-LDP-MIB::jnxLdpLspFec'));
|
||||
$routerID = $trap->getOidData($trap->findOid('JUNIPER-LDP-MIB::jnxLdpRtrid'));
|
||||
$reason = $trap->getOidData($trap->findOid('JUNIPER-LDP-MIB::jnxLdpLspDownReason'));
|
||||
$instanceName = $trap->getOidData($trap->findOid('JUNIPER-LDP-MIB::jnxLdpInstanceName'));
|
||||
|
||||
Log::event("LDP session $instanceName from $routerID to $lspForward has gone down due to $reason", $device->device_id, 'trap', 4);
|
||||
}
|
||||
}
|
51
LibreNMS/Snmptrap/Handlers/JnxLdpLspUp.php
Normal file
51
LibreNMS/Snmptrap/Handlers/JnxLdpLspUp.php
Normal file
@@ -0,0 +1,51 @@
|
||||
<?php
|
||||
/**
|
||||
* JnxLdpLspUp.php
|
||||
*
|
||||
* -Description-
|
||||
*
|
||||
* 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 2018 KanREN, Inc.
|
||||
* @author Neil Kahle <nkahle@kanren.net>
|
||||
*/
|
||||
|
||||
namespace LibreNMS\Snmptrap\Handlers;
|
||||
|
||||
use App\Models\Device;
|
||||
use LibreNMS\Interfaces\SnmptrapHandler;
|
||||
use LibreNMS\Snmptrap\Trap;
|
||||
use Log;
|
||||
|
||||
class JnxLdpLspUp 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)
|
||||
{
|
||||
$lspForward = $trap->getOidData($trap->findOid('JUNIPER-LDP-MIB::jnxLdpLspFec'));
|
||||
$routerID = $trap->getOidData($trap->findOid('JUNIPER-LDP-MIB::jnxLdpRtrid'));
|
||||
$instanceName = $trap->getOidData($trap->findOid('JUNIPER-LDP-MIB::jnxLdpInstanceName'));
|
||||
|
||||
Log::event("LDP session $instanceName from $routerID to $lspForward is now up.", $device->device_id, 'trap', 1);
|
||||
}
|
||||
}
|
58
LibreNMS/Snmptrap/Handlers/JnxLdpSesDown.php
Normal file
58
LibreNMS/Snmptrap/Handlers/JnxLdpSesDown.php
Normal file
@@ -0,0 +1,58 @@
|
||||
<?php
|
||||
/**
|
||||
* JnxLdpSesDown.php
|
||||
*
|
||||
* -Description-
|
||||
*
|
||||
* 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 2018 KanREN, Inc.
|
||||
* @author Neil Kahle <nkahle@kanren.net>
|
||||
*/
|
||||
|
||||
namespace LibreNMS\Snmptrap\Handlers;
|
||||
|
||||
use App\Models\Device;
|
||||
use LibreNMS\Interfaces\SnmptrapHandler;
|
||||
use LibreNMS\Snmptrap\Trap;
|
||||
use Log;
|
||||
|
||||
class JnxLdpSesDown 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)
|
||||
{
|
||||
|
||||
$state = $trap->getOidData($trap->findOid('JUNIPER-MPLS-LDP-MIB::jnxMplsLdpSesState'));
|
||||
$reason = $trap->getOidData($trap->findOid('JUNIPER-LDP-MIB::jnxLdpSesDownReason'));
|
||||
$ifIndex = $trap->getOidData($trap->findOid('JUNIPER-LDP-MIB::jnxLdpSesDownIf'));
|
||||
$port = $device->ports()->where('ifIndex', $ifIndex)->first();
|
||||
|
||||
if (!$port) {
|
||||
Log::warning("Snmptrap LdpSesDown: Could not find port at ifIndex $port->ifIndex for device: " . $device->hostname);
|
||||
return;
|
||||
}
|
||||
|
||||
Log::event("LDP session on interface $port->ifDescr is $state due to $reason", $device->device_id, 'trap', 4);
|
||||
}
|
||||
}
|
57
LibreNMS/Snmptrap/Handlers/JnxLdpSesUp.php
Normal file
57
LibreNMS/Snmptrap/Handlers/JnxLdpSesUp.php
Normal file
@@ -0,0 +1,57 @@
|
||||
<?php
|
||||
/**
|
||||
* JnxLdpSesUp.php
|
||||
*
|
||||
* -Description-
|
||||
*
|
||||
* 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 2018 KanREN, Inc.
|
||||
* @author Neil Kahle <nkahle@kanren.net>
|
||||
*/
|
||||
|
||||
namespace LibreNMS\Snmptrap\Handlers;
|
||||
|
||||
use App\Models\Device;
|
||||
use LibreNMS\Interfaces\SnmptrapHandler;
|
||||
use LibreNMS\Snmptrap\Trap;
|
||||
use Log;
|
||||
|
||||
class JnxLdpSesUp 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)
|
||||
{
|
||||
|
||||
$state = $trap->getOidData($trap->findOid('JUNIPER-MPLS-LDP-MIB::jnxMplsLdpSesState'));
|
||||
$ifIndex = $trap->getOidData($trap->findOid('JUNIPER-LDP-MIB::jnxLdpSesUpIf'));
|
||||
$port = $device->ports()->where('ifIndex', $ifIndex)->first();
|
||||
|
||||
if (!$port) {
|
||||
Log::warning("Snmptrap LdpSesUp: Could not find port at ifIndex $ifIndex for device: " . $device->hostname);
|
||||
return;
|
||||
}
|
||||
|
||||
Log::event("LDP session on interface $port->ifDescr is $state", $device->device_id, 'trap', 1);
|
||||
}
|
||||
}
|
51
LibreNMS/Snmptrap/Handlers/JnxVpnIfDown.php
Normal file
51
LibreNMS/Snmptrap/Handlers/JnxVpnIfDown.php
Normal file
@@ -0,0 +1,51 @@
|
||||
<?php
|
||||
/**
|
||||
* JnxVpnIfDown.php
|
||||
*
|
||||
* -Description-
|
||||
*
|
||||
* 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 2018 KanREN, Inc.
|
||||
* @author Neil Kahle <nkahle@kanren.net>
|
||||
*/
|
||||
|
||||
namespace LibreNMS\Snmptrap\Handlers;
|
||||
|
||||
use App\Models\Device;
|
||||
use LibreNMS\Interfaces\SnmptrapHandler;
|
||||
use LibreNMS\Snmptrap\Trap;
|
||||
use Log;
|
||||
|
||||
class JnxVpnIfDown 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)
|
||||
{
|
||||
|
||||
$vpnType = $trap->getOidData($trap->findOid('JUNIPER-VPN-MIB::jnxVpnIfVpnType'));
|
||||
$vpnName = $trap->getOidData($trap->findOid('JUNIPER-VPN-MIB::jnxVpnIfVpnName'));
|
||||
|
||||
Log::event("$vpnType on interface $vpnName has gone down", $device->device_id, 'trap', 4);
|
||||
}
|
||||
}
|
55
LibreNMS/Snmptrap/Handlers/JnxVpnIfUp.php
Normal file
55
LibreNMS/Snmptrap/Handlers/JnxVpnIfUp.php
Normal file
@@ -0,0 +1,55 @@
|
||||
<?php
|
||||
/**
|
||||
* JnxVpnIfUp.php
|
||||
*
|
||||
* -Description-
|
||||
*
|
||||
* 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 2018 KanREN, Inc.
|
||||
* @author Neil Kahle <nkahle@kanren.net>
|
||||
*/
|
||||
|
||||
namespace LibreNMS\Snmptrap\Handlers;
|
||||
|
||||
use App\Models\Device;
|
||||
use LibreNMS\Interfaces\SnmptrapHandler;
|
||||
use LibreNMS\Snmptrap\Trap;
|
||||
use Log;
|
||||
|
||||
class JnxVpnIfUp 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)
|
||||
{
|
||||
$vpnType = $trap->getOidData($trap->findOid('JUNIPER-VPN-MIB::jnxVpnIfVpnType'));
|
||||
$vpnName = $trap->getOidData($trap->findOid('JUNIPER-VPN-MIB::jnxVpnIfVpnName'));
|
||||
|
||||
if (substr($vpnName, 0, 6) === "vt/lsi") {
|
||||
$vpnDevice = substr($vpnName, 7, 15);
|
||||
Log::event("$vpnType to device $vpnDevice is now connected", $device->device_id, 'trap', 1);
|
||||
} else {
|
||||
Log::event("$vpnType on interface $vpnName is now connected", $device->device_id, 'trap', 1);
|
||||
}
|
||||
}
|
||||
}
|
51
LibreNMS/Snmptrap/Handlers/JnxVpnPwDown.php
Normal file
51
LibreNMS/Snmptrap/Handlers/JnxVpnPwDown.php
Normal file
@@ -0,0 +1,51 @@
|
||||
<?php
|
||||
/**
|
||||
* JnxVpnPwDown.php
|
||||
*
|
||||
* -Description-
|
||||
*
|
||||
* 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 2018 KanREN, Inc.
|
||||
* @author Neil Kahle <nkahle@kanren.net>
|
||||
*/
|
||||
|
||||
namespace LibreNMS\Snmptrap\Handlers;
|
||||
|
||||
use App\Models\Device;
|
||||
use LibreNMS\Interfaces\SnmptrapHandler;
|
||||
use LibreNMS\Snmptrap\Trap;
|
||||
use Log;
|
||||
|
||||
class JnxVpnPwDown 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)
|
||||
{
|
||||
|
||||
$vpnType = $trap->getOidData($trap->findOid('JUNIPER-VPN-MIB::jnxVpnPwVpnType'));
|
||||
$vpnName = $trap->getOidData($trap->findOid('JUNIPER-VPN-MIB::jnxVpnPwVpnName'));
|
||||
|
||||
Log::event("$vpnType on a pseudowire belonging to $vpnName has gone down", $device->device_id, 'trap', 4);
|
||||
}
|
||||
}
|
50
LibreNMS/Snmptrap/Handlers/JnxVpnPwUp.php
Normal file
50
LibreNMS/Snmptrap/Handlers/JnxVpnPwUp.php
Normal file
@@ -0,0 +1,50 @@
|
||||
<?php
|
||||
/**
|
||||
* JnxVpnPwUp.php
|
||||
*
|
||||
* -Description-
|
||||
*
|
||||
* 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 2018 KanREN, Inc.
|
||||
* @author Neil Kahle <nkahle@kanren.net>
|
||||
*/
|
||||
|
||||
namespace LibreNMS\Snmptrap\Handlers;
|
||||
|
||||
use App\Models\Device;
|
||||
use LibreNMS\Interfaces\SnmptrapHandler;
|
||||
use LibreNMS\Snmptrap\Trap;
|
||||
use Log;
|
||||
|
||||
class JnxVpnPwUp 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)
|
||||
{
|
||||
$vpnType = $trap->getOidData($trap->findOid('JUNIPER-VPN-MIB::jnxVpnPwVpnType'));
|
||||
$vpnName = $trap->getOidData($trap->findOid('JUNIPER-VPN-MIB::jnxVpnPwVpnName'));
|
||||
|
||||
Log::event("$vpnType on a pseudowire belonging to $vpnName is now connected", $device->device_id, 'trap', 1);
|
||||
}
|
||||
}
|
@@ -10,38 +10,53 @@
|
||||
|
||||
return [
|
||||
'trap_handlers' => [
|
||||
'SNMPv2-MIB::authenticationFailure' => \LibreNMS\Snmptrap\Handlers\AuthenticationFailure::class,
|
||||
'BGP4-MIB::bgpEstablished' => \LibreNMS\Snmptrap\Handlers\BgpEstablished::class,
|
||||
'BGP4-MIB::bgpBackwardTransition' => \LibreNMS\Snmptrap\Handlers\BgpBackwardTransition::class,
|
||||
'IF-MIB::linkUp' => \LibreNMS\Snmptrap\Handlers\LinkUp::class,
|
||||
'IF-MIB::linkDown' => \LibreNMS\Snmptrap\Handlers\LinkDown::class,
|
||||
'MG-SNMP-UPS-MIB::upsmgUtilityFailure' => \LibreNMS\Snmptrap\Handlers\UpsmgUtilityFailure::class,
|
||||
'MG-SNMP-UPS-MIB::upsmgUtilityRestored' => \LibreNMS\Snmptrap\Handlers\UpsmgUtilityRestored::class,
|
||||
'EQUIPMENT-MIB::equipStatusTrap' => \LibreNMS\Snmptrap\Handlers\EquipStatusTrap::class,
|
||||
'LOG-MIB::logTrap' => \LibreNMS\Snmptrap\Handlers\LogTrap::class,
|
||||
'CM-SYSTEM-MIB::cmObjectCreationTrap' => \LibreNMS\Snmptrap\Handlers\AdvaObjectCreation::class,
|
||||
'CM-SYSTEM-MIB::cmObjectDeletionTrap' => \LibreNMS\Snmptrap\Handlers\AdvaObjectDeletion::class,
|
||||
'CM-SYSTEM-MIB::cmStateChangeTrap' => \LibreNMS\Snmptrap\Handlers\AdvaStateChangeTrap::class,
|
||||
'CM-PERFORMANCE-MIB::cmEthernetAccPortThresholdCrossingAlert' => \LibreNMS\Snmptrap\Handlers\AdvaAccThresholdCrossingAlert::class,
|
||||
'CM-PERFORMANCE-MIB::cmEthernetNetPortThresholdCrossingAlert' => \LibreNMS\Snmptrap\Handlers\AdvaNetThresholdCrossingAlert::class,
|
||||
'BGP4-MIB::bgpEstablished' => \LibreNMS\Snmptrap\Handlers\BgpEstablished::class,
|
||||
'BGP4-V2-MIB-JUNIPER::jnxBgpM2BackwardTransition' => \LibreNMS\Snmptrap\Handlers\JnxBgpM2BackwardTransition::class,
|
||||
'BGP4-V2-MIB-JUNIPER::jnxBgpM2Established' => \LibreNMS\Snmptrap\Handlers\JnxBgpM2Established::class,
|
||||
'CM-ALARM-MIB::cmNetworkElementAlmTrap' => \LibreNMS\Snmptrap\Handlers\AdvaNetworkElementAlmTrap::class,
|
||||
'CM-ALARM-MIB::cmSysAlmTrap' => \LibreNMS\Snmptrap\Handlers\AdvaSysAlmTrap::class,
|
||||
'CM-SYSTEM-MIB::cmSnmpDyingGaspTrap' => \LibreNMS\Snmptrap\Handlers\AdvaSnmpDyingGaspTrap::class,
|
||||
'CM-PERFORMANCE-MIB::cmEthernetAccPortThresholdCrossingAlert' => \LibreNMS\Snmptrap\Handlers\AdvaAccThresholdCrossingAlert::class,
|
||||
'CM-PERFORMANCE-MIB::cmEthernetNetPortThresholdCrossingAlert' => \LibreNMS\Snmptrap\Handlers\AdvaNetThresholdCrossingAlert::class,
|
||||
'CM-SYSTEM-MIB::cmAttributeValueChangeTrap' => \LibreNMS\Snmptrap\Handlers\AdvaAttributeChange::class,
|
||||
'CM-SYSTEM-MIB::cmObjectCreationTrap' => \LibreNMS\Snmptrap\Handlers\AdvaObjectCreation::class,
|
||||
'CM-SYSTEM-MIB::cmObjectDeletionTrap' => \LibreNMS\Snmptrap\Handlers\AdvaObjectDeletion::class,
|
||||
'CM-SYSTEM-MIB::cmSnmpDyingGaspTrap' => \LibreNMS\Snmptrap\Handlers\AdvaSnmpDyingGaspTrap::class,
|
||||
'CM-SYSTEM-MIB::cmStateChangeTrap' => \LibreNMS\Snmptrap\Handlers\AdvaStateChangeTrap::class,
|
||||
'ENTITY-MIB::entConfigChange' => \LibreNMS\Snmptrap\Handlers\AdvaConfigChange::class,
|
||||
'EQUIPMENT-MIB::equipStatusTrap' => \LibreNMS\Snmptrap\Handlers\EquipStatusTrap::class,
|
||||
'FORTINET-CORE-MIB::fnTrapMemThreshold' => \LibreNMS\Snmptrap\Handlers\FnTrapMemThreshold::class,
|
||||
'FORTINET-FORTIGATE-MIB::fgTrapAvOversize' => \LibreNMS\Snmptrap\Handlers\FgTrapAvOversize::class,
|
||||
'FORTINET-FORTIGATE-MIB::fgTrapIpsAnomaly' => \LibreNMS\Snmptrap\Handlers\FgTrapIpsAnomaly::class,
|
||||
'FORTINET-FORTIGATE-MIB::fgTrapIpsPkgUpdate' => \LibreNMS\Snmptrap\Handlers\FgTrapIpsPkgUpdate::class,
|
||||
'FORTINET-FORTIGATE-MIB::fgTrapIpsSignature' => \LibreNMS\Snmptrap\Handlers\FgTrapIpsSignature::class,
|
||||
'FORTINET-FORTIGATE-MIB::fgTrapVpnTunDown' => \LibreNMS\Snmptrap\Handlers\FgTrapVpnTunDown::class,
|
||||
'FORTINET-FORTIGATE-MIB::fgTrapVpnTunUp' => \LibreNMS\Snmptrap\Handlers\FgTrapVpnTunUp::class,
|
||||
'FORTINET-FORTIGATE-MIB::fgTrapIpsSignature' => \LibreNMS\Snmptrap\Handlers\FgTrapIpsSignature::class,
|
||||
'FORTINET-FORTIGATE-MIB::fgTrapIpsAnomaly' => \LibreNMS\Snmptrap\Handlers\FgTrapIpsAnomaly::class,
|
||||
'FORTINET-FORTIGATE-MIB::fgTrapAvOversize' => \LibreNMS\Snmptrap\Handlers\FgTrapAvOversize::class,
|
||||
'FORTINET-FORTIGATE-MIB::fgTrapIpsPkgUpdate' => \LibreNMS\Snmptrap\Handlers\FgTrapIpsPkgUpdate::class,
|
||||
'FORTINET-CORE-MIB::fnTrapMemThreshold' => \LibreNMS\Snmptrap\Handlers\FnTrapMemThreshold::class,
|
||||
'FORTINET-FORTIMANAGER-FORTIANALYZER-MIB::fmTrapLogRateThreshold' => \LibreNMS\Snmptrap\Handlers\FmTrapLogRateThreshold::class,
|
||||
'FORTINET-FORTIMANAGER-FORTIANALYZER-MIB::fmTrapLogAlert' => \LibreNMS\Snmptrap\Handlers\FmTrapLogAlert::class,
|
||||
'NETGEAR-SWITCHING-MIB::failedUserLoginTrap' => \LibreNMS\Snmptrap\Handlers\FailedUserLogin::class,
|
||||
'FORTINET-FORTIMANAGER-FORTIANALYZER-MIB::fmTrapLogRateThreshold' => \LibreNMS\Snmptrap\Handlers\FmTrapLogRateThreshold::class,
|
||||
'IF-MIB::linkDown' => \LibreNMS\Snmptrap\Handlers\LinkDown::class,
|
||||
'IF-MIB::linkUp' => \LibreNMS\Snmptrap\Handlers\LinkUp::class,
|
||||
'JUNIPER-CFGMGMT-MIB::jnxCmCfgChange' => \LibreNMS\Snmptrap\Handlers\JnxCmCfgChange::class,
|
||||
'JUNIPER-DOM-MIB::jnxDomAlarmCleared' => \LibreNMS\Snmptrap\Handlers\JnxDomAlarmCleared::class,
|
||||
'JUNIPER-DOM-MIB::jnxDomAlarmSet' => \LibreNMS\Snmptrap\Handlers\JnxDomAlarmSet::class,
|
||||
'JUNIPER-DOM-MIB::jnxDomLaneAlarmCleared' => \LibreNMS\Snmptrap\Handlers\JnxDomLaneAlarmCleared::class,
|
||||
'JUNIPER-DOM-MIB::jnxDomLaneAlarmSet' => \LibreNMS\Snmptrap\Handlers\JnxDomLaneAlarmSet::class,
|
||||
'JUNIPER-LDP-MIB::jnxLdpLspDown' => \LibreNMS\Snmptrap\Handlers\JnxLdpLspDown::class,
|
||||
'JUNIPER-LDP-MIB::jnxLdpLspUp' => \LibreNMS\Snmptrap\Handlers\JnxLdpLspUp::class,
|
||||
'JUNIPER-LDP-MIB::jnxLdpSesDown' => \LibreNMS\Snmptrap\Handlers\JnxLdpSesDown::class,
|
||||
'JUNIPER-LDP-MIB::jnxLdpSesUp' => \LibreNMS\Snmptrap\Handlers\JnxLdpSesUp::class,
|
||||
'JUNIPER-VPN-MIB::jnxVpnIfDown' => \LibreNMS\Snmptrap\Handlers\JnxVpnIfDown::class,
|
||||
'JUNIPER-VPN-MIB::jnxVpnIfUp' => \LibreNMS\Snmptrap\Handlers\JnxVpnIfUp::class,
|
||||
'JUNIPER-VPN-MIB::jnxVpnPwDown' => \LibreNMS\Snmptrap\Handlers\JnxVpnPwDown::class,
|
||||
'JUNIPER-VPN-MIB::jnxVpnPwUp' => \LibreNMS\Snmptrap\Handlers\JnxVpnPwUp::class,
|
||||
'LOG-MIB::logTrap' => \LibreNMS\Snmptrap\Handlers\LogTrap::class,
|
||||
'MG-SNMP-UPS-MIB::upsmgUtilityFailure' => \LibreNMS\Snmptrap\Handlers\UpsmgUtilityFailure::class,
|
||||
'MG-SNMP-UPS-MIB::upsmgUtilityRestored' => \LibreNMS\Snmptrap\Handlers\UpsmgUtilityRestored::class,
|
||||
'NETGEAR-SMART-SWITCHING-MIB::failedUserLoginTrap' => \LibreNMS\Snmptrap\Handlers\FailedUserLogin::class,
|
||||
'PowerNet-MIB::outletOn' => \LibreNMS\Snmptrap\Handlers\ApcPduOutletOn::class,
|
||||
'NETGEAR-SWITCHING-MIB::failedUserLoginTrap' => \LibreNMS\Snmptrap\Handlers\FailedUserLogin::class,
|
||||
'PowerNet-MIB::outletOff' => \LibreNMS\Snmptrap\Handlers\ApcPduOutletOff::class,
|
||||
'PowerNet-MIB::outletOn' => \LibreNMS\Snmptrap\Handlers\ApcPduOutletOn::class,
|
||||
'PowerNet-MIB::outletReboot' => \LibreNMS\Snmptrap\Handlers\ApcPduOutletReboot::class,
|
||||
'SNMPv2-MIB::authenticationFailure' => \LibreNMS\Snmptrap\Handlers\AuthenticationFailure::class,
|
||||
]
|
||||
];
|
||||
|
84
tests/Feature/SnmpTraps/JnxBgpM2Test.php
Normal file
84
tests/Feature/SnmpTraps/JnxBgpM2Test.php
Normal file
@@ -0,0 +1,84 @@
|
||||
<?php
|
||||
/**
|
||||
* JnxBgpM2Test.php
|
||||
* -Description-
|
||||
*
|
||||
* 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 Junipers BGPv4 traps, specificaly jnxBgpM2Established and
|
||||
* jnxBgpM2BackwardTransition
|
||||
*
|
||||
* @package LibreNMS
|
||||
* @link http://librenms.org
|
||||
* @copyright 2019 KanREN, Inc
|
||||
* @author Heath Barnhart <hbarnhart@kanren.net>
|
||||
*/
|
||||
|
||||
namespace LibreNMS\Tests;
|
||||
|
||||
use App\Models\Device;
|
||||
use LibreNMS\Snmptrap\Dispatcher;
|
||||
use LibreNMS\Snmptrap\Trap;
|
||||
use Log;
|
||||
|
||||
class JnxBgpM2Test extends LaravelTestCase
|
||||
{
|
||||
|
||||
public function testBgpBackwardTrasition()
|
||||
{
|
||||
|
||||
$device = factory(Device::class)->create();
|
||||
|
||||
$trapText = "$device->hostname
|
||||
UDP: [$device->ip]:64610->[192.168.5.5]:162
|
||||
DISMAN-EVENT-MIB::sysUpTimeInstance 198:2:10:48.91
|
||||
SNMPv2-MIB::snmpTrapOID.0 BGP4-V2-MIB-JUNIPER::jnxBgpM2BackwardTransition
|
||||
BGP4-V2-MIB-JUNIPER::jnxBgpM2PeerLocalAddrType.0.2.32.1.13.136.0.1.0.0.0.0.0.0.0.0.0.1.2.32.1.13.136.0.1.0.0.0.0.0.0.0.0.0.2 ipv6
|
||||
BGP4-V2-MIB-JUNIPER::jnxBgpM2PeerLocalAddr.0.2.32.1.13.136.0.1.0.0.0.0.0.0.0.0.0.1.2.32.1.13.136.0.1.0.0.0.0.0.0.0.0.0.2 \"20 01 0D 88 00 01 00 00 00 00 00 00 00 00 00 01 \"
|
||||
BGP4-V2-MIB-JUNIPER::jnxBgpM2PeerRemoteAddrType.0.2.32.1.13.136.0.1.0.0.0.0.0.0.0.0.0.1.2.32.1.13.136.0.1.0.0.0.0.0.0.0.0.0.2 ipv6
|
||||
BGP4-V2-MIB-JUNIPER::jnxBgpM2PeerRemoteAddr.0.2.32.1.13.136.0.1.0.0.0.0.0.0.0.0.0.1.2.32.1.13.136.0.1.0.0.0.0.0.0.0.0.0.2 \"20 01 0D 88 00 01 00 00 00 00 00 00 00 00 00 02 \"
|
||||
BGP4-V2-MIB-JUNIPER::jnxBgpM2PeerLastErrorReceived.0.2.32.1.13.136.0.1.0.0.0.0.0.0.0.0.0.1.2.32.1.13.136.0.1.0.0.0.0.0.0.0.0.0.2 \"00 00 \"
|
||||
BGP4-V2-MIB-JUNIPER::jnxBgpM2PeerState.0.2.32.1.13.136.0.1.0.0.0.0.0.0.0.0.0.1.2.32.1.13.136.0.1.0.0.0.0.0.0.0.0.0.2 idle
|
||||
SNMPv2-MIB::snmpTrapEnterprise.0 JUNIPER-CHASSIS-DEFINES-MIB::jnxProductNameSRX240";
|
||||
|
||||
$trap = new Trap($trapText);
|
||||
$message = "BGP Peer 2001:d88:1::2 is now in the idle state";
|
||||
\Log::shouldReceive('event')->once()->with($message, $device->device_id, 'trap', 3);
|
||||
|
||||
$this->assertTrue(Dispatcher::handle($trap), 'Could not handle JnxBgpM2BackwardsTransition trap');
|
||||
}
|
||||
|
||||
public function testBgpEstablished()
|
||||
{
|
||||
$device = factory(Device::class)->create();
|
||||
|
||||
$trapText = "$device->hostname
|
||||
UDP: [$device->ip]:64610->[192.168.5.5]:162
|
||||
DISMAN-EVENT-MIB::sysUpTimeInstance 198:2:10:48.91
|
||||
SNMPv2-MIB::snmpTrapOID.0 BGP4-V2-MIB-JUNIPER::jnxBgpM2Established
|
||||
BGP4-V2-MIB-JUNIPER::jnxBgpM2PeerLocalAddrType.0.2.32.1.13.136.0.1.0.0.0.0.0.0.0.0.0.1.2.32.1.13.136.0.1.0.0.0.0.0.0.0.0.0.2 ipv6
|
||||
BGP4-V2-MIB-JUNIPER::jnxBgpM2PeerLocalAddr.0.2.32.1.13.136.0.1.0.0.0.0.0.0.0.0.0.1.2.32.1.13.136.0.1.0.0.0.0.0.0.0.0.0.2 \"20 01 0D 88 00 01 00 00 00 00 00 00 00 00 00 01 \"
|
||||
BGP4-V2-MIB-JUNIPER::jnxBgpM2PeerRemoteAddrType.0.2.32.1.13.136.0.1.0.0.0.0.0.0.0.0.0.1.2.32.1.13.136.0.1.0.0.0.0.0.0.0.0.0.2 ipv6
|
||||
BGP4-V2-MIB-JUNIPER::jnxBgpM2PeerRemoteAddr.0.2.32.1.13.136.0.1.0.0.0.0.0.0.0.0.0.1.2.32.1.13.136.0.1.0.0.0.0.0.0.0.0.0.2 \"20 01 0D 88 00 01 00 00 00 00 00 00 00 00 00 02 \"
|
||||
BGP4-V2-MIB-JUNIPER::jnxBgpM2PeerLastErrorReceived.0.2.32.1.13.136.0.1.0.0.0.0.0.0.0.0.0.1.2.32.1.13.136.0.1.0.0.0.0.0.0.0.0.0.2 \"00 00 \"
|
||||
BGP4-V2-MIB-JUNIPER::jnxBgpM2PeerState.0.2.32.1.13.136.0.1.0.0.0.0.0.0.0.0.0.1.2.32.1.13.136.0.1.0.0.0.0.0.0.0.0.0.2 established
|
||||
SNMPv2-MIB::snmpTrapEnterprise.0 JUNIPER-CHASSIS-DEFINES-MIB::jnxProductNameSRX240";
|
||||
|
||||
$trap = new Trap($trapText);
|
||||
$message = "BGP Peer 2001:d88:1::2 is now in the established state";
|
||||
\Log::shouldReceive('event')->once()->with($message, $device->device_id, 'trap', 1);
|
||||
|
||||
$this->assertTrue(Dispatcher::handle($trap), 'Could not handle JnxBgpM2Established trap');
|
||||
}
|
||||
}
|
80
tests/Feature/SnmpTraps/JnxCmCfgChangeTest.php
Normal file
80
tests/Feature/SnmpTraps/JnxCmCfgChangeTest.php
Normal file
@@ -0,0 +1,80 @@
|
||||
<?php
|
||||
/**
|
||||
* JnxCmCfgChangeTest.php
|
||||
*
|
||||
* -Description-
|
||||
*
|
||||
* 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/>.
|
||||
*
|
||||
* Test Juniper configuration change trap jnxCmCfgChange
|
||||
*
|
||||
* @package LibreNMS
|
||||
* @link http://librenms.org
|
||||
* @copyright 2019 KanREN, Inc
|
||||
* @author Heath Barnhart <hbarnhart@kanren.net>
|
||||
*/
|
||||
|
||||
namespace LibreNMS\Tests;
|
||||
|
||||
use App\Models\Device;
|
||||
use LibreNMS\Snmptrap\Dispatcher;
|
||||
use LibreNMS\Snmptrap\Trap;
|
||||
use Log;
|
||||
|
||||
class JnxCmCfgChangeTest extends LaravelTestCase
|
||||
{
|
||||
|
||||
public function testConfigChangeTrap()
|
||||
{
|
||||
|
||||
$device = factory(Device::class)->create();
|
||||
|
||||
$trapText = "$device->hostname
|
||||
UDP: [$device->ip]:64610->[192.168.5.5]:162
|
||||
DISMAN-EVENT-MIB::sysUpTimeInstance 198:2:10:48.91
|
||||
SNMPv2-MIB::snmpTrapOID.0 JUNIPER-CFGMGMT-MIB::jnxCmCfgChange
|
||||
JUNIPER-CFGMGMT-MIB::jnxCmCfgChgEventTime.54 316:13:26:37.65
|
||||
JUNIPER-CFGMGMT-MIB::jnxCmCfgChgEventDate.54 2018-11-21,7:34:39.0,-6:0
|
||||
JUNIPER-CFGMGMT-MIB::jnxCmCfgChgEventSource.54 cli
|
||||
JUNIPER-CFGMGMT-MIB::jnxCmCfgChgEventUser.54 TestUser
|
||||
SNMPv2-MIB::snmpTrapEnterprise.0 JUNIPER-CHASSIS-DEFINES-MIB::jnxProductNameEX2200";
|
||||
|
||||
$trap = new Trap($trapText);
|
||||
$message = "Config modified by TestUser from cli at 2018-11-21,7:34:39.0,-6:0";
|
||||
\Log::shouldReceive('event')->once()->with($message, $device->device_id, 'trap', 2);
|
||||
|
||||
$this->assertTrue(Dispatcher::handle($trap), 'Could not handle JnxCmCfgChange trap');
|
||||
}
|
||||
|
||||
public function testConfigRollbackTrap()
|
||||
{
|
||||
$device = factory(Device::class)->create();
|
||||
|
||||
$trapText = "$device->hostname
|
||||
UDP: [$device->ip]:64610->[192.168.5.5]:162
|
||||
DISMAN-EVENT-MIB::sysUpTimeInstance 198:2:10:48.91
|
||||
SNMPv2-MIB::snmpTrapOID.0 JUNIPER-CFGMGMT-MIB::jnxCmCfgChange
|
||||
JUNIPER-CFGMGMT-MIB::jnxCmCfgChgEventTime.54 316:13:26:37.65
|
||||
JUNIPER-CFGMGMT-MIB::jnxCmCfgChgEventDate.54 2017-12-21,7:34:39.0,-6:0
|
||||
JUNIPER-CFGMGMT-MIB::jnxCmCfgChgEventSource.54 other
|
||||
JUNIPER-CFGMGMT-MIB::jnxCmCfgChgEventUser.54 root
|
||||
SNMPv2-MIB::snmpTrapEnterprise.0 JUNIPER-CHASSIS-DEFINES-MIB::jnxProductNameEX2200";
|
||||
|
||||
$trap = new Trap($trapText);
|
||||
$message = "Config rolled back at 2017-12-21,7:34:39.0,-6:0";
|
||||
\Log::shouldReceive('event')->once()->with($message, $device->device_id, 'trap', 2);
|
||||
|
||||
$this->assertTrue(Dispatcher::handle($trap), 'Could not handle JnxCmCfgChange config rolled back');
|
||||
}
|
||||
}
|
82
tests/Feature/SnmpTraps/JnxDomAlarmTest.php
Normal file
82
tests/Feature/SnmpTraps/JnxDomAlarmTest.php
Normal file
@@ -0,0 +1,82 @@
|
||||
<?php
|
||||
/**
|
||||
* JnxDomAlarmTest.php
|
||||
* -Description-
|
||||
*
|
||||
* 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 JnxDomAlertSet and JnxDomAlertCleared traps from Juniper devices.
|
||||
*
|
||||
* @package LibreNMS
|
||||
* @link http://librenms.org
|
||||
* @copyright 2019 KanREN, Inc
|
||||
* @author Heath Barnhart <hbarnhart@kanren.net>
|
||||
*/
|
||||
|
||||
namespace LibreNMS\Tests;
|
||||
|
||||
use App\Models\Device;
|
||||
use App\Models\Port;
|
||||
use LibreNMS\Snmptrap\Dispatcher;
|
||||
use LibreNMS\Snmptrap\Trap;
|
||||
use Log;
|
||||
|
||||
class JnxDomAlarmTest extends LaravelTestCase
|
||||
{
|
||||
|
||||
public function testJnxDomAlarmSetTrap()
|
||||
{
|
||||
$device = factory(Device::class)->create();
|
||||
$port = factory(Port::class)->make();
|
||||
|
||||
$trapText = "$device->hostname
|
||||
UDP: [$device->ip]:64610->[192.168.5.5]:162
|
||||
DISMAN-EVENT-MIB::sysUpTimeInstance 198:2:10:48.91
|
||||
SNMPv2-MIB::snmpTrapOID.0 JUNIPER-DOM-MIB::jnxDomAlarmSet
|
||||
IF-MIB::ifDescr.$port->ifIndex $port->ifDescr
|
||||
JUNIPER-DOM-MIB::jnxDomLastAlarms.$port->ifIndex \"00 00 00 \"
|
||||
JUNIPER-DOM-MIB::jnxDomCurrentAlarms.$port->ifIndex \"80 00 00 \"
|
||||
JUNIPER-DOM-MIB::jnxDomCurrentAlarmDate.$port->ifIndex 2019-4-17,0:4:51.0,-5:0
|
||||
SNMPv2-MIB::snmpTrapEnterprise.0 JUNIPER-CHASSIS-DEFINES-MIB::jnxProductNameMX480";
|
||||
|
||||
$trap = new Trap($trapText);
|
||||
$message = "DOM alarm set for interface $port->ifDescr. Current alarm(s): input loss of signal";
|
||||
\Log::shouldReceive('event')->once()->with($message, $device->device_id, 'trap', 5);
|
||||
|
||||
$this->assertTrue(Dispatcher::handle($trap), 'Could not handle JnxDomAlarmSet');
|
||||
}
|
||||
|
||||
public function testJnxDomAlarmClearTrap()
|
||||
{
|
||||
$device = factory(Device::class)->create();
|
||||
$port = factory(Port::class)->make();
|
||||
|
||||
$trapText = "$device->hostname
|
||||
UDP: [$device->ip]:64610->[192.168.5.5]:162
|
||||
DISMAN-EVENT-MIB::sysUpTimeInstance 198:2:10:48.91
|
||||
SNMPv2-MIB::snmpTrapOID.0 JUNIPER-DOM-MIB::jnxDomAlarmCleared
|
||||
IF-MIB::ifDescr.$port->ifIndex $port->ifDescr
|
||||
JUNIPER-DOM-MIB::jnxDomLastAlarms.$port->ifIndex \"00 00 00 \"
|
||||
JUNIPER-DOM-MIB::jnxDomCurrentAlarms.$port->ifIndex \"E8 01 00 \"
|
||||
JUNIPER-DOM-MIB::jnxDomCurrentAlarmDate.$port->ifIndex 2019-4-17,0:4:51.0,-5:0
|
||||
SNMPv2-MIB::snmpTrapEnterprise.0 JUNIPER-CHASSIS-DEFINES-MIB::jnxProductNameMX480";
|
||||
|
||||
$trap = new Trap($trapText);
|
||||
$message = "DOM alarm cleared for interface $port->ifDescr. Cleared alarm(s): input loss of signal, input loss of lock, input rx path not ready, input laser power low, module not ready";
|
||||
\Log::shouldReceive('event')->once()->with($message, $device->device_id, 'trap', 1);
|
||||
|
||||
$this->assertTrue(Dispatcher::handle($trap), 'Could not handle JnxDomAlarmCleared');
|
||||
}
|
||||
}
|
90
tests/Feature/SnmpTraps/JnxDomLaneAlarmTest.php
Normal file
90
tests/Feature/SnmpTraps/JnxDomLaneAlarmTest.php
Normal file
@@ -0,0 +1,90 @@
|
||||
<?php
|
||||
/**
|
||||
* JnxDomLaneAlarmTest.php
|
||||
* -Description-
|
||||
*
|
||||
* 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 JnxDomAlertSet and JnxDomAlertCleared traps from Juniper devices.
|
||||
*
|
||||
* @package LibreNMS
|
||||
* @link http://librenms.org
|
||||
* @copyright 2019 KanREN, Inc
|
||||
* @author Heath Barnhart <hbarnhart@kanren.net>
|
||||
*/
|
||||
|
||||
namespace LibreNMS\Tests;
|
||||
|
||||
use App\Models\Device;
|
||||
use App\Models\Port;
|
||||
use LibreNMS\Snmptrap\Dispatcher;
|
||||
use LibreNMS\Snmptrap\Trap;
|
||||
use Log;
|
||||
|
||||
class JnxDomLaneAlarmTest extends LaravelTestCase
|
||||
{
|
||||
|
||||
public function testJnxDomLaneAlarmSetTrap()
|
||||
{
|
||||
$device = factory(Device::class)->create();
|
||||
$port = factory(Port::class)->make(['ifAdminStatus' => 'up', 'ifOperStatus' => 'up']);
|
||||
$device->ports()->save($port);
|
||||
|
||||
$trapText = "$device->hostname
|
||||
UDP: [$device->ip]:64610->[192.168.5.5]:162
|
||||
DISMAN-EVENT-MIB::sysUpTimeInstance 198:2:10:48.91
|
||||
SNMPv2-MIB::snmpTrapOID.0 JUNIPER-DOM-MIB::jnxDomLaneAlarmSet
|
||||
IF-MIB::ifDescr.$port->ifIndex $port->ifDescr
|
||||
JUNIPER-DOM-MIB::jnxDomLaneIndex.$port->ifIndex 0
|
||||
JUNIPER-DOM-MIB::jnxDomLaneLastAlarms.$port->ifIndex \"00 00 00 \"
|
||||
JUNIPER-DOM-MIB::jnxDomCurrentLaneAlarms.$port->ifIndex \"40 00 00 \"
|
||||
JUNIPER-DOM-MIB::jnxDomCurrentLaneAlarmDate.$port->ifIndex 2019-4-10,0:9:35.0,-5:0
|
||||
SNMPv2-MIB::snmpTrapEnterprise.0 JUNIPER-CHASSIS-DEFINES-MIB::jnxProductNameMX960";
|
||||
|
||||
\Log::shouldReceive('warning')->never()->with("Snmptrap JnxDomLaneAlarmSet: Could not find port at ifIndex $port->ifIndex for device: $device->hostname");
|
||||
|
||||
$trap = new Trap($trapText);
|
||||
$message = "DOM lane alarm on interface $port->ifDescr lane 0. Current alarm(s): input signal low";
|
||||
\Log::shouldReceive('event')->once()->with($message, $device->device_id, 'trap', 5);
|
||||
|
||||
$this->assertTrue(Dispatcher::handle($trap), 'Could not handle JnxDomLaneAlarmSet');
|
||||
}
|
||||
|
||||
public function testJnxDomLaneAlarmClearedTrap()
|
||||
{
|
||||
$device = factory(Device::class)->create();
|
||||
$port = factory(Port::class)->make(['ifAdminStatus' => 'up', 'ifOperStatus' => 'up']);
|
||||
$device->ports()->save($port);
|
||||
|
||||
$trapText = "$device->hostname
|
||||
UDP: [$device->ip]:64610->[192.168.5.5]:162
|
||||
DISMAN-EVENT-MIB::sysUpTimeInstance 198:2:10:48.91
|
||||
SNMPv2-MIB::snmpTrapOID.0 JUNIPER-DOM-MIB::jnxDomLaneAlarmCleared
|
||||
IF-MIB::ifDescr.$port->ifIndex $port->ifDescr
|
||||
JUNIPER-DOM-MIB::jnxDomLaneIndex.$port->ifIndex 0
|
||||
JUNIPER-DOM-MIB::jnxDomLaneLastAlarms.$port->ifIndex \"00 00 00 \"
|
||||
JUNIPER-DOM-MIB::jnxDomCurrentLaneAlarms.$port->ifIndex \"08 00 00 \"
|
||||
JUNIPER-DOM-MIB::jnxDomCurrentLaneAlarmDate.$port->ifIndex 2019-4-10,0:9:35.0,-5:0
|
||||
SNMPv2-MIB::snmpTrapEnterprise.0 JUNIPER-CHASSIS-DEFINES-MIB::jnxProductNameMX960";
|
||||
|
||||
\Log::shouldReceive('warning')->never()->with("Snmptrap JnxDomLaneAlarmCleared: Could not find port at ifIndex $port->ifIndex for device: $device->hostname");
|
||||
|
||||
$trap = new Trap($trapText);
|
||||
$message = "DOM lane alarm cleared on interface $port->ifDescr lane 0. Current alarm(s): output signal high";
|
||||
\Log::shouldReceive('event')->once()->with($message, $device->device_id, 'trap', 1);
|
||||
|
||||
$this->assertTrue(Dispatcher::handle($trap), 'Could not handle JnxDomLaneAlarmCleared');
|
||||
}
|
||||
}
|
83
tests/Feature/SnmpTraps/JnxLdpLspTest.php
Normal file
83
tests/Feature/SnmpTraps/JnxLdpLspTest.php
Normal file
@@ -0,0 +1,83 @@
|
||||
<?php
|
||||
/**
|
||||
* JnxLdpLspTest.php
|
||||
* -Description-
|
||||
*
|
||||
* 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 JnxLdpLspDown and JnxLdpLspUp traps from Juniper devices.
|
||||
*
|
||||
* @package LibreNMS
|
||||
* @link http://librenms.org
|
||||
* @copyright 2019 KanREN, Inc
|
||||
* @author Heath Barnhart <hbarnhart@kanren.net>
|
||||
*/
|
||||
|
||||
namespace LibreNMS\Tests;
|
||||
|
||||
use App\Models\Device;
|
||||
use App\Models\Ipv4Address;
|
||||
use LibreNMS\Snmptrap\Dispatcher;
|
||||
use LibreNMS\Snmptrap\Trap;
|
||||
use Log;
|
||||
|
||||
class JnxLdpLspTest extends LaravelTestCase
|
||||
{
|
||||
|
||||
public function testLdpLspDownTrap()
|
||||
{
|
||||
$device = factory(Device::class)->create();
|
||||
$ipv4 = factory(Ipv4Address::class)->make();
|
||||
|
||||
$trapText = "$device->hostname
|
||||
UDP: [$device->ip]:64610->[192.168.5.5]:162
|
||||
DISMAN-EVENT-MIB::sysUpTimeInstance 198:2:10:48.91
|
||||
SNMPv2-MIB::snmpTrapOID.0 JUNIPER-LDP-MIB::jnxLdpLspDown
|
||||
JUNIPER-LDP-MIB::jnxLdpLspFec.0 $ipv4->ipv4_address
|
||||
JUNIPER-LDP-MIB::jnxLdpRtrid.0 $device->ip
|
||||
JUNIPER-LDP-MIB::jnxLdpLspDownReason.0 topologyChanged
|
||||
JUNIPER-LDP-MIB::jnxLdpLspFecLen.0 32
|
||||
JUNIPER-LDP-MIB::jnxLdpInstanceName.0 \"test instance down\"
|
||||
SNMPv2-MIB::snmpTrapEnterprise.0 JUNIPER-CHASSIS-DEFINES-MIB::jnxProductNameMX480";
|
||||
|
||||
$trap = new Trap($trapText);
|
||||
$message = "LDP session test instance down from $device->ip to $ipv4->ipv4_address has gone down due to topologyChanged";
|
||||
\Log::shouldReceive('event')->once()->with($message, $device->device_id, 'trap', 4);
|
||||
|
||||
$this->assertTrue(Dispatcher::handle($trap), 'Could not handle JnxLdpLspDown trap');
|
||||
}
|
||||
|
||||
public function testLdpLspUpTrap()
|
||||
{
|
||||
$device = factory(Device::class)->create();
|
||||
$ipv4 = factory(Ipv4Address::class)->make();
|
||||
|
||||
$trapText = "$device->hostname
|
||||
UDP: [$device->ip]:64610->[192.168.5.5]:162
|
||||
DISMAN-EVENT-MIB::sysUpTimeInstance 198:2:10:48.91
|
||||
SNMPv2-MIB::snmpTrapOID.0 JUNIPER-LDP-MIB::jnxLdpLspUp
|
||||
JUNIPER-LDP-MIB::jnxLdpLspFec.0 $ipv4->ipv4_address
|
||||
JUNIPER-LDP-MIB::jnxLdpRtrid.0 $device->ip
|
||||
JUNIPER-LDP-MIB::jnxLdpLspFecLen.0 32
|
||||
JUNIPER-LDP-MIB::jnxLdpInstanceName.0 \"test instance up\"
|
||||
SNMPv2-MIB::snmpTrapEnterprise.0 JUNIPER-CHASSIS-DEFINES-MIB::jnxProductNameMX480";
|
||||
|
||||
$trap = new Trap($trapText);
|
||||
$message = "LDP session test instance up from $device->ip to $ipv4->ipv4_address is now up.";
|
||||
\Log::shouldReceive('event')->once()->with($message, $device->device_id, 'trap', 1);
|
||||
|
||||
$this->assertTrue(Dispatcher::handle($trap), 'Could not handle JnxLdpLspUp trap');
|
||||
}
|
||||
}
|
85
tests/Feature/SnmpTraps/JnxLdpSesTest.php
Normal file
85
tests/Feature/SnmpTraps/JnxLdpSesTest.php
Normal file
@@ -0,0 +1,85 @@
|
||||
<?php
|
||||
/**
|
||||
* JnxLdpSesTest.php
|
||||
* -Description-
|
||||
*
|
||||
* 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 JnxLdpSesDown and JnxLdpSesUp traps from Juniper devices.
|
||||
*
|
||||
* @package LibreNMS
|
||||
* @link http://librenms.org
|
||||
* @copyright 2019 KanREN, Inc
|
||||
* @author Heath Barnhart <hbarnhart@kanren.net>
|
||||
*/
|
||||
|
||||
namespace LibreNMS\Tests;
|
||||
|
||||
use App\Models\Device;
|
||||
use App\Models\Port;
|
||||
use LibreNMS\Snmptrap\Dispatcher;
|
||||
use LibreNMS\Snmptrap\Trap;
|
||||
use Log;
|
||||
|
||||
class JnxLdpSesTest extends LaravelTestCase
|
||||
{
|
||||
|
||||
public function testJnxLdpSesDownTrap()
|
||||
{
|
||||
$device = factory(Device::class)->create();
|
||||
$port = factory(Port::class)->make(['ifAdminStatus' => 'up', 'ifOperStatus' => 'up']);
|
||||
$device->ports()->save($port);
|
||||
|
||||
$trapText = "$device->hostname
|
||||
UDP: [$device->ip]:64610->[192.168.5.5]:162
|
||||
DISMAN-EVENT-MIB::sysUpTimeInstance 198:2:10:48.91
|
||||
SNMPv2-MIB::snmpTrapOID.0 JUNIPER-LDP-MIB::jnxLdpSesDown
|
||||
JUNIPER-MPLS-LDP-MIB::jnxMplsLdpSesState.'.q.j..'.1.'.q.p..' nonexistent
|
||||
JUNIPER-LDP-MIB::jnxLdpSesDownReason.0 allAdjacenciesDown
|
||||
JUNIPER-LDP-MIB::jnxLdpSesDownIf.0 $port->ifIndex
|
||||
SNMPv2-MIB::snmpTrapEnterprise.0 JUNIPER-CHASSIS-DEFINES-MIB::jnxProductNameMX480";
|
||||
|
||||
\Log::shouldReceive('warning')->never()->with("Snmptrap LdpSesDown: Could not find port at ifIndex $port->ifIndex for device: $device->hostname");
|
||||
|
||||
$trap = new Trap($trapText);
|
||||
$message = "LDP session on interface $port->ifDescr is nonexistent due to allAdjacenciesDown";
|
||||
\Log::shouldReceive('event')->once()->with($message, $device->device_id, 'trap', 4);
|
||||
|
||||
$this->assertTrue(Dispatcher::handle($trap), 'Could not handle JnxLdpSesDown trap');
|
||||
}
|
||||
|
||||
public function testJnxLdpSesUpTrap()
|
||||
{
|
||||
$device = factory(Device::class)->create();
|
||||
$port = factory(Port::class)->make(['ifAdminStatus' => 'up', 'ifOperStatus' => 'up']);
|
||||
$device->ports()->save($port);
|
||||
|
||||
$trapText = "$device->hostname
|
||||
UDP: [$device->ip]:64610->[192.168.5.5]:162
|
||||
DISMAN-EVENT-MIB::sysUpTimeInstance 198:2:10:48.91
|
||||
SNMPv2-MIB::snmpTrapOID.0 JUNIPER-LDP-MIB::jnxLdpSesUp
|
||||
JUNIPER-MPLS-LDP-MIB::jnxMplsLdpSesState.'.q.d..'.1.'.q.p..' operational
|
||||
JUNIPER-LDP-MIB::jnxLdpSesUpIf.0 $port->ifIndex
|
||||
SNMPv2-MIB::snmpTrapEnterprise.0 JUNIPER-CHASSIS-DEFINES-MIB::jnxProductNameMX960";
|
||||
|
||||
\Log::shouldReceive('warning')->never()->with("Snmptrap LdpSesUp: Could not find port at ifIndex $port->ifIndex for device: $device->hostname");
|
||||
|
||||
$trap = new Trap($trapText);
|
||||
$message = "LDP session on interface $port->ifDescr is operational";
|
||||
\Log::shouldReceive('event')->once()->with($message, $device->device_id, 'trap', 1);
|
||||
|
||||
$this->assertTrue(Dispatcher::handle($trap), 'Could not handle JnxLdpSesUp trap');
|
||||
}
|
||||
}
|
83
tests/Feature/SnmpTraps/JnxVpnIfTest.php
Normal file
83
tests/Feature/SnmpTraps/JnxVpnIfTest.php
Normal file
@@ -0,0 +1,83 @@
|
||||
<?php
|
||||
/**
|
||||
* JnxVpnIfTest.php
|
||||
*
|
||||
* -Description-
|
||||
*
|
||||
* 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 JnxVpnIfDown and JnxVpnIfUp traps from Juniper devices.
|
||||
*
|
||||
* @package LibreNMS
|
||||
* @link http://librenms.org
|
||||
* @copyright 2019 KanREN, Inc
|
||||
* @author Heath Barnhart <hbarnhart@kanren.net>
|
||||
*/
|
||||
|
||||
namespace LibreNMS\Tests;
|
||||
|
||||
use App\Models\Device;
|
||||
use App\Models\Port;
|
||||
use LibreNMS\Snmptrap\Dispatcher;
|
||||
use LibreNMS\Snmptrap\Trap;
|
||||
use Log;
|
||||
|
||||
class JnxVpnIfTest extends LaravelTestCase
|
||||
{
|
||||
|
||||
public function testVpnIfDown()
|
||||
{
|
||||
$device = factory(Device::class)->create();
|
||||
$port = factory(Port::class)->make(['ifAdminStatus' => 'up', 'ifOperStatus' => 'up']);
|
||||
$device->ports()->save($port);
|
||||
|
||||
$trapText = "$device->hostname
|
||||
UDP: [$device->ip]:64610->[192.168.5.5]:162
|
||||
DISMAN-EVENT-MIB::sysUpTimeInstance 198:2:10:48.91
|
||||
SNMPv2-MIB::snmpTrapOID.0 JUNIPER-VPN-MIB::jnxVpnIfDown
|
||||
JUNIPER-VPN-MIB::jnxVpnIfVpnType.l2Circuit.\"ge-0/0/2.0\".$port->ifIndex l2Circuit
|
||||
JUNIPER-VPN-MIB::jnxVpnIfVpnName.l2Circuit.\"ge-0/0/2.0\".$port->ifIndex \"$port->ifDescr\"
|
||||
JUNIPER-VPN-MIB::jnxVpnIfIndex.l2Circuit.\"ge-0/0/2.0\".$port->ifIndex $port->ifIndex
|
||||
SNMPv2-MIB::snmpTrapEnterprise.0 JUNIPER-CHASSIS-DEFINES-MIB::jnxProductNameMX960";
|
||||
|
||||
$trap = new Trap($trapText);
|
||||
$message = "l2Circuit on interface $port->ifDescr has gone down";
|
||||
\Log::shouldReceive('event')->once()->with($message, $device->device_id, 'trap', 4);
|
||||
|
||||
$this->assertTrue(Dispatcher::handle($trap), 'Could not handle JnxVpnIfDown trap');
|
||||
}
|
||||
|
||||
public function testVpnIfUp()
|
||||
{
|
||||
$device = factory(Device::class)->create();
|
||||
$port = factory(Port::class)->make(['ifAdminStatus' => 'up', 'ifOperStatus' => 'up']);
|
||||
$device->ports()->save($port);
|
||||
|
||||
$trapText = "$device->hostname
|
||||
UDP: [$device->ip]:64610->[192.168.5.5]:162
|
||||
DISMAN-EVENT-MIB::sysUpTimeInstance 198:2:10:48.91
|
||||
SNMPv2-MIB::snmpTrapOID.0 JUNIPER-VPN-MIB::jnxVpnIfUp
|
||||
JUNIPER-VPN-MIB::jnxVpnIfVpnType.l2Circuit.\"ge-0/0/2.0\".$port->ifIndex l2Circuit
|
||||
JUNIPER-VPN-MIB::jnxVpnIfVpnName.l2Circuit.\"ge-0/0/2.0\".$port->ifIndex $port->ifDescr
|
||||
JUNIPER-VPN-MIB::jnxVpnIfIndex.l2Circuit.\"ge-0/0/2.0\".$port->ifIndex $port->ifIndex
|
||||
SNMPv2-MIB::snmpTrapEnterprise.0 JUNIPER-CHASSIS-DEFINES-MIB::jnxProductNameMX960";
|
||||
|
||||
$trap = new Trap($trapText);
|
||||
$message = "l2Circuit on interface $port->ifDescr is now connected";
|
||||
\Log::shouldReceive('event')->once()->with($message, $device->device_id, 'trap', 1);
|
||||
|
||||
$this->assertTrue(Dispatcher::handle($trap), 'Could not handle JnxVpnIfUp trap');
|
||||
}
|
||||
}
|
83
tests/Feature/SnmpTraps/JnxVpnPwTest.php
Normal file
83
tests/Feature/SnmpTraps/JnxVpnPwTest.php
Normal file
@@ -0,0 +1,83 @@
|
||||
<?php
|
||||
/**
|
||||
* JnxVpnPwTest.php
|
||||
*
|
||||
* -Description-
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* @package LibreNMS
|
||||
* @link http://librenms.org
|
||||
* @copyright 2019 KanREN, Inc
|
||||
* @author Heath Barnhart <hbarnhart@kanren.net>
|
||||
*/
|
||||
|
||||
namespace LibreNMS\Tests;
|
||||
|
||||
use App\Models\Device;
|
||||
use App\Models\Port;
|
||||
use LibreNMS\Snmptrap\Dispatcher;
|
||||
use LibreNMS\Snmptrap\Trap;
|
||||
use Log;
|
||||
|
||||
class JnxVpnPwTest extends LaravelTestCase
|
||||
{
|
||||
|
||||
public function testVpnPwDown()
|
||||
{
|
||||
$device = factory(Device::class)->create();
|
||||
$port = factory(Port::class)->make(['ifAdminStatus' => 'up', 'ifOperStatus' => 'up']);
|
||||
$device->ports()->save($port);
|
||||
|
||||
$trapText = "$device->hostname
|
||||
UDP: [$device->ip]:64610->[192.168.5.5]:162
|
||||
DISMAN-EVENT-MIB::sysUpTimeInstance 198:2:10:48.91
|
||||
SNMPv2-MIB::snmpTrapOID.0 JUNIPER-VPN-MIB::jnxVpnPwDown
|
||||
JUNIPER-VPN-MIB::jnxVpnPwVpnType.l2Circuit.\"ge-0/0/2.0\".$port->ifIndex l2Circuit
|
||||
JUNIPER-VPN-MIB::jnxVpnPwVpnName.l2Circuit.\"ge-0/0/2.0\".$port->ifIndex $port->ifDescr
|
||||
JUNIPER-VPN-MIB::jnxVpnPwIndex.l2Circuit.\"ge-0/0/2.0\".$port->ifIndex $port->ifIndex
|
||||
SNMPv2-MIB::snmpTrapEnterprise.0 JUNIPER-CHASSIS-DEFINES-MIB::jnxProductNameMX480";
|
||||
|
||||
$trap = new Trap($trapText);
|
||||
$message = "l2Circuit on a pseudowire belonging to $port->ifDescr has gone down";
|
||||
\Log::shouldReceive('event')->once()->with($message, $device->device_id, 'trap', 4);
|
||||
|
||||
$this->assertTrue(Dispatcher::handle($trap), 'Could not handle JnxVpnPwDown trap');
|
||||
}
|
||||
|
||||
public function testVpnPwUp()
|
||||
{
|
||||
$device = factory(Device::class)->create();
|
||||
$port = factory(Port::class)->make(['ifAdminStatus' => 'up', 'ifOperStatus' => 'up']);
|
||||
$device->ports()->save($port);
|
||||
|
||||
$trapText = "$device->hostname
|
||||
UDP: [$device->ip]:64610->[192.168.5.5]:162
|
||||
DISMAN-EVENT-MIB::sysUpTimeInstance 198:2:10:48.91
|
||||
SNMPv2-MIB::snmpTrapOID.0 JUNIPER-VPN-MIB::jnxVpnPwUp
|
||||
JUNIPER-VPN-MIB::jnxVpnPwVpnType.l2Circuit.\"ge-0/0/2.0\".$port->ifIndex l2Circuit
|
||||
JUNIPER-VPN-MIB::jnxVpnPwVpnName.l2Circuit.\"ge-0/0/2.0\".$port->ifIndex $port->ifDescr
|
||||
JUNIPER-VPN-MIB::jnxVpnPwIndex.l2Circuit.\"ge-0/02.0\".$port->ifIndex $port->ifIndex
|
||||
SNMPv2-MIB::snmpTrapEnterprise.0 JUNIPER-CHASSIS-DEFINES-MIB::jnxProductNameMX960";
|
||||
|
||||
$trap = new Trap($trapText);
|
||||
$message = "l2Circuit on a pseudowire belonging to $port->ifDescr is now connected";
|
||||
\Log::shouldReceive('event')->once()->with($message, $device->device_id, 'trap', 1);
|
||||
|
||||
$this->assertTrue(Dispatcher::handle($trap), 'Could not handle JnxVpnPwUp trap');
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user