mirror of
https://github.com/librenms/librenms.git
synced 2024-09-21 02:18:39 +00:00
Improve trap testing (#14546)
* Improve trap testing Add helper log() to Trap Avoid saving to the database at all * style * Move all traps to $trap->log() * Update tests * Lint and style fixes * Use correct partial mock call * more style * Add docs * debug in ci * use the correct log function.................... * all, I guess * not the first?? * 3rd? * use event_id to order
This commit is contained in:
parent
7f3301caa4
commit
26318dc4b3
@ -35,10 +35,10 @@ class Dispatcher
|
||||
/**
|
||||
* Instantiate the correct handler for this trap and call it's handle method
|
||||
*/
|
||||
public static function handle(Trap $trap)
|
||||
public static function handle(Trap $trap): bool
|
||||
{
|
||||
if (empty($trap->getDevice())) {
|
||||
Log::warning('Could not find device for trap', ['trap_text' => $trap->getRaw()]);
|
||||
Log::warning('Could not find device for trap', ['trap_text' => $trap->raw]);
|
||||
|
||||
return false;
|
||||
}
|
||||
@ -47,7 +47,7 @@ class Dispatcher
|
||||
// Even the TrapOid is not properly converted to text, so snmptrapd is probably not
|
||||
// configured with any MIBs (-M and/or -m).
|
||||
// LibreNMS snmptraps code cannot process received data. Let's inform the user.
|
||||
Log::event('Misconfigured MIBS or MIBDIRS for snmptrapd, check https://docs.librenms.org/Extensions/SNMP-Trap-Handler/ : ' . $trap->getRaw(), $trap->getDevice(), 'system');
|
||||
Log::event('Misconfigured MIBS or MIBDIRS for snmptrapd, check https://docs.librenms.org/Extensions/SNMP-Trap-Handler/ : ' . $trap->raw, $trap->getDevice(), 'system');
|
||||
|
||||
return false;
|
||||
}
|
||||
@ -62,7 +62,7 @@ class Dispatcher
|
||||
$logging = Config::get('snmptraps.eventlog', 'unhandled');
|
||||
$detailed = Config::get('snmptraps.eventlog_detailed', false);
|
||||
if ($logging == 'all' || ($fallback && $logging == 'unhandled')) {
|
||||
Log::event($trap->toString($detailed), $trap->getDevice(), 'trap');
|
||||
$trap->log($trap->toString($detailed));
|
||||
} else {
|
||||
$rules = new AlertRules;
|
||||
$rules->runRules($trap->getDevice()->device_id);
|
||||
|
@ -31,7 +31,6 @@ use App\Models\Device;
|
||||
use Illuminate\Support\Str;
|
||||
use LibreNMS\Interfaces\SnmptrapHandler;
|
||||
use LibreNMS\Snmptrap\Trap;
|
||||
use Log;
|
||||
|
||||
class AdvaAccThresholdCrossingAlert implements SnmptrapHandler
|
||||
{
|
||||
@ -43,7 +42,7 @@ class AdvaAccThresholdCrossingAlert implements SnmptrapHandler
|
||||
* @param Trap $trap
|
||||
* @return void
|
||||
*/
|
||||
public function handle(Device $device, Trap $trap)
|
||||
public function handle(Device $device, Trap $trap): void
|
||||
{
|
||||
$interval = $trap->getOidData($trap->findOid('CM-PERFORMANCE-MIB::cmEthernetAccPortThresholdInterval'));
|
||||
$ifName = $trap->getOidData($trap->findOid('IF-MIB::ifName'));
|
||||
@ -52,10 +51,10 @@ class AdvaAccThresholdCrossingAlert implements SnmptrapHandler
|
||||
$trap->getOidData($trap->findOid('CM-PERFORMANCE-MIB::cmEthernetAccPortThresholdVariable'))
|
||||
);
|
||||
|
||||
Log::event("$ifName $thresholdMessage threshold exceeded for $interval", $device->device_id, 'trap', 2);
|
||||
$trap->log("$ifName $thresholdMessage threshold exceeded for $interval");
|
||||
}
|
||||
|
||||
public function getThresholdMessage($thresholdOid)
|
||||
public function getThresholdMessage(string $thresholdOid): string
|
||||
{
|
||||
foreach ($this->getThresholds() as $oid => $descr) {
|
||||
if (Str::contains($thresholdOid, $oid)) {
|
||||
@ -66,7 +65,7 @@ class AdvaAccThresholdCrossingAlert implements SnmptrapHandler
|
||||
return 'unknown';
|
||||
}
|
||||
|
||||
public function getThresholds()
|
||||
public function getThresholds(): array
|
||||
{
|
||||
return [
|
||||
'CM-PERFORMANCE-MIB::cmEthernetAccPortStatsUAS' => 'unavailable seconds',
|
||||
|
@ -32,7 +32,6 @@ namespace LibreNMS\Snmptrap\Handlers;
|
||||
use App\Models\Device;
|
||||
use LibreNMS\Interfaces\SnmptrapHandler;
|
||||
use LibreNMS\Snmptrap\Trap;
|
||||
use Log;
|
||||
|
||||
class AdvaAttributeChange implements SnmptrapHandler
|
||||
{
|
||||
@ -44,164 +43,164 @@ class AdvaAttributeChange implements SnmptrapHandler
|
||||
* @param Trap $trap
|
||||
* @return void
|
||||
*/
|
||||
public function handle(Device $device, Trap $trap)
|
||||
public function handle(Device $device, Trap $trap): void
|
||||
{
|
||||
if ($trap->findOid('CM-SYSTEM-MIB::sysLog')) {
|
||||
$this->handleSyslogChg($device, $trap);
|
||||
$this->handleSyslogChg($trap);
|
||||
} elseif ($trap->findOid('CM-SYSTEM-MIB::aclEntry')) {
|
||||
$this->handleAclChg($device, $trap);
|
||||
$this->handleAclChg($trap);
|
||||
} elseif ($trap->findOid('CM-SYSTEM-MIB::securityBanner')) {
|
||||
Log::event('MOTD/Banner modified', $device->device_id, 'trap', 2);
|
||||
$trap->log('MOTD/Banner modified');
|
||||
} elseif ($trap->findOid('CM-SYSTEM-MIB::sysTimeOfDayType')) {
|
||||
$this->handleTimeSrcChg($device, $trap);
|
||||
$this->handleTimeSrcChg($trap);
|
||||
} elseif ($trap->findOid('F3-TIMEZONE-MIB::f3TimeZone')) {
|
||||
$this->handleTimeZoneChg($device, $trap);
|
||||
$this->handleTimeZoneChg($trap);
|
||||
} elseif ($trap->findOid('CM-SYSTEM-MIB::ntp')) {
|
||||
$this->handleNtpChg($device, $trap);
|
||||
$this->handleNtpChg($trap);
|
||||
} elseif ($trap->findOid('CM-SECURITY-MIB::cmRemoteAuthServer')) {
|
||||
$this->handleAuthSvrChg($device, $trap);
|
||||
$this->handleAuthSvrChg($trap);
|
||||
} elseif ($trap->findOid('CM-ENTITY-MIB::ne')) {
|
||||
$this->handleNeChg($device, $trap);
|
||||
$this->handleNeChg($trap);
|
||||
} elseif ($trap->findOid('CM-ENTITY-MIB::ethernetNTEGE114ProCardSnmpDyingGaspEnabled')) {
|
||||
$this->handleDyingGaspChg($device, $trap);
|
||||
$this->handleDyingGaspChg($trap);
|
||||
} elseif ($trap->findOid('CM-FACILITY-MIB::cmEthernetNetPort')) {
|
||||
$this->handleNetPortChg($device, $trap);
|
||||
$this->handleNetPortChg($trap);
|
||||
} elseif ($trap->findOid('CM-FACILITY-MIB::cmEthernetAccPort')) {
|
||||
$this->handleAccPortChg($device, $trap);
|
||||
$this->handleAccPortChg($trap);
|
||||
} elseif ($trap->findOid('CM-FACILITY-MIB::cmFlow')) {
|
||||
$this->handleFlowChg($device, $trap);
|
||||
$this->handleFlowChg($trap);
|
||||
} elseif ($trap->findOid('F3-LAG-MIB')) {
|
||||
$this->handleLagChg($device, $trap);
|
||||
$this->handleLagChg($trap);
|
||||
} elseif ($trap->findOid('CM-FACILITY-MIB::cmQosFlow')) {
|
||||
$this->handleQosFlowChg($device, $trap);
|
||||
$this->handleQosFlowChg($trap);
|
||||
} elseif ($trap->findOid('CM-FACILITY-MIB::cmQosShaper')) {
|
||||
$this->handleQosShaperChg($device, $trap);
|
||||
$this->handleQosShaperChg($trap);
|
||||
} elseif ($trap->findOid('CM-FACILITY-MIB::cmAccPort')) {
|
||||
$this->handleAccPortShaperChg($device, $trap);
|
||||
$this->handleAccPortShaperChg($trap);
|
||||
}
|
||||
}
|
||||
|
||||
public static function handleSyslogChg($device, $trap)
|
||||
public function handleSyslogChg(Trap $trap): void
|
||||
{
|
||||
$syslogEntry = substr($trap->findOid('CM-SYSTEM-MIB::sysLog'), -1);
|
||||
if ($trap->findOid('CM-SYSTEM-MIB::sysLogIpVersion')) {
|
||||
$ipVer = $trap->getOidData($trap->findOid('CM-SYSTEM-MIB::sysLogIpVersion'));
|
||||
Log::event("Syslog server $syslogEntry IP version set to $ipVer", $device->device_id, 'trap', 2);
|
||||
$trap->log("Syslog server $syslogEntry IP version set to $ipVer");
|
||||
}
|
||||
if ($trap->findOid('CM-SYSTEM-MIB::sysLogIpAddress')) {
|
||||
$ipAddr = $trap->getOidData($trap->findOid('CM-SYSTEM-MIB::sysLogIpAddress'));
|
||||
Log::event("Syslog server $syslogEntry IP address changed to $ipAddr", $device->device_id, 'trap', 2);
|
||||
$trap->log("Syslog server $syslogEntry IP address changed to $ipAddr");
|
||||
}
|
||||
if ($trap->findOid('CM-SYSTEM-MIB::sysLogIpv6Addr')) {
|
||||
$ip6Addr = $trap->getOidData($trap->findOid('CM-SYSTEM-MIB::sysLogIpv6Addr'));
|
||||
Log::event("Syslog server $syslogEntry IP address changed to $ip6Addr", $device->device_id, 'trap', 2);
|
||||
$trap->log("Syslog server $syslogEntry IP address changed to $ip6Addr");
|
||||
}
|
||||
if ($trap->findOid('CM-SYSTEM-MIB::sysLogPort')) {
|
||||
$syslogPort = $trap->getOidData($trap->findOid('CM-SYSTEM-MIB::sysLogPort'));
|
||||
Log::event("Syslog server $syslogEntry port changed to $syslogPort", $device->device_id, 'trap', 2);
|
||||
$trap->log("Syslog server $syslogEntry port changed to $syslogPort");
|
||||
}
|
||||
}
|
||||
|
||||
public static function handleAclChg($device, $trap)
|
||||
public function handleAclChg(Trap $trap): void
|
||||
{
|
||||
$aclEntry = substr($trap->findOid('CM-SYSTEM-MIB::aclEntry'), -1);
|
||||
Log::event("ACL $aclEntry modified", $device->device_id, 'trap', 2);
|
||||
$trap->log("ACL $aclEntry modified");
|
||||
}
|
||||
|
||||
public static function handleTimeSrcChg($device, $trap)
|
||||
public function handleTimeSrcChg(Trap $trap): void
|
||||
{
|
||||
$timeSrc = $trap->getOidData($trap->findOid('CM-SYSTEM-MIB::sysTimeOfDayType'));
|
||||
Log::event("Time source set to $timeSrc", $device->device_id, 'trap', 2);
|
||||
$trap->log("Time source set to $timeSrc");
|
||||
}
|
||||
|
||||
public static function handleTimeZoneChg($device, $trap)
|
||||
public function handleTimeZoneChg(Trap $trap): void
|
||||
{
|
||||
$enabled = $trap->getOidData($trap->findOid('F3-TIMEZONE-MIB::f3TimeZoneDstControlEnabled'));
|
||||
if ('true' === $enabled && $trap->findOid('F3-TIMEZONE-MIB::f3TimeZoneDstControlEnabled')) {
|
||||
Log::event('Daylight Savings Time enabled', $device->device_id, 'trap', 2);
|
||||
$trap->log('Daylight Savings Time enabled');
|
||||
} elseif ('false' === $enabled && $trap->findOid('F3-TIMEZONE-MIB::f3TimeZoneDstControlEnabled')) {
|
||||
Log::event('Daylight Savings Time disabled', $device->device_id, 'trap', 2);
|
||||
$trap->log('Daylight Savings Time disabled');
|
||||
}
|
||||
if ($trap->findOid('F3-TIMEZONE-MIB::f3TimeZoneUtcOffset')) {
|
||||
$dstOffset = $trap->getOidData($trap->findOid('F3-TIMEZONE-MIB::f3TimeZoneUtcOffset'));
|
||||
Log::event("UTC offset (timezone) change to $dstOffset", $device->device_id, 'trap', 2);
|
||||
$trap->log("UTC offset (timezone) change to $dstOffset");
|
||||
}
|
||||
}
|
||||
|
||||
public static function handleNtpChg($device, $trap)
|
||||
public function handleNtpChg(Trap $trap): void
|
||||
{
|
||||
if ($trap->findOid('CM-SYSTEM-MIB::ntpPrimaryServer')) {
|
||||
$primaryIP = $trap->getOidData($trap->findOid('CM-SYSTEM-MIB::ntpPrimaryServer'));
|
||||
Log::event("Primary NTP server IP changed to $primaryIP", $device->device_id, 'trap', 2);
|
||||
$trap->log("Primary NTP server IP changed to $primaryIP");
|
||||
}
|
||||
if ($trap->findOid('CM-SYSTEM-MIB::ntpBackupServer')) {
|
||||
$backupIP = $trap->getOidData($trap->findOid('CM-SYSTEM-MIB::ntpBackupServer'));
|
||||
Log::event("Backup NTP server IP changed to $backupIP", $device->device_id, 'trap', 2);
|
||||
$trap->log("Backup NTP server IP changed to $backupIP");
|
||||
}
|
||||
}
|
||||
|
||||
public static function handleAuthSvrChg($device, $trap)
|
||||
public function handleAuthSvrChg(Trap $trap): void
|
||||
{
|
||||
if ($trap->findOid('CM-SECURITY-MIB::cmRemoteAuthServerIpAddress')) {
|
||||
$serverEntry = substr($trap->findOid('CM-SECURITY-MIB::cmRemoteAuthServerIpAddress'), -1);
|
||||
$serverIP = $trap->getOidData($trap->findOid('CM-SECURITY-MIB::cmRemoteAuthServerIpAddress'));
|
||||
Log::event("Authentication server $serverEntry IP changed to $serverIP", $device->device_id, 'trap', 2);
|
||||
$trap->log("Authentication server $serverEntry IP changed to $serverIP");
|
||||
}
|
||||
if ($trap->findOid('CM-SECURITY-MIB::cmRemoteAuthServerSecret')) {
|
||||
$serverEntry = substr($trap->findOid('CM-SECURITY-MIB::cmRemoteAuthServerSecret'), -1);
|
||||
Log::event("Authentication server $serverEntry secret changed", $device->device_id, 'trap', 2);
|
||||
$trap->log("Authentication server $serverEntry secret changed");
|
||||
}
|
||||
if ($trap->findOid('CM-SECURITY-MIB::cmRemoteAuthServerEnabled')) {
|
||||
$serverEntry = substr($trap->findOid('CM-SECURITY-MIB::cmRemoteAuthServerEnabled'), -1);
|
||||
$serverEnable = $trap->getOidData($trap->findOid('CM-SECURITY-MIB::cmRemoteAuthServerEnabled'));
|
||||
if ('true' === $serverEnable) {
|
||||
Log::event("Authentication server $serverEntry enabled", $device->device_id, 'trap', 2);
|
||||
$trap->log("Authentication server $serverEntry enabled");
|
||||
} else {
|
||||
Log::event("Authentication server $serverEntry disabled", $device->device_id, 'trap', 2);
|
||||
$trap->log("Authentication server $serverEntry disabled");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static function handleNeChg($device, $trap)
|
||||
public function handleNeChg(Trap $trap): void
|
||||
{
|
||||
if ($trap->findOid('CM-ENTITY-MIB::neName')) {
|
||||
$neName = $trap->getOidData($trap->findOid('CM-ENTITY-MIB::neName'));
|
||||
Log::event("Network Element name changed to $neName", $device->device_id, 'trap', 2);
|
||||
$trap->log("Network Element name changed to $neName");
|
||||
}
|
||||
if ($trap->findOid('CM-ENTITY-MIB::neCmdPromptPrefix')) {
|
||||
$neCLI = $trap->getOidData($trap->findOid('CM-ENTITY-MIB::neCmdPromptPrefix'));
|
||||
Log::event("Network Element prompt changed to $neCLI", $device->device_id, 'trap', 2);
|
||||
$trap->log("Network Element prompt changed to $neCLI");
|
||||
}
|
||||
}
|
||||
|
||||
public static function handleDyingGaspChg($device, $trap)
|
||||
public function handleDyingGaspChg(Trap $trap): void
|
||||
{
|
||||
$nteSDGEnable = $trap->getOidData($trap->findOid('CM-ENTITY-MIB::ethernetNTEGE114ProCardSnmpDyingGaspEnabled'));
|
||||
if ('true' === $nteSDGEnable && $trap->findOid('CM-ENTITY-MIB::ethernetNTEGE114ProCardSnmpDyingGaspEnabled')) {
|
||||
Log::event('SNMP Dying Gasp is enabled', $device->device_id, 'trap', 2);
|
||||
$trap->log('SNMP Dying Gasp is enabled');
|
||||
} elseif ('false' === $nteSDGEnable && $trap->findOid('CM-ENTITY-MIB::ethernetNTEGE114ProCardSnmpDyingGaspEnabled')) {
|
||||
Log::event('SNMP Dying Gasp is disabled', $device->device_id, 'trap', 2);
|
||||
$trap->log('SNMP Dying Gasp is disabled');
|
||||
}
|
||||
}
|
||||
|
||||
public static function handleNetPortChg($device, $trap)
|
||||
public function handleNetPortChg(Trap $trap): void
|
||||
{
|
||||
$netPort = substr($trap->findOid('CM-FACILITY-MIB::cmEthernetNetPort'), -7);
|
||||
$netPort = str_replace('.', '-', $netPort);
|
||||
$neDefMessage = false;
|
||||
if ($trap->findOid('CM-FACILITY-MIB::cmEthernetNetPortConfigSpeed')) {
|
||||
$netSpeed = $trap->getOidData($trap->findOid('CM-FACILITY-MIB::cmEthernetNetPortConfigSpeed'));
|
||||
Log::event("Network Port $netPort changed speed to $netSpeed", $device->device_id, 'trap', 2);
|
||||
$trap->log("Network Port $netPort changed speed to $netSpeed");
|
||||
$neDefMessage = true;
|
||||
}
|
||||
if ($trap->findOid('CM-FACILITY-MIB::cmEthernetNetPortMediaType')) {
|
||||
$netMedia = $trap->getOidData($trap->findOid('CM-FACILITY-MIB::cmEthernetNetPortMediaType'));
|
||||
Log::event("Network Port $netPort changed media to $netMedia", $device->device_id, 'trap', 2);
|
||||
$trap->log("Network Port $netPort changed media to $netMedia");
|
||||
$neDefMessage = true;
|
||||
}
|
||||
if ($trap->findOid('CM-FACILITY-MIB::cmEthernetNetPortMDIXType')) {
|
||||
$netMDIX = $trap->getOidData($trap->findOid('CM-FACILITY-MIB::cmEthernetNetPortMDIXType'));
|
||||
Log::event("Network Port $netPort changed MDIX to $netMDIX", $device->device_id, 'trap', 2);
|
||||
$trap->log("Network Port $netPort changed MDIX to $netMDIX");
|
||||
$neDefMessage = true;
|
||||
}
|
||||
if ($trap->findOid('CM-FACILITY-MIB::cmEthernetNetPortAutoDiagEnabled')) {
|
||||
@ -211,43 +210,43 @@ class AdvaAttributeChange implements SnmptrapHandler
|
||||
} else {
|
||||
$message = "Network Port $netPort AutoDiagnostic disabled";
|
||||
}
|
||||
Log::event($message, $device->device_id, 'trap', 2);
|
||||
$trap->log($message);
|
||||
$neDefMessage = true;
|
||||
}
|
||||
if ($trap->findOid('CM-FACILITY-MIB::cmEthernetNetPortAdminState')) {
|
||||
$netAdminState = $trap->getOidData($trap->findOid('CM-FACILITY-MIB::cmEthernetNetPortAdminState'));
|
||||
Log::event("Network Port $netPort administrative state changed to $netAdminState", $device->device_id, 'trap', 2);
|
||||
$trap->log("Network Port $netPort administrative state changed to $netAdminState");
|
||||
$neDefMessage = true;
|
||||
}
|
||||
if ($trap->findOid('CM-FACILITY-MIB::cmEthernetNetPortMTU')) {
|
||||
$netMTU = $trap->getOidData($trap->findOid('CM-FACILITY-MIB::cmEthernetNetPortMTU'));
|
||||
Log::event("Network Port $netPort MTU changed to $netMTU bytes", $device->device_id, 'trap', 2);
|
||||
$trap->log("Network Port $netPort MTU changed to $netMTU bytes");
|
||||
$neDefMessage = true;
|
||||
}
|
||||
if ($neDefMessage === false) {
|
||||
/* Catch all other Access Port changes and give a generic message */
|
||||
Log::event("Network Port $netPort modified", $device->device_id, 'trap', 2);
|
||||
$trap->log("Network Port $netPort modified");
|
||||
}
|
||||
}
|
||||
|
||||
public static function handleAccPortChg($device, $trap)
|
||||
public function handleAccPortChg(Trap $trap): void
|
||||
{
|
||||
$accPort = substr($trap->findOid('CM-FACILITY-MIB::cmEthernetAccPort'), -7);
|
||||
$accPort = str_replace('.', '-', $accPort);
|
||||
$accDefMessage = false;
|
||||
if ($trap->findOid('CM-FACILITY-MIB::cmEthernetAccPortConfigSpeed')) {
|
||||
$accSpeed = $trap->getOidData($trap->findOid('CM-FACILITY-MIB::cmEthernetAccPortConfigSpeed'));
|
||||
Log::event("Access Port $accPort changed speed to $accSpeed", $device->device_id, 'trap', 2);
|
||||
$trap->log("Access Port $accPort changed speed to $accSpeed");
|
||||
$accDefMessage = true;
|
||||
}
|
||||
if ($trap->findOid('CM-FACILITY-MIB::cmEthernetAccPortMediaType')) {
|
||||
$accMedia = $trap->getOidData($trap->findOid('CM-FACILITY-MIB::cmEthernetAccPortMediaType'));
|
||||
Log::event("Access Port $accPort changed media to $accMedia", $device->device_id, 'trap', 2);
|
||||
$trap->log("Access Port $accPort changed media to $accMedia");
|
||||
$accDefMessage = true;
|
||||
}
|
||||
if ($trap->findOid('CM-FACILITY-MIB::cmEthernetAccPortMDIXType')) {
|
||||
$accMDIX = $trap->getOidData($trap->findOid('CM-FACILITY-MIB::cmEthernetAccPortMDIXType'));
|
||||
Log::event("Access Port $accPort changed MDIX to $accMDIX", $device->device_id, 'trap', 2);
|
||||
$trap->log("Access Port $accPort changed MDIX to $accMDIX");
|
||||
$accDefMessage = true;
|
||||
}
|
||||
if ($trap->findOid('CM-FACILITY-MIB::cmEthernetAccPortAutoDiagEnabled')) {
|
||||
@ -257,56 +256,56 @@ class AdvaAttributeChange implements SnmptrapHandler
|
||||
} else {
|
||||
$message = "Access Port $accPort AutoDiagnostic disabled";
|
||||
}
|
||||
Log::event($message, $device->device_id, 'trap', 2);
|
||||
$trap->log($message);
|
||||
$accDefMessage = true;
|
||||
}
|
||||
if ($trap->findOid('CM-FACILITY-MIB::cmEthernetAccPortAdminState')) {
|
||||
$accAdminState = $trap->getOidData($trap->findOid('CM-FACILITY-MIB::cmEthernetAccPortAdminState'));
|
||||
Log::event("Access Port $accPort administrative state changed to $accAdminState", $device->device_id, 'trap', 2);
|
||||
$trap->log("Access Port $accPort administrative state changed to $accAdminState");
|
||||
$accDefMessage = true;
|
||||
}
|
||||
if ($trap->findOid('CM-FACILITY-MIB::cmEthernetAccPortMTU')) {
|
||||
$accMTU = $trap->getOidData($trap->findOid('CM-FACILITY-MIB::cmEthernetAccPortMTU'));
|
||||
Log::event("Access Port $accPort MTU changed to $accMTU bytes", $device->device_id, 'trap', 2);
|
||||
$trap->log("Access Port $accPort MTU changed to $accMTU bytes");
|
||||
$accDefMessage = true;
|
||||
}
|
||||
if ($accDefMessage === false) {
|
||||
/* Catch all other Access Port changes and give a generic message */
|
||||
Log::event("Access Port $accPort modified", $device->device_id, 'trap', 2);
|
||||
$trap->log("Access Port $accPort modified");
|
||||
}
|
||||
}
|
||||
|
||||
public static function handleFlowChg($device, $trap)
|
||||
public function handleFlowChg(Trap $trap): void
|
||||
{
|
||||
$flowID = substr($trap->findOid('CM-FACILITY-MIB::cmFlow'), -9);
|
||||
$flowID = str_replace('.', '-', $flowID);
|
||||
Log::event("Access Flow $flowID modified", $device->device_id, 'trap', 2);
|
||||
$trap->log("Access Flow $flowID modified");
|
||||
}
|
||||
|
||||
public static function handleLagChg($device, $trap)
|
||||
public function handleLagChg(Trap $trap): void
|
||||
{
|
||||
$lagID = substr($trap->findOid('F3-LAG-MIB::f3'), -1);
|
||||
Log::event("LAG $lagID modified", $device->device_id, 'trap', 2);
|
||||
$trap->log("LAG $lagID modified");
|
||||
}
|
||||
|
||||
public static function handleQosFlowChg($device, $trap)
|
||||
public function handleQosFlowChg(Trap $trap): void
|
||||
{
|
||||
$flowID = substr($trap->findOid('CM-FACILITY-MIB::cmQosFlow'), -13, 9);
|
||||
$flowID = str_replace('.', '-', $flowID);
|
||||
Log::event("QoS on flow $flowID modified", $device->device_id, 'trap', 2);
|
||||
$trap->log("QoS on flow $flowID modified");
|
||||
}
|
||||
|
||||
public static function handleQosShaperChg($device, $trap)
|
||||
public function handleQosShaperChg(Trap $trap): void
|
||||
{
|
||||
$flowID = substr($trap->findOid('CM-FACILITY-MIB::cmQosShaper'), -13, 9);
|
||||
$flowID = str_replace('.', '-', $flowID);
|
||||
Log::event("QoS on flow $flowID modified", $device->device_id, 'trap', 2);
|
||||
$trap->log("QoS on flow $flowID modified");
|
||||
}
|
||||
|
||||
public static function handleAccPortShaperChg($device, $trap)
|
||||
public function handleAccPortShaperChg(Trap $trap): void
|
||||
{
|
||||
$shaperID = substr($trap->findOid('CM-FACILITY-MIB::cmAccPort'), -9);
|
||||
$shaperID = str_replace('.', '-', $shaperID);
|
||||
Log::event("Shaper modified on access port $shaperID modified", $device->device_id, 'trap', 2);
|
||||
$trap->log("Shaper modified on access port $shaperID modified");
|
||||
}
|
||||
}
|
||||
|
@ -31,7 +31,6 @@ use App\Models\Device;
|
||||
use Illuminate\Support\Str;
|
||||
use LibreNMS\Interfaces\SnmptrapHandler;
|
||||
use LibreNMS\Snmptrap\Trap;
|
||||
use Log;
|
||||
|
||||
class AdvaNetThresholdCrossingAlert implements SnmptrapHandler
|
||||
{
|
||||
@ -43,7 +42,7 @@ class AdvaNetThresholdCrossingAlert implements SnmptrapHandler
|
||||
* @param Trap $trap
|
||||
* @return void
|
||||
*/
|
||||
public function handle(Device $device, Trap $trap)
|
||||
public function handle(Device $device, Trap $trap): void
|
||||
{
|
||||
$interval = $trap->getOidData($trap->findOid('CM-PERFORMANCE-MIB::cmEthernetNetPortThresholdInterval'));
|
||||
$ifName = $trap->getOidData($trap->findOid('IF-MIB::ifName'));
|
||||
@ -51,10 +50,10 @@ class AdvaNetThresholdCrossingAlert implements SnmptrapHandler
|
||||
$trap->getOidData($trap->findOid('CM-PERFORMANCE-MIB::cmEthernetNetPortThresholdVariable'))
|
||||
);
|
||||
|
||||
Log::event("$ifName $threshMessage threshold exceeded for $interval", $device->device_id, 'trap', 2);
|
||||
$trap->log("$ifName $threshMessage threshold exceeded for $interval");
|
||||
}
|
||||
|
||||
public function getThresholdMessage($thresholdOid)
|
||||
public function getThresholdMessage(string $thresholdOid): string
|
||||
{
|
||||
foreach ($this->getThresholds() as $oid => $descr) {
|
||||
if (Str::contains($thresholdOid, $oid)) {
|
||||
@ -65,7 +64,7 @@ class AdvaNetThresholdCrossingAlert implements SnmptrapHandler
|
||||
return 'unknown';
|
||||
}
|
||||
|
||||
public function getThresholds()
|
||||
public function getThresholds(): array
|
||||
{
|
||||
return [
|
||||
'CM-PERFORMANCE-MIB::cmEthernetNetPortStatsUAS' => 'unavailable seconds',
|
||||
|
@ -31,7 +31,6 @@ namespace LibreNMS\Snmptrap\Handlers;
|
||||
use App\Models\Device;
|
||||
use LibreNMS\Interfaces\SnmptrapHandler;
|
||||
use LibreNMS\Snmptrap\Trap;
|
||||
use Log;
|
||||
|
||||
class AdvaNetworkElementAlmTrap implements SnmptrapHandler
|
||||
{
|
||||
@ -66,6 +65,6 @@ class AdvaNetworkElementAlmTrap implements SnmptrapHandler
|
||||
|
||||
$almDescr = $trap->getOidData($trap->findOid('CM-ALARM-MIB::cmNetworkElementAlmDescr'));
|
||||
$almObjName = $trap->getOidData($trap->findOid('CM-ALARM-MIB::cmNetworkElementAlmObjectName'));
|
||||
Log::event("Alarming Element: $almObjName Description: $almDescr Severity: $alSeverity", $device->device_id, 'trap', $logSeverity);
|
||||
$trap->log("Alarming Element: $almObjName Description: $almDescr Severity: $alSeverity", $logSeverity);
|
||||
}
|
||||
}
|
||||
|
@ -31,7 +31,6 @@ namespace LibreNMS\Snmptrap\Handlers;
|
||||
use App\Models\Device;
|
||||
use LibreNMS\Interfaces\SnmptrapHandler;
|
||||
use LibreNMS\Snmptrap\Trap;
|
||||
use Log;
|
||||
|
||||
class AdvaObjectCreation implements SnmptrapHandler
|
||||
{
|
||||
@ -47,10 +46,10 @@ class AdvaObjectCreation implements SnmptrapHandler
|
||||
{
|
||||
if ($trap_oid = $trap->findOid('CM-SECURITY-MIB::cmSecurityUserName')) {
|
||||
$UserName = $trap->getOidData($trap_oid);
|
||||
Log::event("User object $UserName created", $device->device_id, 'trap', 2);
|
||||
$trap->log("User object $UserName created");
|
||||
} elseif ($trap_oid = $trap->findOid('F3-LAG-MIB::f3LagName')) {
|
||||
$lagID = substr($trap_oid, -1);
|
||||
Log::event("LAG $lagID created", $device->device_id, 'trap', 2);
|
||||
$trap->log("LAG $lagID created");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -31,7 +31,6 @@ namespace LibreNMS\Snmptrap\Handlers;
|
||||
use App\Models\Device;
|
||||
use LibreNMS\Interfaces\SnmptrapHandler;
|
||||
use LibreNMS\Snmptrap\Trap;
|
||||
use Log;
|
||||
|
||||
class AdvaObjectDeletion implements SnmptrapHandler
|
||||
{
|
||||
@ -47,17 +46,17 @@ class AdvaObjectDeletion implements SnmptrapHandler
|
||||
{
|
||||
if ($trap_oid = $trap->findOid('CM-SECURITY-MIB::cmSecurityUserName')) {
|
||||
$UserName = $trap->getOidData($trap_oid);
|
||||
Log::event("User object $UserName deleted", $device->device_id, 'trap', 2);
|
||||
$trap->log("User object $UserName deleted");
|
||||
} elseif ($trap_oid = $trap->findOid('CM-FACILITY-MIB::cmFlowIndex')) {
|
||||
$flowID = str_replace('.', '-', substr($trap_oid, 29));
|
||||
Log::event("Flow $flowID deleted", $device->device_id, 'trap', 2);
|
||||
$trap->log("Flow $flowID deleted");
|
||||
} elseif ($trap_oid = $trap->findOid('F3-LAG-MIB::f3LagPortIndex')) {
|
||||
$lagPortID = $trap->getOidData($trap_oid);
|
||||
$lagID = str_replace('.', '-', substr($trap_oid, -5, 3));
|
||||
Log::event("LAG member port $lagPortID removed from LAG $lagID", $device->device_id, 'trap', 2);
|
||||
$trap->log("LAG member port $lagPortID removed from LAG $lagID");
|
||||
} elseif ($trap_oid = $trap->findOid('F3-LAG-MIB::f3LagIndex')) {
|
||||
$lagID = $trap->getOidData($trap_oid);
|
||||
Log::event("LAG $lagID deleted", $device->device_id, 'trap', 2);
|
||||
$trap->log("LAG $lagID deleted");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -31,7 +31,6 @@ namespace LibreNMS\Snmptrap\Handlers;
|
||||
use App\Models\Device;
|
||||
use LibreNMS\Interfaces\SnmptrapHandler;
|
||||
use LibreNMS\Snmptrap\Trap;
|
||||
use Log;
|
||||
|
||||
class AdvaSnmpDyingGaspTrap implements SnmptrapHandler
|
||||
{
|
||||
@ -45,6 +44,6 @@ class AdvaSnmpDyingGaspTrap implements SnmptrapHandler
|
||||
*/
|
||||
public function handle(Device $device, Trap $trap)
|
||||
{
|
||||
Log::event('Dying Gasp received', $device->device_id, 'trap', 5);
|
||||
$trap->log('Dying Gasp received', 5);
|
||||
}
|
||||
}
|
||||
|
@ -33,7 +33,6 @@ namespace LibreNMS\Snmptrap\Handlers;
|
||||
use App\Models\Device;
|
||||
use LibreNMS\Interfaces\SnmptrapHandler;
|
||||
use LibreNMS\Snmptrap\Trap;
|
||||
use Log;
|
||||
|
||||
class AdvaStateChangeTrap implements SnmptrapHandler
|
||||
{
|
||||
@ -51,18 +50,18 @@ class AdvaStateChangeTrap implements SnmptrapHandler
|
||||
$adminState = $trap->getOidData($trap_oid);
|
||||
$opState = $trap->getOidData($trap->findOid('CM-FACILITY-MIB::cmEthernetAccPortOperationalState'));
|
||||
$portName = $trap->getOidData($trap->findOid('IF-MIB::ifName'));
|
||||
Log::event("Port state change: $portName Admin State: $adminState Operational State: $opState", $device->device_id, 'trap', 2);
|
||||
$trap->log("Port state change: $portName Admin State: $adminState Operational State: $opState");
|
||||
} elseif ($trap_oid = $trap->findOid('CM-FACILITY-MIB::cmFlowAdminState')) {
|
||||
$adminState = $trap->getOidData($trap_oid);
|
||||
$opState = $trap->getOidData($trap->findOid('CM-FACILITY-MIB::cmFlowOperationalState'));
|
||||
$flowID = substr($trap->findOid('CM-FACILITY-MIB::cmFlowAdminState'), 34);
|
||||
$flowID = str_replace('.', '-', $flowID);
|
||||
Log::event("Flow state change: $flowID Admin State: $adminState Operational State: $opState", $device->device_id, 'trap', 2);
|
||||
$trap->log("Flow state change: $flowID Admin State: $adminState Operational State: $opState");
|
||||
} elseif ($trap_oid = $trap->findOid('CM-FACILITY-MIB::cmEthernetNetPortAdminState')) {
|
||||
$adminState = $trap->getOidData($trap_oid);
|
||||
$opState = $trap->getOidData($trap->findOid('CM-FACILITY-MIB::cmEthernetNetPortOperationalState'));
|
||||
$portName = $trap->getOidData($trap->findOid('IF-MIB::ifName'));
|
||||
Log::event("Port state change: $portName Admin State: $adminState Operational State: $opState", $device->device_id, 'trap', 2);
|
||||
$trap->log("Port state change: $portName Admin State: $adminState Operational State: $opState");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -31,7 +31,6 @@ namespace LibreNMS\Snmptrap\Handlers;
|
||||
use App\Models\Device;
|
||||
use LibreNMS\Interfaces\SnmptrapHandler;
|
||||
use LibreNMS\Snmptrap\Trap;
|
||||
use Log;
|
||||
|
||||
class AdvaSysAlmTrap implements SnmptrapHandler
|
||||
{
|
||||
@ -65,6 +64,6 @@ class AdvaSysAlmTrap implements SnmptrapHandler
|
||||
}
|
||||
|
||||
$sysAlmDescr = $trap->getOidData($trap->findOid('CM-ALARM-MIB::cmSysAlmDescr'));
|
||||
Log::event("System Alarm: $sysAlmDescr Status: $alSeverity", $device->device_id, 'trap', $logSeverity);
|
||||
$trap->log("System Alarm: $sysAlmDescr Status: $alSeverity", $logSeverity);
|
||||
}
|
||||
}
|
||||
|
@ -33,7 +33,6 @@ namespace LibreNMS\Snmptrap\Handlers;
|
||||
use App\Models\Device;
|
||||
use LibreNMS\Interfaces\SnmptrapHandler;
|
||||
use LibreNMS\Snmptrap\Trap;
|
||||
use Log;
|
||||
|
||||
class AlechassisTrapsAlert implements SnmptrapHandler
|
||||
{
|
||||
@ -51,9 +50,9 @@ class AlechassisTrapsAlert implements SnmptrapHandler
|
||||
$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);
|
||||
$trap->log("$descr_aos6");
|
||||
} elseif (! empty($descr_aos7)) {
|
||||
Log::event("$descr_aos7", $device->device_id, 'trap', 2);
|
||||
$trap->log("$descr_aos7");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -33,7 +33,6 @@ namespace LibreNMS\Snmptrap\Handlers;
|
||||
use App\Models\Device;
|
||||
use LibreNMS\Interfaces\SnmptrapHandler;
|
||||
use LibreNMS\Snmptrap\Trap;
|
||||
use Log;
|
||||
|
||||
class Aos6CfgSavedTrap implements SnmptrapHandler
|
||||
{
|
||||
@ -48,6 +47,6 @@ class Aos6CfgSavedTrap implements SnmptrapHandler
|
||||
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);
|
||||
$trap->log("$descr");
|
||||
}
|
||||
}
|
||||
|
@ -33,7 +33,6 @@ namespace LibreNMS\Snmptrap\Handlers;
|
||||
use App\Models\Device;
|
||||
use LibreNMS\Interfaces\SnmptrapHandler;
|
||||
use LibreNMS\Snmptrap\Trap;
|
||||
use Log;
|
||||
|
||||
class Aos6DoSTrap implements SnmptrapHandler
|
||||
{
|
||||
@ -53,6 +52,6 @@ class Aos6DoSTrap implements SnmptrapHandler
|
||||
$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);
|
||||
$trap->log("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.");
|
||||
}
|
||||
}
|
||||
|
@ -33,7 +33,6 @@ namespace LibreNMS\Snmptrap\Handlers;
|
||||
use App\Models\Device;
|
||||
use LibreNMS\Interfaces\SnmptrapHandler;
|
||||
use LibreNMS\Snmptrap\Trap;
|
||||
use Log;
|
||||
|
||||
class Aos6HicServerTrap implements SnmptrapHandler
|
||||
{
|
||||
@ -48,6 +47,6 @@ class Aos6HicServerTrap implements SnmptrapHandler
|
||||
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);
|
||||
$trap->log("Radius server with the IP: $ip might be unreachable or recovered.");
|
||||
}
|
||||
}
|
||||
|
@ -33,7 +33,6 @@ namespace LibreNMS\Snmptrap\Handlers;
|
||||
use App\Models\Device;
|
||||
use LibreNMS\Interfaces\SnmptrapHandler;
|
||||
use LibreNMS\Snmptrap\Trap;
|
||||
use Log;
|
||||
|
||||
class Aos6LbdStateChangeForAutoRecovery implements SnmptrapHandler
|
||||
{
|
||||
@ -51,6 +50,6 @@ class Aos6LbdStateChangeForAutoRecovery implements SnmptrapHandler
|
||||
$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);
|
||||
$trap->log("Loopback detection has been recovered on the port $port->ifDescr. Status of the port before was $before and now is $current.", 1);
|
||||
}
|
||||
}
|
||||
|
@ -33,7 +33,6 @@ namespace LibreNMS\Snmptrap\Handlers;
|
||||
use App\Models\Device;
|
||||
use LibreNMS\Interfaces\SnmptrapHandler;
|
||||
use LibreNMS\Snmptrap\Trap;
|
||||
use Log;
|
||||
|
||||
class Aos6LbdStateChangeToShutdown implements SnmptrapHandler
|
||||
{
|
||||
@ -52,6 +51,6 @@ class Aos6LbdStateChangeToShutdown implements SnmptrapHandler
|
||||
$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);
|
||||
$trap->log("There has been a loop detected on the port $port->ifDescr. Status of the port before was $before and now is $current.", 5);
|
||||
}
|
||||
}
|
||||
|
@ -33,7 +33,6 @@ namespace LibreNMS\Snmptrap\Handlers;
|
||||
use App\Models\Device;
|
||||
use LibreNMS\Interfaces\SnmptrapHandler;
|
||||
use LibreNMS\Snmptrap\Trap;
|
||||
use Log;
|
||||
|
||||
class Aos6StackMgrDuplicateSlot implements SnmptrapHandler
|
||||
{
|
||||
@ -48,6 +47,6 @@ class Aos6StackMgrDuplicateSlot implements SnmptrapHandler
|
||||
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);
|
||||
$trap->log("Stack member $slot_nr is duplicated.", 5);
|
||||
}
|
||||
}
|
||||
|
@ -33,7 +33,6 @@ namespace LibreNMS\Snmptrap\Handlers;
|
||||
use App\Models\Device;
|
||||
use LibreNMS\Interfaces\SnmptrapHandler;
|
||||
use LibreNMS\Snmptrap\Trap;
|
||||
use Log;
|
||||
|
||||
class Aos6StackMgrRoleChange implements SnmptrapHandler
|
||||
{
|
||||
@ -49,6 +48,6 @@ class Aos6StackMgrRoleChange implements SnmptrapHandler
|
||||
{
|
||||
$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);
|
||||
$trap->log("Stack management change.Primary unit of the stack is now chassis: $p_nr. Secondary unit of the stack is now chassis: $s_nr.");
|
||||
}
|
||||
}
|
||||
|
@ -33,7 +33,6 @@ namespace LibreNMS\Snmptrap\Handlers;
|
||||
use App\Models\Device;
|
||||
use LibreNMS\Interfaces\SnmptrapHandler;
|
||||
use LibreNMS\Snmptrap\Trap;
|
||||
use Log;
|
||||
|
||||
class Aos7portViolation implements SnmptrapHandler
|
||||
{
|
||||
@ -52,6 +51,6 @@ class Aos7portViolation implements SnmptrapHandler
|
||||
$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);
|
||||
$trap->log("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.", 5);
|
||||
}
|
||||
}
|
||||
|
@ -33,7 +33,6 @@ namespace LibreNMS\Snmptrap\Handlers;
|
||||
use App\Models\Device;
|
||||
use LibreNMS\Interfaces\SnmptrapHandler;
|
||||
use LibreNMS\Snmptrap\Trap;
|
||||
use Log;
|
||||
|
||||
class Aos7portViolationNotification implements SnmptrapHandler
|
||||
{
|
||||
@ -51,6 +50,6 @@ class Aos7portViolationNotification implements SnmptrapHandler
|
||||
$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);
|
||||
$trap->log("There has been a loop detected on the port $port->ifDescr. The current status code is: $reason.", 5);
|
||||
}
|
||||
}
|
||||
|
@ -28,7 +28,6 @@ namespace LibreNMS\Snmptrap\Handlers;
|
||||
use App\Models\Device;
|
||||
use LibreNMS\Interfaces\SnmptrapHandler;
|
||||
use LibreNMS\Snmptrap\Trap;
|
||||
use Log;
|
||||
|
||||
class Aos7stpNewRoot implements SnmptrapHandler
|
||||
{
|
||||
@ -42,6 +41,6 @@ class Aos7stpNewRoot implements SnmptrapHandler
|
||||
*/
|
||||
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);
|
||||
$trap->log('SNMP Trap: Device ' . $device->displayName() . ' was elected as new root on one of its Spanning Tree Instances', 3, 'stp');
|
||||
}
|
||||
}
|
||||
|
@ -28,7 +28,6 @@ namespace LibreNMS\Snmptrap\Handlers;
|
||||
use App\Models\Device;
|
||||
use LibreNMS\Interfaces\SnmptrapHandler;
|
||||
use LibreNMS\Snmptrap\Trap;
|
||||
use Log;
|
||||
|
||||
class Aos7stpRootPortChange implements SnmptrapHandler
|
||||
{
|
||||
@ -42,6 +41,6 @@ class Aos7stpRootPortChange implements SnmptrapHandler
|
||||
*/
|
||||
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);
|
||||
$trap->log('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.', 3, 'stp');
|
||||
}
|
||||
}
|
||||
|
@ -29,7 +29,6 @@ namespace LibreNMS\Snmptrap\Handlers;
|
||||
use App\Models\Device;
|
||||
use LibreNMS\Interfaces\SnmptrapHandler;
|
||||
use LibreNMS\Snmptrap\Trap;
|
||||
use Log;
|
||||
|
||||
class ApcOnBattery implements SnmptrapHandler
|
||||
{
|
||||
@ -44,6 +43,6 @@ class ApcOnBattery implements SnmptrapHandler
|
||||
public function handle(Device $device, Trap $trap)
|
||||
{
|
||||
$message = $trap->getOidData($trap->findOid('PowerNet-MIB::mtrapargsString'));
|
||||
Log::event($message, $device->device_id, 'trap', 4);
|
||||
$trap->log($message, 4);
|
||||
}
|
||||
}
|
||||
|
@ -33,7 +33,6 @@ namespace LibreNMS\Snmptrap\Handlers;
|
||||
use App\Models\Device;
|
||||
use LibreNMS\Interfaces\SnmptrapHandler;
|
||||
use LibreNMS\Snmptrap\Trap;
|
||||
use Log;
|
||||
|
||||
class ApcPduNearOverload implements SnmptrapHandler
|
||||
{
|
||||
@ -51,6 +50,6 @@ class ApcPduNearOverload implements SnmptrapHandler
|
||||
$pdu_id = ApcTrapUtil::getPduIdentName($trap);
|
||||
$phase_num = ApcTrapUtil::getPduPhaseNum($trap);
|
||||
$alarm_str = ApcTrapUtil::getApcTrapString($trap);
|
||||
Log::event("$pdu_id phase $phase_num $alarm_str", $device->device_id, 'trap', 4);
|
||||
$trap->log("$pdu_id phase $phase_num $alarm_str", 4);
|
||||
}
|
||||
}
|
||||
|
@ -33,7 +33,6 @@ namespace LibreNMS\Snmptrap\Handlers;
|
||||
use App\Models\Device;
|
||||
use LibreNMS\Interfaces\SnmptrapHandler;
|
||||
use LibreNMS\Snmptrap\Trap;
|
||||
use Log;
|
||||
|
||||
class ApcPduNearOverloadCleared implements SnmptrapHandler
|
||||
{
|
||||
@ -51,6 +50,6 @@ class ApcPduNearOverloadCleared implements SnmptrapHandler
|
||||
$pdu_id = ApcTrapUtil::getPduIdentName($trap);
|
||||
$phase_num = ApcTrapUtil::getPduPhaseNum($trap);
|
||||
$alarm_str = ApcTrapUtil::getApcTrapString($trap);
|
||||
Log::event("$pdu_id phase $phase_num $alarm_str", $device->device_id, 'trap', 1);
|
||||
$trap->log("$pdu_id phase $phase_num $alarm_str", 1);
|
||||
}
|
||||
}
|
||||
|
@ -25,7 +25,6 @@ namespace LibreNMS\Snmptrap\Handlers;
|
||||
use App\Models\Device;
|
||||
use LibreNMS\Interfaces\SnmptrapHandler;
|
||||
use LibreNMS\Snmptrap\Trap;
|
||||
use Log;
|
||||
|
||||
class ApcPduOutletOff implements SnmptrapHandler
|
||||
{
|
||||
@ -40,6 +39,6 @@ class ApcPduOutletOff implements SnmptrapHandler
|
||||
public function handle(Device $device, Trap $trap)
|
||||
{
|
||||
$outlet = $trap->getOidData($trap->findOid('PowerNet-MIB::mtrapargsInteger.0'));
|
||||
Log::event("APC PDU: Outlet has turned off: $outlet", $device->device_id, 'trap', 4);
|
||||
$trap->log("APC PDU: Outlet has turned off: $outlet", 4);
|
||||
}
|
||||
}
|
||||
|
@ -25,7 +25,6 @@ namespace LibreNMS\Snmptrap\Handlers;
|
||||
use App\Models\Device;
|
||||
use LibreNMS\Interfaces\SnmptrapHandler;
|
||||
use LibreNMS\Snmptrap\Trap;
|
||||
use Log;
|
||||
|
||||
class ApcPduOutletOn implements SnmptrapHandler
|
||||
{
|
||||
@ -40,6 +39,6 @@ class ApcPduOutletOn implements SnmptrapHandler
|
||||
public function handle(Device $device, Trap $trap)
|
||||
{
|
||||
$outlet = $trap->getOidData($trap->findOid('PowerNet-MIB::mtrapargsInteger.0'));
|
||||
Log::event("APC PDU: Outlet has been turned on: $outlet", $device->device_id, 'trap', 4);
|
||||
$trap->log("APC PDU: Outlet has been turned on: $outlet", 4);
|
||||
}
|
||||
}
|
||||
|
@ -25,7 +25,6 @@ namespace LibreNMS\Snmptrap\Handlers;
|
||||
use App\Models\Device;
|
||||
use LibreNMS\Interfaces\SnmptrapHandler;
|
||||
use LibreNMS\Snmptrap\Trap;
|
||||
use Log;
|
||||
|
||||
class ApcPduOutletReboot implements SnmptrapHandler
|
||||
{
|
||||
@ -40,6 +39,6 @@ class ApcPduOutletReboot implements SnmptrapHandler
|
||||
public function handle(Device $device, Trap $trap)
|
||||
{
|
||||
$outlet = $trap->getOidData($trap->findOid('PowerNet-MIB::mtrapargsInteger.0'));
|
||||
Log::event("APC PDU: Outlet has rebooted: $outlet", $device->device_id, 'trap', 4);
|
||||
$trap->log("APC PDU: Outlet has rebooted: $outlet", 4);
|
||||
}
|
||||
}
|
||||
|
@ -33,7 +33,6 @@ namespace LibreNMS\Snmptrap\Handlers;
|
||||
use App\Models\Device;
|
||||
use LibreNMS\Interfaces\SnmptrapHandler;
|
||||
use LibreNMS\Snmptrap\Trap;
|
||||
use Log;
|
||||
|
||||
class ApcPduOverload implements SnmptrapHandler
|
||||
{
|
||||
@ -51,6 +50,6 @@ class ApcPduOverload implements SnmptrapHandler
|
||||
$pdu_id = ApcTrapUtil::getPduIdentName($trap);
|
||||
$phase_num = ApcTrapUtil::getPduPhaseNum($trap);
|
||||
$alarm_str = ApcTrapUtil::getApcTrapString($trap);
|
||||
Log::event("$pdu_id phase $phase_num $alarm_str", $device->device_id, 'trap', 5);
|
||||
$trap->log("$pdu_id phase $phase_num $alarm_str", 5);
|
||||
}
|
||||
}
|
||||
|
@ -33,7 +33,6 @@ namespace LibreNMS\Snmptrap\Handlers;
|
||||
use App\Models\Device;
|
||||
use LibreNMS\Interfaces\SnmptrapHandler;
|
||||
use LibreNMS\Snmptrap\Trap;
|
||||
use Log;
|
||||
|
||||
class ApcPduOverloadCleared implements SnmptrapHandler
|
||||
{
|
||||
@ -51,6 +50,6 @@ class ApcPduOverloadCleared implements SnmptrapHandler
|
||||
$pdu_id = ApcTrapUtil::getPduIdentName($trap);
|
||||
$phase_num = ApcTrapUtil::getPduPhaseNum($trap);
|
||||
$alarm_str = ApcTrapUtil::getApcTrapString($trap);
|
||||
Log::event("$pdu_id phase $phase_num $alarm_str", $device->device_id, 'trap', 1);
|
||||
$trap->log("$pdu_id phase $phase_num $alarm_str", 1);
|
||||
}
|
||||
}
|
||||
|
@ -29,7 +29,6 @@ namespace LibreNMS\Snmptrap\Handlers;
|
||||
use App\Models\Device;
|
||||
use LibreNMS\Interfaces\SnmptrapHandler;
|
||||
use LibreNMS\Snmptrap\Trap;
|
||||
use Log;
|
||||
|
||||
class ApcPowerRestored implements SnmptrapHandler
|
||||
{
|
||||
@ -44,6 +43,6 @@ class ApcPowerRestored implements SnmptrapHandler
|
||||
public function handle(Device $device, Trap $trap)
|
||||
{
|
||||
$message = $trap->getOidData($trap->findOid('PowerNet-MIB::mtrapargsString'));
|
||||
Log::event($message, $device->device_id, 'trap', 1);
|
||||
$trap->log($message, 1);
|
||||
}
|
||||
}
|
||||
|
@ -29,7 +29,6 @@ namespace LibreNMS\Snmptrap\Handlers;
|
||||
use App\Models\Device;
|
||||
use LibreNMS\Interfaces\SnmptrapHandler;
|
||||
use LibreNMS\Snmptrap\Trap;
|
||||
use Log;
|
||||
|
||||
class ApcSmartAvrReducing implements SnmptrapHandler
|
||||
{
|
||||
@ -44,6 +43,6 @@ class ApcSmartAvrReducing implements SnmptrapHandler
|
||||
public function handle(Device $device, Trap $trap)
|
||||
{
|
||||
$message = $trap->getOidData($trap->findOid('PowerNet-MIB::mtrapargsString'));
|
||||
Log::event($message, $device->device_id, 'trap', 3);
|
||||
$trap->log($message, 3);
|
||||
}
|
||||
}
|
||||
|
@ -29,7 +29,6 @@ namespace LibreNMS\Snmptrap\Handlers;
|
||||
use App\Models\Device;
|
||||
use LibreNMS\Interfaces\SnmptrapHandler;
|
||||
use LibreNMS\Snmptrap\Trap;
|
||||
use Log;
|
||||
|
||||
class ApcSmartAvrReducingOff implements SnmptrapHandler
|
||||
{
|
||||
@ -44,6 +43,6 @@ class ApcSmartAvrReducingOff implements SnmptrapHandler
|
||||
public function handle(Device $device, Trap $trap)
|
||||
{
|
||||
$message = $trap->getOidData($trap->findOid('PowerNet-MIB::mtrapargsString'));
|
||||
Log::event($message, $device->device_id, 'trap', 1);
|
||||
$trap->log($message, 1);
|
||||
}
|
||||
}
|
||||
|
@ -28,7 +28,6 @@ namespace LibreNMS\Snmptrap\Handlers;
|
||||
use App\Models\Device;
|
||||
use LibreNMS\Interfaces\SnmptrapHandler;
|
||||
use LibreNMS\Snmptrap\Trap;
|
||||
use Log;
|
||||
|
||||
class AuthenticationFailure implements SnmptrapHandler
|
||||
{
|
||||
@ -42,6 +41,6 @@ class AuthenticationFailure implements SnmptrapHandler
|
||||
*/
|
||||
public function handle(Device $device, Trap $trap)
|
||||
{
|
||||
Log::event('SNMP Trap: Authentication Failure: ' . $device->displayName(), $device->device_id, 'auth', 3);
|
||||
$trap->log('SNMP Trap: Authentication Failure: ' . $device->displayName(), 3, 'auth');
|
||||
}
|
||||
}
|
||||
|
@ -56,7 +56,7 @@ class BgpBackwardTransition implements SnmptrapHandler
|
||||
$bgpPeer->bgpPeerState = $trap->getOidData($state_oid);
|
||||
|
||||
if ($bgpPeer->isDirty('bgpPeerState')) {
|
||||
\Log::event('SNMP Trap: BGP Down ' . $bgpPeer->bgpPeerIdentifier . ' ' . get_astext($bgpPeer->bgpPeerRemoteAs) . ' is now ' . $bgpPeer->bgpPeerState, $device->device_id, 'bgpPeer', 5, $bgpPeerIp);
|
||||
$trap->log('SNMP Trap: BGP Down ' . $bgpPeer->bgpPeerIdentifier . ' ' . get_astext($bgpPeer->bgpPeerRemoteAs) . ' is now ' . $bgpPeer->bgpPeerState, 5, 'bgpPeer', $bgpPeerIp);
|
||||
}
|
||||
|
||||
$bgpPeer->save();
|
||||
|
@ -56,7 +56,7 @@ class BgpEstablished implements SnmptrapHandler
|
||||
$bgpPeer->bgpPeerState = $trap->getOidData($state_oid);
|
||||
|
||||
if ($bgpPeer->isDirty('bgpPeerState')) {
|
||||
Log::event('SNMP Trap: BGP Up ' . $bgpPeer->bgpPeerIdentifier . ' ' . get_astext($bgpPeer->bgpPeerRemoteAs) . ' is now ' . $bgpPeer->bgpPeerState, $device->device_id, 'bgpPeer', 1, $bgpPeerIp);
|
||||
$trap->log('SNMP Trap: BGP Up ' . $bgpPeer->bgpPeerIdentifier . ' ' . get_astext($bgpPeer->bgpPeerRemoteAs) . ' is now ' . $bgpPeer->bgpPeerState, 1, 'bgpPeer', $bgpPeerIp);
|
||||
}
|
||||
|
||||
$bgpPeer->save();
|
||||
|
@ -25,7 +25,6 @@ namespace LibreNMS\Snmptrap\Handlers;
|
||||
use App\Models\Device;
|
||||
use LibreNMS\Interfaces\SnmptrapHandler;
|
||||
use LibreNMS\Snmptrap\Trap;
|
||||
use Log;
|
||||
|
||||
class BridgeNewRoot implements SnmptrapHandler
|
||||
{
|
||||
@ -39,6 +38,6 @@ class BridgeNewRoot implements SnmptrapHandler
|
||||
*/
|
||||
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);
|
||||
$trap->log('SNMP Trap: Device ' . $device->displayName() . ' was elected as new root on one of its Spanning Tree Instances', 3, 'stp');
|
||||
}
|
||||
}
|
||||
|
@ -25,7 +25,6 @@ namespace LibreNMS\Snmptrap\Handlers;
|
||||
use App\Models\Device;
|
||||
use LibreNMS\Interfaces\SnmptrapHandler;
|
||||
use LibreNMS\Snmptrap\Trap;
|
||||
use Log;
|
||||
|
||||
class BridgeTopologyChanged implements SnmptrapHandler
|
||||
{
|
||||
@ -39,6 +38,6 @@ class BridgeTopologyChanged implements SnmptrapHandler
|
||||
*/
|
||||
public function handle(Device $device, Trap $trap)
|
||||
{
|
||||
Log::event('SNMP Trap: Topology of Spanning Tree Instance on device ' . $device->displayName() . ' was changed', $device->device_id, 'stp', 3);
|
||||
$trap->log('SNMP Trap: Topology of Spanning Tree Instance on device ' . $device->displayName() . ' was changed', 3, 'stp');
|
||||
}
|
||||
}
|
||||
|
@ -28,7 +28,6 @@ namespace LibreNMS\Snmptrap\Handlers;
|
||||
use App\Models\Device;
|
||||
use LibreNMS\Interfaces\SnmptrapHandler;
|
||||
use LibreNMS\Snmptrap\Trap;
|
||||
use Log;
|
||||
|
||||
class CiscoErrDisableInterfaceEvent implements SnmptrapHandler
|
||||
{
|
||||
@ -48,10 +47,10 @@ class CiscoErrDisableInterfaceEvent implements SnmptrapHandler
|
||||
$cause = $trap->getOidData($trap->findOid('CISCO-ERR-DISABLE-MIB::cErrDisableIfStatusCause.' . $ifIndex[1] . '.0'));
|
||||
|
||||
if (! $port) {
|
||||
Log::event('SNMP TRAP: ' . $cause . ' error detected on unknown port. Either ifIndex is not found in the trap, or it does not match a port on this device.', $device->device_id, 'trap', 4);
|
||||
$trap->log('SNMP TRAP: ' . $cause . ' error detected on unknown port. Either ifIndex is not found in the trap, or it does not match a port on this device.', 4);
|
||||
|
||||
return;
|
||||
}
|
||||
Log::event('SNMP TRAP: ' . $cause . ' error detected on ' . $port->ifName . ' (Description: ' . $port->ifDescr . '). ' . $port->ifName . ' in err-disable state.', $device->device_id, 'trap', 4);
|
||||
$trap->log('SNMP TRAP: ' . $cause . ' error detected on ' . $port->ifName . ' (Description: ' . $port->ifDescr . '). ' . $port->ifName . ' in err-disable state.', 4);
|
||||
}
|
||||
}
|
||||
|
@ -28,7 +28,6 @@ namespace LibreNMS\Snmptrap\Handlers;
|
||||
use App\Models\Device;
|
||||
use LibreNMS\Interfaces\SnmptrapHandler;
|
||||
use LibreNMS\Snmptrap\Trap;
|
||||
use Log;
|
||||
|
||||
class CiscoMacViolation implements SnmptrapHandler
|
||||
{
|
||||
@ -45,6 +44,6 @@ class CiscoMacViolation implements SnmptrapHandler
|
||||
$ifName = $trap->getOidData($trap->findOid('IF-MIB::ifName'));
|
||||
$mac = $trap->getOidData($trap->findOid('CISCO-PORT-SECURITY-MIB::cpsIfSecureLastMacAddress'));
|
||||
|
||||
Log::event("SNMP Trap: Secure MAC Address Violation on port $ifName. Last MAC address: $mac", $device->device_id, 'trap', 4);
|
||||
$trap->log("SNMP Trap: Secure MAC Address Violation on port $ifName. Last MAC address: $mac", 4);
|
||||
}
|
||||
}
|
||||
|
@ -25,7 +25,6 @@ namespace LibreNMS\Snmptrap\Handlers;
|
||||
use App\Models\Device;
|
||||
use LibreNMS\Interfaces\SnmptrapHandler;
|
||||
use LibreNMS\Snmptrap\Trap;
|
||||
use Log;
|
||||
|
||||
class ColdBoot implements SnmptrapHandler
|
||||
{
|
||||
@ -39,6 +38,6 @@ class ColdBoot implements SnmptrapHandler
|
||||
*/
|
||||
public function handle(Device $device, Trap $trap)
|
||||
{
|
||||
Log::event('SNMP Trap: Device ' . $device->displayName() . ' cold booted', $device->device_id, 'reboot', 4);
|
||||
$trap->log('SNMP Trap: Device ' . $device->displayName() . ' cold booted', 4, 'reboot');
|
||||
}
|
||||
}
|
||||
|
@ -30,7 +30,6 @@ namespace LibreNMS\Snmptrap\Handlers;
|
||||
use App\Models\Device;
|
||||
use LibreNMS\Interfaces\SnmptrapHandler;
|
||||
use LibreNMS\Snmptrap\Trap;
|
||||
use Log;
|
||||
|
||||
class CpLowBattery implements SnmptrapHandler
|
||||
{
|
||||
@ -45,6 +44,6 @@ class CpLowBattery implements SnmptrapHandler
|
||||
public function handle(Device $device, Trap $trap)
|
||||
{
|
||||
$battery = CyberPowerUtil::getMessage($trap);
|
||||
Log::event("$battery", $device->device_id, 'trap', 4);
|
||||
$trap->log("$battery", 4);
|
||||
}
|
||||
}
|
||||
|
@ -30,7 +30,6 @@ namespace LibreNMS\Snmptrap\Handlers;
|
||||
use App\Models\Device;
|
||||
use LibreNMS\Interfaces\SnmptrapHandler;
|
||||
use LibreNMS\Snmptrap\Trap;
|
||||
use Log;
|
||||
|
||||
class CpPowerRestored implements SnmptrapHandler
|
||||
{
|
||||
@ -45,6 +44,6 @@ class CpPowerRestored implements SnmptrapHandler
|
||||
public function handle(Device $device, Trap $trap)
|
||||
{
|
||||
$power = CyberPowerUtil::getMessage($trap);
|
||||
Log::event("$power", $device->device_id, 'trap', 1);
|
||||
$trap->log("$power", 1);
|
||||
}
|
||||
}
|
||||
|
@ -30,7 +30,6 @@ namespace LibreNMS\Snmptrap\Handlers;
|
||||
use App\Models\Device;
|
||||
use LibreNMS\Interfaces\SnmptrapHandler;
|
||||
use LibreNMS\Snmptrap\Trap;
|
||||
use Log;
|
||||
|
||||
class CpRtnDischarge implements SnmptrapHandler
|
||||
{
|
||||
@ -45,6 +44,6 @@ class CpRtnDischarge implements SnmptrapHandler
|
||||
public function handle(Device $device, Trap $trap)
|
||||
{
|
||||
$returnInfo = CyberPowerUtil::getMessage($trap);
|
||||
Log::event("$returnInfo", $device->device_id, 'trap', 1);
|
||||
$trap->log("$returnInfo", 1);
|
||||
}
|
||||
}
|
||||
|
@ -30,7 +30,6 @@ namespace LibreNMS\Snmptrap\Handlers;
|
||||
use App\Models\Device;
|
||||
use LibreNMS\Interfaces\SnmptrapHandler;
|
||||
use LibreNMS\Snmptrap\Trap;
|
||||
use Log;
|
||||
|
||||
class CpRtnLowBattery implements SnmptrapHandler
|
||||
{
|
||||
@ -45,6 +44,6 @@ class CpRtnLowBattery implements SnmptrapHandler
|
||||
public function handle(Device $device, Trap $trap)
|
||||
{
|
||||
$battery = CyberPowerUtil::getMessage($trap);
|
||||
Log::event("$battery", $device->device_id, 'trap', 1);
|
||||
$trap->log("$battery", 1);
|
||||
}
|
||||
}
|
||||
|
@ -30,7 +30,6 @@ namespace LibreNMS\Snmptrap\Handlers;
|
||||
use App\Models\Device;
|
||||
use LibreNMS\Interfaces\SnmptrapHandler;
|
||||
use LibreNMS\Snmptrap\Trap;
|
||||
use Log;
|
||||
|
||||
class CpUpsBatteryNotPresent implements SnmptrapHandler
|
||||
{
|
||||
@ -45,6 +44,6 @@ class CpUpsBatteryNotPresent implements SnmptrapHandler
|
||||
public function handle(Device $device, Trap $trap)
|
||||
{
|
||||
$status = CyberPowerUtil::getMessage($trap);
|
||||
Log::event("$status", $device->device_id, 'trap', 2);
|
||||
$trap->log("$status");
|
||||
}
|
||||
}
|
||||
|
@ -30,7 +30,6 @@ namespace LibreNMS\Snmptrap\Handlers;
|
||||
use App\Models\Device;
|
||||
use LibreNMS\Interfaces\SnmptrapHandler;
|
||||
use LibreNMS\Snmptrap\Trap;
|
||||
use Log;
|
||||
|
||||
class CpUpsChargerFailure implements SnmptrapHandler
|
||||
{
|
||||
@ -45,6 +44,6 @@ class CpUpsChargerFailure implements SnmptrapHandler
|
||||
public function handle(Device $device, Trap $trap)
|
||||
{
|
||||
$chargeInfo = CyberPowerUtil::getMessage($trap);
|
||||
Log::event("$chargeInfo", $device->device_id, 'trap', 4);
|
||||
$trap->log("$chargeInfo", 4);
|
||||
}
|
||||
}
|
||||
|
@ -30,7 +30,6 @@ namespace LibreNMS\Snmptrap\Handlers;
|
||||
use App\Models\Device;
|
||||
use LibreNMS\Interfaces\SnmptrapHandler;
|
||||
use LibreNMS\Snmptrap\Trap;
|
||||
use Log;
|
||||
|
||||
class CpUpsDiagFailed implements SnmptrapHandler
|
||||
{
|
||||
@ -45,6 +44,6 @@ class CpUpsDiagFailed implements SnmptrapHandler
|
||||
public function handle(Device $device, Trap $trap)
|
||||
{
|
||||
$diagInfo = CyberPowerUtil::getMessage($trap);
|
||||
Log::event("$diagInfo", $device->device_id, 'trap', 5);
|
||||
$trap->log("$diagInfo", 5);
|
||||
}
|
||||
}
|
||||
|
@ -30,7 +30,6 @@ namespace LibreNMS\Snmptrap\Handlers;
|
||||
use App\Models\Device;
|
||||
use LibreNMS\Interfaces\SnmptrapHandler;
|
||||
use LibreNMS\Snmptrap\Trap;
|
||||
use Log;
|
||||
|
||||
class CpUpsDiagPassed implements SnmptrapHandler
|
||||
{
|
||||
@ -45,6 +44,6 @@ class CpUpsDiagPassed implements SnmptrapHandler
|
||||
public function handle(Device $device, Trap $trap)
|
||||
{
|
||||
$diagInfo = CyberPowerUtil::getMessage($trap);
|
||||
Log::event("$diagInfo", $device->device_id, 'trap', 2);
|
||||
$trap->log("$diagInfo");
|
||||
}
|
||||
}
|
||||
|
@ -30,7 +30,6 @@ namespace LibreNMS\Snmptrap\Handlers;
|
||||
use App\Models\Device;
|
||||
use LibreNMS\Interfaces\SnmptrapHandler;
|
||||
use LibreNMS\Snmptrap\Trap;
|
||||
use Log;
|
||||
|
||||
class CpUpsDischarged implements SnmptrapHandler
|
||||
{
|
||||
@ -45,6 +44,6 @@ class CpUpsDischarged implements SnmptrapHandler
|
||||
public function handle(Device $device, Trap $trap)
|
||||
{
|
||||
$dischargeInfo = CyberPowerUtil::getMessage($trap);
|
||||
Log::event("$dischargeInfo", $device->device_id, 'trap', 2);
|
||||
$trap->log("$dischargeInfo");
|
||||
}
|
||||
}
|
||||
|
@ -30,7 +30,6 @@ namespace LibreNMS\Snmptrap\Handlers;
|
||||
use App\Models\Device;
|
||||
use LibreNMS\Interfaces\SnmptrapHandler;
|
||||
use LibreNMS\Snmptrap\Trap;
|
||||
use Log;
|
||||
|
||||
class CpUpsOnBattery implements SnmptrapHandler
|
||||
{
|
||||
@ -45,6 +44,6 @@ class CpUpsOnBattery implements SnmptrapHandler
|
||||
public function handle(Device $device, Trap $trap)
|
||||
{
|
||||
$battery = CyberPowerUtil::getMessage($trap);
|
||||
Log::event("$battery", $device->device_id, 'trap', 4);
|
||||
$trap->log("$battery", 4);
|
||||
}
|
||||
}
|
||||
|
@ -30,7 +30,6 @@ namespace LibreNMS\Snmptrap\Handlers;
|
||||
use App\Models\Device;
|
||||
use LibreNMS\Interfaces\SnmptrapHandler;
|
||||
use LibreNMS\Snmptrap\Trap;
|
||||
use Log;
|
||||
|
||||
class CpUpsOverTemp implements SnmptrapHandler
|
||||
{
|
||||
@ -45,6 +44,6 @@ class CpUpsOverTemp implements SnmptrapHandler
|
||||
public function handle(Device $device, Trap $trap)
|
||||
{
|
||||
$temp = CyberPowerUtil::getMessage($trap);
|
||||
Log::event("$temp", $device->device_id, 'trap', 5);
|
||||
$trap->log("$temp", 5);
|
||||
}
|
||||
}
|
||||
|
@ -30,7 +30,6 @@ namespace LibreNMS\Snmptrap\Handlers;
|
||||
use App\Models\Device;
|
||||
use LibreNMS\Interfaces\SnmptrapHandler;
|
||||
use LibreNMS\Snmptrap\Trap;
|
||||
use Log;
|
||||
|
||||
class CpUpsOverload implements SnmptrapHandler
|
||||
{
|
||||
@ -45,6 +44,6 @@ class CpUpsOverload implements SnmptrapHandler
|
||||
public function handle(Device $device, Trap $trap)
|
||||
{
|
||||
$overload = CyberPowerUtil::getMessage($trap);
|
||||
Log::event("$overload", $device->device_id, 'trap', 5);
|
||||
$trap->log("$overload", 5);
|
||||
}
|
||||
}
|
||||
|
@ -30,7 +30,6 @@ namespace LibreNMS\Snmptrap\Handlers;
|
||||
use App\Models\Device;
|
||||
use LibreNMS\Interfaces\SnmptrapHandler;
|
||||
use LibreNMS\Snmptrap\Trap;
|
||||
use Log;
|
||||
|
||||
class CpUpsRebootStarted implements SnmptrapHandler
|
||||
{
|
||||
@ -45,6 +44,6 @@ class CpUpsRebootStarted implements SnmptrapHandler
|
||||
public function handle(Device $device, Trap $trap)
|
||||
{
|
||||
$status = CyberPowerUtil::getMessage($trap);
|
||||
Log::event("$status", $device->device_id, 'trap', 4);
|
||||
$trap->log("$status", 4);
|
||||
}
|
||||
}
|
||||
|
@ -30,7 +30,6 @@ namespace LibreNMS\Snmptrap\Handlers;
|
||||
use App\Models\Device;
|
||||
use LibreNMS\Interfaces\SnmptrapHandler;
|
||||
use LibreNMS\Snmptrap\Trap;
|
||||
use Log;
|
||||
|
||||
class CpUpsRtnChargerFailure implements SnmptrapHandler
|
||||
{
|
||||
@ -45,6 +44,6 @@ class CpUpsRtnChargerFailure implements SnmptrapHandler
|
||||
public function handle(Device $device, Trap $trap)
|
||||
{
|
||||
$chargeInfo = CyberPowerUtil::getMessage($trap);
|
||||
Log::event("$chargeInfo", $device->device_id, 'trap', 1);
|
||||
$trap->log("$chargeInfo", 1);
|
||||
}
|
||||
}
|
||||
|
@ -30,7 +30,6 @@ namespace LibreNMS\Snmptrap\Handlers;
|
||||
use App\Models\Device;
|
||||
use LibreNMS\Interfaces\SnmptrapHandler;
|
||||
use LibreNMS\Snmptrap\Trap;
|
||||
use Log;
|
||||
|
||||
class CpUpsRtnDischarged implements SnmptrapHandler
|
||||
{
|
||||
@ -45,6 +44,6 @@ class CpUpsRtnDischarged implements SnmptrapHandler
|
||||
public function handle(Device $device, Trap $trap)
|
||||
{
|
||||
$dischargeInfo = CyberPowerUtil::getMessage($trap);
|
||||
Log::event("$dischargeInfo", $device->device_id, 'trap', 2);
|
||||
$trap->log("$dischargeInfo");
|
||||
}
|
||||
}
|
||||
|
@ -30,7 +30,6 @@ namespace LibreNMS\Snmptrap\Handlers;
|
||||
use App\Models\Device;
|
||||
use LibreNMS\Interfaces\SnmptrapHandler;
|
||||
use LibreNMS\Snmptrap\Trap;
|
||||
use Log;
|
||||
|
||||
class CpUpsRtnOverTemp implements SnmptrapHandler
|
||||
{
|
||||
@ -45,6 +44,6 @@ class CpUpsRtnOverTemp implements SnmptrapHandler
|
||||
public function handle(Device $device, Trap $trap)
|
||||
{
|
||||
$temp = CyberPowerUtil::getMessage($trap);
|
||||
Log::event("$temp", $device->device_id, 'trap', 1);
|
||||
$trap->log("$temp", 1);
|
||||
}
|
||||
}
|
||||
|
@ -30,7 +30,6 @@ namespace LibreNMS\Snmptrap\Handlers;
|
||||
use App\Models\Device;
|
||||
use LibreNMS\Interfaces\SnmptrapHandler;
|
||||
use LibreNMS\Snmptrap\Trap;
|
||||
use Log;
|
||||
|
||||
class CpUpsRtnOverload implements SnmptrapHandler
|
||||
{
|
||||
@ -45,6 +44,6 @@ class CpUpsRtnOverload implements SnmptrapHandler
|
||||
public function handle(Device $device, Trap $trap)
|
||||
{
|
||||
$overload = CyberPowerUtil::getMessage($trap);
|
||||
Log::event("$overload", $device->device_id, 'trap', 1);
|
||||
$trap->log("$overload", 1);
|
||||
}
|
||||
}
|
||||
|
@ -30,7 +30,6 @@ namespace LibreNMS\Snmptrap\Handlers;
|
||||
use App\Models\Device;
|
||||
use LibreNMS\Interfaces\SnmptrapHandler;
|
||||
use LibreNMS\Snmptrap\Trap;
|
||||
use Log;
|
||||
|
||||
class CpUpsSleeping implements SnmptrapHandler
|
||||
{
|
||||
@ -45,6 +44,6 @@ class CpUpsSleeping implements SnmptrapHandler
|
||||
public function handle(Device $device, Trap $trap)
|
||||
{
|
||||
$status = CyberPowerUtil::getMessage($trap);
|
||||
Log::event("$status", $device->device_id, 'trap', 4);
|
||||
$trap->log("$status", 4);
|
||||
}
|
||||
}
|
||||
|
@ -30,7 +30,6 @@ namespace LibreNMS\Snmptrap\Handlers;
|
||||
use App\Models\Device;
|
||||
use LibreNMS\Interfaces\SnmptrapHandler;
|
||||
use LibreNMS\Snmptrap\Trap;
|
||||
use Log;
|
||||
|
||||
class CpUpsStartBatteryTest implements SnmptrapHandler
|
||||
{
|
||||
@ -45,6 +44,6 @@ class CpUpsStartBatteryTest implements SnmptrapHandler
|
||||
public function handle(Device $device, Trap $trap)
|
||||
{
|
||||
$battTestInfo = CyberPowerUtil::getMessage($trap);
|
||||
Log::event("$battTestInfo", $device->device_id, 'trap', 2);
|
||||
$trap->log("$battTestInfo");
|
||||
}
|
||||
}
|
||||
|
@ -30,7 +30,6 @@ namespace LibreNMS\Snmptrap\Handlers;
|
||||
use App\Models\Device;
|
||||
use LibreNMS\Interfaces\SnmptrapHandler;
|
||||
use LibreNMS\Snmptrap\Trap;
|
||||
use Log;
|
||||
|
||||
class CpUpsTurnedOff implements SnmptrapHandler
|
||||
{
|
||||
@ -45,6 +44,6 @@ class CpUpsTurnedOff implements SnmptrapHandler
|
||||
public function handle(Device $device, Trap $trap)
|
||||
{
|
||||
$status = CyberPowerUtil::getMessage($trap);
|
||||
Log::event("$status", $device->device_id, 'trap', 4);
|
||||
$trap->log("$status", 4);
|
||||
}
|
||||
}
|
||||
|
@ -30,7 +30,6 @@ namespace LibreNMS\Snmptrap\Handlers;
|
||||
use App\Models\Device;
|
||||
use LibreNMS\Interfaces\SnmptrapHandler;
|
||||
use LibreNMS\Snmptrap\Trap;
|
||||
use Log;
|
||||
|
||||
class CpUpsWokeUp implements SnmptrapHandler
|
||||
{
|
||||
@ -45,6 +44,6 @@ class CpUpsWokeUp implements SnmptrapHandler
|
||||
public function handle(Device $device, Trap $trap)
|
||||
{
|
||||
$status = CyberPowerUtil::getMessage($trap);
|
||||
Log::event("$status", $device->device_id, 'trap', 1);
|
||||
$trap->log("$status", 1);
|
||||
}
|
||||
}
|
||||
|
@ -25,7 +25,6 @@ namespace LibreNMS\Snmptrap\Handlers;
|
||||
use App\Models\Device;
|
||||
use LibreNMS\Interfaces\SnmptrapHandler;
|
||||
use LibreNMS\Snmptrap\Trap;
|
||||
use Log;
|
||||
|
||||
class EntityDatabaseConfigChanged implements SnmptrapHandler
|
||||
{
|
||||
@ -39,6 +38,6 @@ class EntityDatabaseConfigChanged implements SnmptrapHandler
|
||||
*/
|
||||
public function handle(Device $device, Trap $trap)
|
||||
{
|
||||
Log::event('SNMP Trap: Configuration of Entity Database on device ' . $device->displayName() . ' was changed', $device->device_id, 'system', 3);
|
||||
$trap->log('SNMP Trap: Configuration of Entity Database on device ' . $device->displayName() . ' was changed', 3, 'system');
|
||||
}
|
||||
}
|
||||
|
@ -28,7 +28,6 @@ namespace LibreNMS\Snmptrap\Handlers;
|
||||
use App\Models\Device;
|
||||
use LibreNMS\Interfaces\SnmptrapHandler;
|
||||
use LibreNMS\Snmptrap\Trap;
|
||||
use Log;
|
||||
|
||||
class EquipStatusTrap implements SnmptrapHandler
|
||||
{
|
||||
@ -40,29 +39,22 @@ class EquipStatusTrap implements SnmptrapHandler
|
||||
* @param Trap $trap
|
||||
* @return void
|
||||
*/
|
||||
public function handle(Device $device, Trap $trap)
|
||||
public function handle(Device $device, Trap $trap): void
|
||||
{
|
||||
$state = $trap->getOidData('EQUIPMENT-MIB::equipStatus.0');
|
||||
|
||||
$severity = $this->getSeverity($state);
|
||||
Log::event('SNMP Trap: Equipment Status ' . $state, $device->device_id, 'state', $severity);
|
||||
$trap->log('SNMP Trap: Equipment Status ' . $state, $severity, 'state');
|
||||
}
|
||||
|
||||
private function getSeverity($state)
|
||||
private function getSeverity(string $state): int
|
||||
{
|
||||
$severity_map = [
|
||||
'warning' => 4,
|
||||
'major' => 4,
|
||||
'5' => 4,
|
||||
'3' => 4,
|
||||
'critical' => 5,
|
||||
'4' => 5,
|
||||
'minor' => 3,
|
||||
'2' => 3,
|
||||
'nonAlarmed' => 1,
|
||||
'1' => 1,
|
||||
];
|
||||
|
||||
return $severity_map[$state] ?? 0;
|
||||
return match ($state) {
|
||||
'warning', '3', 'major', '5' => 4,
|
||||
'critical', '4' => 5,
|
||||
'minor', '2' => 3,
|
||||
'nonAlarmed', '1' => 1,
|
||||
default => 0,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@ -25,7 +25,6 @@ namespace LibreNMS\Snmptrap\Handlers;
|
||||
use App\Models\Device;
|
||||
use LibreNMS\Interfaces\SnmptrapHandler;
|
||||
use LibreNMS\Snmptrap\Trap;
|
||||
use Log;
|
||||
|
||||
class FailedUserLogin implements SnmptrapHandler
|
||||
{
|
||||
@ -39,6 +38,6 @@ class FailedUserLogin implements SnmptrapHandler
|
||||
*/
|
||||
public function handle(Device $device, Trap $trap)
|
||||
{
|
||||
Log::event('SNMP Trap: Failed User Login: ' . $device->displayName(), $device->device_id, 'auth', 4);
|
||||
$trap->log('SNMP Trap: Failed User Login: ' . $device->displayName(), 4, 'auth');
|
||||
}
|
||||
}
|
||||
|
@ -31,7 +31,6 @@ namespace LibreNMS\Snmptrap\Handlers;
|
||||
use App\Models\Device;
|
||||
use LibreNMS\Interfaces\SnmptrapHandler;
|
||||
use LibreNMS\Snmptrap\Trap;
|
||||
use Log;
|
||||
|
||||
class FgTrapAvOversize implements SnmptrapHandler
|
||||
{
|
||||
@ -45,6 +44,6 @@ class FgTrapAvOversize implements SnmptrapHandler
|
||||
*/
|
||||
public function handle(Device $device, Trap $trap)
|
||||
{
|
||||
Log::event("$device->hostname received a file that exceeds proxy buffer, skipping AV scan", $device->device_id, 'trap', 2);
|
||||
$trap->log("$device->hostname received a file that exceeds proxy buffer, skipping AV scan");
|
||||
}
|
||||
}
|
||||
|
@ -30,7 +30,6 @@ namespace LibreNMS\Snmptrap\Handlers;
|
||||
use App\Models\Device;
|
||||
use LibreNMS\Interfaces\SnmptrapHandler;
|
||||
use LibreNMS\Snmptrap\Trap;
|
||||
use Log;
|
||||
|
||||
class FgTrapIpsAnomaly implements SnmptrapHandler
|
||||
{
|
||||
@ -46,6 +45,6 @@ class FgTrapIpsAnomaly implements SnmptrapHandler
|
||||
{
|
||||
$srcIp = $trap->getOidData($trap->findOid('FORTINET-FORTIGATE-MIB::fgIpsTrapSrcIp'));
|
||||
$proto = $trap->getOidData($trap->findOid('FORTINET-FORTIGATE-MIB::fgIpsTrapSigMsg'));
|
||||
Log::event("DDoS prevention triggered. Source: $srcIp Protocol: $proto", $device->device_id, 'trap', 4);
|
||||
$trap->log("DDoS prevention triggered. Source: $srcIp Protocol: $proto", 4);
|
||||
}
|
||||
}
|
||||
|
@ -30,7 +30,6 @@ namespace LibreNMS\Snmptrap\Handlers;
|
||||
use App\Models\Device;
|
||||
use LibreNMS\Interfaces\SnmptrapHandler;
|
||||
use LibreNMS\Snmptrap\Trap;
|
||||
use Log;
|
||||
|
||||
class FgTrapIpsPkgUpdate implements SnmptrapHandler
|
||||
{
|
||||
@ -44,6 +43,6 @@ class FgTrapIpsPkgUpdate implements SnmptrapHandler
|
||||
*/
|
||||
public function handle(Device $device, Trap $trap)
|
||||
{
|
||||
Log::event("IPS package updated on $device->hostname", $device->device_id, 'trap', 2);
|
||||
$trap->log("IPS package updated on $device->hostname");
|
||||
}
|
||||
}
|
||||
|
@ -30,7 +30,6 @@ namespace LibreNMS\Snmptrap\Handlers;
|
||||
use App\Models\Device;
|
||||
use LibreNMS\Interfaces\SnmptrapHandler;
|
||||
use LibreNMS\Snmptrap\Trap;
|
||||
use Log;
|
||||
|
||||
class FgTrapIpsSignature implements SnmptrapHandler
|
||||
{
|
||||
@ -47,6 +46,6 @@ class FgTrapIpsSignature implements SnmptrapHandler
|
||||
$srcIp = $trap->getOidData($trap->findOid('FORTINET-FORTIGATE-MIB::fgIpsTrapSrcIp'));
|
||||
$sigNum = $trap->getOidData($trap->findOid('FORTINET-FORTIGATE-MIB::fgIpsTrapSigId'));
|
||||
$sigName = $trap->getOidData($trap->findOid('FORTINET-FORTIGATE-MIB::fgIpsTrapSigMsg'));
|
||||
Log::event("IPS signature $sigName detected from $srcIp with Fortiguard ID $sigNum", $device->device_id, 'trap', 4);
|
||||
$trap->log("IPS signature $sigName detected from $srcIp with Fortiguard ID $sigNum", 4);
|
||||
}
|
||||
}
|
||||
|
@ -30,7 +30,6 @@ namespace LibreNMS\Snmptrap\Handlers;
|
||||
use App\Models\Device;
|
||||
use LibreNMS\Interfaces\SnmptrapHandler;
|
||||
use LibreNMS\Snmptrap\Trap;
|
||||
use Log;
|
||||
|
||||
class FgTrapVpnTunDown implements SnmptrapHandler
|
||||
{
|
||||
@ -46,6 +45,6 @@ class FgTrapVpnTunDown implements SnmptrapHandler
|
||||
{
|
||||
$remoteGw = $trap->getOidData($trap->findOid('FORTIGATE-MIB::fgVpnTrapRemoteGateway'));
|
||||
$tunName = $trap->getOidData($trap->findOid('FORTIGATE-MIB::fgVpnTrapPhase1Name'));
|
||||
Log::event("VPN tunnel $tunName to $remoteGw is down", $device->device_id, 'trap', 3);
|
||||
$trap->log("VPN tunnel $tunName to $remoteGw is down", 3);
|
||||
}
|
||||
}
|
||||
|
@ -30,7 +30,6 @@ namespace LibreNMS\Snmptrap\Handlers;
|
||||
use App\Models\Device;
|
||||
use LibreNMS\Interfaces\SnmptrapHandler;
|
||||
use LibreNMS\Snmptrap\Trap;
|
||||
use Log;
|
||||
|
||||
class FgTrapVpnTunUp implements SnmptrapHandler
|
||||
{
|
||||
@ -46,6 +45,6 @@ class FgTrapVpnTunUp implements SnmptrapHandler
|
||||
{
|
||||
$remoteGw = $trap->getOidData($trap->findOid('FORTIGATE-MIB::fgVpnTrapRemoteGateway'));
|
||||
$tunName = $trap->getOidData($trap->findOid('FORTIGATE-MIB::fgVpnTrapPhase1Name'));
|
||||
Log::event("VPN tunnel $tunName to $remoteGw is up", $device->device_id, 'trap', 1);
|
||||
$trap->log("VPN tunnel $tunName to $remoteGw is up", 1);
|
||||
}
|
||||
}
|
||||
|
@ -31,7 +31,6 @@ namespace LibreNMS\Snmptrap\Handlers;
|
||||
use App\Models\Device;
|
||||
use LibreNMS\Interfaces\SnmptrapHandler;
|
||||
use LibreNMS\Snmptrap\Trap;
|
||||
use Log;
|
||||
|
||||
class FmTrapLogRateThreshold implements SnmptrapHandler
|
||||
{
|
||||
@ -47,6 +46,6 @@ class FmTrapLogRateThreshold implements SnmptrapHandler
|
||||
{
|
||||
$logRate = $trap->getOidData($trap->findOid('FORTINET-FORTIMANAGER-FORTIANALYZER-MIB::fmLogRate'));
|
||||
$logThresh = $trap->getOidData($trap->findOid('FORTINET-FORTIMANAGER-FORTIANALYZER-MIB::fmLogRateThreshold'));
|
||||
Log::event("Recommended log rate exceeded. Current Rate: $logRate Recommended Rate: $logThresh", $device->device_id, 'trap', 3);
|
||||
$trap->log("Recommended log rate exceeded. Current Rate: $logRate Recommended Rate: $logThresh", 3);
|
||||
}
|
||||
}
|
||||
|
@ -5,7 +5,6 @@ namespace LibreNMS\Snmptrap\Handlers;
|
||||
use App\Models\Device;
|
||||
use LibreNMS\Interfaces\SnmptrapHandler;
|
||||
use LibreNMS\Snmptrap\Trap;
|
||||
use Log;
|
||||
|
||||
class HpFault implements SnmptrapHandler
|
||||
{
|
||||
@ -22,16 +21,16 @@ class HpFault implements SnmptrapHandler
|
||||
$type = $trap->getOidData($trap->findOid('HP-ICF-FAULT-FINDER-MIB::hpicfFfLogFaultType'));
|
||||
switch ($type) {
|
||||
case 'badXcvr':
|
||||
Log::event('Fault - CRC Error ' . $trap->getOidData($trap->findOid('HP-ICF-FAULT-FINDER-MIB::hpicfFfFaultInfoURL')), $device->device_id, $type, 4);
|
||||
$trap->log('Fault - CRC Error ' . $trap->getOidData($trap->findOid('HP-ICF-FAULT-FINDER-MIB::hpicfFfFaultInfoURL')), 4, $type);
|
||||
break;
|
||||
case 'badCable':
|
||||
Log::event('Fault - Bad Cable ' . $trap->getOidData($trap->findOid('HP-ICF-FAULT-FINDER-MIB::hpicfFfFaultInfoURL')), $device->device_id, $type, 4);
|
||||
$trap->log('Fault - Bad Cable ' . $trap->getOidData($trap->findOid('HP-ICF-FAULT-FINDER-MIB::hpicfFfFaultInfoURL')), 4, $type);
|
||||
break;
|
||||
case 'bcastStorm':
|
||||
Log::event('Fault - Broadcaststorm ' . $trap->getOidData($trap->findOid('HP-ICF-FAULT-FINDER-MIB::hpicfFfFaultInfoURL')), $device->device_id, $type, 5);
|
||||
$trap->log('Fault - Broadcaststorm ' . $trap->getOidData($trap->findOid('HP-ICF-FAULT-FINDER-MIB::hpicfFfFaultInfoURL')), 5, $type);
|
||||
break;
|
||||
default:
|
||||
Log::event('Fault - Unhandled ' . $trap->getOidData($trap->findOid('HP-ICF-FAULT-FINDER-MIB::hpicfFfFaultInfoURL')), $device->device_id, $type, 2);
|
||||
$trap->log('Fault - Unhandled ' . $trap->getOidData($trap->findOid('HP-ICF-FAULT-FINDER-MIB::hpicfFfFaultInfoURL')), 2, $type);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -61,7 +61,7 @@ class JnxBgpM2BackwardTransition implements SnmptrapHandler
|
||||
$bgpPeer->bgpPeerState = $peerState;
|
||||
|
||||
if ($bgpPeer->isDirty('bgpPeerState')) {
|
||||
Log::event("BGP Peer $peerAddr is now in the $peerState state", $device->device_id, 'trap', 5);
|
||||
$trap->log("BGP Peer $peerAddr is now in the $peerState state", 5);
|
||||
}
|
||||
|
||||
$bgpPeer->save();
|
||||
|
@ -57,7 +57,7 @@ class JnxBgpM2Established implements SnmptrapHandler
|
||||
$bgpPeer->bgpPeerState = $peerState;
|
||||
|
||||
if ($bgpPeer->isDirty('bgpPeerState')) {
|
||||
Log::event("BGP Peer $peerAddr is now in the $peerState state", $device->device_id, 'trap', 1);
|
||||
$trap->log("BGP Peer $peerAddr is now in the $peerState state", 1);
|
||||
}
|
||||
|
||||
$bgpPeer->save();
|
||||
|
@ -33,7 +33,6 @@ namespace LibreNMS\Snmptrap\Handlers;
|
||||
use App\Models\Device;
|
||||
use LibreNMS\Interfaces\SnmptrapHandler;
|
||||
use LibreNMS\Snmptrap\Trap;
|
||||
use Log;
|
||||
|
||||
class JnxCmCfgChange implements SnmptrapHandler
|
||||
{
|
||||
@ -51,9 +50,9 @@ class JnxCmCfgChange implements SnmptrapHandler
|
||||
$user = $trap->getOidData($trap->findOid('JUNIPER-CFGMGMT-MIB::jnxCmCfgChgEventUser'));
|
||||
$changeTime = $trap->getOidData($trap->findOid('JUNIPER-CFGMGMT-MIB::jnxCmCfgChgEventDate'));
|
||||
if ($source == 'other' && $user == 'root') {
|
||||
Log::event("Config rolled back at $changeTime", $device->device_id, 'trap', 2);
|
||||
$trap->log("Config rolled back at $changeTime");
|
||||
} else {
|
||||
Log::event("Config modified by $user from $source at $changeTime", $device->device_id, 'trap', 2);
|
||||
$trap->log("Config modified by $user from $source at $changeTime");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -28,7 +28,6 @@ namespace LibreNMS\Snmptrap\Handlers;
|
||||
use App\Models\Device;
|
||||
use LibreNMS\Interfaces\SnmptrapHandler;
|
||||
use LibreNMS\Snmptrap\Trap;
|
||||
use Log;
|
||||
|
||||
class JnxDomAlarmCleared implements SnmptrapHandler
|
||||
{
|
||||
@ -45,6 +44,6 @@ class JnxDomAlarmCleared implements SnmptrapHandler
|
||||
$currentAlarm = $trap->getOidData($trap->findOid('JUNIPER-DOM-MIB::jnxDomCurrentAlarms'));
|
||||
$ifDescr = $trap->getOidData($trap->findOid('IF-MIB::ifDescr'));
|
||||
$alarmList = JnxDomAlarmId::getAlarms($currentAlarm);
|
||||
Log::event("DOM alarm cleared for interface $ifDescr. Cleared alarm(s): $alarmList", $device->device_id, 'trap', 1);
|
||||
$trap->log("DOM alarm cleared for interface $ifDescr. Cleared alarm(s): $alarmList", 1);
|
||||
}
|
||||
}
|
||||
|
@ -31,7 +31,7 @@ namespace LibreNMS\Snmptrap\Handlers;
|
||||
|
||||
class JnxDomAlarmId
|
||||
{
|
||||
public static function getAlarms($currentAlarm)
|
||||
public static function getAlarms(string $currentAlarm): string
|
||||
{
|
||||
$alarmBin = preg_split(
|
||||
'//',
|
||||
@ -72,8 +72,7 @@ class JnxDomAlarmId
|
||||
}
|
||||
$index++;
|
||||
}
|
||||
$message = implode(', ', $descr);
|
||||
|
||||
return $message;
|
||||
return implode(', ', $descr);
|
||||
}
|
||||
}
|
||||
|
@ -28,7 +28,6 @@ namespace LibreNMS\Snmptrap\Handlers;
|
||||
use App\Models\Device;
|
||||
use LibreNMS\Interfaces\SnmptrapHandler;
|
||||
use LibreNMS\Snmptrap\Trap;
|
||||
use Log;
|
||||
|
||||
class JnxDomAlarmSet implements SnmptrapHandler
|
||||
{
|
||||
@ -45,6 +44,6 @@ class JnxDomAlarmSet implements SnmptrapHandler
|
||||
$currentAlarm = $trap->getOidData($trap->findOid('JUNIPER-DOM-MIB::jnxDomCurrentAlarms'));
|
||||
$ifDescr = $trap->getOidData($trap->findOid('IF-MIB::ifDescr'));
|
||||
$alarmList = JnxDomAlarmId::getAlarms($currentAlarm);
|
||||
Log::event("DOM alarm set for interface $ifDescr. Current alarm(s): $alarmList", $device->device_id, 'trap', 5);
|
||||
$trap->log("DOM alarm set for interface $ifDescr. Current alarm(s): $alarmList", 5);
|
||||
}
|
||||
}
|
||||
|
@ -56,6 +56,6 @@ class JnxDomLaneAlarmCleared implements SnmptrapHandler
|
||||
return;
|
||||
}
|
||||
|
||||
Log::event("DOM lane alarm cleared on interface $port->ifDescr lane $lane. Current alarm(s): $alarmList", $device->device_id, 'trap', 1);
|
||||
$trap->log("DOM lane alarm cleared on interface $port->ifDescr lane $lane. Current alarm(s): $alarmList", 1);
|
||||
}
|
||||
}
|
||||
|
@ -31,7 +31,7 @@ namespace LibreNMS\Snmptrap\Handlers;
|
||||
|
||||
class JnxDomLaneAlarmId
|
||||
{
|
||||
public static function getLaneAlarms($currentAlarm)
|
||||
public static function getLaneAlarms(string $currentAlarm): string
|
||||
{
|
||||
$alarmBin = preg_split(
|
||||
'//',
|
||||
@ -59,8 +59,7 @@ class JnxDomLaneAlarmId
|
||||
}
|
||||
$index++;
|
||||
}
|
||||
$message = implode(', ', $descr);
|
||||
|
||||
return $message;
|
||||
return implode(', ', $descr);
|
||||
}
|
||||
}
|
||||
|
@ -54,6 +54,6 @@ class JnxDomLaneAlarmSet implements SnmptrapHandler
|
||||
return;
|
||||
}
|
||||
|
||||
Log::event("DOM lane alarm on interface $port->ifDescr lane $lane. Current alarm(s): $alarmList", $device->device_id, 'trap', 5);
|
||||
$trap->log("DOM lane alarm on interface $port->ifDescr lane $lane. Current alarm(s): $alarmList", 5);
|
||||
}
|
||||
}
|
||||
|
@ -28,7 +28,6 @@ namespace LibreNMS\Snmptrap\Handlers;
|
||||
use App\Models\Device;
|
||||
use LibreNMS\Interfaces\SnmptrapHandler;
|
||||
use LibreNMS\Snmptrap\Trap;
|
||||
use Log;
|
||||
|
||||
class JnxLdpLspDown implements SnmptrapHandler
|
||||
{
|
||||
@ -47,6 +46,6 @@ class JnxLdpLspDown implements SnmptrapHandler
|
||||
$reason = $trap->getOidData($trap->findOid('JUNIPER-LDP-MIB::jnxLdpLspDownReason'));
|
||||
$instanceName = $trap->getOidData($trap->findOid('JUNIPER-LDP-MIB::jnxLdpInstanceName'));
|
||||
|
||||
Log::event("LDP session $instanceName from $routerID to $lspForward has gone down due to $reason", $device->device_id, 'trap', 4);
|
||||
$trap->log("LDP session $instanceName from $routerID to $lspForward has gone down due to $reason", 4);
|
||||
}
|
||||
}
|
||||
|
@ -28,7 +28,6 @@ namespace LibreNMS\Snmptrap\Handlers;
|
||||
use App\Models\Device;
|
||||
use LibreNMS\Interfaces\SnmptrapHandler;
|
||||
use LibreNMS\Snmptrap\Trap;
|
||||
use Log;
|
||||
|
||||
class JnxLdpLspUp implements SnmptrapHandler
|
||||
{
|
||||
@ -46,6 +45,6 @@ class JnxLdpLspUp implements SnmptrapHandler
|
||||
$routerID = $trap->getOidData($trap->findOid('JUNIPER-LDP-MIB::jnxLdpRtrid'));
|
||||
$instanceName = $trap->getOidData($trap->findOid('JUNIPER-LDP-MIB::jnxLdpInstanceName'));
|
||||
|
||||
Log::event("LDP session $instanceName from $routerID to $lspForward is now up.", $device->device_id, 'trap', 1);
|
||||
$trap->log("LDP session $instanceName from $routerID to $lspForward is now up.", 1);
|
||||
}
|
||||
}
|
||||
|
@ -53,6 +53,6 @@ class JnxLdpSesDown implements SnmptrapHandler
|
||||
return;
|
||||
}
|
||||
|
||||
Log::event("LDP session on interface $port->ifDescr is $state due to $reason", $device->device_id, 'trap', 4);
|
||||
$trap->log("LDP session on interface $port->ifDescr is $state due to $reason", 4);
|
||||
}
|
||||
}
|
||||
|
@ -52,6 +52,6 @@ class JnxLdpSesUp implements SnmptrapHandler
|
||||
return;
|
||||
}
|
||||
|
||||
Log::event("LDP session on interface $port->ifDescr is $state", $device->device_id, 'trap', 1);
|
||||
$trap->log("LDP session on interface $port->ifDescr is $state", 1);
|
||||
}
|
||||
}
|
||||
|
@ -28,7 +28,6 @@ namespace LibreNMS\Snmptrap\Handlers;
|
||||
use App\Models\Device;
|
||||
use LibreNMS\Interfaces\SnmptrapHandler;
|
||||
use LibreNMS\Snmptrap\Trap;
|
||||
use Log;
|
||||
|
||||
class JnxPowerSupplyFailure implements SnmptrapHandler
|
||||
{
|
||||
@ -44,6 +43,6 @@ class JnxPowerSupplyFailure implements SnmptrapHandler
|
||||
{
|
||||
$powerSupply = $trap->getOidData($trap->findOid('JUNIPER-MIB::jnxContentsDescr'));
|
||||
$state = $trap->getOidData($trap->findOid('JUNIPER-MIB::jnxOperatingState'));
|
||||
Log::event("Power Supply $powerSupply is $state", $device->device_id, 'trap', 5);
|
||||
$trap->log("Power Supply $powerSupply is $state", 5);
|
||||
}
|
||||
}
|
||||
|
@ -28,7 +28,6 @@ namespace LibreNMS\Snmptrap\Handlers;
|
||||
use App\Models\Device;
|
||||
use LibreNMS\Interfaces\SnmptrapHandler;
|
||||
use LibreNMS\Snmptrap\Trap;
|
||||
use Log;
|
||||
|
||||
class JnxPowerSupplyOk implements SnmptrapHandler
|
||||
{
|
||||
@ -43,6 +42,6 @@ class JnxPowerSupplyOk implements SnmptrapHandler
|
||||
public function handle(Device $device, Trap $trap)
|
||||
{
|
||||
$powerSupply = $trap->getOidData($trap->findOid('JUNIPER-MIB::jnxContentsDescr'));
|
||||
Log::event("Power Supply $powerSupply is OK", $device->device_id, 'trap', 1);
|
||||
$trap->log("Power Supply $powerSupply is OK", 1);
|
||||
}
|
||||
}
|
||||
|
@ -28,7 +28,6 @@ namespace LibreNMS\Snmptrap\Handlers;
|
||||
use App\Models\Device;
|
||||
use LibreNMS\Interfaces\SnmptrapHandler;
|
||||
use LibreNMS\Snmptrap\Trap;
|
||||
use Log;
|
||||
|
||||
class JnxVpnIfDown implements SnmptrapHandler
|
||||
{
|
||||
@ -45,6 +44,6 @@ class JnxVpnIfDown implements SnmptrapHandler
|
||||
$vpnType = $trap->getOidData($trap->findOid('JUNIPER-VPN-MIB::jnxVpnIfVpnType'));
|
||||
$vpnName = $trap->getOidData($trap->findOid('JUNIPER-VPN-MIB::jnxVpnIfVpnName'));
|
||||
|
||||
Log::event("$vpnType on interface $vpnName has gone down", $device->device_id, 'trap', 4);
|
||||
$trap->log("$vpnType on interface $vpnName has gone down", 4);
|
||||
}
|
||||
}
|
||||
|
@ -28,7 +28,6 @@ namespace LibreNMS\Snmptrap\Handlers;
|
||||
use App\Models\Device;
|
||||
use LibreNMS\Interfaces\SnmptrapHandler;
|
||||
use LibreNMS\Snmptrap\Trap;
|
||||
use Log;
|
||||
|
||||
class JnxVpnIfUp implements SnmptrapHandler
|
||||
{
|
||||
@ -47,9 +46,9 @@ class JnxVpnIfUp implements SnmptrapHandler
|
||||
|
||||
if (substr($vpnName, 0, 6) === 'vt/lsi') {
|
||||
$vpnDevice = substr($vpnName, 7, 15);
|
||||
Log::event("$vpnType to device $vpnDevice is now connected", $device->device_id, 'trap', 1);
|
||||
$trap->log("$vpnType to device $vpnDevice is now connected", 1);
|
||||
} else {
|
||||
Log::event("$vpnType on interface $vpnName is now connected", $device->device_id, 'trap', 1);
|
||||
$trap->log("$vpnType on interface $vpnName is now connected", 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -28,7 +28,6 @@ namespace LibreNMS\Snmptrap\Handlers;
|
||||
use App\Models\Device;
|
||||
use LibreNMS\Interfaces\SnmptrapHandler;
|
||||
use LibreNMS\Snmptrap\Trap;
|
||||
use Log;
|
||||
|
||||
class JnxVpnPwDown implements SnmptrapHandler
|
||||
{
|
||||
@ -45,6 +44,6 @@ class JnxVpnPwDown implements SnmptrapHandler
|
||||
$vpnType = $trap->getOidData($trap->findOid('JUNIPER-VPN-MIB::jnxVpnPwVpnType'));
|
||||
$vpnName = $trap->getOidData($trap->findOid('JUNIPER-VPN-MIB::jnxVpnPwVpnName'));
|
||||
|
||||
Log::event("$vpnType on a pseudowire belonging to $vpnName has gone down", $device->device_id, 'trap', 4);
|
||||
$trap->log("$vpnType on a pseudowire belonging to $vpnName has gone down", 4);
|
||||
}
|
||||
}
|
||||
|
@ -28,7 +28,6 @@ namespace LibreNMS\Snmptrap\Handlers;
|
||||
use App\Models\Device;
|
||||
use LibreNMS\Interfaces\SnmptrapHandler;
|
||||
use LibreNMS\Snmptrap\Trap;
|
||||
use Log;
|
||||
|
||||
class JnxVpnPwUp implements SnmptrapHandler
|
||||
{
|
||||
@ -45,6 +44,6 @@ class JnxVpnPwUp implements SnmptrapHandler
|
||||
$vpnType = $trap->getOidData($trap->findOid('JUNIPER-VPN-MIB::jnxVpnPwVpnType'));
|
||||
$vpnName = $trap->getOidData($trap->findOid('JUNIPER-VPN-MIB::jnxVpnPwVpnName'));
|
||||
|
||||
Log::event("$vpnType on a pseudowire belonging to $vpnName is now connected", $device->device_id, 'trap', 1);
|
||||
$trap->log("$vpnType on a pseudowire belonging to $vpnName is now connected", 1);
|
||||
}
|
||||
}
|
||||
|
@ -58,14 +58,14 @@ class LinkDown implements SnmptrapHandler
|
||||
if ($trapAdminStatus) {
|
||||
$port->ifAdminStatus = $trapAdminStatus;
|
||||
}
|
||||
Log::event("SNMP Trap: linkDown $port->ifAdminStatus/$port->ifOperStatus " . $port->ifDescr, $device->device_id, 'interface', 5, $port->port_id);
|
||||
$trap->log("SNMP Trap: linkDown $port->ifAdminStatus/$port->ifOperStatus " . $port->ifDescr, 5, 'interface', $port->port_id);
|
||||
|
||||
if ($port->isDirty('ifAdminStatus')) {
|
||||
Log::event("Interface Disabled : $port->ifDescr (TRAP)", $device->device_id, 'interface', 3, $port->port_id);
|
||||
$trap->log("Interface Disabled : $port->ifDescr (TRAP)", 3, 'interface', $port->port_id);
|
||||
}
|
||||
|
||||
if ($port->isDirty('ifOperStatus')) {
|
||||
Log::event("Interface went Down : $port->ifDescr (TRAP)", $device->device_id, 'interface', 5, $port->port_id);
|
||||
$trap->log("Interface went Down : $port->ifDescr (TRAP)", 5, 'interface', $port->port_id);
|
||||
}
|
||||
|
||||
$port->save();
|
||||
|
@ -55,14 +55,14 @@ class LinkUp implements SnmptrapHandler
|
||||
$port->ifOperStatus = $trap->getOidData("IF-MIB::ifOperStatus.$ifIndex") ?: 'up';
|
||||
$port->ifAdminStatus = $trap->getOidData("IF-MIB::ifAdminStatus.$ifIndex") ?: 'up'; // If we receive LinkUp trap, we can safely assume that the ifAdminStatus is also up.
|
||||
|
||||
Log::event("SNMP Trap: linkUp $port->ifAdminStatus/$port->ifOperStatus " . $port->ifDescr, $device->device_id, 'interface', 1, $port->port_id);
|
||||
$trap->log("SNMP Trap: linkUp $port->ifAdminStatus/$port->ifOperStatus " . $port->ifDescr, 1, 'interface', $port->port_id);
|
||||
|
||||
if ($port->isDirty('ifAdminStatus')) {
|
||||
Log::event("Interface Enabled : $port->ifDescr (TRAP)", $device->device_id, 'interface', 3, $port->port_id);
|
||||
$trap->log("Interface Enabled : $port->ifDescr (TRAP)", 3, 'interface', $port->port_id);
|
||||
}
|
||||
|
||||
if ($port->isDirty('ifOperStatus')) {
|
||||
Log::event("Interface went Up : $port->ifDescr (TRAP)", $device->device_id, 'interface', 1, $port->port_id);
|
||||
$trap->log("Interface went Up : $port->ifDescr (TRAP)", 1, 'interface', $port->port_id);
|
||||
}
|
||||
|
||||
$port->save();
|
||||
|
@ -28,7 +28,6 @@ namespace LibreNMS\Snmptrap\Handlers;
|
||||
use App\Models\Device;
|
||||
use LibreNMS\Interfaces\SnmptrapHandler;
|
||||
use LibreNMS\Snmptrap\Trap;
|
||||
use Log;
|
||||
|
||||
class LogTrap implements SnmptrapHandler
|
||||
{
|
||||
@ -40,7 +39,7 @@ class LogTrap implements SnmptrapHandler
|
||||
* @param Trap $trap
|
||||
* @return void
|
||||
*/
|
||||
public function handle(Device $device, Trap $trap)
|
||||
public function handle(Device $device, Trap $trap): void
|
||||
{
|
||||
$index = $trap->findOid('LOG-MIB::logIndex');
|
||||
$index = $trap->getOidData($index);
|
||||
@ -52,24 +51,17 @@ class LogTrap implements SnmptrapHandler
|
||||
$state = $trap->getOidData('LOG-MIB::logEquipStatusV2.' . $index);
|
||||
|
||||
$severity = $this->getSeverity($state);
|
||||
Log::event('SNMP Trap: Log ' . $logName . ' ' . $logEvent . ' ' . $logPC . ' ' . $logAI . ' ' . $state, $device->device_id, 'log', $severity);
|
||||
$trap->log('SNMP Trap: Log ' . $logName . ' ' . $logEvent . ' ' . $logPC . ' ' . $logAI . ' ' . $state, $severity, 'log');
|
||||
}
|
||||
|
||||
private function getSeverity($state)
|
||||
private function getSeverity(string $state): int
|
||||
{
|
||||
$severity_map = [
|
||||
'warning' => 4,
|
||||
'major' => 4,
|
||||
'5' => 4,
|
||||
'3' => 4,
|
||||
'critical' => 5,
|
||||
'4' => 5,
|
||||
'minor' => 3,
|
||||
'2' => 3,
|
||||
'nonAlarmed' => 1,
|
||||
'1' => 1,
|
||||
];
|
||||
|
||||
return $severity_map[$state] ?? 0;
|
||||
return match ($state) {
|
||||
'warning', '3', 'major', '5' => 4,
|
||||
'critical', '4' => 5,
|
||||
'minor', '2' => 3,
|
||||
'nonAlarmed', '1' => 1,
|
||||
default => 0,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@ -30,7 +30,6 @@ namespace LibreNMS\Snmptrap\Handlers;
|
||||
use App\Models\Device;
|
||||
use LibreNMS\Interfaces\SnmptrapHandler;
|
||||
use LibreNMS\Snmptrap\Trap;
|
||||
use Log;
|
||||
|
||||
class Mgnt2TrapNmsAlarm implements SnmptrapHandler
|
||||
{
|
||||
@ -94,6 +93,6 @@ class Mgnt2TrapNmsAlarm implements SnmptrapHandler
|
||||
break;
|
||||
}
|
||||
|
||||
Log::event($msg, $device->device_id, 'trap', $severity);
|
||||
$trap->log($msg, $severity);
|
||||
}
|
||||
}
|
||||
|
@ -30,7 +30,6 @@ namespace LibreNMS\Snmptrap\Handlers;
|
||||
use App\Models\Device;
|
||||
use LibreNMS\Interfaces\SnmptrapHandler;
|
||||
use LibreNMS\Snmptrap\Trap;
|
||||
use Log;
|
||||
|
||||
class Mgnt2TrapNmsEvent implements SnmptrapHandler
|
||||
{
|
||||
@ -62,6 +61,6 @@ class Mgnt2TrapNmsEvent implements SnmptrapHandler
|
||||
} else {
|
||||
$msg = "Event on slot $slot, $sourcePm Reason: $logReason";
|
||||
}
|
||||
Log::event($msg, $device->device_id, 'trap', 2);
|
||||
$trap->log($msg);
|
||||
}
|
||||
}
|
||||
|
@ -85,7 +85,7 @@ class OspfIfStateChange implements SnmptrapHandler
|
||||
break;
|
||||
}
|
||||
|
||||
Log::event("OSPF interface $port->ifName is $ospfPort->ospfIfState", $device->device_id, 'trap', $severity);
|
||||
$trap->log("OSPF interface $port->ifName is $ospfPort->ospfIfState", $severity);
|
||||
|
||||
$ospfPort->save();
|
||||
}
|
||||
|
@ -31,7 +31,6 @@ namespace LibreNMS\Snmptrap\Handlers;
|
||||
use App\Models\Device;
|
||||
use LibreNMS\Interfaces\SnmptrapHandler;
|
||||
use LibreNMS\Snmptrap\Trap;
|
||||
use Log;
|
||||
|
||||
class OspfNbrStateChange implements SnmptrapHandler
|
||||
{
|
||||
@ -58,7 +57,7 @@ class OspfNbrStateChange implements SnmptrapHandler
|
||||
$severity = 5;
|
||||
}
|
||||
|
||||
Log::event("OSPF neighbor $ospfNbrIpAddr changed state to $ospfNbr->ospfNbrState", $device->device_id, 'trap', $severity);
|
||||
$trap->log("OSPF neighbor $ospfNbrIpAddr changed state to $ospfNbr->ospfNbrState", $severity);
|
||||
|
||||
$ospfNbr->save();
|
||||
}
|
||||
|
@ -28,7 +28,6 @@ namespace LibreNMS\Snmptrap\Handlers;
|
||||
use App\Models\Device;
|
||||
use LibreNMS\Interfaces\SnmptrapHandler;
|
||||
use LibreNMS\Snmptrap\Trap;
|
||||
use Log;
|
||||
|
||||
class OspfTxRetransmit implements SnmptrapHandler
|
||||
{
|
||||
@ -50,11 +49,11 @@ class OspfTxRetransmit implements SnmptrapHandler
|
||||
$ospfLsdbLsid = $trap->getOidData($trap->findOid('OSPF-MIB::ospfLsdbLsid'));
|
||||
|
||||
if ($ospfPacketType != 'lsUpdate') {
|
||||
Log::event('SNMP TRAP: ' . $device->displayName() . "(Router ID: $ospfRouterId) sent a $ospfPacketType packet to $ospfNbrRtrId.", $device->device_id, 'trap', 2);
|
||||
$trap->log('SNMP TRAP: ' . $device->displayName() . "(Router ID: $ospfRouterId) sent a $ospfPacketType packet to $ospfNbrRtrId.");
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
Log::event('SNMP Trap: OSPFTxRetransmit trap recieved from ' . $device->displayName() . "(Router ID: $ospfRouterId). A $ospfPacketType packet was sent to $ospfNbrRtrId. LSType: $ospfLsdbType, route ID: $ospfLsdbLsid, originating from $ospfLsdbRouterId.", $device->device_id, 'trap', 2);
|
||||
$trap->log('SNMP Trap: OSPFTxRetransmit trap received from ' . $device->displayName() . "(Router ID: $ospfRouterId). A $ospfPacketType packet was sent to $ospfNbrRtrId. LSType: $ospfLsdbType, route ID: $ospfLsdbLsid, originating from $ospfLsdbRouterId.");
|
||||
}
|
||||
}
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user