mirror of
https://github.com/librenms/librenms.git
synced 2024-10-07 16:52:45 +00:00
* Remove Log::event Use the Eventlog class directly instead * wip * wip * wip * Apply fixes from StyleCI * Update Eventlog.php
32 lines
909 B
PHP
32 lines
909 B
PHP
<?php
|
|
|
|
namespace App\Observers;
|
|
|
|
use App\Models\Eventlog;
|
|
use App\Models\Stp;
|
|
|
|
class StpObserver
|
|
{
|
|
/**
|
|
* Handle the Stp "updating" event.
|
|
*
|
|
* @param \App\Models\Stp $stp
|
|
* @return void
|
|
*/
|
|
public function updating(Stp $stp)
|
|
{
|
|
if ($stp->isDirty('designatedRoot')) {
|
|
Eventlog::log('STP designated root changed: ' . $stp->getOriginal('designatedRoot') . ' > ' . $stp->designatedRoot, $stp->device_id, 'stp', 4);
|
|
}
|
|
|
|
if ($stp->isDirty('rootPort')) {
|
|
Eventlog::log('STP root port changed: ' . $stp->getOriginal('rootPort') . ' > ' . $stp->rootPort, $stp->device_id, 'stp', 4);
|
|
}
|
|
|
|
if ($stp->isDirty('rootPort')) {
|
|
$time = \LibreNMS\Util\Time::formatInterval($stp->timeSinceTopologyChange);
|
|
Eventlog::log('STP topology changed after: ' . $time, $stp->device_id, 'stp', 4);
|
|
}
|
|
}
|
|
}
|