forked from librenms/librenms
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Initial push * renamed mib files * adding eki mgmt event trap handler * Adding handler to config/snmptraps.php * added slot state monitoring * Ekinops port discovery script * cleanup * moved ifDescr change from discovery to poller * simplified port poller script * fixed poller array * add Mgnt2TrapNMSEvent handler * Adding nms alarm handler * adding handler to snmptrap.php * Updated handler names, exapanded event traphandler * beginning tests and cleanup * adding snmpsim data * making tests * finished trap tests * fixed ekinops.yaml * style and lint pass * new snmpsim data and fixes * adding correct snmpsim * fixed test data * Update ekinops.svg * Update ekinops.svg * Update ekinops.yaml * new os discovery method * remove unneeded precache line * removing unneccesary pre-cache script * styleci fixes * few more style fixes * trim whitespace in discovery * remove unused mibs Co-authored-by: Tony Murray <[email protected]>
- Loading branch information
1 parent
0e0e80c
commit 8a92156
Showing
18 changed files
with
19,288 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
<?php | ||
/** | ||
* Ekinops.php | ||
* | ||
* Ekinops Optical Network | ||
* | ||
* 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/>. | ||
* | ||
* @link http://librenms.org | ||
* @copyright KanREN, Inc 2020 | ||
* @author Heath Barnhart <[email protected]> | ||
*/ | ||
|
||
namespace LibreNMS\OS; | ||
|
||
use App\Models\Device; | ||
use LibreNMS\Interfaces\Discovery\OSDiscovery; | ||
use LibreNMS\OS; | ||
|
||
class Ekinops extends OS implements OSDiscovery | ||
{ | ||
public function discoverOS(Device $device): void | ||
{ | ||
$sysDescr = $device->sysDescr; | ||
$info = explode(',', $sysDescr); | ||
|
||
$device->hardware = trim($info[1]); | ||
$device->version = trim($info[2]); | ||
|
||
$mgmtCard = snmp_get($this->getDeviceArray(), 'mgnt2RinvHwPlatform.0', '-OQv', 'EKINOPS-MGNT2-MIB'); | ||
$mgmtInfo = self::ekinopsInfo($mgmtCard); | ||
$device->serial = $mgmtInfo['Serial Number']; | ||
} | ||
|
||
/** | ||
* Parses Ekinops inventory returned in a tabular format within a single OID | ||
* @param string $ekiInfo | ||
* @return array $inv | ||
*/ | ||
public static function ekinopsInfo($ekiInfo) | ||
{ | ||
$info = explode("\n", $ekiInfo); | ||
unset($info[0]); | ||
$inv = []; | ||
foreach ($info as $line) { | ||
[$attr, $value] = explode(':', $line); | ||
$attr = trim($attr); | ||
$value = trim($value); | ||
$inv[$attr] = $value; | ||
} | ||
|
||
return $inv; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
<?php | ||
/** | ||
* Mgnt2TrapNMSEvent.php | ||
* | ||
* -Description- | ||
* | ||
* Ekinops managment module alarms | ||
* | ||
* 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/>. | ||
* | ||
* @link http://librenms.org | ||
* @copyright 2020 KanREN, Inc. | ||
* @author Heath Barnhart <[email protected]> | ||
*/ | ||
|
||
namespace LibreNMS\Snmptrap\Handlers; | ||
|
||
use App\Models\Device; | ||
use LibreNMS\Interfaces\SnmptrapHandler; | ||
use LibreNMS\Snmptrap\Trap; | ||
use Log; | ||
|
||
class Mgnt2TrapNmsAlarm 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) | ||
{ | ||
$alarmObj = $trap->getOidData($trap->findOid('EKINOPS-MGNT2-NMS-MIB::mgnt2AlmLogObjectClassIdentifier')); | ||
$sourcePm = $trap->getOidData($trap->findOid('EKINOPS-MGNT2-NMS-MIB::mgnt2AlmLogSourcePm')); | ||
$slot = $trap->getOidData($trap->findOid('EKINOPS-MGNT2-NMS-MIB::mgnt2AlmLogBoardNumber')); | ||
$portType = $trap->getOidData($trap->findOid('EKINOPS-MGNT2-NMS-MIB::mgnt2AlmLogSourcePortType')); | ||
$portNum = $trap->getOidData($trap->findOid('EKINOPS-MGNT2-NMS-MIB::mgnt2AlmLogSourcePortNumber')); | ||
$probCause = $trap->getOidData($trap->findOid('EKINOPS-MGNT2-NMS-MIB::mgnt2AlmLogProbableCause')); | ||
$probSpecific = $trap->getOidData($trap->findOid('EKINOPS-MGNT2-NMS-MIB::mgnt2AlmLogSpecificProblem')); | ||
$probAdd = $trap->getOidData($trap->findOid('EKINOPS-MGNT2-NMS-MIB::mgnt2AlmLogAdditionalText')); | ||
$alarmSeverity = $trap->getOidData($trap->findOid('EKINOPS-MGNT2-NMS-MIB::mgnt2AlmLogSeverity')); | ||
|
||
// Adding additional info if it exists. | ||
if (! empty($probAdd)) { | ||
$probSpecific = "$probSpecific Additional info: $probAdd"; | ||
} | ||
|
||
// Changing other to unknown | ||
if ($probCause == 'other') { | ||
$probCause = 'Unknown'; | ||
} | ||
|
||
if ($alarmObj == 'port') { | ||
$msg = "Alarm on slot $slot, $sourcePm Port: $portType $portNum Issue: $probSpecific Possible Cause: $probCause"; | ||
} else { | ||
$msg = "Alarm on slot $slot, $sourcePm Issue: $probSpecific Possible Cause: $probCause"; | ||
} | ||
|
||
switch ($alarmSeverity) { | ||
case 'cleared': | ||
$severity = 1; | ||
break; | ||
case 'critical': | ||
$severity = 5; | ||
break; | ||
case 'major': | ||
$severity = 5; | ||
break; | ||
case 'minor': | ||
$severity = 4; | ||
break; | ||
case 'warning': | ||
$severity = 4; | ||
break; | ||
case 'indeterminate': | ||
$severity = 0; | ||
break; | ||
default: | ||
$severity = 2; | ||
break; | ||
} | ||
|
||
Log::event($msg, $device->device_id, 'trap', $severity); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
<?php | ||
/** | ||
* Mgnt2TrapNMSEvent.php | ||
* | ||
* -Description- | ||
* | ||
* Ekinops managment module events | ||
* | ||
* 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/>. | ||
* | ||
* @link http://librenms.org | ||
* @copyright 2020 KanREN, Inc. | ||
* @author Heath Barnhart <[email protected]> | ||
*/ | ||
|
||
namespace LibreNMS\Snmptrap\Handlers; | ||
|
||
use App\Models\Device; | ||
use LibreNMS\Interfaces\SnmptrapHandler; | ||
use LibreNMS\Snmptrap\Trap; | ||
use Log; | ||
|
||
class Mgnt2TrapNmsEvent 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) | ||
{ | ||
$eventObj = $trap->getOidData($trap->findOid('EKINOPS-MGNT2-NMS-MIB::mgnt2EventLogObjectClassIdentifier')); | ||
$sourcePm = $trap->getOidData($trap->findOid('EKINOPS-MGNT2-NMS-MIB::mgnt2EventLogSourcePm')); | ||
$slot = $trap->getOidData($trap->findOid('EKINOPS-MGNT2-NMS-MIB::mgnt2EventLogBoardNumber')); | ||
$portType = $trap->getOidData($trap->findOid('EKINOPS-MGNT2-NMS-MIB::mgnt2EventLogSourcePortType')); | ||
$portNum = $trap->getOidData($trap->findOid('EKINOPS-MGNT2-NMS-MIB::mgnt2EventLogSourcePortNumber')); | ||
$logReason = $trap->getOidData($trap->findOid('EKINOPS-MGNT2-NMS-MIB::mgnt2EventLogReason')); | ||
$logAdd = $trap->getOidData($trap->findOid('EKINOPS-MGNT2-NMS-MIB::mgnt2EventLogAdditionalText')); | ||
|
||
// Adding additional info if it exists. | ||
if (! empty($logAdd)) { | ||
$logReason = "$logReason Additional info: $logAdd"; | ||
} | ||
|
||
if ($eventObj == 'port') { | ||
$msg = "Event on slot $slot, $sourcePm Port: $portType $portNum. Reason: $logReason"; | ||
} else { | ||
$msg = "Event on slot $slot, $sourcePm Reason: $logReason"; | ||
} | ||
Log::event($msg, $device->device_id, 'trap', 2); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.