Add Alcatel Omniswitch Traps Handlers (#13492)

* first

* style1

* lint

* add another trap

* add another trap

* change juniper to alcatel

* style

* style

* style
This commit is contained in:
paulierco
2021-11-20 17:10:19 +02:00
committed by GitHub
parent 716725758d
commit 53d3495b7e
13 changed files with 662 additions and 0 deletions

View File

@@ -0,0 +1,59 @@
<?php
/**
* AlechassisTrapsAlert.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 <https://www.gnu.org/licenses/>.
*
* Alcatel 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".
*
* @link https://www.librenms.org
*
* @copyright 2021 paulierco
* @author Paul Iercosan <mail@paulierco.ro>
*/
namespace LibreNMS\Snmptrap\Handlers;
use App\Models\Device;
use LibreNMS\Interfaces\SnmptrapHandler;
use LibreNMS\Snmptrap\Trap;
use Log;
class AlechassisTrapsAlert 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)
{
$descr_aos6 = $trap->getOidData($trap->findOid('ALCATEL-IND1-CHASSIS-MIB::chassisTrapsAlertDescr'));
$descr_aos7 = $trap->getOidData($trap->findOid('ALCATEL-IND1-CHASSIS-MIB::chassisTrapsAlertDescr.0'));
if (! empty($descr_aos6)) {
Log::event("$descr_aos6", $device->device_id, 'trap', 2);
} elseif (! empty($descr_aos7)) {
Log::event("$descr_aos7", $device->device_id, 'trap', 2);
}
}
}

View File

@@ -0,0 +1,53 @@
<?php
/**
* Aos6CfgSavedTrap.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 <https://www.gnu.org/licenses/>.
*
* Alcatel 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".
*
* @link https://www.librenms.org
*
* @copyright 2021 Paulierco
* @author Paul Iercosan <mail@paulierco.ro>
*/
namespace LibreNMS\Snmptrap\Handlers;
use App\Models\Device;
use LibreNMS\Interfaces\SnmptrapHandler;
use LibreNMS\Snmptrap\Trap;
use Log;
class Aos6CfgSavedTrap 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)
{
$descr = $trap->getOidData($trap->findOid('ALCATEL-IND1-CONFIG-MGR-MIB::alcatelIND1ConfigMgrMIB.3.1.1'));
Log::event("$descr", $device->device_id, 'trap', 2);
}
}

View File

@@ -0,0 +1,58 @@
<?php
/**
* Aos6DoSTrap.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 <https://www.gnu.org/licenses/>.
*
* Alcatel 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".
*
* @link https://www.librenms.org
*
* @copyright 2021 paulierco
* @author Paul Iercosan <mail@paulierco.ro>
*/
namespace LibreNMS\Snmptrap\Handlers;
use App\Models\Device;
use LibreNMS\Interfaces\SnmptrapHandler;
use LibreNMS\Snmptrap\Trap;
use Log;
class Aos6DoSTrap 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)
{
$type = $trap->getOidData($trap->findOid('ALCATEL-IND1-IP-MIB::alaDoSType'));
$detected = $trap->getOidData($trap->findOid('ALCATEL-IND1-IP-MIB::alaDoSDetected'));
$ip = $trap->getOidData($trap->findOid('ALCATEL-IND1-IP-MIB::alaDoSIp'));
$slot = $trap->getOidData($trap->findOid('ALCATEL-IND1-IP-MIB::alaDoSSlot'));
$port = $trap->getOidData($trap->findOid('ALCATEL-IND1-IP-MIB::alaDoSPort'));
$mac = $trap->getOidData($trap->findOid('ALCATEL-IND1-IP-MIB::alaDoSMac'));
Log::event("There has been detected a Denial of Service (DoS) attack. Type of the attack is: $type. Number of attacks are: $detected. Slot where was received is: $slot. Source IP is: $ip. Mac address is: $mac.", $device->device_id, 'trap', 2);
}
}

View File

@@ -0,0 +1,53 @@
<?php
/**
* Aos6HicServerTrap.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 <https://www.gnu.org/licenses/>.
*
* Alcatel 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".
*
* @link https://www.librenms.org
*
* @copyright 2021 Paulierco
* @author Paul Iercosan <mail@paulierco.ro>
*/
namespace LibreNMS\Snmptrap\Handlers;
use App\Models\Device;
use LibreNMS\Interfaces\SnmptrapHandler;
use LibreNMS\Snmptrap\Trap;
use Log;
class Aos6HicServerTrap 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)
{
$ip = $trap->getOidData($trap->findOid('ALCATEL-IND1-AAA-MIB::aaaHSvrIpAddress'));
Log::event("Radius server with the IP: $ip might be unreachable or recovered.", $device->device_id, 'trap', 2);
}
}

