mirror of
https://github.com/librenms/librenms.git
synced 2024-10-07 16:52:45 +00:00
Adva SNMP Trap Handlers (#10094)
* Added SNMP Trap Handlers for Adva Ethernet devices * Fixed formatting. * Fixed errors from previous commit. * Refactored AdvaAttributeChange.php * Updated a few handlers, added test script. * Added changes to snmptraps.php to make handlers active * Fixed issues found by travisci * Missed two mistakes in travisci, fixed. Should be ready for human eyes. * Added SNMP Trap Handlers for Adva Ethernet devices * Fixed formatting. * Fixed errors from previous commit. * Refactored AdvaAttributeChange.php * Updated a few handlers, added test script. * Added changes to snmptraps.php to make handlers active * Fixed issues found by travisci * Missed two mistakes in travisci, fixed. Should be ready for human eyes. * Added two tests. * fixed error * Updated handlers with changes introduced in 1.50 * Refactored and added a few tests * Added test for StateChangeTraps * Added AdvaObjectDeletionTest, still wip as I need to recapture flow del. * Added Network Element Alarm Trap Test * Added more tests, but they are wip. * Finished traps handler tests, few handler refoactors. * fixed style errors and refactored as requested * made requested changes to threshold trap handlers * removed a test script * modified adva port threshold handler * Update AdvaAccThresholdCrossingAlert.php * Update AdvaNetThresholdCrossingAlert.php * removed static method * fixed mistake in AdvaNetThresholdCrossingAlert.php
This commit is contained in:
128
LibreNMS/Snmptrap/Handlers/AdvaAccThresholdCrossingAlert.php
Normal file
128
LibreNMS/Snmptrap/Handlers/AdvaAccThresholdCrossingAlert.php
Normal file
@@ -0,0 +1,128 @@
|
||||
<?php
|
||||
/**
|
||||
* AdvaAccThresholdCrossingAlert.php
|
||||
*
|
||||
* -Description-
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* Adva Threshold Exceeded Alarms.
|
||||
*
|
||||
* @package LibreNMS
|
||||
* @link http://librenms.org
|
||||
* @copyright 2018 KanREN, Inc
|
||||
* @author Heath Barnhart <hbarnhart@kanren.net> & Neil Kahle <nkahle@kanren.net>
|
||||
*/
|
||||
|
||||
namespace LibreNMS\Snmptrap\Handlers;
|
||||
|
||||
use App\Models\Device;
|
||||
use LibreNMS\Interfaces\SnmptrapHandler;
|
||||
use LibreNMS\Snmptrap\Trap;
|
||||
use Log;
|
||||
|
||||
class AdvaAccThresholdCrossingAlert implements SnmptrapHandler
|
||||
{
|
||||
/**
|
||||
* Handle snmptrap.
|
||||
* Data is pre-parsed and delivered as a Trap.
|
||||
*
|
||||
* @param Device $device
|
||||
* @param Trap $trap
|
||||
* @return void
|
||||
*/
|
||||
public function handle(Device $device, Trap $trap)
|
||||
{
|
||||
$interval = $trap->getOidData($trap->findOid("CM-PERFORMANCE-MIB::cmEthernetAccPortThresholdInterval"));
|
||||
$ifName = $trap->getOidData($trap->findOid("IF-MIB::ifName"));
|
||||
|
||||
$thresholdMessage = $this->getThresholdMessage(
|
||||
$trap->getOidData($trap->findOid("CM-PERFORMANCE-MIB::cmEthernetAccPortThresholdVariable"))
|
||||
);
|
||||
|
||||
Log::event("$ifName $thresholdMessage threshold exceeded for $interval", $device->device_id, 'trap', 2);
|
||||
}
|
||||
|
||||
public function getThresholdMessage($thresholdOid)
|
||||
{
|
||||
foreach ($this->getThresholds() as $oid => $descr) {
|
||||
if (str_contains($thresholdOid, $oid)) {
|
||||
return $descr;
|
||||
}
|
||||
}
|
||||
return 'unknown';
|
||||
}
|
||||
|
||||
public function getThresholds()
|
||||
{
|
||||
return [
|
||||
'CM-PERFORMANCE-MIB::cmEthernetAccPortStatsUAS' => 'unavailable seconds',
|
||||
'CM-PERFORMANCE-MIB::cmEthernetAccPortStatsESBF' => 'broadcast frames sent',
|
||||
'CM-PERFORMANCE-MIB::cmEthernetAccPortStatsESBP' => 'broadcast frames received',
|
||||
'CM-PERFORMANCE-MIB::cmEthernetAccPortStatsESBS' => 'bytes sent',
|
||||
'CM-PERFORMANCE-MIB::cmEthernetAccPortStatsESCAE' => 'crc align errors',
|
||||
'CM-PERFORMANCE-MIB::cmEthernetAccPortStatsESC' => 'collisions',
|
||||
'CM-PERFORMANCE-MIB::cmEthernetAccPortStatsESDE' => 'drop events',
|
||||
'CM-PERFORMANCE-MIB::cmEthernetAccPortStatsESFS' => 'frames sent',
|
||||
'CM-PERFORMANCE-MIB::cmEthernetAccPortStatsESF' => 'fragments',
|
||||
'CM-PERFORMANCE-MIB::cmEthernetAccPortStatsESJ' => 'jabbers',
|
||||
'CM-PERFORMANCE-MIB::cmEthernetAccPortStatsESMF' => 'multicast frames sent',
|
||||
'CM-PERFORMANCE-MIB::cmEthernetAccPortStatsESMP' => 'multicast pakcets received',
|
||||
'CM-PERFORMANCE-MIB::cmEthernetAccPortStatsESOF' => 'oversize frames discarded',
|
||||
'CM-PERFORMANCE-MIB::cmEthernetAccPortStatsESOP' => 'oversize packets received',
|
||||
'CM-PERFORMANCE-MIB::cmEthernetAccPortStatsESO' => 'octets received',
|
||||
'CM-PERFORMANCE-MIB::cmEthernetAccPortStatsESP64' => '64 byte octets received',
|
||||
'CM-PERFORMANCE-MIB::cmEthernetAccPortStatsESP65' => '65 to 127 byte octets received',
|
||||
'CM-PERFORMANCE-MIB::cmEthernetAccPortStatsESP128' => '128 to 255 byte octets received',
|
||||
'CM-PERFORMANCE-MIB::cmEthernetAccPortStatsESP256' => '256 to 511 byte octets received',
|
||||
'CM-PERFORMANCE-MIB::cmEthernetAccPortStatsESP512' => '512 to 1023 byte octets received',
|
||||
'CM-PERFORMANCE-MIB::cmEthernetAccPortStatsESP1024' => '1024 to 1518 byte octets received',
|
||||
'CM-PERFORMANCE-MIB::cmEthernetAccPortStatsESP1519' => '1519 to MTU byte octets received',
|
||||
'CM-PERFORMANCE-MIB::cmEthernetAccPortStatsESP' => 'packets received',
|
||||
'CM-PERFORMANCE-MIB::cmEthernetAccPortStatsESUF' => 'unicast frames sent',
|
||||
'CM-PERFORMANCE-MIB::cmEthernetAccPortStatsESUP' => 'unicast frames received',
|
||||
'CM-PERFORMANCE-MIB::cmEthernetAccPortStatsL2CPFD' => 'layer 2 control protocol frames discarded',
|
||||
'CM-PERFORMANCE-MIB::cmEthernetAccPortStatsL2CPFP' => 'layer 2 control protocol frames discarded',
|
||||
'CM-PERFORMANCE-MIB::cmEthernetAccPortStatsABRRx' => 'average bit rate received',
|
||||
'CM-PERFORMANCE-MIB::cmEthernetAccPortStatsABRTx' => 'average bit rate transmitted',
|
||||
'CM-PERFORMANCE-MIB::cmEthernetAccPortStatsL2PTRxFramesEncap' => 'layer 2 control protocol frames encapsulated',
|
||||
'CM-PERFORMANCE-MIB::cmEthernetAccPortStatsL2PTTxFramesDecap' => 'layer 2 control protocol frames decapsulated',
|
||||
'CM-PERFORMANCE-MIB::cmEthernetAccPortStatsIBRMaxRx' => 'instantaneous bit rate received max',
|
||||
'CM-PERFORMANCE-MIB::cmEthernetAccPortStatsIBRMaxTx' => 'instantaneous bit rate transmitted max',
|
||||
'CM-PERFORMANCE-MIB::cmEthernetAccPortStatsIBRMinRx' => 'instantaneous bit rate received min',
|
||||
'CM-PERFORMANCE-MIB::cmEthernetAccPortStatsIBRMinTx' => 'instantaneous bit rate transmitted min',
|
||||
'CM-PERFORMANCE-MIB::cmEthernetAccPortStatsIBRRx' => 'instantaneous bit rate received',
|
||||
'CM-PERFORMANCE-MIB::cmEthernetAccPortStatsIBRTx' => 'instantaneous bit rate transmitted',
|
||||
'CM-PERFORMANCE-MIB::cmEthernetAccPortStatsAclDropNoMatch' => 'acl drop no match',
|
||||
'CM-PERFORMANCE-MIB::cmEthernetAccPortStatsAclFwd2Cpu' => 'acl forwarded to cpu',
|
||||
'CM-PERFORMANCE-MIB::cmEthernetAccPortStatsDhcpDropNoAssocIf' => 'dhcp dropped due to no associated interface',
|
||||
'cmQosFlowPolicerStatsFMG' => 'frames marked green and passed',
|
||||
'cmQosFlowPolicerStatsFMY' => 'frames marked yellow and passed',
|
||||
'cmQosFlowPolicerStatsFMYD' => 'frames marked yellow and discarded',
|
||||
'cmQosFlowPolicerStatsFMRD' => 'frames marked red and discarded',
|
||||
'cmQosFlowPolicerStatsBytesIn' => 'total bytes in',
|
||||
'cmQosFlowPolicerStatsBytesOut' => 'total bytes out',
|
||||
'cmQosFlowPolicerStatsABR' => 'average bit rate',
|
||||
'cmAccPortQosShaperStatsBT' => 'bytes dequeued',
|
||||
'cmAccPortQosShaperStatsBTD' => 'bytes tail dropped',
|
||||
'cmAccPortQosShaperStatsFD' => 'frames dequeued',
|
||||
'cmAccPortQosShaperStatsFTD' => 'frames tail dropped',
|
||||
'cmAccPortQosShaperStatsBR' => 'bytes replicated',
|
||||
'cmAccPortQosShaperStatsFR' => 'frames replicated',
|
||||
'cmAccPortQosShaperStatsABRRL' => 'average bit rate - rate limited',
|
||||
'cmAccPortQosShaperStatsBREDD' => 'bytes random early discard, dropped',
|
||||
'cmAccPortQosShaperStatsFREDD' => 'frames random early discard, dropped',
|
||||
];
|
||||
}
|
||||
}
|
297
LibreNMS/Snmptrap/Handlers/AdvaAttributeChange.php
Normal file
297
LibreNMS/Snmptrap/Handlers/AdvaAttributeChange.php
Normal file
@@ -0,0 +1,297 @@
|
||||
<?php
|
||||
/**
|
||||
* AdvaAtributeChange.php
|
||||
*
|
||||
* -Description-
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* Attribute change traps show changes to Adva configuration values after they are submitted.
|
||||
* This handler only catches some of those changes and aims to provide the user with
|
||||
* information about what configuration module was modified.
|
||||
*
|
||||
* @package LibreNMS
|
||||
* @link http://librenms.org
|
||||
* @copyright 2018 KanREN, Inc
|
||||
* @author Heath Barnhart <hbarnhart@kanren.net>
|
||||
*/
|
||||
|
||||
namespace LibreNMS\Snmptrap\Handlers;
|
||||
|
||||
use App\Models\Device;
|
||||
use LibreNMS\Interfaces\SnmptrapHandler;
|
||||
use LibreNMS\Snmptrap\Trap;
|
||||
use Log;
|
||||
|
||||
class AdvaAttributeChange implements SnmptrapHandler
|
||||
{
|
||||
/**
|
||||
* Handle snmptrap.
|
||||
* Data is pre-parsed and delivered as a Trap.
|
||||
*
|
||||
* @param Device $device
|
||||
* @param Trap $trap
|
||||
* @return void
|
||||
*/
|
||||
public function handle(Device $device, Trap $trap)
|
||||
{
|
||||
if ($trap->findOid('CM-SYSTEM-MIB::sysLog')) {
|
||||
$this->handleSyslogChg($device, $trap);
|
||||
} elseif ($trap->findOid('CM-SYSTEM-MIB::aclEntry')) {
|
||||
$this->handleAclChg($device, $trap);
|
||||
} elseif ($trap->findOid('CM-SYSTEM-MIB::securityBanner')) {
|
||||
Log::event("MOTD/Banner modified", $device->device_id, 'trap', 2);
|
||||
} elseif ($trap->findOid('CM-SYSTEM-MIB::sysTimeOfDayType')) {
|
||||
$this->handleTimeSrcChg($device, $trap);
|
||||
} elseif ($trap->findOid('F3-TIMEZONE-MIB::f3TimeZone')) {
|
||||
$this->handleTimeZoneChg($device, $trap);
|
||||
} elseif ($trap->findOid('CM-SYSTEM-MIB::ntp')) {
|
||||
$this->handleNtpChg($device, $trap);
|
||||
} elseif ($trap->findOid('CM-SECURITY-MIB::cmRemoteAuthServer')) {
|
||||
$this->handleAuthSvrChg($device, $trap);
|
||||
} elseif ($trap->findOid('CM-ENTITY-MIB::ne')) {
|
||||
$this->handleNeChg($device, $trap);
|
||||
} elseif ($trap->findOid('CM-ENTITY-MIB::ethernetNTEGE114ProCardSnmpDyingGaspEnabled')) {
|
||||
$this->handleDyingGaspChg($device, $trap);
|
||||
} elseif ($trap->findOid('CM-FACILITY-MIB::cmEthernetNetPort')) {
|
||||
$this->handleNetPortChg($device, $trap);
|
||||
} elseif ($trap->findOid('CM-FACILITY-MIB::cmEthernetAccPort')) {
|
||||
$this->handleAccPortChg($device, $trap);
|
||||
} elseif ($trap->findOid('CM-FACILITY-MIB::cmFlow')) {
|
||||
$this->handleFlowChg($device, $trap);
|
||||
} elseif ($trap->findOid('F3-LAG-MIB')) {
|
||||
$this->handleLagChg($device, $trap);
|
||||
} elseif ($trap->findOid('CM-FACILITY-MIB::cmQosFlow')) {
|
||||
$this->handleQosFlowChg($device, $trap);
|
||||
} elseif ($trap->findOid('CM-FACILITY-MIB::cmQosShaper')) {
|
||||
$this->handleQosShaperChg($device, $trap);
|
||||
} elseif ($trap->findOid('CM-FACILITY-MIB::cmAccPort')) {
|
||||
$this->handleAccPortShaperChg($device, $trap);
|
||||
}
|
||||
}
|
||||
public static function handleSyslogChg($device, $trap)
|
||||
{
|
||||
$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);
|
||||
}
|
||||
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);
|
||||
}
|
||||
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);
|
||||
}
|
||||
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);
|
||||
}
|
||||
}
|
||||
public static function handleAclChg($device, $trap)
|
||||
{
|
||||
$aclEntry = substr($trap->findOid('CM-SYSTEM-MIB::aclEntry'), -1);
|
||||
Log::event("ACL $aclEntry modified", $device->device_id, 'trap', 2);
|
||||
}
|
||||
public static function handleTimeSrcChg($device, $trap)
|
||||
{
|
||||
$timeSrc = $trap->getOidData($trap->findOid('CM-SYSTEM-MIB::sysTimeOfDayType'));
|
||||
Log::event("Time source set to $timeSrc", $device->device_id, 'trap', 2);
|
||||
}
|
||||
public static function handleTimeZoneChg($device, $trap)
|
||||
{
|
||||
$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);
|
||||
} elseif ('false' === $enabled && $trap->findOid('F3-TIMEZONE-MIB::f3TimeZoneDstControlEnabled')) {
|
||||
Log::event('Daylight Savings Time disabled', $device->device_id, 'trap', 2);
|
||||
}
|
||||
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);
|
||||
}
|
||||
}
|
||||
public static function handleNtpChg($device, $trap)
|
||||
{
|
||||
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);
|
||||
}
|
||||
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);
|
||||
}
|
||||
}
|
||||
public static function handleAuthSvrChg($device, $trap)
|
||||
{
|
||||
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);
|
||||
}
|
||||
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);
|
||||
}
|
||||
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);
|
||||
} else {
|
||||
Log::event("Authentication server $serverEntry disabled", $device->device_id, 'trap', 2);
|
||||
}
|
||||
}
|
||||
}
|
||||
public static function handleNeChg($device, $trap)
|
||||
{
|
||||
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);
|
||||
}
|
||||
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);
|
||||
}
|
||||
}
|
||||
public static function handleDyingGaspChg($device, $trap)
|
||||
{
|
||||
$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);
|
||||
} elseif ('false' === $nteSDGEnable && $trap->findOid('CM-ENTITY-MIB::ethernetNTEGE114ProCardSnmpDyingGaspEnabled')) {
|
||||
Log::event("SNMP Dying Gasp is disabled", $device->device_id, 'trap', 2);
|
||||
}
|
||||
}
|
||||
public static function handleNetPortChg($device, $trap)
|
||||
{
|
||||
$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);
|
||||
$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);
|
||||
$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);
|
||||
$neDefMessage = true;
|
||||
}
|
||||
if ($trap->findOid('CM-FACILITY-MIB::cmEthernetNetPortAutoDiagEnabled')) {
|
||||
$netAutoDiag = $trap->getOidData($trap->findOid('CM-FACILITY-MIB::cmEthernetNetPortAutoDiagEnabled'));
|
||||
if ('true' === $netAutoDiag) {
|
||||
$message = "Network Port $netPort AutoDiagnostic enabled";
|
||||
} else {
|
||||
$message = "Network Port $netPort AutoDiagnostic disabled";
|
||||
}
|
||||
Log::event($message, $device->device_id, 'trap', 2);
|
||||
$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);
|
||||
$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);
|
||||
$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);
|
||||
}
|
||||
}
|
||||
public static function handleAccPortChg($device, $trap)
|
||||
{
|
||||
$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);
|
||||
$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);
|
||||
$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);
|
||||
$accDefMessage = true;
|
||||
}
|
||||
if ($trap->findOid('CM-FACILITY-MIB::cmEthernetAccPortAutoDiagEnabled')) {
|
||||
$accAutoDiag = $trap->getOidData($trap->findOid('CM-FACILITY-MIB::cmEthernetAccPortAutoDiagEnabled'));
|
||||
if ('true' === $accAutoDiag) {
|
||||
$message = "Access Port $accPort AutoDiagnostic enabled";
|
||||
} else {
|
||||
$message = "Access Port $accPort AutoDiagnostic disabled";
|
||||
}
|
||||
Log::event($message, $device->device_id, 'trap', 2);
|
||||
$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);
|
||||
$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);
|
||||
$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);
|
||||
}
|
||||
}
|
||||
public static function handleFlowChg($device, $trap)
|
||||
{
|
||||
$flowID = substr($trap->findOid('CM-FACILITY-MIB::cmFlow'), -9);
|
||||
$flowID = str_replace(".", "-", $flowID);
|
||||
Log::event("Access Flow $flowID modified", $device->device_id, 'trap', 2);
|
||||
}
|
||||
public static function handleLagChg($device, $trap)
|
||||
{
|
||||
$lagID = substr($trap->findOid('F3-LAG-MIB::f3'), -1);
|
||||
Log::event("LAG $lagID modified", $device->device_id, 'trap', 2);
|
||||
}
|
||||
public static function handleQosFlowChg($device, $trap)
|
||||
{
|
||||
$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);
|
||||
}
|
||||
public static function handleQosShaperChg($device, $trap)
|
||||
{
|
||||
$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);
|
||||
}
|
||||
public static function handleAccPortShaperChg($device, $trap)
|
||||
{
|
||||
$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);
|
||||
}
|
||||
}
|
125
LibreNMS/Snmptrap/Handlers/AdvaNetThresholdCrossingAlert.php
Normal file
125
LibreNMS/Snmptrap/Handlers/AdvaNetThresholdCrossingAlert.php
Normal file
@@ -0,0 +1,125 @@
|
||||
<?php
|
||||
/**
|
||||
* AdvaNetThresholdCrossingAlert.php
|
||||
*
|
||||
* -Description-
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* Adva Threshold Exceeded Alarms.
|
||||
*
|
||||
* @package LibreNMS
|
||||
* @link http://librenms.org
|
||||
* @copyright 2018 KanREN, Inc
|
||||
* @author Heath Barnhart <hbarnhart@kanren.net> & Neil Kahle <nkahle@kanren.net>
|
||||
*/
|
||||
|
||||
namespace LibreNMS\Snmptrap\Handlers;
|
||||
|
||||
use App\Models\Device;
|
||||
use LibreNMS\Interfaces\SnmptrapHandler;
|
||||
use LibreNMS\Snmptrap\Trap;
|
||||
use Log;
|
||||
|
||||
class AdvaNetThresholdCrossingAlert implements SnmptrapHandler
|
||||
{
|
||||
/**
|
||||
* Handle snmptrap.
|
||||
* Data is pre-parsed and delivered as a Trap.
|
||||
*
|
||||
* @param Device $device
|
||||
* @param Trap $trap
|
||||
* @return void
|
||||
*/
|
||||
public function handle(Device $device, Trap $trap)
|
||||
{
|
||||
$interval = $trap->getOidData($trap->findOid("CM-PERFORMANCE-MIB::cmEthernetNetPortThresholdInterval"));
|
||||
$ifName = $trap->getOidData($trap->findOid("IF-MIB::ifName"));
|
||||
$threshMessage = $this->getThresholdMessage(
|
||||
$trap->getOidData($trap->findOid("CM-PERFORMANCE-MIB::cmEthernetNetPortThresholdVariable"))
|
||||
);
|
||||
|
||||
Log::event("$ifName $threshMessage threshold exceeded for $interval", $device->device_id, 'trap', 2);
|
||||
}
|
||||
public function getThresholdMessage($thresholdOid)
|
||||
{
|
||||
foreach ($this->getThresholds() as $oid => $descr) {
|
||||
if (str_contains($thresholdOid, $oid)) {
|
||||
return $descr;
|
||||
}
|
||||
}
|
||||
return 'unknown';
|
||||
}
|
||||
public function getThresholds()
|
||||
{
|
||||
return [
|
||||
'CM-PERFORMANCE-MIB::cmEthernetNetPortStatsUAS' => 'unavailable seconds',
|
||||
'CM-PERFORMANCE-MIB::cmEthernetNetPortStatsESBF' => 'broadcast frames sent',
|
||||
'CM-PERFORMANCE-MIB::cmEthernetNetPortStatsESBP' => 'broadcast frames received',
|
||||
'CM-PERFORMANCE-MIB::cmEthernetNetPortStatsESBS' => 'bytes sent',
|
||||
'CM-PERFORMANCE-MIB::cmEthernetNetPortStatsESCAE' => 'crc align errors',
|
||||
'CM-PERFORMANCE-MIB::cmEthernetNetPortStatsESC' => 'collisions',
|
||||
'CM-PERFORMANCE-MIB::cmEthernetNetPortStatsESDE' => 'drop events',
|
||||
'CM-PERFORMANCE-MIB::cmEthernetNetPortStatsESFS' => 'frames sent',
|
||||
'CM-PERFORMANCE-MIB::cmEthernetNetPortStatsESF' => 'fragments',
|
||||
'CM-PERFORMANCE-MIB::cmEthernetNetPortStatsESJ' => 'jabbers',
|
||||
'CM-PERFORMANCE-MIB::cmEthernetNetPortStatsESMF' => 'multicast frames sent',
|
||||
'CM-PERFORMANCE-MIB::cmEthernetNetPortStatsESMP' => 'multicast pakcets received',
|
||||
'CM-PERFORMANCE-MIB::cmEthernetNetPortStatsESOF' => 'oversize frames discarded',
|
||||
'CM-PERFORMANCE-MIB::cmEthernetNetPortStatsESOP' => 'oversize packets received',
|
||||
'CM-PERFORMANCE-MIB::cmEthernetNetPortStatsESO' => 'octets received',
|
||||
'CM-PERFORMANCE-MIB::cmEthernetNetPortStatsESP64' => '64 byte octets received',
|
||||
'CM-PERFORMANCE-MIB::cmEthernetNetPortStatsESP65' => '65 to 127 byte octets received',
|
||||
'CM-PERFORMANCE-MIB::cmEthernetNetPortStatsESP128' => '128 to 255 byte octets received',
|
||||
'CM-PERFORMANCE-MIB::cmEthernetNetPortStatsESP256' => '256 to 511 byte octets received',
|
||||
'CM-PERFORMANCE-MIB::cmEthernetNetPortStatsESP512' => '512 to 1023 byte octets received',
|
||||
'CM-PERFORMANCE-MIB::cmEthernetNetPortStatsESP1024' => '1024 to 1518 byte octets received',
|
||||
'CM-PERFORMANCE-MIB::cmEthernetNetPortStatsESP1519' => '1519 to MTU byte octets received',
|
||||
'CM-PERFORMANCE-MIB::cmEthernetNetPortStatsESP' => 'packets received',
|
||||
'CM-PERFORMANCE-MIB::cmEthernetNetPortStatsESUF' => 'unicast frames sent',
|
||||
'CM-PERFORMANCE-MIB::cmEthernetNetPortStatsESUP' => 'unicast frames received',
|
||||
'CM-PERFORMANCE-MIB::cmEthernetNetPortStatsL2CPFD' => 'layer 2 control protocol frames discarded',
|
||||
'CM-PERFORMANCE-MIB::cmEthernetNetPortStatsL2CPFP' => 'layer 2 control protocol frames discarded',
|
||||
'CM-PERFORMANCE-MIB::cmEthernetNetPortStatsABRRx' => 'average bit rate received',
|
||||
'CM-PERFORMANCE-MIB::cmEthernetNetPortStatsABRTx' => 'average bit rate transmitted',
|
||||
'CM-PERFORMANCE-MIB::cmEthernetNetPortStatsL2PTRxFramesEncap' => 'layer 2 control protocol frames encapsulated',
|
||||
'CM-PERFORMANCE-MIB::cmEthernetNetPortStatsL2PTTxFramesDecap' => 'layer 2 control protocol frames decapsulated',
|
||||
'CM-PERFORMANCE-MIB::cmEthernetNetPortStatsIBRMaxRx' => 'instantaneous bit rate received max',
|
||||
'CM-PERFORMANCE-MIB::cmEthernetNetPortStatsIBRMaxTx' => 'instantaneous bit rate transmitted max',
|
||||
'CM-PERFORMANCE-MIB::cmEthernetNetPortStatsIBRMinRx' => 'instantaneous bit rate received min',
|
||||
'CM-PERFORMANCE-MIB::cmEthernetNetPortStatsIBRMinTx' => 'instantaneous bit rate transmitted min',
|
||||
'CM-PERFORMANCE-MIB::cmEthernetNetPortStatsIBRRx' => 'instantaneous bit rate received',
|
||||
'CM-PERFORMANCE-MIB::cmEthernetNetPortStatsIBRTx' => 'instantaneous bit rate transmitted',
|
||||
'CM-PERFORMANCE-MIB::cmEthernetNetPortStatsAclDropNoMatch' => 'acl drop no match',
|
||||
'CM-PERFORMANCE-MIB::cmEthernetNetPortStatsAclFwd2Cpu' => 'acl forwarded to cpu',
|
||||
'CM-PERFORMANCE-MIB::cmEthernetNetPortStatsDhcpDropNoAssocIf' => 'dhcp dropped due to no associated interface',
|
||||
'cmQosFlowPolicerStatsFMG' => 'frames marked green and passed',
|
||||
'cmQosFlowPolicerStatsFMY' => 'frames marked yellow and passed',
|
||||
'cmQosFlowPolicerStatsFMYD' => 'frames marked yellow and discarded',
|
||||
'cmQosFlowPolicerStatsFMRD' => 'frames marked red and discarded',
|
||||
'cmQosFlowPolicerStatsBytesIn' => 'total bytes in',
|
||||
'cmQosFlowPolicerStatsBytesOut' => 'total bytes out',
|
||||
'cmQosFlowPolicerStatsABR' => 'average bit rate',
|
||||
'cmAccPortQosShaperStatsBT' => 'bytes dequeued',
|
||||
'cmAccPortQosShaperStatsBTD' => 'bytes tail dropped',
|
||||
'cmAccPortQosShaperStatsFD' => 'frames dequeued',
|
||||
'cmAccPortQosShaperStatsFTD' => 'frames tail dropped',
|
||||
'cmAccPortQosShaperStatsBR' => 'bytes replicated',
|
||||
'cmAccPortQosShaperStatsFR' => 'frames replicated',
|
||||
'cmAccPortQosShaperStatsABRRL' => 'average bit rate - rate limited',
|
||||
'cmAccPortQosShaperStatsBREDD' => 'bytes random early discard, dropped',
|
||||
'cmAccPortQosShaperStatsFREDD' => 'frames random early discard, dropped',
|
||||
];
|
||||
}
|
||||
}
|
71
LibreNMS/Snmptrap/Handlers/AdvaNetworkElementAlmTrap.php
Normal file
71
LibreNMS/Snmptrap/Handlers/AdvaNetworkElementAlmTrap.php
Normal file
@@ -0,0 +1,71 @@
|
||||
<?php
|
||||
/**
|
||||
* NetworkElementAlmTrap.php
|
||||
*
|
||||
* -Description-
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* Adva network element is in an alarm state. Gets the alarm description
|
||||
* and severity assigned by the Adva.
|
||||
*
|
||||
* @package LibreNMS
|
||||
* @link http://librenms.org
|
||||
* @copyright 2018 KanREN, Inc
|
||||
* @author Heath Barnhart <hbarnhart@kanren.net> & Neil Kahle <nkahle@kanren.net>
|
||||
*/
|
||||
|
||||
namespace LibreNMS\Snmptrap\Handlers;
|
||||
|
||||
use App\Models\Device;
|
||||
use LibreNMS\Interfaces\SnmptrapHandler;
|
||||
use LibreNMS\Snmptrap\Trap;
|
||||
use Log;
|
||||
|
||||
class AdvaNetworkElementAlmTrap implements SnmptrapHandler
|
||||
{
|
||||
/**
|
||||
* Handle snmptrap.
|
||||
* Data is pre-parsed and delivered as a Trap.
|
||||
*
|
||||
* @param Device $device
|
||||
* @param Trap $trap
|
||||
* @return void
|
||||
*/
|
||||
public function handle(Device $device, Trap $trap)
|
||||
{
|
||||
$alSeverity = $trap->getOidData($trap->findOid('CM-ALARM-MIB::cmNetworkElementAlmNotifCode'));
|
||||
switch ($alSeverity) {
|
||||
case "critical":
|
||||
$logSeverity = 5;
|
||||
break;
|
||||
case "major":
|
||||
$logSeverity = 4;
|
||||
break;
|
||||
case "minor":
|
||||
$logSeverity = 3;
|
||||
break;
|
||||
case "cleared":
|
||||
$logSeverity = 1;
|
||||
break;
|
||||
default:
|
||||
$logSeverity = 2;
|
||||
break;
|
||||
}
|
||||
|
||||
$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);
|
||||
}
|
||||
}
|
57
LibreNMS/Snmptrap/Handlers/AdvaObjectCreation.php
Normal file
57
LibreNMS/Snmptrap/Handlers/AdvaObjectCreation.php
Normal file
@@ -0,0 +1,57 @@
|
||||
<?php
|
||||
/**
|
||||
* AdvaObjectCreation.php
|
||||
*
|
||||
* -Description-
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* Traps when Adva objects are created. This includes Remote User Login object,
|
||||
* Flow Creation object, and LAG Creation object.
|
||||
*
|
||||
* @package LibreNMS
|
||||
* @link http://librenms.org
|
||||
* @copyright 2018 KanREN, Inc
|
||||
* @author Heath Barnhart <hbarnhart#kanren.net> & Neil Kahle <nkahle@kanren.net>
|
||||
*/
|
||||
|
||||
namespace LibreNMS\Snmptrap\Handlers;
|
||||
|
||||
use App\Models\Device;
|
||||
use LibreNMS\Interfaces\SnmptrapHandler;
|
||||
use LibreNMS\Snmptrap\Trap;
|
||||
use Log;
|
||||
|
||||
class AdvaObjectCreation implements SnmptrapHandler
|
||||
{
|
||||
/**
|
||||
* Handle snmptrap.
|
||||
* Data is pre-parsed and delivered as a Trap.
|
||||
*
|
||||
* @param Device $device
|
||||
* @param Trap $trap
|
||||
* @return void
|
||||
*/
|
||||
public function handle(Device $device, Trap $trap)
|
||||
{
|
||||
|
||||
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);
|
||||
} elseif ($trap_oid = $trap->findOid('F3-LAG-MIB::f3LagName')) {
|
||||
$lagID = substr($trap_oid, -1);
|
||||
Log::event("LAG $lagID created", $device->device_id, 'trap', 2);
|
||||
}
|
||||
}
|
||||
}
|
63
LibreNMS/Snmptrap/Handlers/AdvaObjectDeletion.php
Normal file
63
LibreNMS/Snmptrap/Handlers/AdvaObjectDeletion.php
Normal file
@@ -0,0 +1,63 @@
|
||||
<?php
|
||||
/**
|
||||
* AdvaObjectDeletion.php
|
||||
*
|
||||
* -Description-
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* Traps when Adva objects are deleted. This includes Remote User Login object,
|
||||
* Flow Deletion object, LAG Member Port Removed object, and Lag Deletion object.
|
||||
*
|
||||
* @package LibreNMS
|
||||
* @link http://librenms.org
|
||||
* @copyright 2018 KanREN, Inc
|
||||
* @author Heath Barnhart <hbarnhart@kanren.net> & Neil Kahle <nkahle@kanren.net>
|
||||
*/
|
||||
|
||||
namespace LibreNMS\Snmptrap\Handlers;
|
||||
|
||||
use App\Models\Device;
|
||||
use LibreNMS\Interfaces\SnmptrapHandler;
|
||||
use LibreNMS\Snmptrap\Trap;
|
||||
use Log;
|
||||
|
||||
class AdvaObjectDeletion implements SnmptrapHandler
|
||||
{
|
||||
/**
|
||||
* Handle snmptrap.
|
||||
* Data is pre-parsed and delivered as a Trap.
|
||||
*
|
||||
* @param Device $device
|
||||
* @param Trap $trap
|
||||
* @return void
|
||||
*/
|
||||
public function handle(Device $device, Trap $trap)
|
||||
{
|
||||
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);
|
||||
} 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);
|
||||
} 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);
|
||||
} elseif ($trap_oid = $trap->findOid('F3-LAG-MIB::f3LagIndex')) {
|
||||
$lagID = $trap->getOidData($trap_oid);
|
||||
Log::event("LAG $lagID deleted", $device->device_id, 'trap', 2);
|
||||
}
|
||||
}
|
||||
}
|
50
LibreNMS/Snmptrap/Handlers/AdvaSnmpDyingGaspTrap.php
Normal file
50
LibreNMS/Snmptrap/Handlers/AdvaSnmpDyingGaspTrap.php
Normal file
@@ -0,0 +1,50 @@
|
||||
<?php
|
||||
/**
|
||||
* AdvaSnmpDyingGaspTrap.php
|
||||
*
|
||||
* -Description-
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* Adva SNMP Dying Gasp Trap. Trap that is sent when the Adva loses
|
||||
* power and about to shut off.
|
||||
*
|
||||
* @package LibreNMS
|
||||
* @link http://librenms.org
|
||||
* @copyright 2018 KanREN, Inc.
|
||||
* @author Heath Barnhart <hbarnhart@kanren.net> & Neil Kahle <nkahle@kanren.net>
|
||||
*/
|
||||
|
||||
namespace LibreNMS\Snmptrap\Handlers;
|
||||
|
||||
use App\Models\Device;
|
||||
use LibreNMS\Interfaces\SnmptrapHandler;
|
||||
use LibreNMS\Snmptrap\Trap;
|
||||
use Log;
|
||||
|
||||
class AdvaSnmpDyingGaspTrap implements SnmptrapHandler
|
||||
{
|
||||
/**
|
||||
* Handle snmptrap.
|
||||
* Data is pre-parsed and delivered as a Trap.
|
||||
*
|
||||
* @param Device $device
|
||||
* @param Trap $trap
|
||||
* @return void
|
||||
*/
|
||||
public function handle(Device $device, Trap $trap)
|
||||
{
|
||||
Log::event("Dying Gasp received", $device->device_id, 'trap', 5);
|
||||
}
|
||||
}
|
68
LibreNMS/Snmptrap/Handlers/AdvaStateChangeTrap.php
Normal file
68
LibreNMS/Snmptrap/Handlers/AdvaStateChangeTrap.php
Normal file
@@ -0,0 +1,68 @@
|
||||
<?php
|
||||
/**
|
||||
* AdvaStateChangeTrap.php
|
||||
*
|
||||
* -Description-
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* Takes traps for interface state changes on Adva Ethernet Devices.
|
||||
* On an interface state change serveral traps (6 observed) are sent via
|
||||
* CM-SYSTEM-MIB::cmStateChangeTrap. This handler creates log entries based
|
||||
* on the unit that sent the trap.
|
||||
*
|
||||
* @package LibreNMS
|
||||
* @link http://librenms.org
|
||||
* @copyright 2018 Heath Barnhart
|
||||
* @author Heath Barnhart <hbarnhart@kanren.net> & Neil Kahle <nkahle@kanren.net>
|
||||
*/
|
||||
|
||||
namespace LibreNMS\Snmptrap\Handlers;
|
||||
|
||||
use App\Models\Device;
|
||||
use LibreNMS\Interfaces\SnmptrapHandler;
|
||||
use LibreNMS\Snmptrap\Trap;
|
||||
use Log;
|
||||
|
||||
class AdvaStateChangeTrap implements SnmptrapHandler
|
||||
{
|
||||
/**
|
||||
* Handle snmptrap.
|
||||
* Data is pre-parsed and delivered as a Trap.
|
||||
*
|
||||
* @param Device $device
|
||||
* @param Trap $trap
|
||||
* @return void
|
||||
*/
|
||||
public function handle(Device $device, Trap $trap)
|
||||
{
|
||||
if ($trap_oid = $trap->findOid('CM-FACILITY-MIB::cmEthernetAccPortAdminState')) {
|
||||
$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);
|
||||
} 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);
|
||||
} 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);
|
||||
}
|
||||
}
|
||||
}
|
70
LibreNMS/Snmptrap/Handlers/AdvaSysAlmTrap.php
Normal file
70
LibreNMS/Snmptrap/Handlers/AdvaSysAlmTrap.php
Normal file
@@ -0,0 +1,70 @@
|
||||
<?php
|
||||
/**
|
||||
* AdvaSysAlmTrap.php
|
||||
*
|
||||
* -Description-
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* Adva system alarm traps. This handler will log the description and a
|
||||
* description of the alarm.
|
||||
*
|
||||
* @package LibreNMS
|
||||
* @link http://librenms.org
|
||||
* @copyright 2018 KanREN, Inc.
|
||||
* @author Heath Barnhart <hbarnhart@kanren.net>
|
||||
*/
|
||||
|
||||
namespace LibreNMS\Snmptrap\Handlers;
|
||||
|
||||
use App\Models\Device;
|
||||
use LibreNMS\Interfaces\SnmptrapHandler;
|
||||
use LibreNMS\Snmptrap\Trap;
|
||||
use Log;
|
||||
|
||||
class AdvaSysAlmTrap implements SnmptrapHandler
|
||||
{
|
||||
/**
|
||||
* Handle snmptrap.
|
||||
* Data is pre-parsed and delivered as a Trap.
|
||||
*
|
||||
* @param Device $device
|
||||
* @param Trap $trap
|
||||
* @return void
|
||||
*/
|
||||
public function handle(Device $device, Trap $trap)
|
||||
{
|
||||
$alSeverity = $trap->getOidData($trap->findOid('CM-ALARM-MIB::cmSysAlmNotifCode'));
|
||||
switch ($alSeverity) {
|
||||
case "critical":
|
||||
$logSeverity = 5;
|
||||
break;
|
||||
case "major":
|
||||
$logSeverity = 4;
|
||||
break;
|
||||
case "minor":
|
||||
$logSeverity = 3;
|
||||
break;
|
||||
case "cleared":
|
||||
$logSeverity = 1;
|
||||
break;
|
||||
default:
|
||||
$logSeverity = 2;
|
||||
break;
|
||||
}
|
||||
|
||||
$sysAlmDescr = $trap->getOidData($trap->findOid('CM-ALARM-MIB::cmSysAlmDescr'));
|
||||
Log::event("System Alarm: $sysAlmDescr Status: $alSeverity", $device->device_id, 'trap', $logSeverity);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user