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);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user