View File

@@ -0,0 +1,56 @@
<?php
/**
* Aos6LbdStateChangeForAutoRecovery.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 <https://www.gnu.org/licenses/>.
*
* Alcatel 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".
*
* @link https://www.librenms.org
*
* @copyright 2021 Paulierco
* @author Paul Iercosan <mail@paulierco.ro>
*/
namespace LibreNMS\Snmptrap\Handlers;
use App\Models\Device;
use LibreNMS\Interfaces\SnmptrapHandler;
use LibreNMS\Snmptrap\Trap;
use Log;
class Aos6LbdStateChangeForAutoRecovery 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)
{
$before = $trap->getOidData($trap->findOid('ALCATEL-IND1-LBD-MIB::alaLbdPreviousStateAutoRecovery'));
$current = $trap->getOidData($trap->findOid('ALCATEL-IND1-LBD-MIB::alaLbdCurrentStateAutoRecovery'));
$ifIndex = $trap->getOidData($trap->findOid('ALCATEL-IND1-LBD-MIB::alaLbdPortIfIndex'));
$port = $device->ports()->where('ifIndex', $ifIndex)->first();
Log::event("Loopback detection has been recovered on the port $port->ifDescr. Status of the port before was $before and now is $current.", $device->device_id, 'trap', 1);
}
}

View File

@@ -0,0 +1,57 @@
<?php
/**
* Aos6LbdStateChangeToShutdown
*
* -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 <https://www.gnu.org/licenses/>.
*
* Alcatel 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".
*
* @link https://www.librenms.org
*
* @copyright 2021 Paulierco
* @author Paul Iercosan <mail@paulierco.ro>
*/
namespace LibreNMS\Snmptrap\Handlers;
use App\Models\Device;
use LibreNMS\Interfaces\SnmptrapHandler;
use LibreNMS\Snmptrap\Trap;
use Log;
class Aos6LbdStateChangeToShutdown 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)
{
$before = $trap->getOidData($trap->findOid('ALCATEL-IND1-LBD-MIB::alaLbdPreviousState'));
$current = $trap->getOidData($trap->findOid('ALCATEL-IND1-LBD-MIB::alaLbdCurrentState'));
$ifDescr = $trap->getOidData($trap->findOid('IF-MIB::ifDescr'));
$ifIndex = $trap->getOidData($trap->findOid('ALCATEL-IND1-LBD-MIB::alaLbdPortIfIndex'));
$port = $device->ports()->where('ifIndex', $ifIndex)->first();
Log::event("There has been a loop detected on the port $port->ifDescr. Status of the port before was $before and now is $current.", $device->device_id, 'trap', 5);
}
}

View File

@@ -0,0 +1,53 @@
<?php
/**
* Aos6StackMgrDuplicateSlot.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 <https://www.gnu.org/licenses/>.
*
* Alcatel 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".
*
* @link https://www.librenms.org
*
* @copyright 2021 paulierco
* @author Paul Iercosan <mail@paulierco.ro>
*/
namespace LibreNMS\Snmptrap\Handlers;
use App\Models\Device;
use LibreNMS\Interfaces\SnmptrapHandler;
use LibreNMS\Snmptrap\Trap;
use Log;
class Aos6StackMgrDuplicateSlot 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)
{
$slot_nr = $trap->getOidData($trap->findOid('ALCATEL-IND1-STACK-MANAGER-MIB::alaStackMgrSlotNINumber'));
Log::event("Stack member $slot_nr is duplicated.", $device->device_id, 'trap', 5);
}
}

View File

