mirror of
https://github.com/librenms/librenms.git
synced 2024-10-07 16:52:45 +00:00
CyberPower SNMP Traps (#11403)
* Initial Commit of Handlers * Starting unit tests * Completed Unit Tests
This commit is contained in:
51
LibreNMS/Snmptrap/Handlers/CpLowBattery.php
Normal file
51
LibreNMS/Snmptrap/Handlers/CpLowBattery.php
Normal file
@@ -0,0 +1,51 @@
|
||||
<?php
|
||||
/**
|
||||
* CpLowBattery.php
|
||||
*
|
||||
* -Description-
|
||||
*
|
||||
* CyberPower UPS battery voltage low.
|
||||
*
|
||||
* 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
|
||||
* @copyright 2020 KanREN Inc.
|
||||
* @author Heath Barnhart <hbarnhart@kanren.net>
|
||||
*/
|
||||
|
||||
namespace LibreNMS\Snmptrap\Handlers;
|
||||
|
||||
use App\Models\Device;
|
||||
use LibreNMS\Interfaces\SnmptrapHandler;
|
||||
use LibreNMS\Snmptrap\Handlers\CyberPowerUtil;
|
||||
use LibreNMS\Snmptrap\Trap;
|
||||
use Log;
|
||||
|
||||
class CpLowBattery 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)
|
||||
{
|
||||
$battery = CyberPowerUtil::getMessage($trap);
|
||||
Log::event("$battery", $device->device_id, 'trap', 4);
|
||||
}
|
||||
}
|
51
LibreNMS/Snmptrap/Handlers/CpPowerRestored.php
Normal file
51
LibreNMS/Snmptrap/Handlers/CpPowerRestored.php
Normal file
@@ -0,0 +1,51 @@
|
||||
<?php
|
||||
/**
|
||||
* CpPowerRestored.php
|
||||
*
|
||||
* -Description-
|
||||
*
|
||||
* CyberPower UPS trap utility power restored.
|
||||
*
|
||||
* 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
|
||||
* @copyright 2020 KanREN Inc.
|
||||
* @author Heath Barnhart <hbarnhart@kanren.net>
|
||||
*/
|
||||
|
||||
namespace LibreNMS\Snmptrap\Handlers;
|
||||
|
||||
use App\Models\Device;
|
||||
use LibreNMS\Interfaces\SnmptrapHandler;
|
||||
use LibreNMS\Snmptrap\Handlers\CyberPowerUtil;
|
||||
use LibreNMS\Snmptrap\Trap;
|
||||
use Log;
|
||||
|
||||
class CpPowerRestored 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)
|
||||
{
|
||||
$power = CyberPowerUtil::getMessage($trap);
|
||||
Log::event("$power", $device->device_id, 'trap', 1);
|
||||
}
|
||||
}
|
51
LibreNMS/Snmptrap/Handlers/CpRtnDischarge.php
Normal file
51
LibreNMS/Snmptrap/Handlers/CpRtnDischarge.php
Normal file
@@ -0,0 +1,51 @@
|
||||
<?php
|
||||
/**
|
||||
* CpRtnDischarge.php
|
||||
*
|
||||
* -Description-
|
||||
*
|
||||
* CyberPower runtime calibration completed.
|
||||
*
|
||||
* 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
|
||||
* @copyright 2020 KanREN Inc.
|
||||
* @author Heath Barnhart <hbarnhart@kanren.net
|
||||
*/
|
||||
|
||||
namespace LibreNMS\Snmptrap\Handlers;
|
||||
|
||||
use App\Models\Device;
|
||||
use LibreNMS\Interfaces\SnmptrapHandler;
|
||||
use LibreNMS\Snmptrap\Handlers\CyberPowerUtil;
|
||||
use LibreNMS\Snmptrap\Trap;
|
||||
use Log;
|
||||
|
||||
class CpRtnDischarge 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)
|
||||
{
|
||||
$returnInfo = CyberPowerUtil::getMessage($trap);
|
||||
Log::event("$returnInfo", $device->device_id, 'trap', 1);
|
||||
}
|
||||
}
|
51
LibreNMS/Snmptrap/Handlers/CpRtnLowBattery.php
Normal file
51
LibreNMS/Snmptrap/Handlers/CpRtnLowBattery.php
Normal file
@@ -0,0 +1,51 @@
|
||||
<?php
|
||||
/**
|
||||
* CpRtnLowBattery.php
|
||||
*
|
||||
* -Description-
|
||||
*
|
||||
* CyberPower UPS trap battery low voltage cleared.
|
||||
*
|
||||
* 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
|
||||
* @copyright 2020 KanREN Inc.
|
||||
* @author Heath Barnhart <hbarnhart@kanren.net>
|
||||
*/
|
||||
|
||||
namespace LibreNMS\Snmptrap\Handlers;
|
||||
|
||||
use App\Models\Device;
|
||||
use LibreNMS\Interfaces\SnmptrapHandler;
|
||||
use LibreNMS\Snmptrap\Handlers\CyberPowerUtil;
|
||||
use LibreNMS\Snmptrap\Trap;
|
||||
use Log;
|
||||
|
||||
class CpRtnLowBattery 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)
|
||||
{
|
||||
$battery = CyberPowerUtil::getMessage($trap);
|
||||
Log::event("$battery", $device->device_id, 'trap', 1);
|
||||
}
|
||||
}
|
51
LibreNMS/Snmptrap/Handlers/CpUpsBatteryNotPresent.php
Normal file
51
LibreNMS/Snmptrap/Handlers/CpUpsBatteryNotPresent.php
Normal file
@@ -0,0 +1,51 @@
|
||||
<?php
|
||||
/**
|
||||
* CpUpsBatteryNotPresent.php
|
||||
*
|
||||
* -Description-
|
||||
*
|
||||
* CyberPower UPS trap battery not present.
|
||||
*
|
||||
* 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
|
||||
* @copyright 2020 Kanren Inc.
|
||||
* @author Heath Barnhart <hbarnhart@kanren.net>
|
||||
*/
|
||||
|
||||
namespace LibreNMS\Snmptrap\Handlers;
|
||||
|
||||
use App\Models\Device;
|
||||
use LibreNMS\Interfaces\SnmptrapHandler;
|
||||
use LibreNMS\Snmptrap\Handlers\CyberPowerUtil;
|
||||
use LibreNMS\Snmptrap\Trap;
|
||||
use Log;
|
||||
|
||||
class CpUpsBatteryNotPresent 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)
|
||||
{
|
||||
$status = CyberPowerUtil::getMessage($trap);
|
||||
Log::event("$status", $device->device_id, 'trap', 2);
|
||||
}
|
||||
}
|
51
LibreNMS/Snmptrap/Handlers/CpUpsChargerFailure.php
Normal file
51
LibreNMS/Snmptrap/Handlers/CpUpsChargerFailure.php
Normal file
@@ -0,0 +1,51 @@
|
||||
<?php
|
||||
/**
|
||||
* CpUpsChargerFailure.php
|
||||
*
|
||||
* -Description-
|
||||
*
|
||||
* CyberPower UPS trap battery charger failed.
|
||||
*
|
||||
* 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
|
||||
* @copyright 2020 Kanren Inc.
|
||||
* @author Heath Barnhart <hbarnhart@kanren.net>
|
||||
*/
|
||||
|
||||
namespace LibreNMS\Snmptrap\Handlers;
|
||||
|
||||
use App\Models\Device;
|
||||
use LibreNMS\Interfaces\SnmptrapHandler;
|
||||
use LibreNMS\Snmptrap\Handlers\CyberPowerUtil;
|
||||
use LibreNMS\Snmptrap\Trap;
|
||||
use Log;
|
||||
|
||||
class CpUpsChargerFailure 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)
|
||||
{
|
||||
$chargeInfo = CyberPowerUtil::getMessage($trap);
|
||||
Log::event("$chargeInfo", $device->device_id, 'trap', 4);
|
||||
}
|
||||
}
|
51
LibreNMS/Snmptrap/Handlers/CpUpsDiagFailed.php
Normal file
51
LibreNMS/Snmptrap/Handlers/CpUpsDiagFailed.php
Normal file
@@ -0,0 +1,51 @@
|
||||
<?php
|
||||
/**
|
||||
* CpUpsDiagFailed.php
|
||||
*
|
||||
* -Description-
|
||||
*
|
||||
* CyberPower UPS battery test failed.
|
||||
*
|
||||
* 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
|
||||
* @copyright 2020 KanREN Inc.
|
||||
* @author Heath Barnhart <hbarnhart@kanren.net>
|
||||
*/
|
||||
|
||||
namespace LibreNMS\Snmptrap\Handlers;
|
||||
|
||||
use App\Models\Device;
|
||||
use LibreNMS\Interfaces\SnmptrapHandler;
|
||||
use LibreNMS\Snmptrap\Handlers\CyberPowerUtil;
|
||||
use LibreNMS\Snmptrap\Trap;
|
||||
use Log;
|
||||
|
||||
class CpUpsDiagFailed 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)
|
||||
{
|
||||
$diagInfo = CyberPowerUtil::getMessage($trap);
|
||||
Log::event("$diagInfo", $device->device_id, 'trap', 5);
|
||||
}
|
||||
}
|
51
LibreNMS/Snmptrap/Handlers/CpUpsDiagPassed.php
Normal file
51
LibreNMS/Snmptrap/Handlers/CpUpsDiagPassed.php
Normal file
@@ -0,0 +1,51 @@
|
||||
<?php
|
||||
/**
|
||||
* CpUpsDiagPassed.php
|
||||
*
|
||||
* -Description-
|
||||
*
|
||||
* CyberPower UPS battery test passed.
|
||||
*
|
||||
* 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
|
||||
* @copyright 2020 KanREN Inc.
|
||||
* @author Heath Barnhart <hbarnhart@kanren.net>
|
||||
*/
|
||||
|
||||
namespace LibreNMS\Snmptrap\Handlers;
|
||||
|
||||
use App\Models\Device;
|
||||
use LibreNMS\Interfaces\SnmptrapHandler;
|
||||
use LibreNMS\Snmptrap\Handlers\CyberPowerUtil;
|
||||
use LibreNMS\Snmptrap\Trap;
|
||||
use Log;
|
||||
|
||||
class CpUpsDiagPassed 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)
|
||||
{
|
||||
$diagInfo = CyberPowerUtil::getMessage($trap);
|
||||
Log::event("$diagInfo", $device->device_id, 'trap', 2);
|
||||
}
|
||||
}
|
51
LibreNMS/Snmptrap/Handlers/CpUpsDischarged.php
Normal file
51
LibreNMS/Snmptrap/Handlers/CpUpsDischarged.php
Normal file
@@ -0,0 +1,51 @@
|
||||
<?php
|
||||
/**
|
||||
* CpUpsDischarged.php
|
||||
*
|
||||
* -Description-
|
||||
*
|
||||
* CyberPower UPS runtime calibration started.
|
||||
*
|
||||
* 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
|
||||
* @copyright 2020 Kanren Inc.
|
||||
* @author Heath Barnhart <hbarnhart@kanren.net>
|
||||
*/
|
||||
|
||||
namespace LibreNMS\Snmptrap\Handlers;
|
||||
|
||||
use App\Models\Device;
|
||||
use LibreNMS\Interfaces\SnmptrapHandler;
|
||||
use LibreNMS\Snmptrap\Handlers\CyberPowerUtil;
|
||||
use LibreNMS\Snmptrap\Trap;
|
||||
use Log;
|
||||
|
||||
class CpUpsDischarged 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)
|
||||
{
|
||||
$dischargeInfo = CyberPowerUtil::getMessage($trap);
|
||||
Log::event("$dischargeInfo", $device->device_id, 'trap', 2);
|
||||
}
|
||||
}
|
51
LibreNMS/Snmptrap/Handlers/CpUpsOnBattery.php
Normal file
51
LibreNMS/Snmptrap/Handlers/CpUpsOnBattery.php
Normal file
@@ -0,0 +1,51 @@
|
||||
<?php
|
||||
/**
|
||||
* CpUpsOnBattery.php
|
||||
*
|
||||
* -Description-
|
||||
*
|
||||
* CyberPower UPS is on battery power.
|
||||
*
|
||||
* 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
|
||||
* @copyright 2020 KanREN Inc.
|
||||
* @author Heath Barnhart <hbarnhart@kanren.net>
|
||||
*/
|
||||
|
||||
namespace LibreNMS\Snmptrap\Handlers;
|
||||
|
||||
use App\Models\Device;
|
||||
use LibreNMS\Interfaces\SnmptrapHandler;
|
||||
use LibreNMS\Snmptrap\Handlers\CyberPowerUtil;
|
||||
use LibreNMS\Snmptrap\Trap;
|
||||
use Log;
|
||||
|
||||
class CpUpsOnBattery 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)
|
||||
{
|
||||
$battery = CyberPowerUtil::getMessage($trap);
|
||||
Log::event("$battery", $device->device_id, 'trap', 4);
|
||||
}
|
||||
}
|
51
LibreNMS/Snmptrap/Handlers/CpUpsOverTemp.php
Normal file
51
LibreNMS/Snmptrap/Handlers/CpUpsOverTemp.php
Normal file
@@ -0,0 +1,51 @@
|
||||
<?php
|
||||
/**
|
||||
* CpUpsOverTemp.php
|
||||
*
|
||||
* -Description-
|
||||
*
|
||||
* CyberPower UPS trap high temperature.
|
||||
*
|
||||
* 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
|
||||
* @copyright 2020 KanREN Inc.
|
||||
* @author Heath Barnhart <hbarnhart@kanren.net>
|
||||
*/
|
||||
|
||||
namespace LibreNMS\Snmptrap\Handlers;
|
||||
|
||||
use App\Models\Device;
|
||||
use LibreNMS\Interfaces\SnmptrapHandler;
|
||||
use LibreNMS\Snmptrap\Handlers\CyberPowerUtil;
|
||||
use LibreNMS\Snmptrap\Trap;
|
||||
use Log;
|
||||
|
||||
class CpUpsOverTemp 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)
|
||||
{
|
||||
$temp = CyberPowerUtil::getMessage($trap);
|
||||
Log::event("$temp", $device->device_id, 'trap', 5);
|
||||
}
|
||||
}
|
51
LibreNMS/Snmptrap/Handlers/CpUpsOverload.php
Normal file
51
LibreNMS/Snmptrap/Handlers/CpUpsOverload.php
Normal file
@@ -0,0 +1,51 @@
|
||||
<?php
|
||||
/**
|
||||
* CpUpsOverload.php
|
||||
*
|
||||
* -Description-
|
||||
*
|
||||
* CyberPower UPS is in an overload condition.
|
||||
*
|
||||
* 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
|
||||
* @copyright 2020 KanREN Inc.
|
||||
* @author Heath Barnhart <hbarnhart@kanren.net>
|
||||
*/
|
||||
|
||||
namespace LibreNMS\Snmptrap\Handlers;
|
||||
|
||||
use App\Models\Device;
|
||||
use LibreNMS\Interfaces\SnmptrapHandler;
|
||||
use LibreNMS\Snmptrap\Handlers\CyberPowerUtil;
|
||||
use LibreNMS\Snmptrap\Trap;
|
||||
use Log;
|
||||
|
||||
class CpUpsOverload 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)
|
||||
{
|
||||
$overload = CyberPowerUtil::getMessage($trap);
|
||||
Log::event("$overload", $device->device_id, 'trap', 5);
|
||||
}
|
||||
}
|
51
LibreNMS/Snmptrap/Handlers/CpUpsRebootStarted.php
Normal file
51
LibreNMS/Snmptrap/Handlers/CpUpsRebootStarted.php
Normal file
@@ -0,0 +1,51 @@
|
||||
<?php
|
||||
/**
|
||||
* CpUpsRebootStarted.php
|
||||
*
|
||||
* -Description-
|
||||
*
|
||||
* CyberPower UPS trap UPS is rebooting.
|
||||
*
|
||||
* 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
|
||||
* @copyright 2020 KanREN Inc.
|
||||
* @author Heath Barnhart <hbarnhart@kanren.net>
|
||||
*/
|
||||
|
||||
namespace LibreNMS\Snmptrap\Handlers;
|
||||
|
||||
use App\Models\Device;
|
||||
use LibreNMS\Interfaces\SnmptrapHandler;
|
||||
use LibreNMS\Snmptrap\Handlers\CyberPowerUtil;
|
||||
use LibreNMS\Snmptrap\Trap;
|
||||
use Log;
|
||||
|
||||
class CpUpsRebootStarted 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)
|
||||
{
|
||||
$status = CyberPowerUtil::getMessage($trap);
|
||||
Log::event("$status", $device->device_id, 'trap', 4);
|
||||
}
|
||||
}
|
51
LibreNMS/Snmptrap/Handlers/CpUpsRtnChargerFailure.php
Normal file
51
LibreNMS/Snmptrap/Handlers/CpUpsRtnChargerFailure.php
Normal file
@@ -0,0 +1,51 @@
|
||||
<?php
|
||||
/**
|
||||
* CpUpsRtnChargerFailure.php
|
||||
*
|
||||
* -Description-
|
||||
*
|
||||
* CyberPower UPS trap battery charger recovered from failure.
|
||||
*
|
||||
* 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
|
||||
* @copyright 2020 Kanren Inc.
|
||||
* @author Heath Barnhart <hbarnhart@kanren.net>
|
||||
*/
|
||||
|
||||
namespace LibreNMS\Snmptrap\Handlers;
|
||||
|
||||
use App\Models\Device;
|
||||
use LibreNMS\Interfaces\SnmptrapHandler;
|
||||
use LibreNMS\Snmptrap\Handlers\CyberPowerUtil;
|
||||
use LibreNMS\Snmptrap\Trap;
|
||||
use Log;
|
||||
|
||||
class CpUpsRtnChargerFailure 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)
|
||||
{
|
||||
$chargeInfo = CyberPowerUtil::getMessage($trap);
|
||||
Log::event("$chargeInfo", $device->device_id, 'trap', 1);
|
||||
}
|
||||
}
|
51
LibreNMS/Snmptrap/Handlers/CpUpsRtnDischarged.php
Normal file
51
LibreNMS/Snmptrap/Handlers/CpUpsRtnDischarged.php
Normal file
@@ -0,0 +1,51 @@
|
||||
<?php
|
||||
/**
|
||||
* CpUpsRtnDischarged.php
|
||||
*
|
||||
* -Description-
|
||||
*
|
||||
* CyberPower UPS runtime calibration complete.
|
||||
*
|
||||
* 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
|
||||
* @copyright 2020 Kanren Inc.
|
||||
* @author Heath Barnhart <hbarnhart@kanren.net>
|
||||
*/
|
||||
|
||||
namespace LibreNMS\Snmptrap\Handlers;
|
||||
|
||||
use App\Models\Device;
|
||||
use LibreNMS\Interfaces\SnmptrapHandler;
|
||||
use LibreNMS\Snmptrap\Handlers\CyberPowerUtil;
|
||||
use LibreNMS\Snmptrap\Trap;
|
||||
use Log;
|
||||
|
||||
class CpUpsRtnDischarged 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)
|
||||
{
|
||||
$dischargeInfo = CyberPowerUtil::getMessage($trap);
|
||||
Log::event("$dischargeInfo", $device->device_id, 'trap', 2);
|
||||
}
|
||||
}
|
51
LibreNMS/Snmptrap/Handlers/CpUpsRtnOverTemp.php
Normal file
51
LibreNMS/Snmptrap/Handlers/CpUpsRtnOverTemp.php
Normal file
@@ -0,0 +1,51 @@
|
||||
<?php
|
||||
/**
|
||||
* CpUpsRtnOverTemp.php
|
||||
*
|
||||
* -Description-
|
||||
*
|
||||
* CyberPower UPS trap high temperature cleared.
|
||||
*
|
||||
* 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
|
||||
* @copyright 2020 KanREN Inc.
|
||||
* @author Heath Barnhart <hbarnhart@kanren.net>
|
||||
*/
|
||||
|
||||
namespace LibreNMS\Snmptrap\Handlers;
|
||||
|
||||
use App\Models\Device;
|
||||
use LibreNMS\Interfaces\SnmptrapHandler;
|
||||
use LibreNMS\Snmptrap\Handlers\CyberPowerUtil;
|
||||
use LibreNMS\Snmptrap\Trap;
|
||||
use Log;
|
||||
|
||||
class CpUpsRtnOverTemp 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)
|
||||
{
|
||||
$temp = CyberPowerUtil::getMessage($trap);
|
||||
Log::event("$temp", $device->device_id, 'trap', 1);
|
||||
}
|
||||
}
|
51
LibreNMS/Snmptrap/Handlers/CpUpsRtnOverload.php
Normal file
51
LibreNMS/Snmptrap/Handlers/CpUpsRtnOverload.php
Normal file
@@ -0,0 +1,51 @@
|
||||
<?php
|
||||
/**
|
||||
* CpUpsRtnOverload.php
|
||||
*
|
||||
* -Description-
|
||||
*
|
||||
* CyberPower UPS recovered from overload condition.
|
||||
*
|
||||
* 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
|
||||
* @copyright 2020 KanREN Inc.
|
||||
* @author Heath Barnhart <hbarnhart@kanren.net>
|
||||
*/
|
||||
|
||||
namespace LibreNMS\Snmptrap\Handlers;
|
||||
|
||||
use App\Models\Device;
|
||||
use LibreNMS\Interfaces\SnmptrapHandler;
|
||||
use LibreNMS\Snmptrap\Handlers\CyberPowerUtil;
|
||||
use LibreNMS\Snmptrap\Trap;
|
||||
use Log;
|
||||
|
||||
class CpUpsRtnOverload 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)
|
||||
{
|
||||
$overload = CyberPowerUtil::getMessage($trap);
|
||||
Log::event("$overload", $device->device_id, 'trap', 1);
|
||||
}
|
||||
}
|
51
LibreNMS/Snmptrap/Handlers/CpUpsSleeping.php
Normal file
51
LibreNMS/Snmptrap/Handlers/CpUpsSleeping.php
Normal file
@@ -0,0 +1,51 @@
|
||||
<?php
|
||||
/**
|
||||
* CpUpsSleeping.php
|
||||
*
|
||||
* -Description-
|
||||
*
|
||||
* CyberPower UPS trap UPS is entering sleep mode.
|
||||
*
|
||||
* 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
|
||||
* @copyright 2020 KanREN Inc.
|
||||
* @author Heath Barnhart <hbarnhart@kanren.net>
|
||||
*/
|
||||
|
||||
namespace LibreNMS\Snmptrap\Handlers;
|
||||
|
||||
use App\Models\Device;
|
||||
use LibreNMS\Interfaces\SnmptrapHandler;
|
||||
use LibreNMS\Snmptrap\Handlers\CyberPowerUtil;
|
||||
use LibreNMS\Snmptrap\Trap;
|
||||
use Log;
|
||||
|
||||
class CpUpsSleeping 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)
|
||||
{
|
||||
$status = CyberPowerUtil::getMessage($trap);
|
||||
Log::event("$status", $device->device_id, 'trap', 4);
|
||||
}
|
||||
}
|
51
LibreNMS/Snmptrap/Handlers/CpUpsStartBatteryTest.php
Normal file
51
LibreNMS/Snmptrap/Handlers/CpUpsStartBatteryTest.php
Normal file
@@ -0,0 +1,51 @@
|
||||
<?php
|
||||
/**
|
||||
* CpUpsStartBatteryTest.php
|
||||
*
|
||||
* -Description-
|
||||
*
|
||||
* CyberPower UPS battery test started.
|
||||
*
|
||||
* 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
|
||||
* @copyright 2020 KanREN Inc.
|
||||
* @author Heath Barnhart <hbarnhart@kanren.net>
|
||||
*/
|
||||
|
||||
namespace LibreNMS\Snmptrap\Handlers;
|
||||
|
||||
use App\Models\Device;
|
||||
use LibreNMS\Interfaces\SnmptrapHandler;
|
||||
use LibreNMS\Snmptrap\Handlers\CyberPowerUtil;
|
||||
use LibreNMS\Snmptrap\Trap;
|
||||
use Log;
|
||||
|
||||
class CpUpsStartBatteryTest 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)
|
||||
{
|
||||
$battTestInfo = CyberPowerUtil::getMessage($trap);
|
||||
Log::event("$battTestInfo", $device->device_id, 'trap', 2);
|
||||
}
|
||||
}
|
51
LibreNMS/Snmptrap/Handlers/CpUpsTurnedOff.php
Normal file
51
LibreNMS/Snmptrap/Handlers/CpUpsTurnedOff.php
Normal file
@@ -0,0 +1,51 @@
|
||||
<?php
|
||||
/**
|
||||
* CpUpsTurnedOff.php
|
||||
*
|
||||
* -Description-
|
||||
*
|
||||
* CyberPower UPS trap UPS is powering off.
|
||||
*
|
||||
* 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
|
||||
* @copyright 2020 KanREN Inc.
|
||||
* @author Heath Barnhart <hbarnhart@kanren.net>
|
||||
*/
|
||||
|
||||
namespace LibreNMS\Snmptrap\Handlers;
|
||||
|
||||
use App\Models\Device;
|
||||
use LibreNMS\Interfaces\SnmptrapHandler;
|
||||
use LibreNMS\Snmptrap\Handlers\CyberPowerUtil;
|
||||
use LibreNMS\Snmptrap\Trap;
|
||||
use Log;
|
||||
|
||||
class CpUpsTurnedOff 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)
|
||||
{
|
||||
$status = CyberPowerUtil::getMessage($trap);
|
||||
Log::event("$status", $device->device_id, 'trap', 4);
|
||||
}
|
||||
}
|
51
LibreNMS/Snmptrap/Handlers/CpUpsWokeUp.php
Normal file
51
LibreNMS/Snmptrap/Handlers/CpUpsWokeUp.php
Normal file
@@ -0,0 +1,51 @@
|
||||
<?php
|
||||
/**
|
||||
* CpUpsWokeUp.php
|
||||
*
|
||||
* -Description-
|
||||
*
|
||||
* CyberPower UPS trap UPS is leaving sleep mode.
|
||||
*
|
||||
* 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
|
||||
* @copyright 2020 KanREN Inc.
|
||||
* @author Heath Barnhart <hbarnhart@kanren.net>
|
||||
*/
|
||||
|
||||
namespace LibreNMS\Snmptrap\Handlers;
|
||||
|
||||
use App\Models\Device;
|
||||
use LibreNMS\Interfaces\SnmptrapHandler;
|
||||
use LibreNMS\Snmptrap\Handlers\CyberPowerUtil;
|
||||
use LibreNMS\Snmptrap\Trap;
|
||||
use Log;
|
||||
|
||||
class CpUpsWokeUp 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)
|
||||
{
|
||||
$status = CyberPowerUtil::getMessage($trap);
|
||||
Log::event("$status", $device->device_id, 'trap', 1);
|
||||
}
|
||||
}
|
42
LibreNMS/Snmptrap/Handlers/CyberPowerUtil.php
Normal file
42
LibreNMS/Snmptrap/Handlers/CyberPowerUtil.php
Normal file
@@ -0,0 +1,42 @@
|
||||
<?php
|
||||
/**
|
||||
* CyberPowerUtil.php
|
||||
*
|
||||
* -Description-
|
||||
*
|
||||
* CyberPower UPS SNMP Trap utility class
|
||||
*
|
||||
* 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
|
||||
* @copyright 2020 KanREN Inc.
|
||||
* @author Heath Barnhart <hbarnhart@kanren.net>
|
||||
*/
|
||||
|
||||
namespace LibreNMS\Snmptrap\Handlers;
|
||||
|
||||
class CyberPowerUtil
|
||||
{
|
||||
/**
|
||||
* Get the trap message
|
||||
*
|
||||
* @param Trap $trap
|
||||
* @return string
|
||||
*/
|
||||
public static function getMessage($trap)
|
||||
{
|
||||
return $trap->getOidData($trap->findOid('CPS-MIB::mtrapinfoString'));
|
||||
}
|
||||
}
|
@@ -25,6 +25,27 @@ return [
|
||||
'CM-SYSTEM-MIB::cmObjectDeletionTrap' => \LibreNMS\Snmptrap\Handlers\AdvaObjectDeletion::class,
|
||||
'CM-SYSTEM-MIB::cmSnmpDyingGaspTrap' => \LibreNMS\Snmptrap\Handlers\AdvaSnmpDyingGaspTrap::class,
|
||||
'CM-SYSTEM-MIB::cmStateChangeTrap' => \LibreNMS\Snmptrap\Handlers\AdvaStateChangeTrap::class,
|
||||
'CPS-MIB::lowBattery' => LibreNMS\Snmptrap\Handlers\CpLowBattery::class,
|
||||
'CPS-MIB::powerRestored' => \LibreNMS\Snmptrap\Handlers\CpPowerRestored::class,
|
||||
'CPS-MIB::returnFromChargerFailure' => \LibreNMS\Snmptrap\Handlers\CpUpsRtnChargerFailure::class,
|
||||
'CPS-MIB::returnFromDischarged' => \LibreNMS\Snmptrap\Handlers\CpRtnFromDischarge::class,
|
||||
'CPS-MIB::returnFromLowBattery' => \LibreNMS\Snmptrap\Handlers\CpRtnLowBattery::class,
|
||||
'CPS-MIB::upsDiagnosticsFailed' => \LibreNMS\Snmptrap\Handlers\CpUpsDiagFailed::class,
|
||||
'CPS-MIB::returnFromDischarged' => \LibreNMS\Snmptrap\Handlers\CpRtnDischarge::class,
|
||||
'CPS-MIB::returnFromOverLoad' => \LibreNMS\Snmptrap\Handlers\CpUpsRtnOverload::class,
|
||||
'CPS-MIB::returnFromOverTemp' => \LibreNMS\Snmptrap\Handlers\CpUpsRtnOverTemp::class,
|
||||
'CPS-MIB::upsBatteryNotPresent' => \LibreNMS\Snmptrap\Handlers\CpUpsBatteryNotPresent::class,
|
||||
'CPS-MIB::upsChargerFailure' => \LibreNMS\Snmptrap\Handlers\CpUpsChargerFailure::class,
|
||||
'CPS-MIB::upsDiagnosticsPassed' => \LibreNMS\Snmptrap\Handlers\CpUpsDiagPassed::class,
|
||||
'CPS-MIB::upsDischarged' => \LibreNMS\Snmptrap\Handlers\CpUpsDischarged::class,
|
||||
'CPS-MIB::upsOnBattery' => \LibreNMS\Snmptrap\Handlers\CpUpsOnBattery::class,
|
||||
'CPS-MIB::upsOverload' => \LibreNMS\Snmptrap\Handlers\CpUpsOverload::class,
|
||||
'CPS-MIB::upsOverTemp' => \LibreNMS\Snmptrap\Handlers\CpUpsOverTemp::class,
|
||||
'CPS-MIB::upsRebootStarted' => \LibreNMS\Snmptrap\Handlers\CpUpsRebootStarted::class,
|
||||
'CPS-MIB::upsSleeping' => \LibreNMS\Snmptrap\Handlers\CpUpsSleeping::class,
|
||||
'CPS-MIB::upsStartBatteryTest' => \LibreNMS\Snmptrap\Handlers\CpUpsStartBatteryTest::class,
|
||||
'CPS-MIB::upsTurnedOff' => \LibreNMS\Snmptrap\Handlers\CpUpsTurnedOff::class,
|
||||
'CPS-MIB::upsWokeUp' => \LibreNMS\Snmptrap\Handlers\CpUpsWokeUp::class,
|
||||
'ENTITY-MIB::entConfigChange' => \LibreNMS\Snmptrap\Handlers\EntityDatabaseConfigChanged::class,
|
||||
'EQUIPMENT-MIB::equipStatusTrap' => \LibreNMS\Snmptrap\Handlers\EquipStatusTrap::class,
|
||||
'FORTINET-CORE-MIB::fnTrapMemThreshold' => \LibreNMS\Snmptrap\Handlers\FnTrapMemThreshold::class,
|
||||
|
433
tests/Feature/SnmpTraps/CyberPowerTrapsTest.php
Normal file
433
tests/Feature/SnmpTraps/CyberPowerTrapsTest.php
Normal file
@@ -0,0 +1,433 @@
|
||||
<?php
|
||||
/*
|
||||
* CyberPowerTrapsTest.php
|
||||
*
|
||||
* 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/>.
|
||||
*
|
||||
* Unit tests for CyberPower UPS SNMP trap handlers
|
||||
*
|
||||
* @package LibreNMS
|
||||
* @link http://librenms.org
|
||||
* @copyright 2020 KanREN, Inc
|
||||
* @author Heath Barnhart <hbarnhart@kanren.net>
|
||||
*/
|
||||
|
||||
namespace LibreNMS\Tests\Feature\SnmpTraps;
|
||||
|
||||
use App\Models\Device;
|
||||
use App\Models\Ipv4Address;
|
||||
use LibreNMS\Snmptrap\Dispatcher;
|
||||
use LibreNMS\Snmptrap\Trap;
|
||||
|
||||
class CyberPowerTrapsTest extends SnmpTrapTestCase
|
||||
{
|
||||
public function testCpUpsOverload()
|
||||
{
|
||||
$device = factory(Device::class)->create();
|
||||
$ipv4 = factory(Ipv4Address::class)->make();
|
||||
|
||||
$trapText = "$device->hostname
|
||||
UDP: [$device->ip]:161->[192.168.5.5]:162
|
||||
DISMAN-EVENT-MIB::sysUpTimeInstance 488:17:19:10.00
|
||||
SNMPv2-MIB::snmpTrapOID.0 CPS-MIB::upsOverload
|
||||
CPS-MIB::mtrapinfoString \"The UPS has sensed an overload condition.\"
|
||||
SNMP-COMMUNITY-MIB::snmpTrapAddress.0 $device->ip
|
||||
SNMP-COMMUNITY-MIB::snmpTrapCommunity.0 \"comstring\"
|
||||
SNMPv2-MIB::snmpTrapEnterprise.0 CPS-MIB::cps";
|
||||
|
||||
$message = "The UPS has sensed an overload condition.";
|
||||
\Log::shouldReceive('event')->once()->with($message, $device->device_id, 'trap', 5);
|
||||
|
||||
$trap = new Trap($trapText);
|
||||
$this->assertTrue(Dispatcher::handle($trap), 'Could not handle CpUpsOverload trap');
|
||||
}
|
||||
|
||||
public function testCpUpsDiagFailed()
|
||||
{
|
||||
$device = factory(Device::class)->create();
|
||||
$ipv4 = factory(Ipv4Address::class)->make();
|
||||
|
||||
$trapText = "$device->hostname
|
||||
UDP: [$device->ip]:161->[192.168.5.5]:162
|
||||
DISMAN-EVENT-MIB::sysUpTimeInstance 488:17:19:10.00
|
||||
SNMPv2-MIB::snmpTrapOID.0 CPS-MIB::upsDiagnosticsFailed
|
||||
CPS-MIB::mtrapinfoString \"The UPS battery test failed.\"
|
||||
SNMP-COMMUNITY-MIB::snmpTrapAddress.0 $device->ip
|
||||
SNMP-COMMUNITY-MIB::snmpTrapCommunity.0 \"comstring\"
|
||||
SNMPv2-MIB::snmpTrapEnterprise.0 CPS-MIB::cps";
|
||||
|
||||
$message = "The UPS battery test failed.";
|
||||
\Log::shouldReceive('event')->once()->with($message, $device->device_id, 'trap', 5);
|
||||
|
||||
$trap = new Trap($trapText);
|
||||
$this->assertTrue(Dispatcher::handle($trap), 'Could not handle CpUpsDiagFailed trap');
|
||||
}
|
||||
|
||||
public function testCpUpsDischarged()
|
||||
{
|
||||
$device = factory(Device::class)->create();
|
||||
$ipv4 = factory(Ipv4Address::class)->make();
|
||||
|
||||
$trapText = "$device->hostname
|
||||
UDP: [$device->ip]:161->[192.168.5.5]:162
|
||||
DISMAN-EVENT-MIB::sysUpTimeInstance 488:17:19:10.00
|
||||
SNMPv2-MIB::snmpTrapOID.0 CPS-MIB::upsDischarged
|
||||
CPS-MIB::mtrapinfoString \"The UPS has started a runtime calibration process.\"
|
||||
SNMP-COMMUNITY-MIB::snmpTrapAddress.0 $device->ip
|
||||
SNMP-COMMUNITY-MIB::snmpTrapCommunity.0 \"comstring\"
|
||||
SNMPv2-MIB::snmpTrapEnterprise.0 CPS-MIB::cps";
|
||||
|
||||
$message = "The UPS has started a runtime calibration process.";
|
||||
\Log::shouldReceive('event')->once()->with($message, $device->device_id, 'trap', 2);
|
||||
|
||||
$trap = new Trap($trapText);
|
||||
$this->assertTrue(Dispatcher::handle($trap), 'Could not handle CpUpsDischarged trap');
|
||||
}
|
||||
|
||||
public function testCpUpsOnBattery()
|
||||
{
|
||||
$device = factory(Device::class)->create();
|
||||
$ipv4 = factory(Ipv4Address::class)->make();
|
||||
|
||||
$trapText = "$device->hostname
|
||||
UDP: [$device->ip]:161->[192.168.5.5]:162
|
||||
DISMAN-EVENT-MIB::sysUpTimeInstance 488:17:19:10.00
|
||||
SNMPv2-MIB::snmpTrapOID.0 CPS-MIB::upsOnBattery
|
||||
CPS-MIB::mtrapinfoString \"Utility power failed, transfer to backup mode.\"
|
||||
SNMP-COMMUNITY-MIB::snmpTrapAddress.0 $device->ip
|
||||
SNMP-COMMUNITY-MIB::snmpTrapCommunity.0 \"comstring\"
|
||||
SNMPv2-MIB::snmpTrapEnterprise.0 CPS-MIB::cps";
|
||||
|
||||
$message = "Utility power failed, transfer to backup mode.";
|
||||
\Log::shouldReceive('event')->once()->with($message, $device->device_id, 'trap', 4);
|
||||
|
||||
$trap = new Trap($trapText);
|
||||
$this->assertTrue(Dispatcher::handle($trap), 'Could not handle CpUpsOnBattery trap');
|
||||
}
|
||||
|
||||
public function testCpLowBattery()
|
||||
{
|
||||
$device = factory(Device::class)->create();
|
||||
$ipv4 = factory(Ipv4Address::class)->make();
|
||||
|
||||
$trapText = "$device->hostname
|
||||
UDP: [$device->ip]:161->[192.168.5.5]:162
|
||||
DISMAN-EVENT-MIB::sysUpTimeInstance 488:17:19:10.00
|
||||
SNMPv2-MIB::snmpTrapOID.0 CPS-MIB::lowBattery
|
||||
CPS-MIB::mtrapinfoString \"The UPS battery capacity is low than threshold, soon to be exhausted.\"
|
||||
SNMP-COMMUNITY-MIB::snmpTrapAddress.0 $device->ip
|
||||
SNMP-COMMUNITY-MIB::snmpTrapCommunity.0 \"comstring\"
|
||||
SNMPv2-MIB::snmpTrapEnterprise.0 CPS-MIB::cps";
|
||||
|
||||
$message = "The UPS battery capacity is low than threshold, soon to be exhausted.";
|
||||
\Log::shouldReceive('event')->once()->with($message, $device->device_id, 'trap', 4);
|
||||
|
||||
$trap = new Trap($trapText);
|
||||
$this->assertTrue(Dispatcher::handle($trap), 'Could not handle CpLowBattery trap');
|
||||
}
|
||||
|
||||
public function testCpPowerRestored()
|
||||
{
|
||||
$device = factory(Device::class)->create();
|
||||
$ipv4 = factory(Ipv4Address::class)->make();
|
||||
|
||||
$trapText = "$device->hostname
|
||||
UDP: [$device->ip]:161->[192.168.5.5]:162
|
||||
DISMAN-EVENT-MIB::sysUpTimeInstance 488:17:19:10.00
|
||||
SNMPv2-MIB::snmpTrapOID.0 CPS-MIB::powerRestored
|
||||
CPS-MIB::mtrapinfoString \"Utility power restored, return from backup mode.\"
|
||||
SNMP-COMMUNITY-MIB::snmpTrapAddress.0 $device->ip
|
||||
SNMP-COMMUNITY-MIB::snmpTrapCommunity.0 \"comstring\"
|
||||
SNMPv2-MIB::snmpTrapEnterprise.0 CPS-MIB::cps";
|
||||
|
||||
$message = "Utility power restored, return from backup mode.";
|
||||
\Log::shouldReceive('event')->once()->with($message, $device->device_id, 'trap', 1);
|
||||
|
||||
$trap = new Trap($trapText);
|
||||
$this->assertTrue(Dispatcher::handle($trap), 'Could not handle CpPowerRestored trap');
|
||||
}
|
||||
|
||||
public function testCpUpsDiagPassed()
|
||||
{
|
||||
$device = factory(Device::class)->create();
|
||||
$ipv4 = factory(Ipv4Address::class)->make();
|
||||
|
||||
$trapText = "$device->hostname
|
||||
UDP: [$device->ip]:161->[192.168.5.5]:162
|
||||
DISMAN-EVENT-MIB::sysUpTimeInstance 488:17:19:10.00
|
||||
SNMPv2-MIB::snmpTrapOID.0 CPS-MIB::upsDiagnosticsPassed
|
||||
CPS-MIB::mtrapinfoString \"The UPS battery test passed.\"
|
||||
SNMP-COMMUNITY-MIB::snmpTrapAddress.0 $device->ip
|
||||
SNMP-COMMUNITY-MIB::snmpTrapCommunity.0 \"comstring\"
|
||||
SNMPv2-MIB::snmpTrapEnterprise.0 CPS-MIB::cps";
|
||||
|
||||
$message = "The UPS battery test passed.";
|
||||
\Log::shouldReceive('event')->once()->with($message, $device->device_id, 'trap', 2);
|
||||
|
||||
$trap = new Trap($trapText);
|
||||
$this->assertTrue(Dispatcher::handle($trap), 'Could not handle CpUpsDiagPassed trap');
|
||||
}
|
||||
|
||||
public function testCpRtnLowBattery()
|
||||
{
|
||||
$device = factory(Device::class)->create();
|
||||
$ipv4 = factory(Ipv4Address::class)->make();
|
||||
|
||||
$trapText = "$device->hostname
|
||||
UDP: [$device->ip]:161->[192.168.5.5]:162
|
||||
DISMAN-EVENT-MIB::sysUpTimeInstance 488:17:19:10.00
|
||||
SNMPv2-MIB::snmpTrapOID.0 CPS-MIB::returnFromLowBattery
|
||||
CPS-MIB::mtrapinfoString \"The UPS has returned from a low battery condition.\"
|
||||
SNMP-COMMUNITY-MIB::snmpTrapAddress.0 $device->ip
|
||||
SNMP-COMMUNITY-MIB::snmpTrapCommunity.0 \"comstring\"
|
||||
SNMPv2-MIB::snmpTrapEnterprise.0 CPS-MIB::cps";
|
||||
|
||||
$message = "The UPS has returned from a low battery condition.";
|
||||
\Log::shouldReceive('event')->once()->with($message, $device->device_id, 'trap', 1);
|
||||
|
||||
$trap = new Trap($trapText);
|
||||
$this->assertTrue(Dispatcher::handle($trap), 'Could not handle CpRtnLowBattery trap');
|
||||
}
|
||||
|
||||
public function testCpUpsTurnedOff()
|
||||
{
|
||||
$device = factory(Device::class)->create();
|
||||
$ipv4 = factory(Ipv4Address::class)->make();
|
||||
|
||||
$trapText = "$device->hostname
|
||||
UDP: [$device->ip]:161->[192.168.5.5]:162
|
||||
DISMAN-EVENT-MIB::sysUpTimeInstance 488:17:19:10.00
|
||||
SNMPv2-MIB::snmpTrapOID.0 CPS-MIB::upsTurnedOff
|
||||
CPS-MIB::mtrapinfoString \"The UPS has been turned off.\"
|
||||
SNMP-COMMUNITY-MIB::snmpTrapAddress.0 $device->ip
|
||||
SNMP-COMMUNITY-MIB::snmpTrapCommunity.0 \"comstring\"
|
||||
SNMPv2-MIB::snmpTrapEnterprise.0 CPS-MIB::cps";
|
||||
|
||||
$message = "The UPS has been turned off.";
|
||||
\Log::shouldReceive('event')->once()->with($message, $device->device_id, 'trap', 4);
|
||||
|
||||
$trap = new Trap($trapText);
|
||||
$this->assertTrue(Dispatcher::handle($trap), 'Could not handle CpUpsTurnedOff trap');
|
||||
}
|
||||
|
||||
public function testCpUpsSleeping()
|
||||
{
|
||||
$device = factory(Device::class)->create();
|
||||
$ipv4 = factory(Ipv4Address::class)->make();
|
||||
|
||||
$trapText = "$device->hostname
|
||||
UDP: [$device->ip]:161->[192.168.5.5]:162
|
||||
DISMAN-EVENT-MIB::sysUpTimeInstance 488:17:19:10.00
|
||||
SNMPv2-MIB::snmpTrapOID.0 CPS-MIB::upsSleeping
|
||||
CPS-MIB::mtrapinfoString \"The UPS entered sleep mode. Output power will not be provided.\"
|
||||
SNMP-COMMUNITY-MIB::snmpTrapAddress.0 $device->ip
|
||||
SNMP-COMMUNITY-MIB::snmpTrapCommunity.0 \"comstring\"
|
||||
SNMPv2-MIB::snmpTrapEnterprise.0 CPS-MIB::cps";
|
||||
|
||||
$message = "The UPS entered sleep mode. Output power will not be provided.";
|
||||
\Log::shouldReceive('event')->once()->with($message, $device->device_id, 'trap', 4);
|
||||
|
||||
$trap = new Trap($trapText);
|
||||
$this->assertTrue(Dispatcher::handle($trap), 'Could not handle CpUpsSleeping trap');
|
||||
}
|
||||
|
||||
public function testCpUpsWokeUp()
|
||||
{
|
||||
$device = factory(Device::class)->create();
|
||||
$ipv4 = factory(Ipv4Address::class)->make();
|
||||
|
||||
$trapText = "$device->hostname
|
||||
UDP: [$device->ip]:161->[192.168.5.5]:162
|
||||
DISMAN-EVENT-MIB::sysUpTimeInstance 488:17:19:10.00
|
||||
SNMPv2-MIB::snmpTrapOID.0 CPS-MIB::upsWokeUp
|
||||
CPS-MIB::mtrapinfoString \"The UPS woke up from sleep mode. Output power is being provided.\"
|
||||
SNMP-COMMUNITY-MIB::snmpTrapAddress.0 $device->ip
|
||||
SNMP-COMMUNITY-MIB::snmpTrapCommunity.0 \"comstring\"
|
||||
SNMPv2-MIB::snmpTrapEnterprise.0 CPS-MIB::cps";
|
||||
|
||||
$message = "The UPS woke up from sleep mode. Output power is being provided.";
|
||||
\Log::shouldReceive('event')->once()->with($message, $device->device_id, 'trap', 1);
|
||||
|
||||
$trap = new Trap($trapText);
|
||||
$this->assertTrue(Dispatcher::handle($trap), 'Could not handle CpUpsWokeUp trap');
|
||||
}
|
||||
|
||||
public function testCpUpsRebootStarted()
|
||||
{
|
||||
$device = factory(Device::class)->create();
|
||||
$ipv4 = factory(Ipv4Address::class)->make();
|
||||
|
||||
$trapText = "$device->hostname
|
||||
UDP: [$device->ip]:161->[192.168.5.5]:162
|
||||
DISMAN-EVENT-MIB::sysUpTimeInstance 488:17:19:10.00
|
||||
SNMPv2-MIB::snmpTrapOID.0 CPS-MIB::upsRebootStarted
|
||||
CPS-MIB::mtrapinfoString \"The UPS started reboot sequence.\"
|
||||
SNMP-COMMUNITY-MIB::snmpTrapAddress.0 $device->ip
|
||||
SNMP-COMMUNITY-MIB::snmpTrapCommunity.0 \"comstring\"
|
||||
SNMPv2-MIB::snmpTrapEnterprise.0 CPS-MIB::cps";
|
||||
|
||||
$message = "The UPS started reboot sequence.";
|
||||
\Log::shouldReceive('event')->once()->with($message, $device->device_id, 'trap', 4);
|
||||
|
||||
$trap = new Trap($trapText);
|
||||
$this->assertTrue(Dispatcher::handle($trap), 'Could not handle CpUpsRebootStarted trap');
|
||||
}
|
||||
|
||||
public function testCpUpsOverTemp()
|
||||
{
|
||||
$device = factory(Device::class)->create();
|
||||
$ipv4 = factory(Ipv4Address::class)->make();
|
||||
|
||||
$trapText = "$device->hostname
|
||||
UDP: [$device->ip]:161->[192.168.5.5]:162
|
||||
DISMAN-EVENT-MIB::sysUpTimeInstance 488:17:19:10.00
|
||||
SNMPv2-MIB::snmpTrapOID.0 CPS-MIB::upsOverTemp
|
||||
CPS-MIB::mtrapinfoString \"The UPS inner temperature is too high.\"
|
||||
SNMP-COMMUNITY-MIB::snmpTrapAddress.0 $device->ip
|
||||
SNMP-COMMUNITY-MIB::snmpTrapCommunity.0 \"comstring\"
|
||||
SNMPv2-MIB::snmpTrapEnterprise.0 CPS-MIB::cps";
|
||||
|
||||
$message = "The UPS inner temperature is too high.";
|
||||
\Log::shouldReceive('event')->once()->with($message, $device->device_id, 'trap', 5);
|
||||
|
||||
$trap = new Trap($trapText);
|
||||
$this->assertTrue(Dispatcher::handle($trap), 'Could not handle CpUpsOverTemp trap');
|
||||
}
|
||||
|
||||
public function testCpRtnOverTemp()
|
||||
{
|
||||
$device = factory(Device::class)->create();
|
||||
$ipv4 = factory(Ipv4Address::class)->make();
|
||||
|
||||
$trapText = "$device->hostname
|
||||
UDP: [$device->ip]:161->[192.168.5.5]:162
|
||||
DISMAN-EVENT-MIB::sysUpTimeInstance 488:17:19:10.00
|
||||
SNMPv2-MIB::snmpTrapOID.0 CPS-MIB::returnFromOverTemp
|
||||
CPS-MIB::mtrapinfoString \"The UPS over temperature condition cleared.\"
|
||||
SNMP-COMMUNITY-MIB::snmpTrapAddress.0 $device->ip
|
||||
SNMP-COMMUNITY-MIB::snmpTrapCommunity.0 \"comstring\"
|
||||
SNMPv2-MIB::snmpTrapEnterprise.0 CPS-MIB::cps";
|
||||
|
||||
$message = "The UPS over temperature condition cleared.";
|
||||
\Log::shouldReceive('event')->once()->with($message, $device->device_id, 'trap', 1);
|
||||
|
||||
$trap = new Trap($trapText);
|
||||
$this->assertTrue(Dispatcher::handle($trap), 'Could not handle CpRtnOverTemp trap');
|
||||
}
|
||||
|
||||
public function testCpRtOverLoad()
|
||||
{
|
||||
$device = factory(Device::class)->create();
|
||||
$ipv4 = factory(Ipv4Address::class)->make();
|
||||
|
||||
$trapText = "$device->hostname
|
||||
UDP: [$device->ip]:161->[192.168.5.5]:162
|
||||
DISMAN-EVENT-MIB::sysUpTimeInstance 488:17:19:10.00
|
||||
SNMPv2-MIB::snmpTrapOID.0 CPS-MIB::returnFromOverLoad
|
||||
CPS-MIB::mtrapinfoString \"The UPS has returned from an overload condition.\"
|
||||
SNMP-COMMUNITY-MIB::snmpTrapAddress.0 $device->ip
|
||||
SNMP-COMMUNITY-MIB::snmpTrapCommunity.0 \"comstring\"
|
||||
SNMPv2-MIB::snmpTrapEnterprise.0 CPS-MIB::cps";
|
||||
|
||||
$message = "The UPS has returned from an overload condition.";
|
||||
\Log::shouldReceive('event')->once()->with($message, $device->device_id, 'trap', 1);
|
||||
|
||||
$trap = new Trap($trapText);
|
||||
$this->assertTrue(Dispatcher::handle($trap), 'Could not handle CpRtOverLoad trap');
|
||||
}
|
||||
|
||||
public function testCpRtnDischarged()
|
||||
{
|
||||
$device = factory(Device::class)->create();
|
||||
$ipv4 = factory(Ipv4Address::class)->make();
|
||||
|
||||
$trapText = "$device->hostname
|
||||
UDP: [$device->ip]:161->[192.168.5.5]:162
|
||||
DISMAN-EVENT-MIB::sysUpTimeInstance 488:17:19:10.00
|
||||
SNMPv2-MIB::snmpTrapOID.0 CPS-MIB::returnFromDischarged
|
||||
CPS-MIB::mtrapinfoString \"The UPS runtime calibration completed.\"
|
||||
SNMP-COMMUNITY-MIB::snmpTrapAddress.0 $device->ip
|
||||
SNMP-COMMUNITY-MIB::snmpTrapCommunity.0 \"comstring\"
|
||||
SNMPv2-MIB::snmpTrapEnterprise.0 CPS-MIB::cps";
|
||||
|
||||
$message = "The UPS runtime calibration completed.";
|
||||
\Log::shouldReceive('event')->once()->with($message, $device->device_id, 'trap', 1);
|
||||
|
||||
$trap = new Trap($trapText);
|
||||
$this->assertTrue(Dispatcher::handle($trap), 'Could not handle CpRtnDischarged trap');
|
||||
}
|
||||
|
||||
public function testCpUpsChargerFailure()
|
||||
{
|
||||
$device = factory(Device::class)->create();
|
||||
$ipv4 = factory(Ipv4Address::class)->make();
|
||||
|
||||
$trapText = "$device->hostname
|
||||
UDP: [$device->ip]:161->[192.168.5.5]:162
|
||||
DISMAN-EVENT-MIB::sysUpTimeInstance 488:17:19:10.00
|
||||
SNMPv2-MIB::snmpTrapOID.0 CPS-MIB::upsChargerFailure
|
||||
CPS-MIB::mtrapinfoString \"The battery charger is abnormal.\"
|
||||
SNMP-COMMUNITY-MIB::snmpTrapAddress.0 $device->ip
|
||||
SNMP-COMMUNITY-MIB::snmpTrapCommunity.0 \"comstring\"
|
||||
SNMPv2-MIB::snmpTrapEnterprise.0 CPS-MIB::cps";
|
||||
|
||||
$message = "The battery charger is abnormal.";
|
||||
\Log::shouldReceive('event')->once()->with($message, $device->device_id, 'trap', 4);
|
||||
|
||||
$trap = new Trap($trapText);
|
||||
$this->assertTrue(Dispatcher::handle($trap), 'Could not handle CpUpsChargerFailure trap');
|
||||
}
|
||||
|
||||
public function testCpRtnChargerFailure()
|
||||
{
|
||||
$device = factory(Device::class)->create();
|
||||
$ipv4 = factory(Ipv4Address::class)->make();
|
||||
|
||||
$trapText = "$device->hostname
|
||||
UDP: [$device->ip]:161->[192.168.5.5]:162
|
||||
DISMAN-EVENT-MIB::sysUpTimeInstance 488:17:19:10.00
|
||||
SNMPv2-MIB::snmpTrapOID.0 CPS-MIB::returnFromChargerFailure
|
||||
CPS-MIB::mtrapinfoString \"The charger returned from a failure condition.\"
|
||||
SNMP-COMMUNITY-MIB::snmpTrapAddress.0 $device->ip
|
||||
SNMP-COMMUNITY-MIB::snmpTrapCommunity.0 \"comstring\"
|
||||
SNMPv2-MIB::snmpTrapEnterprise.0 CPS-MIB::cps";
|
||||
|
||||
$message = "The charger returned from a failure condition.";
|
||||
\Log::shouldReceive('event')->once()->with($message, $device->device_id, 'trap', 1);
|
||||
|
||||
$trap = new Trap($trapText);
|
||||
$this->assertTrue(Dispatcher::handle($trap), 'Could not handle CpRtnChargerFailure trap');
|
||||
}
|
||||
|
||||
public function testCpUpsBatteryNotPresent()
|
||||
{
|
||||
$device = factory(Device::class)->create();
|
||||
$ipv4 = factory(Ipv4Address::class)->make();
|
||||
|
||||
$trapText = "$device->hostname
|
||||
UDP: [$device->ip]:161->[192.168.5.5]:162
|
||||
DISMAN-EVENT-MIB::sysUpTimeInstance 488:17:19:10.00
|
||||
SNMPv2-MIB::snmpTrapOID.0 CPS-MIB::upsBatteryNotPresent
|
||||
CPS-MIB::mtrapinfoString \"Battery is not present.\"
|
||||
SNMP-COMMUNITY-MIB::snmpTrapAddress.0 $device->ip
|
||||
SNMP-COMMUNITY-MIB::snmpTrapCommunity.0 \"comstring\"
|
||||
SNMPv2-MIB::snmpTrapEnterprise.0 CPS-MIB::cps";
|
||||
|
||||
$message = "Battery is not present.";
|
||||
\Log::shouldReceive('event')->once()->with($message, $device->device_id, 'trap', 2);
|
||||
|
||||
$trap = new Trap($trapText);
|
||||
$this->assertTrue(Dispatcher::handle($trap), 'Could not handle CpUpsBatteryNotPresent trap');
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user