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.
- Loading branch information
Showing
57 changed files
with
28,992 additions
and
10,913 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,59 @@ | ||
<?php | ||
/** | ||
* AxisAlarmCleared.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 <https://www.gnu.org/licenses/>. | ||
* | ||
* @link https://www.librenms.org | ||
* | ||
* @copyright 2024 Transitiv Technologies Ltd. <info@transitiv.co.uk> | ||
* @author Adam Sweet <adam.sweet@transitiv.co.uk> | ||
*/ | ||
|
||
namespace LibreNMS\Snmptrap\Handlers; | ||
|
||
use App\Models\Device; | ||
use LibreNMS\Enum\Severity; | ||
use LibreNMS\Interfaces\SnmptrapHandler; | ||
use LibreNMS\Snmptrap\Trap; | ||
|
||
class AxisAlarmCleared 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) | ||
{ | ||
$AlarmString = $trap->getOidData($trap->findOid('AXIS-VIDEO-MIB::alarmID')); | ||
// Handle data type errors in translated trap | ||
$AlarmID = preg_match('/^(?P<error>.+?)?(\:\s)?(?P<value>\d+)$/m', $AlarmString, $matches); | ||
if (! empty($matches['value'])) { | ||
$AlarmID = $matches['value']; | ||
} else { | ||
$AlarmID = $trap->getOidData($trap->findOid('AXIS-VIDEO-MIB::alarmID')); | ||
} | ||
|
||
$AlarmName = $trap->getOidData($trap->findOid('AXIS-VIDEO-MIB::alarmName')); | ||
$Message = $trap->getOidData($trap->findOid('AXIS-VIDEO-MIB::alarmText')); | ||
|
||
$trap->log("Axis Alarm Cleared Trap: Alarm ID $AlarmID for $AlarmName with text \"$Message\" has cleared", Severity::Ok); | ||
} | ||
} |
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,59 @@ | ||
<?php | ||
/** | ||
* AxisAlarmNew.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 <https://www.gnu.org/licenses/>. | ||
* | ||
* @link https://www.librenms.org | ||
* | ||
* @copyright 2024 Transitiv Technologies Ltd. <info@transitiv.co.uk> | ||
* @author Adam Sweet <adam.sweet@transitiv.co.uk> | ||
*/ | ||
|
||
namespace LibreNMS\Snmptrap\Handlers; | ||
|
||
use App\Models\Device; | ||
use LibreNMS\Enum\Severity; | ||
use LibreNMS\Interfaces\SnmptrapHandler; | ||
use LibreNMS\Snmptrap\Trap; | ||
|
||
class AxisAlarmNew 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) | ||
{ | ||
$AlarmString = $trap->getOidData($trap->findOid('AXIS-VIDEO-MIB::alarmID')); | ||
// Handle data type errors in translated trap | ||
$AlarmID = preg_match('/^(?P<error>.+?)?(\:\s)?(?P<value>\d+)$/m', $AlarmString, $matches); | ||
if (! empty($matches['value'])) { | ||
$AlarmID = $matches['value']; | ||
} else { | ||
$AlarmID = $trap->getOidData($trap->findOid('AXIS-VIDEO-MIB::alarmID')); | ||
} | ||
|
||
$AlarmName = $trap->getOidData($trap->findOid('AXIS-VIDEO-MIB::alarmName')); | ||
$Message = $trap->getOidData($trap->findOid('AXIS-VIDEO-MIB::alarmText')); | ||
|
||
$trap->log("Axis Alarm Trap: Alarm ID $AlarmID: $AlarmName: $Message", Severity::Warning); | ||
} | ||
} |
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,59 @@ | ||
<?php | ||
/** | ||
* AxisAlarmSingle.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 <https://www.gnu.org/licenses/>. | ||
* | ||
* @link https://www.librenms.org | ||
* | ||
* @copyright 2024 Transitiv Technologies Ltd. <info@transitiv.co.uk> | ||
* @author Adam Sweet <adam.sweet@transitiv.co.uk> | ||
*/ | ||
|
||
namespace LibreNMS\Snmptrap\Handlers; | ||
|
||
use App\Models\Device; | ||
use LibreNMS\Enum\Severity; | ||
use LibreNMS\Interfaces\SnmptrapHandler; | ||
use LibreNMS\Snmptrap\Trap; | ||
|
||
class AxisAlarmSingle 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) | ||
{ | ||
$AlarmString = $trap->getOidData($trap->findOid('AXIS-VIDEO-MIB::alarmID')); | ||
// Handle data type errors in translated trap | ||
$AlarmID = preg_match('/^(?P<error>.+?)?(\:\s)?(?P<value>\d+)$/m', $AlarmString, $matches); | ||
if (! empty($matches['value'])) { | ||
$AlarmID = $matches['value']; | ||
} else { | ||
$AlarmID = $trap->getOidData($trap->findOid('AXIS-VIDEO-MIB::alarmID')); | ||
} | ||
|
||
$AlarmName = $trap->getOidData($trap->findOid('AXIS-VIDEO-MIB::alarmName')); | ||
$Message = $trap->getOidData($trap->findOid('AXIS-VIDEO-MIB::alarmText')); | ||
|
||
$trap->log("Axis Alarm Trap: Alarm ID $AlarmID: $AlarmName: $Message", Severity::Warning); | ||
} | ||
} |
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
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
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
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,21 @@ | ||
<?php | ||
|
||
namespace App\Logging; | ||
|
||
class LogFileFormatter extends \Monolog\Formatter\LineFormatter | ||
{ | ||
public function __construct() | ||
{ | ||
parent::__construct( | ||
"[%datetime%][%level_name%] %message% %context% %extra%\n", | ||
'Y-m-d\TH:i:s', | ||
true, | ||
true | ||
); | ||
} | ||
|
||
public function format(\Monolog\LogRecord $record): string | ||
{ | ||
return parent::format($record); | ||
} | ||
} |
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
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
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.