Skip to content

Commit

Permalink
Fix lint issues
Browse files Browse the repository at this point in the history
  • Loading branch information
murrant committed Oct 4, 2023
1 parent eaa86d4 commit 818fd10
Show file tree
Hide file tree
Showing 10 changed files with 22 additions and 26 deletions.
2 changes: 1 addition & 1 deletion LibreNMS/Interfaces/Module.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public function discover(OS $os): void;
* Run frequently (default every 5 minutes)
*
* @param \LibreNMS\OS $os
* @param \LibreNMS\Interfaces\DataStorageInterface $datastore
* @param \LibreNMS\Interfaces\Data\DataStorageInterface $datastore
*/
public function poll(OS $os, DataStorageInterface $datastore): void;

Expand Down
2 changes: 1 addition & 1 deletion LibreNMS/Modules/Availability.php
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ public function poll(OS $os, DataStorageInterface $datastore): void
*/
public function cleanup(Device $device): void
{
$os->getDevice()->availability()->delete();
$device->availability()->delete();
}

/**
Expand Down
2 changes: 1 addition & 1 deletion LibreNMS/Modules/Core.php
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,7 @@ private function calculateUptime(OS $os, ?string $sysUpTime, DataStorageInterfac

$os->enableGraph('uptime');

echo 'Uptime: ' . Time::formatInterval($uptime) . PHP_EOL;
Log::info('Uptime: ' . Time::formatInterval($uptime));
$device->uptime = $uptime;
}
}
Expand Down
2 changes: 1 addition & 1 deletion LibreNMS/Modules/Slas.php
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ public function poll(OS $os, DataStorageInterface $datastore): void

// The base RRD
foreach ($slas as $sla) {
$datastore->put($device, 'sla', [
$datastore->put($os->getDeviceArray(), 'sla', [
'sla_nr' => $sla->sla_nr,
'rrd_name' => ['sla', $sla->sla_nr],
'rrd_def' => RrdDefinition::make()->addDataset('rtt', 'GAUGE', 0, 300000),
Expand Down
6 changes: 3 additions & 3 deletions LibreNMS/Modules/Xdsl.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,9 @@ public function shouldDiscover(OS $os, ModuleStatus $status): bool
*/
public function discover(OS $os): void
{
//discover if any port has dsl data. We use the pollXdsl functions, with the store parameter set to false
$this->pollAdsl($os, false);
$this->pollVdsl($os, false);
//discover if any port has dsl data. We use the pollXdsl functions, with the datastore parameter ommitted
$this->pollAdsl($os);
$this->pollVdsl($os);
}

public function shouldPoll(OS $os, ModuleStatus $status): bool
Expand Down
1 change: 1 addition & 0 deletions LibreNMS/OS/Fortigate.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@

use App\Models\Device;
use LibreNMS\Device\WirelessSensor;
use LibreNMS\Interfaces\Data\DataStorageInterface;
use LibreNMS\Interfaces\Discovery\Sensors\WirelessApCountDiscovery;
use LibreNMS\Interfaces\Discovery\Sensors\WirelessClientsDiscovery;
use LibreNMS\Interfaces\Polling\OSPolling;
Expand Down
3 changes: 2 additions & 1 deletion LibreNMS/OS/Poweralert.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
namespace LibreNMS\OS;

use App\Models\Device;
use LibreNMS\Interfaces\Data\DataStorageInterface;
use LibreNMS\Interfaces\Polling\OSPolling;

class Poweralert extends \LibreNMS\OS implements OSPolling
Expand All @@ -37,7 +38,7 @@ public function discoverOS(Device $device): void
$this->customSysName($device);
}

