mirror of
https://github.com/librenms/librenms.git
synced 2024-10-07 16:52:45 +00:00
Miscellaneous cleanup - part 3 (#14450)
* Miscellaneous cleanup - part 3 * Apply fixes from StyleCI
This commit is contained in:
@@ -309,7 +309,7 @@ class YamlDiscovery
|
||||
Config::set('os.' . $os->getName() . '.snmp_bulk', (bool) $data['snmp_bulk']);
|
||||
}
|
||||
|
||||
$mib = $os->getDiscovery()['mib'];
|
||||
$mib = $os->getDiscovery()['mib'] ?? null;
|
||||
$pre_cache[$oid] = snmpwalk_cache_oid($device, $oid, $pre_cache[$oid] ?? [], $mib, null, $snmp_flag);
|
||||
|
||||
Config::set('os.' . $os->getName() . '.snmp_bulk', $saved_nobulk);
|
||||
|
||||
@@ -281,7 +281,7 @@ class PrinterSupplies implements Module
|
||||
return 0;
|
||||
}
|
||||
} elseif ($device['os'] == 'brother') {
|
||||
if (! Str::contains($device['hardware'], 'MFC-L8850')) {
|
||||
if (! Str::contains($device['hardware'] ?? '', 'MFC-L8850')) {
|
||||
switch ($raw_value) {
|
||||
case '0':
|
||||
return 100;
|
||||
|
||||
@@ -85,7 +85,7 @@ class Boss extends OS implements OSDiscovery, ProcessorDiscovery
|
||||
zeropad($count),
|
||||
"Unit $count processor",
|
||||
1,
|
||||
$entry['sgProxyCpuCoreBusyPerCent']
|
||||
$entry['sgProxyCpuCoreBusyPerCent'] ?? null
|
||||
);
|
||||
|
||||
$count++;
|
||||
|
||||
@@ -883,7 +883,7 @@ function discovery_process(&$valid, $os, $sensor_class, $pre_cache)
|
||||
if (! is_numeric($snmp_value)) {
|
||||
if ($sensor_class === 'temperature') {
|
||||
// For temp sensors, try and detect fahrenheit values
|
||||
if (Str::endsWith($snmp_value, ['f', 'F'])) {
|
||||
if (is_string($snmp_value) && Str::endsWith($snmp_value, ['f', 'F'])) {
|
||||
$user_function = 'fahrenheit_to_celsius';
|
||||
}
|
||||
}
|
||||
|
||||
@@ -57,6 +57,9 @@ foreach ($oids as $index => $entry) {
|
||||
$type = $entry['type'];
|
||||
$descr = $entry['descr'];
|
||||
|
||||
if (! isset($tmp_snmp_multi[$oid])) {
|
||||
continue;
|
||||
}
|
||||
$current = $tmp_snmp_multi[$oid];
|
||||
|
||||
if ($type === 'dhcpatriotLicenseExpiration' && $current !== 'FULL:0' && gettype($current) === 'string') {
|
||||
|
||||
@@ -35,6 +35,7 @@ if ($device['os'] === 'boss') {
|
||||
}
|
||||
|
||||
$ps_num = 0;
|
||||
$temp_unit = null;
|
||||
foreach ($ers_sensors as $index => $entry) {
|
||||
//Get unit number
|
||||
$unit_array = explode('.', $index);
|
||||
|
||||
@@ -72,17 +72,16 @@ foreach ($tables as $tablevalue) {
|
||||
}
|
||||
|
||||
// Create State Index
|
||||
create_state_index($value_oid, $states);
|
||||
create_state_index($value_oid, $states ?? []);
|
||||
|
||||
foreach ($temp as $index => $entry) {
|
||||
if ($value_oid == 'memoryDeviceStatus') {
|
||||
$descr = $entry[$descr_oid] . ', ' . $entry['memoryDeviceSize'] / 1024 . ' MB';
|
||||
} else {
|
||||
$descr = $entry[$descr_oid];
|
||||
}
|
||||
|
||||
//Discover Sensors
|
||||
if (isset($entry[$descr_oid])) {
|
||||
if ($value_oid == 'memoryDeviceStatus') {
|
||||
$descr = $entry[$descr_oid] . ', ' . $entry['memoryDeviceSize'] / 1024 . ' MB';
|
||||
} else {
|
||||
$descr = $entry[$descr_oid];
|
||||
}
|
||||
discover_sensor(
|
||||
$valid['sensor'],
|
||||
'state',
|
||||
|
||||
@@ -4,16 +4,17 @@ $temps = snmp_walk($device, '.1.3.6.1.4.1.674.10895.5000.2.6132.1.1.43.1.8.1.5',
|
||||
//This will return at least 4 OIDs (multiplied by the number of switches if stacked) and associated values for various temperatures
|
||||
|
||||
$counter = 0;
|
||||
if (! empty($temps)) {
|
||||
foreach (explode("\n", $temps) as $i => $t) {
|
||||
$t = explode(' ', $t);
|
||||
$oid = $t[0];
|
||||
$val = $t[1];
|
||||
|
||||
foreach (explode("\n", $temps) as $i => $t) {
|
||||
$t = explode(' ', $t);
|
||||
$oid = $t[0];
|
||||
$val = $t[1];
|
||||
|
||||
if (substr($oid, -1) == '1') {
|
||||
// This code will only pull CPU temp for each stack member, but there is no reason why the additional values couldn't be graphed
|
||||
$counter = $counter + 1;
|
||||
discover_sensor($valid['sensor'], 'temperature', $device, $oid, $counter, 'dnos', 'Unit ' . $counter . ' CPU temperature', '1', '1', null, null, null, null, $val);
|
||||
if (substr($oid, -1) == '1') {
|
||||
// This code will only pull CPU temp for each stack member, but there is no reason why the additional values couldn't be graphed
|
||||
$counter = $counter + 1;
|
||||
discover_sensor($valid['sensor'], 'temperature', $device, $oid, $counter, 'dnos', 'Unit ' . $counter . ' CPU temperature', '1', '1', null, null, null, null, $val);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
<?php
|
||||
|
||||
$agent_data = $agent_data ?? [];
|
||||
\DeviceCache::getPrimary()->applications->each(function ($app) use ($device, $agent_data) {
|
||||
echo 'Application: ' . $app->app_type . ', app_id=' . $app->app_id;
|
||||
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
use LibreNMS\RRD\RrdDefinition;
|
||||
use LibreNMS\Util\Number;
|
||||
|
||||
$storage_cache = $storage_cache ?? [];
|
||||
foreach (dbFetchRows('SELECT * FROM storage WHERE device_id = ?', [$device['device_id']]) as $storage) {
|
||||
$descr = $storage['storage_descr'];
|
||||
$mib = $storage['storage_mib'];
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
* @author Abel Laura <[email protected]>
|
||||
*/
|
||||
|
||||
if (! is_array($storage_cache['ddos-storage'])) {
|
||||
if (! isset($storage_cache['ddos-storage'])) {
|
||||
$storage_cache['ddos-storage'] = snmpwalk_cache_oid($device, 'fileSystemSpaceTable', null, 'DATA-DOMAIN-MIB', 'datadomain');
|
||||
d_echo($storage_cache);
|
||||
}
|
||||
|
||||
@@ -12,12 +12,12 @@
|
||||
* the source code distribution for details.
|
||||
*/
|
||||
|
||||
if (! is_array($storage_cache1['eql-storage'])) {
|
||||
if (! isset($storage_cache1['eql-storage'])) {
|
||||
$storage_cache1['eql-storage'] = snmpwalk_cache_oid($device, 'EqliscsiVolumeEntry', null, 'EQLVOLUME-MIB', 'equallogic');
|
||||
d_echo($storage_cache1);
|
||||
}
|
||||
|
||||
if (! is_array($storage_cache2['eql-storage'])) {
|
||||
if (! isset($storage_cache2['eql-storage'])) {
|
||||
$storage_cache2['eql-storage'] = snmpwalk_cache_oid($device, 'EqliscsiVolumeStatusEntry', null, 'EQLVOLUME-MIB', 'equallogic');
|
||||
d_echo($storage_cache2);
|
||||
}
|
||||
@@ -26,8 +26,6 @@ $iind = 0;
|
||||
$storage_cache10 = [];
|
||||
$storage_cache20 = [];
|
||||
|
||||
d_echo($storage);
|
||||
|
||||
foreach ($storage_cache1['eql-storage'] as $index => $ventry) {
|
||||
if (! array_key_exists('eqliscsiVolumeName', $ventry)) {
|
||||
continue;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
if (! is_array($storage_cache['dataset'])) {
|
||||
if (! isset($storage_cache['dataset'])) {
|
||||
$storage_cache['dataset'] = snmpwalk_cache_oid($device, 'datasetTable', null, 'FREENAS-MIB');
|
||||
d_echo($storage_cache);
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
if (! is_array($storage_cache['zpool'])) {
|
||||
if (! isset($storage_cache['zpool'])) {
|
||||
$storage_cache['zpool'] = snmpwalk_cache_oid($device, 'zpoolTable', null, 'FREENAS-MIB');
|
||||
d_echo($storage_cache);
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
%
|
||||
<?php
|
||||
|
||||
if (! is_array($storage_cache['hpe-ilo'])) {
|
||||
if (! isset($storage_cache['hpe-ilo'])) {
|
||||
$storage_cache['hpe-ilo'] = snmpwalk_group($device, 'cpqHoFileSysEntry', 'CPQHOST-MIB');
|
||||
echo 'HPE ILO4 ';
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<?php
|
||||
|
||||
// HOST-RESOURCES-MIB - Storage Objects
|
||||
if (! is_array($storage_cache['hrstorage'] ?? null)) {
|
||||
if (! isset($storage_cache['hrstorage'])) {
|
||||
$storage_cache['hrstorage'] = snmpwalk_cache_oid($device, 'hrStorageEntry', null, 'HOST-RESOURCES-MIB:HOST-RESOURCES-TYPES');
|
||||
d_echo($storage_cache);
|
||||
}
|
||||
|
||||
@@ -21,7 +21,7 @@
|
||||
* @copyright 2018 Ryan Finney
|
||||
* @author https://github.com/theherodied/
|
||||
*/
|
||||
if (! is_array($storage_cache['intelliflash-pl'])) {
|
||||
if (! isset($storage_cache['intelliflash-pl'])) {
|
||||
$storage_cache['intelliflash-pl'] = snmpwalk_cache_oid($device, 'poolEntry', null, 'TEGILE-MIB');
|
||||
d_echo($storage_cache);
|
||||
}
|
||||
|
||||
@@ -21,7 +21,7 @@
|
||||
* @copyright 2018 Ryan Finney
|
||||
* @author https://github.com/theherodied/
|
||||
*/
|
||||
if (! is_array($storage_cache['intelliflash-pr'])) {
|
||||
if (! isset($storage_cache['intelliflash-pr'])) {
|
||||
$storage_cache['intelliflash-pr'] = snmpwalk_cache_oid($device, 'projectEntry', null, 'TEGILE-MIB');
|
||||
d_echo($storage_cache);
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
if (! is_array($storage_cache['netapp-storage'])) {
|
||||
if (! isset($storage_cache['netapp-storage'])) {
|
||||
$storage_cache['netapp-storage'] = snmpwalk_cache_oid($device, 'dfEntry', null, 'NETAPP-MIB');
|
||||
d_echo($storage_cache);
|
||||
}
|
||||
|
||||
@@ -21,7 +21,7 @@
|
||||
* @copyright 2018 Ryan Finney
|
||||
* @author https://github.com/theherodied/
|
||||
*/
|
||||
if (! is_array($storage_cache['nimbleos'])) {
|
||||
if (! isset($storage_cache['nimbleos'])) {
|
||||
$storage_cache['nimbleos'] = snmpwalk_cache_oid($device, 'volEntry', null, 'NIMBLE-MIB');
|
||||
d_echo($storage_cache);
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
if (! is_array($storage_cache['dsk'] ?? null)) {
|
||||
if (! isset($storage_cache['dsk'])) {
|
||||
$storage_cache['dsk'] = snmpwalk_cache_oid($device, 'dskTable', null, 'UCD-SNMP-MIB');
|
||||
d_echo($storage_cache);
|
||||
}
|
||||
|
||||
@@ -21,7 +21,7 @@
|
||||
* @copyright 2018 Ryan Finney
|
||||
* @author https://github.com/theherodied/
|
||||
*/
|
||||
if (! is_array($storage_cache['vrp'])) {
|
||||
if (! isset($storage_cache['vrp'])) {
|
||||
$storage_cache['vrp'] = snmpwalk_cache_oid($device, 'hwStorageEntry', null, 'HUAWEI-FLASH-MAN-MIB');
|
||||
d_echo($storage_cache);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user