mirror of
https://github.com/librenms/librenms.git
synced 2024-10-07 16:52:45 +00:00
Added snmp trap OnBattery for UPS-MIB
This commit is contained in:
48
LibreNMS/Snmptrap/Handlers/UpsTrapsOnBattery.php
Normal file
48
LibreNMS/Snmptrap/Handlers/UpsTrapsOnBattery.php
Normal file
@@ -0,0 +1,48 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* UpsTrapsOnBattery.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/>.
|
||||||
|
*
|
||||||
|
* @package LibreNMS
|
||||||
|
* @link http://librenms.org
|
||||||
|
* @author TheGreatDoc
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace LibreNMS\Snmptrap\Handlers;
|
||||||
|
|
||||||
|
use App\Models\Device;
|
||||||
|
use LibreNMS\Interfaces\SnmptrapHandler;
|
||||||
|
use LibreNMS\Snmptrap\Trap;
|
||||||
|
use Log;
|
||||||
|
|
||||||
|
class UpsTrapsOnBattery 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)
|
||||||
|
{
|
||||||
|
$remaining = $trap->getOidData($trap->findOid('UPS-MIB::upsEstimatedMinutesRemaining.0'));
|
||||||
|
$time = $trap->getOidData($trap->findOid('UPS-MIB::upsSecondsOnBattery.0'));
|
||||||
|
Log::event("UPS running on battery for $time seconds. Estimated $remaining minutes remaining", $device->device_id, 'trap', 5);
|
||||||
|
}
|
||||||
|
}
|
@@ -101,5 +101,6 @@ return [
|
|||||||
'VMWARE-VMINFO-MIB::vmwVmSuspended' => \LibreNMS\Snmptrap\Handlers\VmwVmSuspended::class,
|
'VMWARE-VMINFO-MIB::vmwVmSuspended' => \LibreNMS\Snmptrap\Handlers\VmwVmSuspended::class,
|
||||||
'OSPF-TRAP-MIB::ospfIfStateChange' => \LibreNMS\Snmptrap\Handlers\OspfIfStateChange::class,
|
'OSPF-TRAP-MIB::ospfIfStateChange' => \LibreNMS\Snmptrap\Handlers\OspfIfStateChange::class,
|
||||||
'OSPF-TRAP-MIB::ospfNbrStateChange' => \LibreNMS\Snmptrap\Handlers\OspfNbrStateChange::class,
|
'OSPF-TRAP-MIB::ospfNbrStateChange' => \LibreNMS\Snmptrap\Handlers\OspfNbrStateChange::class,
|
||||||
|
'UPS-MIB::upsTraps.0.1' => \LibreNMS\Snmptrap\Handlers\UpsTrapsOnBattery::class,
|
||||||
]
|
]
|
||||||
];
|
];
|
||||||
|
Reference in New Issue
Block a user