Revert "Poller command rewrite (#13414)" (#13524)

This reverts commit 1752d1efd4.
This commit is contained in:
Tony Murray
2021-11-16 21:40:29 -06:00
committed by GitHub
parent 1752d1efd4
commit f8764ddcb5
49 changed files with 304 additions and 1181 deletions

View File

@@ -51,7 +51,7 @@ class Isis implements Module
* Discover this module. Heavier processes can be run here
* Run infrequently (default 4 times a day)
*
* @param \LibreNMS\OS $os
* @param OS $os
*/
public function discover(OS $os)
{
@@ -68,7 +68,7 @@ class Isis implements Module
* Try to keep this efficient and only run if discovery has indicated there is a reason to run.
* Run frequently (default every 5 minutes)
*
* @param \LibreNMS\OS $os
* @param OS $os
*/
public function poll(OS $os)
{
@@ -89,7 +89,7 @@ class Isis implements Module
* Remove all DB data for this module.
* This will be run when the module is disabled.
*
* @param Os $os
* @param OS $os
*/
public function cleanup(OS $os)
{

View File

@@ -1,65 +0,0 @@
<?php
/**
* LegacyModule.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 2021 Tony Murray
* @author Tony Murray <murraytony@gmail.com>
*/
namespace LibreNMS\Modules;
use LibreNMS\Interfaces\Module;
use LibreNMS\OS;
use LibreNMS\Util\Debug;
class LegacyModule implements Module
{
/**
* @var string
*/
private $name;
public function __construct(string $name)
{
$this->name = $name;
}
public function discover(OS $os): void
{
// TODO: Implement discover() method.
}
public function poll(OS $os): void
{
$device = &$os->getDeviceArray();
$device['attribs'] = $os->getDevice()->attribs->toArray();
Debug::disableErrorReporting(); // ignore errors in legacy code
include_once base_path('includes/dbFacile.php');
include base_path("includes/polling/$this->name.inc.php");
Debug::enableErrorReporting(); // and back to normal
}
public function cleanup(OS $os): void
{
// TODO: Implement cleanup() method.
}
}

View File

@@ -108,7 +108,7 @@ class Mempools implements Module
}
/**
* @param \LibreNMS\OS $os
* @param OS $os
* @param \Illuminate\Support\Collection $mempools
* @return \Illuminate\Support\Collection
*/

View File

@@ -42,7 +42,7 @@ class Mpls implements Module
* Discover this module. Heavier processes can be run here
* Run infrequently (default 4 times a day)
*
* @param \LibreNMS\OS $os
* @param OS $os
*/
public function discover(OS $os)
{
@@ -88,7 +88,7 @@ class Mpls implements Module
* Try to keep this efficient and only run if discovery has indicated there is a reason to run.
* Run frequently (default every 5 minutes)
*
* @param \LibreNMS\OS $os
* @param OS $os
*/
public function poll(OS $os)
{
@@ -151,7 +151,7 @@ class Mpls implements Module
* Remove all DB data for this module.
* This will be run when the module is disabled.
*
* @param Os $os
* @param OS $os
*/
public function cleanup(OS $os)
{

View File

@@ -37,7 +37,7 @@ class Nac implements Module
* Discover this module. Heavier processes can be run here
* Run infrequently (default 4 times a day)
*
* @param Os $os
* @param OS $os
*/
public function discover(OS $os)
{
@@ -49,7 +49,7 @@ class Nac implements Module
* Try to keep this efficient and only run if discovery has indicated there is a reason to run.
* Run frequently (default every 5 minutes)
*
* @param \LibreNMS\OS $os
* @param OS $os
*/
public function poll(OS $os)
{
@@ -82,7 +82,7 @@ class Nac implements Module
* Remove all DB data for this module.
* This will be run when the module is disabled.
*
* @param \LibreNMS\OS $os
* @param OS $os
*/
public function cleanup(OS $os)
{

View File

@@ -30,9 +30,9 @@ use LibreNMS\Interfaces\Module;
use LibreNMS\Interfaces\Polling\OSPolling;
use LibreNMS\Util\Url;
class Os implements Module
class OS implements Module
{
public function discover(\LibreNMS\OS $os): void
public function discover(\LibreNMS\OS $os)
{
$this->updateLocation($os);
$this->sysContact($os);
@@ -50,7 +50,7 @@ class Os implements Module
$this->handleChanges($os);
}
public function poll(\LibreNMS\OS $os): void
public function poll(\LibreNMS\OS $os)
{
$deviceModel = $os->getDevice(); /** @var \App\Models\Device $deviceModel */
if ($os instanceof OSPolling) {
@@ -58,11 +58,6 @@ class Os implements Module
} else {
// legacy poller files
global $graphs, $device;
if (empty($device)) {
$device = $os->getDeviceArray();
}
$location = null;
if (is_file(base_path('/includes/polling/os/' . $device['os'] . '.inc.php'))) {
@@ -90,12 +85,12 @@ class Os implements Module
$this->handleChanges($os);
}
public function cleanup(\LibreNMS\OS $os): void
public function cleanup(\LibreNMS\OS $os)
{
// no cleanup needed?
}
private function handleChanges(\LibreNMS\OS $os): void
private function handleChanges(\LibreNMS\OS $os)
{
$device = $os->getDevice();
@@ -109,7 +104,7 @@ class Os implements Module
$device->save();
}
private function updateLocation(\LibreNMS\OS $os): void
private function updateLocation(\LibreNMS\OS $os)
{
$device = $os->getDevice();
$new_location = $device->override_sysLocation ? new Location() : $os->fetchLocation(); // fetch location data from device
@@ -117,7 +112,7 @@ class Os implements Module
optional($device->location)->save();
}
private function sysContact(\LibreNMS\OS $os): void
private function sysContact(\LibreNMS\OS $os)
{
$device = $os->getDevice();
$device->sysContact = snmp_get($os->getDeviceArray(), 'sysContact.0', '-Ovq', 'SNMPv2-MIB');

View File

@@ -39,7 +39,7 @@ class PrinterSupplies implements Module
* Discover this module. Heavier processes can be run here
* Run infrequently (default 4 times a day)
*
* @param \LibreNMS\OS $os
* @param OS $os
*/
public function discover(OS $os)
{
@@ -58,7 +58,7 @@ class PrinterSupplies implements Module
* Try to keep this efficient and only run if discovery has indicated there is a reason to run.
* Run frequently (default every 5 minutes)
*
* @param \LibreNMS\OS $os
* @param OS $os
*/
public function poll(OS $os)
{
@@ -114,7 +114,7 @@ class PrinterSupplies implements Module
* Remove all DB data for this module.
* This will be run when the module is disabled.
*
* @param Os $os
* @param OS $os
*/
public function cleanup(OS $os)
{

View File

@@ -36,7 +36,7 @@ class Slas implements Module
* Discover this module. Heavier processes can be run here
* Run infrequently (default 4 times a day)
*
* @param \LibreNMS\OS $os
* @param OS $os
*/
public function discover(OS $os)
{
@@ -52,7 +52,7 @@ class Slas implements Module
* Try to keep this efficient and only run if discovery has indicated there is a reason to run.
* Run frequently (default every 5 minutes)
*
* @param \LibreNMS\OS $os
* @param OS $os
*/
public function poll(OS $os)
{
@@ -73,7 +73,7 @@ class Slas implements Module
* Remove all DB data for this module.
* This will be run when the module is disabled.
*
* @param \LibreNMS\OS $os
* @param OS $os
*/
public function cleanup(OS $os)
{