2019-05-01 11:12:51 -05:00
|
|
|
<?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
|
2021-02-09 00:29:04 +01:00
|
|
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
2019-05-01 11:12:51 -05:00
|
|
|
*
|
|
|
|
|
*
|
|
|
|
|
* Tests JnxLdpLspDown and JnxLdpLspUp traps from Juniper devices.
|
|
|
|
|
*
|
2021-02-09 00:29:04 +01:00
|
|
|
* @link https://www.librenms.org
|
2021-09-10 20:09:53 +02:00
|
|
|
*
|
2019-05-01 11:12:51 -05:00
|
|
|
* @copyright 2019 KanREN, Inc
|
|
|
|
|
* @author Heath Barnhart <hbarnhart@kanren.net>
|
|
|
|
|
*/
|
|
|
|
|
|
2020-04-03 17:13:18 -05:00
|
|
|
namespace LibreNMS\Tests\Feature\SnmpTraps;
|
2019-05-01 11:12:51 -05:00
|
|
|
|
|
|
|
|
use App\Models\Device;
|
|
|
|
|
use App\Models\Ipv4Address;
|
2022-11-05 14:43:54 -05:00
|
|
|
use Illuminate\Foundation\Testing\DatabaseTransactions;
|
2023-08-05 12:12:36 -05:00
|
|
|
use LibreNMS\Enum\Severity;
|
2022-11-05 14:43:54 -05:00
|
|
|
use LibreNMS\Tests\Traits\RequiresDatabase;
|
2019-05-01 11:12:51 -05:00
|
|
|
|
2019-10-13 13:40:38 +00:00
|
|
|
class JnxLdpLspTest extends SnmpTrapTestCase
|
2019-05-01 11:12:51 -05:00
|
|
|
{
|
2022-11-05 14:43:54 -05:00
|
|
|
use RequiresDatabase;
|
|
|
|
|
use DatabaseTransactions;
|
|
|
|
|
|
|
|
|
|
public function testLdpLspDownTrap(): void
|
2019-05-01 11:12:51 -05:00
|
|
|
{
|
2021-07-13 16:35:43 -05:00
|
|
|
$device = Device::factory()->create(); /** @var Device $device */
|
|
|
|
|
$ipv4 = Ipv4Address::factory()->make(); /** @var Ipv4Address $ipv4 */
|
2022-11-05 14:43:54 -05:00
|
|
|
$this->assertTrapLogsMessage("$device->hostname
|
2019-05-01 11:12:51 -05:00
|
|
|
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\"
|
2022-11-05 14:43:54 -05:00
|
|
|
SNMPv2-MIB::snmpTrapEnterprise.0 JUNIPER-CHASSIS-DEFINES-MIB::jnxProductNameMX480",
|
|
|
|
|
"LDP session test instance down from $device->ip to $ipv4->ipv4_address has gone down due to topologyChanged",
|
|
|
|
|
'Could not handle JnxLdpLspDown trap',
|
2023-08-05 12:12:36 -05:00
|
|
|
[Severity::Warning],
|
2022-11-05 14:43:54 -05:00
|
|
|
$device,
|
|
|
|
|
);
|
2019-05-01 11:12:51 -05:00
|
|
|
}
|
|
|
|
|
|
2022-11-05 14:43:54 -05:00
|
|
|
public function testLdpLspUpTrap(): void
|
2019-05-01 11:12:51 -05:00
|
|
|
{
|
2021-07-13 16:35:43 -05:00
|
|
|
$device = Device::factory()->create(); /** @var Device $device */
|
|
|
|
|
$ipv4 = Ipv4Address::factory()->make(); /** @var Ipv4Address $ipv4 */
|
2022-11-05 14:43:54 -05:00
|
|
|
$this->assertTrapLogsMessage("$device->hostname
|
2019-05-01 11:12:51 -05:00
|
|
|
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\"
|
2022-11-05 14:43:54 -05:00
|
|
|
SNMPv2-MIB::snmpTrapEnterprise.0 JUNIPER-CHASSIS-DEFINES-MIB::jnxProductNameMX480",
|
|
|
|
|
"LDP session test instance up from $device->ip to $ipv4->ipv4_address is now up.",
|
|
|
|
|
'Could not handle JnxLdpLspUp trap',
|
2023-08-05 12:12:36 -05:00
|
|
|
[Severity::Ok],
|
2022-11-05 14:43:54 -05:00
|
|
|
$device,
|
|
|
|
|
);
|
2019-05-01 11:12:51 -05:00
|
|
|
}
|
|
|
|
|
}
|