@@ -0,0 +1,54 @@
<?php
/**
* Aos6StackMgrRoleChange.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 <https://www.gnu.org/licenses/>.
*
* Alcatel 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".
*
* @link https://www.librenms.org
*
* @copyright 2021 paulierco
* @author Paul Iercosan <mail@paulierco.ro>
*/
namespace LibreNMS\Snmptrap\Handlers;
use App\Models\Device;
use LibreNMS\Interfaces\SnmptrapHandler;
use LibreNMS\Snmptrap\Trap;
use Log;
class Aos6StackMgrRoleChange 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)
{
$p_nr = $trap->getOidData($trap->findOid('ALCATEL-IND1-STACK-MANAGER-MIB::alaStackMgrPrimary'));
$s_nr = $trap->getOidData($trap->findOid('ALCATEL-IND1-STACK-MANAGER-MIB::alaStackMgrSecondary'));
Log::event("Stack management change.Primary unit of the stack is now chassis: $p_nr. Secondary unit of the stack is now chassis: $s_nr.", $device->device_id, 'trap', 2);
}
}

View File

@@ -0,0 +1,57 @@
<?php
/**
* Aos7portViolation.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 <https://www.gnu.org/licenses/>.
*
* Alcatel 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".
*
* @link https://www.librenms.org
*
* @copyright 2021 paulierco
* @author Paul Iercosan <mail@paulierco.ro>
*/
namespace LibreNMS\Snmptrap\Handlers;
use App\Models\Device;
use LibreNMS\Interfaces\SnmptrapHandler;
use LibreNMS\Snmptrap\Trap;
use Log;
class Aos7portViolation 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)
{
$reason = $trap->getOidData($trap->findOid('ALCATEL-IND1-PORT-MIB::portViolationSource.2.0'));
$current = $trap->getOidData($trap->findOid('ALCATEL-IND1-PORT-MIB::portViolationReason.3.0'));
$ifDescr = $trap->getOidData($trap->findOid('IF-MIB::ifDescr'));
$ifIndex = $trap->getOidData($trap->findOid('IF-MIB::ifIndex'));
$port = $device->ports()->where('ifIndex', $ifIndex)->first();
Log::event("There has been a loop detected on the port $port->ifDescr. The source code of the violation is: $reason and the current status code is: $current.", $device->device_id, 'trap', 5);
}
}

View File

@@ -0,0 +1,56 @@
<?php
/**
* Aos7portViolationNotification.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 <https://www.gnu.org/licenses/>.
*
* Alcatel 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".
*
* @link https://www.librenms.org
*
* @copyright 2021 paulierco
* @author Paul Iercosan <mail@paulierco.ro>
*/
namespace LibreNMS\Snmptrap\Handlers;
use App\Models\Device;
use LibreNMS\Interfaces\SnmptrapHandler;
use LibreNMS\Snmptrap\Trap;
use Log;
class Aos7portViolationNotification 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)
{
$reason = $trap->getOidData($trap->findOid('ALCATEL-IND1-PORT-MIB::portViolationRecoveryReason.1.0'));
$ifDescr = $trap->getOidData($trap->findOid('IF-MIB::ifDescr'));
$ifIndex = $trap->getOidData($trap->findOid('IF-MIB::ifIndex'));
$port = $device->ports()->where('ifIndex', $ifIndex)->first();
Log::event("There has been a loop detected on the port $port->ifDescr. The current status code is: $reason.", $device->device_id, 'trap', 5);
}
}

View File

@@ -0,0 +1,47 @@
<?php
/**
* Aos7stpNewRoot.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 <https://www.gnu.org/licenses/>.
*
* @link https://www.librenms.org
*
* @copyright 2021 paulierco
* @author Paul Iercosan <mail@paulierco.ro>
*/
namespace LibreNMS\Snmptrap\Handlers;
use App\Models\Device;
use LibreNMS\Interfaces\SnmptrapHandler;
use LibreNMS\Snmptrap\Trap;
use Log;
class Aos7stpNewRoot 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)
{
Log::event('SNMP Trap: Device ' . $device->displayName() . ' was elected as new root on one of its Spanning Tree Instances', $device->device_id, 'stp', 3);
}
}

View File

@@ -0,0 +1,47 @@
<?php
/**
* Aos7stpRootPortChange.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 <https://www.gnu.org/licenses/>.
*
* @link https://www.librenms.org
*
* @copyright 2021 paulierco
* @author Paul Iercosan <mail@paulierco.ro>
*/
namespace LibreNMS\Snmptrap\Handlers;
use App\Models\Device;
use LibreNMS\Interfaces\SnmptrapHandler;
use LibreNMS\Snmptrap\Trap;
use Log;
class Aos7stpRootPortChange 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)
{
Log::event('SNMP Trap: A root port has changed for a spanning tree bridge. The root port is the port that offers the lowest cost path from this bridge to the root bridge.', $device->device_id, 'stp', 3);
}
}