public function pollOs(): void
public function pollOS(DataStorageInterface $datastore): void
{
$this->customSysName($this->getDevice());
}
Expand Down
18 changes: 5 additions & 13 deletions LibreNMS/OS/Vrp.php
Original file line number Diff line number Diff line change
Expand Up @@ -542,15 +542,7 @@ public function pollSlas($slas): void
$time = Carbon::parse($data[$owner][$test]['pingResultsLastGoodProbe'] ?? null)->toDateTimeString();
echo 'SLA : ' . $rtt_type . ' ' . $owner . ' ' . $test . '... ' . $sla->rtt . 'ms at ' . $time . "\n";

$fields = [
'rtt' => $sla->rtt,
];

// The base RRD
$rrd_name = ['sla', $sla['sla_nr']];
$rrd_def = RrdDefinition::make()->addDataset('rtt', 'GAUGE', 0, 300000);
$tags = compact('sla_nr', 'rrd_name', 'rrd_def');
$datastore->put($device, 'sla', $tags, $fields);
$collected = ['rtt' => $sla->rtt];

// Let's gather some per-type fields.
switch ($rtt_type) {
Expand All @@ -568,13 +560,13 @@ public function pollSlas($slas): void
->addDataset('ProbeResponses', 'GAUGE', 0, 300000)
->addDataset('ProbeLoss', 'GAUGE', 0, 300000);
$tags = compact('rrd_name', 'rrd_def', 'sla_nr', 'rtt_type');
$datastore->put($device, 'sla', $tags, $icmp);
$fields = array_merge($fields, $icmp);
app('Datastore')->put($device, 'sla', $tags, $icmp);
$collected = array_merge($collected, $icmp);
break;
}

d_echo('The following datasources were collected for #' . $sla['sla_nr'] . ":\n");
d_echo($fields);
d_echo('The following datasources were collected for #' . $sla->sla_nr. ":\n");
d_echo($collected);
}
}
}
7 changes: 4 additions & 3 deletions LibreNMS/Poller.php
Original file line number Diff line number Diff line change
Expand Up @@ -178,15 +178,15 @@ private function pollModules(): void
foreach (array_keys(Config::get('poller_modules')) as $module) {
$module_status = Module::status($module, $this->device, $this->isModuleManuallyEnabled($module));
$should_poll = false;
$start_memory = memory_get_usage();
$module_start = microtime(true);

try {
$instance = Module::fromName($module);
$should_poll = $instance->shouldPoll($this->os, $module_status);

if ($should_poll) {
$start_memory = memory_get_usage();
$module_start = microtime(true);
$this->logger->info("\n#### Load poller module $module ####");
$this->logger->info("#### Load poller module $module ####\n");
$this->logger->debug($module_status);

$instance->poll($this->os, $datastore);
Expand All @@ -199,6 +199,7 @@ private function pollModules(): void
}

if ($should_poll) {
$this->logger->info('');
app(MeasurementManager::class)->printChangedStats();
$this->saveModulePerformance($module, $module_start, $start_memory);
$this->logger->info("#### Unload poller module $module ####\n");
Expand Down
5 changes: 3 additions & 2 deletions LibreNMS/Waas.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,17 +25,18 @@

namespace LibreNMS;

use LibreNMS\Interfaces\Data\DataStorageInterface;
use LibreNMS\Interfaces\Polling\OSPolling;
use LibreNMS\RRD\RrdDefinition;

class Waas extends OS implements OSPolling
{
public function pollOS(): void
public function pollOS(DataStorageInterface $datastore): void
{
$connections = \SnmpQuery::get('CISCO-WAN-OPTIMIZATION-MIB::cwoTfoStatsActiveOptConn.0')->value();

if (is_numeric($connections)) {
data_update($this->getDeviceArray(), 'waas_cwotfostatsactiveoptconn', [
$datastore->put($this->getDeviceArray(), 'waas_cwotfostatsactiveoptconn', [
'rrd_def' => RrdDefinition::make()->addDataset('connections', 'GAUGE', 0),
], [
'connections' => $connections,
Expand Down

0 comments on commit 818fd10

Please sign in to comment.