mirror of
https://github.com/librenms/librenms.git
synced 2024-10-07 16:52:45 +00:00
Added warmStart trap handler (#11583)
* Added warmStart Trap * Added warmStart Trap Test
This commit is contained in:
45
LibreNMS/Snmptrap/Handlers/WarmBoot.php
Normal file
45
LibreNMS/Snmptrap/Handlers/WarmBoot.php
Normal file
@@ -0,0 +1,45 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* WarmBoot.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
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace LibreNMS\Snmptrap\Handlers;
|
||||||
|
|
||||||
|
use App\Models\Device;
|
||||||
|
use LibreNMS\Interfaces\SnmptrapHandler;
|
||||||
|
use LibreNMS\Snmptrap\Trap;
|
||||||
|
use Log;
|
||||||
|
|
||||||
|
class WarmBoot 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() . ' warm booted', $device->device_id, 'reboot', 4);
|
||||||
|
}
|
||||||
|
}
|
@@ -93,6 +93,7 @@ return [
|
|||||||
'RUCKUS-SZ-EVENT-MIB::ruckusSZClusterBackToInServiceTrap' => \LibreNMS\Snmptrap\Handlers\RuckusSzClusterInService::class,
|
'RUCKUS-SZ-EVENT-MIB::ruckusSZClusterBackToInServiceTrap' => \LibreNMS\Snmptrap\Handlers\RuckusSzClusterInService::class,
|
||||||
'SNMPv2-MIB::authenticationFailure' => \LibreNMS\Snmptrap\Handlers\AuthenticationFailure::class,
|
'SNMPv2-MIB::authenticationFailure' => \LibreNMS\Snmptrap\Handlers\AuthenticationFailure::class,
|
||||||
'SNMPv2-MIB::coldStart' => \LibreNMS\Snmptrap\Handlers\ColdBoot::class,
|
'SNMPv2-MIB::coldStart' => \LibreNMS\Snmptrap\Handlers\ColdBoot::class,
|
||||||
|
'SNMPv2-MIB::warmStart' => \LibreNMS\Snmptrap\Handlers\WarmBoot::class,
|
||||||
'VMWARE-VMINFO-MIB::vmwVmHBDetected' => \LibreNMS\Snmptrap\Handlers\VmwVmHBDetected::class,
|
'VMWARE-VMINFO-MIB::vmwVmHBDetected' => \LibreNMS\Snmptrap\Handlers\VmwVmHBDetected::class,
|
||||||
'VMWARE-VMINFO-MIB::vmwVmHBLost' => \LibreNMS\Snmptrap\Handlers\VmwVmHBLost::class,
|
'VMWARE-VMINFO-MIB::vmwVmHBLost' => \LibreNMS\Snmptrap\Handlers\VmwVmHBLost::class,
|
||||||
'VMWARE-VMINFO-MIB::vmwVmPoweredOn' => \LibreNMS\Snmptrap\Handlers\VmwVmPoweredOn::class,
|
'VMWARE-VMINFO-MIB::vmwVmPoweredOn' => \LibreNMS\Snmptrap\Handlers\VmwVmPoweredOn::class,
|
||||||
|
@@ -163,6 +163,23 @@ SNMPv2-MIB::snmpTrapOID.0 SNMPv2-MIB::coldStart";
|
|||||||
$this->assertEquals($device->hostname, $trap->getDevice()->hostname);
|
$this->assertEquals($device->hostname, $trap->getDevice()->hostname);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testWarmStart()
|
||||||
|
{
|
||||||
|
$device = factory(Device::class)->create();
|
||||||
|
|
||||||
|
$trapText = "$device->hostname
|
||||||
|
UDP: [$device->ip]:44298->[192.168.5.5]:162
|
||||||
|
DISMAN-EVENT-MIB::sysUpTimeInstance 0:0:2:12.7
|
||||||
|
SNMPv2-MIB::snmpTrapOID.0 SNMPv2-MIB::warmStart";
|
||||||
|
|
||||||
|
Log::shouldReceive('event')->once()->with('SNMP Trap: Device ' . $device->displayName() . ' warm booted', $device->device_id, 'reboot', 4);
|
||||||
|
|
||||||
|
$trap = new Trap($trapText);
|
||||||
|
$this->assertTrue(Dispatcher::handle($trap));
|
||||||
|
|
||||||
|
// check that the device was found
|
||||||
|
$this->assertEquals($device->hostname, $trap->getDevice()->hostname);
|
||||||
|
}
|
||||||
|
|
||||||
public function testEntityDatabaseChanged()
|
public function testEntityDatabaseChanged()
|
||||||
{
|
{
|
||||||
|
Reference in New Issue
Block a user