2019-05-01 11:12:51 -05:00
|
|
|
<?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
|
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 JnxDomAlertSet and JnxDomAlertCleared 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\Port;
|
2022-11-05 14:43:54 -05:00
|
|
|
use Illuminate\Foundation\Testing\DatabaseTransactions;
|
|
|
|
use LibreNMS\Tests\Traits\RequiresDatabase;
|
2019-05-01 11:12:51 -05:00
|
|
|
|
2019-10-13 13:40:38 +00:00
|
|
|
class JnxDomLaneAlarmTest extends SnmpTrapTestCase
|
2019-05-01 11:12:51 -05:00
|
|
|
{
|
2022-11-05 14:43:54 -05:00
|
|
|
use RequiresDatabase;
|
|
|
|
use DatabaseTransactions;
|
|
|
|
|
|
|
|
public function testJnxDomLaneAlarmSetTrap(): void
|
2019-05-01 11:12:51 -05:00
|
|
|
{
|
2022-11-05 14:43:54 -05:00
|
|
|
$device = Device::factory()->create();
|
|
|
|
/** @var Device $device */
|
|
|
|
$port = Port::factory()->make(['ifAdminStatus' => 'up', 'ifOperStatus' => 'up']);
|
|
|
|
/** @var Port $port */
|
2019-05-01 11:12:51 -05:00
|
|
|
$device->ports()->save($port);
|
|
|
|
|
2022-11-05 14:43:54 -05:00
|
|
|
$warning = "Snmptrap JnxDomLaneAlarmSet: Could not find port at ifIndex $port->ifIndex for device: $device->hostname";
|
|
|
|
\Log::shouldReceive('warning')->never()->with($warning);
|
|
|
|
|
|
|
|
$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-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
|
2022-11-05 14:43:54 -05:00
|
|
|
SNMPv2-MIB::snmpTrapEnterprise.0 JUNIPER-CHASSIS-DEFINES-MIB::jnxProductNameMX960",
|
|
|
|
"DOM lane alarm on interface $port->ifDescr lane 0. Current alarm(s): input signal low",
|
|
|
|
'Could not handle JnxDomLaneAlarmSet',
|
|
|
|
[5],
|
|
|
|
$device,
|
|
|
|
);
|
2019-05-01 11:12:51 -05:00
|
|
|
}
|
|
|
|
|
2022-11-05 14:43:54 -05:00
|
|
|
public function testJnxDomLaneAlarmClearedTrap(): void
|
2019-05-01 11:12:51 -05:00
|
|
|
{
|
2022-11-05 14:43:54 -05:00
|
|
|
$device = Device::factory()->create();
|
|
|
|
/** @var Device $device */
|
|
|
|
$port = Port::factory()->make(['ifAdminStatus' => 'up', 'ifOperStatus' => 'up']);
|
|
|
|
/** @var Port $port */
|
2019-05-01 11:12:51 -05:00
|
|
|
$device->ports()->save($port);
|
|
|
|
|
2022-11-05 14:43:54 -05:00
|
|
|
$warning = "Snmptrap JnxDomLaneAlarmCleared: Could not find port at ifIndex $port->ifIndex for device: $device->hostname";
|
|
|
|
\Log::shouldReceive('warning')->never()->with($warning);
|
|
|
|
|
|
|
|
$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-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
|
2022-11-05 14:43:54 -05:00
|
|
|
SNMPv2-MIB::snmpTrapEnterprise.0 JUNIPER-CHASSIS-DEFINES-MIB::jnxProductNameMX960",
|
|
|
|
"DOM lane alarm cleared on interface $port->ifDescr lane 0. Current alarm(s): output signal high",
|
|
|
|
'Could not handle JnxDomLaneAlarmCleared',
|
|
|
|
[1],
|
|
|
|
$device,
|
|
|
|
);
|
2019-05-01 11:12:51 -05:00
|
|
|
}
|
|
|
|
}
|