mirror of
https://github.com/librenms/librenms.git
synced 2024-09-21 10:28:13 +00:00
Replace echo with Log calls in OS code (#16310)
This commit is contained in:
parent
89d70bd48e
commit
3dd4084404
@ -28,6 +28,7 @@ namespace LibreNMS\OS;
|
||||
use App\Models\Eventlog;
|
||||
use App\Models\TnmsneInfo;
|
||||
use App\Observers\ModuleModelObserver;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use LibreNMS\Enum\Severity;
|
||||
use LibreNMS\Interfaces\Data\DataStorageInterface;
|
||||
use LibreNMS\Interfaces\Polling\OSPolling;
|
||||
@ -36,7 +37,7 @@ class Coriant extends \LibreNMS\OS implements OSPolling
|
||||
{
|
||||
public function pollOS(DataStorageInterface $datastore): void
|
||||
{
|
||||
echo 'TNMS-NBI-MIB: enmsNETable';
|
||||
Log::info('TNMS-NBI-MIB: enmsNETable');
|
||||
|
||||
/*
|
||||
* Coriant have done some SQL over SNMP, since we have to populate and update all the tables
|
||||
|
@ -26,6 +26,7 @@
|
||||
namespace LibreNMS\OS;
|
||||
|
||||
use App\Models\Device;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use LibreNMS\Device\WirelessSensor;
|
||||
use LibreNMS\Interfaces\Data\DataStorageInterface;
|
||||
use LibreNMS\Interfaces\Discovery\Sensors\WirelessApCountDiscovery;
|
||||
@ -52,7 +53,7 @@ class Fortigate extends Fortinet implements
|
||||
if (is_numeric($sessions)) {
|
||||
$rrd_def = RrdDefinition::make()->addDataset('sessions', 'GAUGE', 0, 3000000);
|
||||
|
||||
echo "Sessions: $sessions\n";
|
||||
Log::info("Sessions: $sessions");
|
||||
$fields = [
|
||||
'sessions' => $sessions,
|
||||
];
|
||||
@ -66,7 +67,7 @@ class Fortigate extends Fortinet implements
|
||||
if (is_numeric($cpu_usage)) {
|
||||
$rrd_def = RrdDefinition::make()->addDataset('LOAD', 'GAUGE', -1, 100);
|
||||
|
||||
echo "CPU: $cpu_usage%\n";
|
||||
Log::info("CPU: $cpu_usage%");
|
||||
$fields = [
|
||||
'LOAD' => $cpu_usage,
|
||||
];
|
||||
|
@ -29,6 +29,7 @@ namespace LibreNMS\OS;
|
||||
use App\Models\IsisAdjacency;
|
||||
use Illuminate\Support\Arr;
|
||||
use Illuminate\Support\Collection;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use LibreNMS\DB\SyncsModels;
|
||||
use LibreNMS\Interfaces\Data\DataStorageInterface;
|
||||
use LibreNMS\Interfaces\Discovery\IsIsDiscovery;
|
||||
@ -124,7 +125,7 @@ class Iosxe extends Ciscowlc implements
|
||||
$up_count = array_count_values($states)['up'] ?? 0;
|
||||
|
||||
if ($up_count !== $adjacencies->count()) {
|
||||
echo 'New Adjacencies, running discovery';
|
||||
Log::info('New Adjacencies, running discovery');
|
||||
|
||||
return $this->fillNew($adjacencies, $this->discoverIsIs());
|
||||
}
|
||||
|
@ -30,6 +30,7 @@ use App\Models\EntPhysical;
|
||||
use App\Models\Sla;
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Support\Collection;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use LibreNMS\Interfaces\Data\DataStorageInterface;
|
||||
use LibreNMS\Interfaces\Discovery\SlaDiscovery;
|
||||
use LibreNMS\Interfaces\Polling\OSPolling;
|
||||
@ -190,7 +191,7 @@ class Junos extends \LibreNMS\OS implements SlaDiscovery, OSPolling, SlaPolling
|
||||
|
||||
$sla->rtt = ($data[$owner][$test]['jnxPingResultsAvgRttUs'] ?? 0) / 1000;
|
||||
$time = Carbon::parse($data[$owner][$test]['jnxPingResultsTime'] ?? null)->toDateTimeString();
|
||||
echo 'SLA : ' . $rtt_type . ' ' . $owner . ' ' . $test . '... ' . $sla->rtt . 'ms at ' . $time . "\n";
|
||||
Log::info('SLA : ' . $rtt_type . ' ' . $owner . ' ' . $test . '... ' . $sla->rtt . 'ms at ' . $time);
|
||||
|
||||
$collected = ['rtt' => $sla->rtt];
|
||||
|
||||
|
@ -50,8 +50,6 @@ class Linux extends Shared\Unix implements VminfoDiscovery
|
||||
return $vms;
|
||||
}
|
||||
|
||||
echo PHP_EOL;
|
||||
|
||||
return $this->discoverVmwareVminfo();
|
||||
}
|
||||
|
||||
|
@ -25,6 +25,7 @@
|
||||
|
||||
namespace LibreNMS\OS;
|
||||
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use LibreNMS\Interfaces\Data\DataStorageInterface;
|
||||
use LibreNMS\Interfaces\Polling\OSPolling;
|
||||
use LibreNMS\RRD\RrdDefinition;
|
||||
@ -33,7 +34,7 @@ class Netscaler extends \LibreNMS\OS implements OSPolling
|
||||
{
|
||||
public function pollOS(DataStorageInterface $datastore): void
|
||||
{
|
||||
echo ' IP';
|
||||
Log::info('IP:');
|
||||
|
||||
// These are at the start of large trees that we don't want to walk the entirety of, so we snmp_get_multi them
|
||||
$oids_gauge = [
|
||||
|
@ -25,6 +25,7 @@
|
||||
|
||||
namespace LibreNMS\OS;
|
||||
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use LibreNMS\Device\Processor;
|
||||
use LibreNMS\Interfaces\Data\DataStorageInterface;
|
||||
use LibreNMS\Interfaces\Discovery\ProcessorDiscovery;
|
||||
@ -59,7 +60,7 @@ class Sgos extends OS implements ProcessorDiscovery, OSPolling
|
||||
$datastore->put($this->getDeviceArray(), 'sgos_average_requests', $tags, $fields);
|
||||
|
||||
$this->enableGraph('sgos_average_requests');
|
||||
echo ' HTTP Req Rate';
|
||||
Log::info(' HTTP Req Rate');
|
||||
}
|
||||
|
||||
if (is_numeric($sgos[0]['sgProxyHttpClientConnections'] ?? null)) {
|
||||
@ -73,7 +74,7 @@ class Sgos extends OS implements ProcessorDiscovery, OSPolling
|
||||
$datastore->put($this->getDeviceArray(), 'sgos_client_connections', $tags, $fields);
|
||||
|
||||
$this->enableGraph('sgos_client_connections');
|
||||
echo ' Client Conn';
|
||||
Log::info(' Client Conn');
|
||||
}
|
||||
|
||||
if (is_numeric($sgos[0]['sgProxyHttpServerConnections'] ?? null)) {
|
||||
@ -87,7 +88,7 @@ class Sgos extends OS implements ProcessorDiscovery, OSPolling
|
||||
$datastore->put($this->getDeviceArray(), 'sgos_server_connections', $tags, $fields);
|
||||
|
||||
$this->enableGraph('sgos_server_connections');
|
||||
echo ' Server Conn';
|
||||
Log::info(' Server Conn');
|
||||
}
|
||||
|
||||
if (is_numeric($sgos[0]['sgProxyHttpClientConnectionsActive'] ?? null)) {
|
||||
@ -101,7 +102,7 @@ class Sgos extends OS implements ProcessorDiscovery, OSPolling
|
||||
$datastore->put($this->getDeviceArray(), 'sgos_client_connections_active', $tags, $fields);
|
||||
|
||||
$this->enableGraph('sgos_client_connections_active');
|
||||
echo ' Client Conn Active';
|
||||
Log::info(' Client Conn Active');
|
||||
}
|
||||
|
||||
if (is_numeric($sgos[0]['sgProxyHttpServerConnectionsActive'] ?? null)) {
|
||||
@ -115,7 +116,7 @@ class Sgos extends OS implements ProcessorDiscovery, OSPolling
|
||||
$datastore->put($this->getDeviceArray(), 'sgos_server_connections_active', $tags, $fields);
|
||||
|
||||
$this->enableGraph('sgos_server_connections_active');
|
||||
echo ' Server Conn Active';
|
||||
Log::info(' Server Conn Active');
|
||||
}
|
||||
|
||||
if (is_numeric($sgos[0]['sgProxyHttpClientConnectionsIdle'] ?? null)) {
|
||||
@ -129,7 +130,7 @@ class Sgos extends OS implements ProcessorDiscovery, OSPolling
|
||||
$datastore->put($this->getDeviceArray(), 'sgos_client_connections_idle', $tags, $fields);
|
||||
|
||||
$this->enableGraph('sgos_client_connections_idle');
|
||||
echo ' Client Conne Idle';
|
||||
Log::info(' Client Conne Idle');
|
||||
}
|
||||
|
||||
if (is_numeric($sgos[0]['sgProxyHttpServerConnectionsIdle'] ?? null)) {
|
||||
@ -143,7 +144,7 @@ class Sgos extends OS implements ProcessorDiscovery, OSPolling
|
||||
$datastore->put($this->getDeviceArray(), 'sgos_server_connections_idle', $tags, $fields);
|
||||
|
||||
$this->enableGraph('sgos_server_connections_idle');
|
||||
echo ' Server Conn Idle';
|
||||
Log::info(' Server Conn Idle');
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -33,6 +33,7 @@ use App\Models\PortsNac;
|
||||
use App\Models\Sla;
|
||||
use Illuminate\Support\Arr;
|
||||
use Illuminate\Support\Collection;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use LibreNMS\Device\Processor;
|
||||
use LibreNMS\Interfaces\Discovery\MempoolsDiscovery;
|
||||
use LibreNMS\Interfaces\Discovery\OSDiscovery;
|
||||
@ -504,7 +505,7 @@ class Cisco extends OS implements
|
||||
// Use Nagios Status codes. 0: Good, 2: Critical
|
||||
$sla->opstatus = $data[$sla_nr]['rttMonLatestRttOperSense'] == 1 ? 0 : 2;
|
||||
|
||||
echo 'SLA ' . $sla_nr . ': ' . $rtt_type . ' ' . $sla['owner'] . ' ' . $sla['tag'] . '... ' . $sla->rtt . 'ms at ' . $time . "\n";
|
||||
Log::info('SLA ' . $sla_nr . ': ' . $rtt_type . ' ' . $sla['owner'] . ' ' . $sla['tag'] . '... ' . $sla->rtt . 'ms at ' . $time);
|
||||
|
||||
$collected = ['rtt' => $sla->rtt];
|
||||
|
||||
|
@ -29,6 +29,7 @@ use App\Models\Mempool;
|
||||
use Closure;
|
||||
use Exception;
|
||||
use Illuminate\Support\Collection;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use Illuminate\Support\Str;
|
||||
use LibreNMS\Device\Processor;
|
||||
use Rrd;
|
||||
@ -70,7 +71,7 @@ trait HostResources
|
||||
*/
|
||||
public function discoverProcessors()
|
||||
{
|
||||
echo 'Host Resources: ';
|
||||
Log::info('Host Resources: ');
|
||||
$processors = [];
|
||||
|
||||
try {
|
||||
|
@ -27,6 +27,7 @@ namespace LibreNMS\OS\Traits;
|
||||
|
||||
use App\Models\Mempool;
|
||||
use Illuminate\Support\Collection;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use LibreNMS\Device\Processor;
|
||||
|
||||
trait UcdResources
|
||||
@ -39,7 +40,7 @@ trait UcdResources
|
||||
*/
|
||||
public function discoverProcessors()
|
||||
{
|
||||
echo 'UCD Resources: ';
|
||||
Log::info('UCD Resources: ');
|
||||
|
||||
return [
|
||||
Processor::discover(
|
||||
|
@ -35,10 +35,10 @@ trait VminfoLibvirt
|
||||
{
|
||||
public function discoverVminfo(): Collection
|
||||
{
|
||||
echo 'LibVirt VM: ';
|
||||
Log::info('LibVirt VM: ');
|
||||
|
||||
if (! Config::get('enable_libvirt')) {
|
||||
echo 'not configured';
|
||||
Log::info('not configured');
|
||||
|
||||
return new Collection;
|
||||
}
|
||||
|
@ -27,13 +27,14 @@ namespace LibreNMS\OS\Traits;
|
||||
|
||||
use App\Models\Vminfo;
|
||||
use Illuminate\Support\Collection;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use LibreNMS\Enum\PowerState;
|
||||
|
||||
trait VminfoVmware
|
||||
{
|
||||
public function discoverVmInfo(): Collection
|
||||
{
|
||||
echo 'VMware VM: ';
|
||||
Log::info('VMware VM: ');
|
||||
|
||||
/*
|
||||
* Fetch the Virtual Machine information.
|
||||
|
@ -35,6 +35,7 @@ use App\Observers\ModuleModelObserver;
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Support\Arr;
|
||||
use Illuminate\Support\Collection;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use Illuminate\Support\Str;
|
||||
use LibreNMS\DB\SyncsModels;
|
||||
use LibreNMS\Device\Processor;
|
||||
@ -564,7 +565,7 @@ class Vrp extends OS implements
|
||||
|
||||
$sla->rtt = ($data[$owner][$test]['pingResultsAverageRtt'] ?? 0) / $divisor;
|
||||
$time = Carbon::parse($data[$owner][$test]['pingResultsLastGoodProbe'] ?? null)->toDateTimeString();
|
||||
echo 'SLA : ' . $rtt_type . ' ' . $owner . ' ' . $test . '... ' . $sla->rtt . 'ms at ' . $time . "\n";
|
||||
Log::info('SLA : ' . $rtt_type . ' ' . $owner . ' ' . $test . '... ' . $sla->rtt . 'ms at ' . $time);
|
||||
|
||||
$collected = ['rtt' => $sla->rtt];
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user