Apply fixes from StyleCI (#14899)

Co-authored-by: StyleCI Bot <bot@styleci.io>
This commit is contained in:
Jellyfrog 2023-03-13 22:32:22 +01:00 committed by GitHub
parent 0e322ae5d5
commit 68e0b3df28
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
220 changed files with 2050 additions and 2035 deletions

View File

@ -39,7 +39,6 @@ class AlertRules
{
public function runRules($device_id)
{
//Check to see if under maintenance
if (AlertUtil::isMaintenance($device_id) > 0) {
echo "Under Maintenance, skipping alert rules check.\r\n";

View File

@ -70,7 +70,7 @@ class Alertmanager extends Transport
unset($api['url']);
foreach ($api as $label => $value) {
// To allow dynamic values
if ((preg_match('/^extra_[A-Za-z0-9_]+$/', $label)) && (! empty($obj['faults'][1][$value]))) {
if (preg_match('/^extra_[A-Za-z0-9_]+$/', $label) && (! empty($obj['faults'][1][$value]))) {
$data[0]['labels'][$label] = $obj['faults'][1][$value];
} else {
$data[0]['labels'][$label] = $value;

View File

@ -90,7 +90,6 @@ class Boxcar extends Transport
default:
$title_text = $severity;
break;
}
$data['notification[title]'] = $title_text . ' - ' . $obj['hostname'] . ' - ' . $obj['name'];
$message_text = 'Timestamp: ' . $obj['timestamp'];

View File

@ -21,6 +21,7 @@
*
* @copyright 2018 Ryan Finney
* @author https://github.com/theherodied/
*
* @contributer f0o, sdef2
* Thanks to F0o <f0o@devilcode.org> for creating the Slack transport which is the majority of this code.
* Thanks to sdef2 for figuring out the differences needed to make Discord work.

View File

@ -56,7 +56,7 @@ class Telegram extends Transport
if (! empty($data['message_thread_id'])) {
$messageThreadId = '&message_thread_id=' . $data['message_thread_id'];
}
curl_setopt($curl, CURLOPT_URL, ("https://api.telegram.org/bot{$data['token']}/sendMessage?chat_id={$data['chat_id']}$messageThreadId&text=$text{$format}"));
curl_setopt($curl, CURLOPT_URL, "https://api.telegram.org/bot{$data['token']}/sendMessage?chat_id={$data['chat_id']}$messageThreadId&text=$text{$format}");
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
$ret = curl_exec($curl);
$code = curl_getinfo($curl, CURLINFO_HTTP_CODE);

View File

@ -70,7 +70,7 @@ class QueryBuilderFilter implements \JsonSerializable
continue; // don't include the time based macros, they don't work like that
}
if ((Str::endsWith($key, '_usage_perc')) || (Str::startsWith($key, 'packet_loss_'))) {
if (Str::endsWith($key, '_usage_perc') || Str::startsWith($key, 'packet_loss_')) {
$this->filter[$field] = [
'id' => $field,
'type' => 'integer',

View File

@ -656,9 +656,9 @@ class Rrd extends BaseDatastore
$substr_count_length = $length <= 0 ? null : min(strlen($descr), $length);
$extra = substr_count($descr, ':', 0, $substr_count_length);
$result = substr(str_pad($result, $length), 0, ($length + $extra));
$result = substr(str_pad($result, $length), 0, $length + $extra);
if ($extra > 0) {
$result = substr($result, 0, (-1 * $extra));
$result = substr($result, 0, -1 * $extra);
}
}

View File

@ -27,7 +27,7 @@ namespace LibreNMS\Enum;
use LibreNMS\Config;
enum ImageFormat : string
enum ImageFormat: string
{
case png = 'png';
case svg = 'svg';

View File

@ -225,7 +225,7 @@ class IRCBot
return false;
}
if (($this->socket['alert'] = fopen($f, 'r+'))) {
if ($this->socket['alert'] = fopen($f, 'r+')) {
$this->log('Opened Alert-File');
stream_set_blocking($this->socket['alert'], false);
@ -246,7 +246,7 @@ class IRCBot
$r = strlen($r);
if (strstr($this->buff[$buff], "\n")) {
$tmp = explode("\n", $this->buff[$buff], 2);
$this->buff[$buff] = substr($this->buff[$buff], (strlen($tmp[0]) + 1));
$this->buff[$buff] = substr($this->buff[$buff], strlen($tmp[0]) + 1);
if ($this->debug) {
$this->log("Returning buffer '$buff': '" . trim($tmp[0]) . "'");
}
@ -369,7 +369,7 @@ class IRCBot
}
}
if (($this->config['irc_ctcp']) && (preg_match('/^:' . chr(1) . '.*/', $ex[3]))) {
if ($this->config['irc_ctcp'] && preg_match('/^:' . chr(1) . '.*/', $ex[3])) {
// Handle CTCP
$ctcp = trim(preg_replace('/[^A-Z]/', '', $ex[3]));
$ctcp_reply = null;
@ -529,7 +529,7 @@ class IRCBot
if ($try > $this->max_retry) {
$this->log('Failed too many connection attempts, aborting');
return exit();
return exit;
}
$this->log('Trying to connect (' . ($try + 1) . ') to ' . $this->server . ':' . $this->port . ($this->ssl ? ' (SSL)' : ''));
@ -612,7 +612,7 @@ class IRCBot
} catch (\PDOException $e) {
$this->log('Cannot connect to MySQL: ' . $e->getMessage());
return exit();
return exit;
}
}
@ -765,7 +765,7 @@ class IRCBot
if ($this->user['level'] == 10) {
$this->ircRaw('QUIT :Requested');
return exit();
return exit;
} else {
return $this->respond('Permission denied.');
}

View File

@ -13,8 +13,7 @@ class Ruckuswireless extends OS implements
{
public function discoverWirelessClients()
{
// Find Per SSID Client Count
// Find Per SSID Client Count
$sensors = [];
$ssids = $this->getCacheByIndex('ruckusZDWLANSSID', 'RUCKUS-ZD-WLAN-MIB');
$counts = $this->getCacheByIndex('ruckusZDWLANNumSta', 'RUCKUS-ZD-WLAN-MIB');
@ -42,7 +41,7 @@ class Ruckuswireless extends OS implements
if (count($total_oids) > 1) {
// Find Total Client Count
$oid = '.1.3.6.1.4.1.25053.1.2.1.1.1.15.2.0'; //RUCKUS-ZD-SYSTEM-MIB::ruckusZDSystemStatsNumSta.0
array_push($sensors, new WirelessSensor('clients', $this->getDeviceId(), $oid, 'ruckuswireless', ($index + 1), 'System Total:'));
array_push($sensors, new WirelessSensor('clients', $this->getDeviceId(), $oid, 'ruckuswireless', $index + 1, 'System Total:'));
}
return $sensors;

View File

@ -55,7 +55,7 @@ class RuckuswirelessSz extends OS implements
if (count($total_oids) > 1) {
// clients - Discover System Total Client Count
$oid = '.1.3.6.1.4.1.25053.1.4.1.1.1.15.2.0'; //RUCKUS-SZ-SYSTEM-MIB::ruckusSZSystemStatsNumSta.0
array_push($sensors, new WirelessSensor('clients', $this->getDeviceId(), $oid, 'ruckuswireless-sz', ($index + 1), 'System Total:'));
array_push($sensors, new WirelessSensor('clients', $this->getDeviceId(), $oid, 'ruckuswireless-sz', $index + 1, 'System Total:'));
}
return $sensors;

View File

@ -430,7 +430,7 @@ class Cisco extends OS implements
$rtt_type = $sla->rtt_type;
// Lets process each SLA
$unixtime = intval(($data[$sla_nr]['rttMonLatestRttOperTime'] / 100 + $time_offset));
$unixtime = intval($data[$sla_nr]['rttMonLatestRttOperTime'] / 100 + $time_offset);
$time = date('Y-m-d H:i:s', $unixtime);
// Save data

View File

@ -57,7 +57,7 @@ class Zyxel extends OS
return;
}
$device->hardware = $data['.1.3.6.1.4.1.890.1.15.3.1.11.0'] ?? null;
[$device->version,] = explode(' | ', $data['.1.3.6.1.4.1.890.1.15.3.1.6.0'] ?? null);
[$device->version] = explode(' | ', $data['.1.3.6.1.4.1.890.1.15.3.1.6.0'] ?? null);
$device->serial = $data['.1.3.6.1.4.1.890.1.15.3.1.12.0'] ?? null;
}
}

View File

@ -37,7 +37,7 @@ class ThreeCom extends OS implements OSDiscovery
if (Str::contains($device->sysDescr, 'Software')) {
$device->hardware = str_replace('3Com ', '', substr($device->sysDescr, 0, strpos($device->sysDescr, 'Software')));
// Version is the last word in the sysDescr's first line
[$device->version] = explode("\n", substr($device->sysDescr, (strpos($device->sysDescr, 'Version') + 8)));
[$device->version] = explode("\n", substr($device->sysDescr, strpos($device->sysDescr, 'Version') + 8));
return;
}

View File

@ -295,7 +295,7 @@ SVG;
$px = (int) ((imagesx($img) - 7.5 * strlen($text)) / 2);
$font = $width < 200 ? 3 : 5;
imagestring($img, $font, $px, ($height / 2 - 8), $text, imagecolorallocate($img, ...$color));
imagestring($img, $font, $px, $height / 2 - 8, $text, imagecolorallocate($img, ...$color));
// Output the image
ob_start();

View File

@ -489,7 +489,7 @@ class ModuleTestHelper
foreach ($snmprec_data as $line) {
if (! empty($line)) {
[$oid,] = explode('|', $line, 2);
[$oid] = explode('|', $line, 2);
$result[$oid] = $line;
}
}

View File

@ -45,14 +45,14 @@ class Number
if ($value >= '0.1') {
$sizes = ['', 'k', 'M', 'G', 'T', 'P', 'E', 'Z', 'Y'];
$ext = $sizes[0];
for ($i = 1; (($i < count($sizes)) && ($value >= 1000)); $i++) {
for ($i = 1; ($i < count($sizes)) && ($value >= 1000); $i++) {
$value = $value / 1000;
$ext = $sizes[$i];
}
} else {
$sizes = ['', 'm', 'u', 'n', 'p'];
$ext = $sizes[0];
for ($i = 1; (($i < count($sizes)) && ($value != 0) && ($value <= 0.1)); $i++) {
for ($i = 1; ($i < count($sizes)) && ($value != 0) && ($value <= 0.1); $i++) {
$value = $value * 1000;
$ext = $sizes[$i];
}
@ -74,7 +74,7 @@ class Number
}
$sizes = ['', 'Ki', 'Mi', 'Gi', 'Ti', 'Pi', 'Ei', 'Zi', 'Yi'];
$ext = $sizes[0];
for ($i = 1; (($i < count($sizes)) && ($value >= 1024)); $i++) {
for ($i = 1; ($i < count($sizes)) && ($value >= 1024); $i++) {
$value = $value / 1024;
$ext = $sizes[$i];
}

View File

@ -155,7 +155,7 @@ class Rewrite
*/
public static function readableOUI($mac)
{
$cached = Cache::get('OUIDB-' . (substr($mac, 0, 6)), '');
$cached = Cache::get('OUIDB-' . substr($mac, 0, 6), '');
if ($cached == 'IEEE Registration Authority') {
// Then we may have a shorter prefix, so let's try them one ater the other, ordered by probability
return Cache::get('OUIDB-' . substr($mac, 0, 9)) ?: Cache::get('OUIDB-' . substr($mac, 0, 7));

View File

@ -111,7 +111,6 @@ class Updates extends BaseValidation
$modifiedcmd = 'git diff --name-only --exit-code';
$validator->execAsUser($modifiedcmd, $cmdoutput, $code);
if ($code !== 0 && ! empty($cmdoutput)) {
// Check so it's not only plugins that "pests" the diff
if (! ($cmdoutput === ['composer.json', 'composer.lock'] && ComposerHelper::getPlugins())) {
$result = ValidationResult::warn(

View File

@ -116,14 +116,14 @@ class DevSimulate extends LnmsCommand
{
if (function_exists('pcntl_signal')) {
pcntl_signal(SIGINT, function () {
exit(); // exit normally on SIGINT
exit; // exit normally on SIGINT
});
}
register_shutdown_function(function () use ($device_id) {
Device::findOrNew($device_id)->delete();
$this->info(trans('commands.dev:simulate.removed', ['id' => $device_id]));
exit();
exit;
});
}

View File

@ -35,7 +35,7 @@ class NetflowController implements DeviceTab
{
if (Config::get('nfsen_enable')) {
foreach ((array) Config::get('nfsen_rrds', []) as $nfsenrrds) {
if ($nfsenrrds[(strlen($nfsenrrds) - 1)] != '/') {
if ($nfsenrrds[strlen($nfsenrrds) - 1] != '/') {
$nfsenrrds .= '/';
}

View File

@ -104,7 +104,7 @@ class ShowConfigController extends Controller implements DeviceTab
if (Config::has('rancid_configs.0')) {
$device = DeviceCache::getPrimary();
foreach (Config::get('rancid_configs') as $configs) {
if ($configs[(strlen($configs) - 1)] != '/') {
if ($configs[strlen($configs) - 1] != '/') {
$configs .= '/';
}

View File

@ -76,6 +76,7 @@ abstract class PaginatedAjaxController extends Controller
*
* @param \Illuminate\Http\Request $request
* @return array
*
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*/
protected function searchFields($request)
@ -88,6 +89,7 @@ abstract class PaginatedAjaxController extends Controller
*
* @param \Illuminate\Http\Request $request
* @return array
*
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*/
protected function filterFields($request)
@ -100,6 +102,7 @@ abstract class PaginatedAjaxController extends Controller
*
* @param \Illuminate\Http\Request $request
* @return array
*
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*/
protected function sortFields($request)

View File

@ -49,6 +49,7 @@ class EventlogController extends SelectController
*
* @param \Illuminate\Http\Request $request
* @return array
*
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*/
protected function sortFields($request)

View File

@ -35,6 +35,7 @@ class LocationController extends TableController
*
* @param \Illuminate\Http\Request $request
* @return array
*
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*/
public function searchFields($request)

View File

@ -113,7 +113,7 @@ class OutagesController extends TableController
}
$output = "<span style='display:inline;'>";
$output .= (Carbon::createFromTimestamp($timestamp))->format(Config::get('dateformat.compact')); // Convert epoch to local time
$output .= Carbon::createFromTimestamp($timestamp)->format(Config::get('dateformat.compact')); // Convert epoch to local time
$output .= '</span>';
return $output;

View File

@ -27,7 +27,6 @@ class QueryDebugListener
public function handle(QueryExecuted $query)
{
if (Debug::queryDebugIsEnabled()) {
// collect bindings and make them a little more readable
$bindings = collect($query->bindings)->map(function ($item) {
if ($item instanceof \Carbon\Carbon) {

View File

@ -23,6 +23,7 @@ use LibreNMS\Alert\Transport;
* @method static \Illuminate\Database\Eloquent\Builder|AlertTransport whereTransportId($value)
* @method static \Illuminate\Database\Eloquent\Builder|AlertTransport whereTransportName($value)
* @method static \Illuminate\Database\Eloquent\Builder|AlertTransport whereTransportType($value)
*
* @mixin \Eloquent
*/
class AlertTransport extends Model

View File

@ -106,7 +106,7 @@ class Port extends DeviceRelatedModel
*/
public function getDescription(): string
{
return (string) ($this->ifAlias);
return (string) $this->ifAlias;
}
/**

View File

@ -42,7 +42,6 @@ class EventServiceProvider extends ServiceProvider
*/
public function boot()
{
//
}
}

View File

@ -38,7 +38,6 @@ class RouteServiceProvider extends ServiceProvider
//$this->configureRateLimiting();
$this->routes(function () {
/**
* Define the "api" routes for the application.
*

View File

@ -8,7 +8,7 @@
| request an environment variable to be created upstream or send a pull request.
*/
return [
return [
/*
|--------------------------------------------------------------------------
@ -254,4 +254,4 @@ return [
],
'charset' => env('CHARSET', ini_get('php.output_encoding') ?: ini_get('default_charset') ?: 'UTF-8'),
];
];

View File

@ -8,7 +8,7 @@
| request an environment variable to be created upstream or send a pull request.
*/
return [
return [
/*
|--------------------------------------------------------------------------
@ -133,4 +133,4 @@ return [
'password_timeout' => 10800,
];
];

View File

@ -8,7 +8,7 @@
| request an environment variable to be created upstream or send a pull request.
*/
return [
return [
/*
|--------------------------------------------------------------------------
@ -69,4 +69,4 @@ return [
],
];
];

View File

@ -8,9 +8,9 @@
| request an environment variable to be created upstream or send a pull request.
*/
use Illuminate\Support\Str;
use Illuminate\Support\Str;
return [
return [
/*
|--------------------------------------------------------------------------
@ -115,4 +115,4 @@ return [
'prefix' => env('CACHE_PREFIX', Str::slug(env('APP_NAME', 'laravel'), '_') . '_cache'),
];
];

View File

@ -8,9 +8,9 @@
| request an environment variable to be created upstream or send a pull request.
*/
use Illuminate\Support\Str;
use Illuminate\Support\Str;
return [
return [
/*
|--------------------------------------------------------------------------
@ -229,4 +229,4 @@ return [
],
];
];

View File

@ -8,7 +8,7 @@
| request an environment variable to be created upstream or send a pull request.
*/
return [
return [
/*
|--------------------------------------------------------------------------
@ -208,4 +208,4 @@ return [
| To override default domain, specify it as a non-empty value.
*/
'route_domain' => null,
];
];

View File

@ -8,7 +8,7 @@
| request an environment variable to be created upstream or send a pull request.
*/
return [
return [
/*
|--------------------------------------------------------------------------
@ -83,4 +83,4 @@ return [
public_path('storage') => storage_path('app/public'),
],
];
];

View File

@ -8,7 +8,7 @@
| request an environment variable to be created upstream or send a pull request.
*/
return [
return [
/*
|
|--------------------------------------------------------------------------
@ -67,4 +67,4 @@ return [
*/
'censor_request_body_fields' => ['username', 'password', 'sysContact', 'community', 'authname', 'authpass', 'cryptopass'],
];
];

View File

@ -8,7 +8,7 @@
| request an environment variable to be created upstream or send a pull request.
*/
return [
return [
/*
|--------------------------------------------------------------------------
@ -57,4 +57,4 @@ return [
'time' => 2,
],
];
];

View File

@ -8,7 +8,7 @@
| request an environment variable to be created upstream or send a pull request.
*/
return [
return [
/*
|--------------------------------------------------------------------------
@ -53,4 +53,4 @@ return [
'node_id' => env('NODE_ID'),
];
];

View File

@ -8,11 +8,11 @@
| request an environment variable to be created upstream or send a pull request.
*/
use Monolog\Handler\NullHandler;
use Monolog\Handler\StreamHandler;
use Monolog\Handler\SyslogUdpHandler;
use Monolog\Handler\NullHandler;
use Monolog\Handler\StreamHandler;
use Monolog\Handler\SyslogUdpHandler;
return [
return [
/*
|--------------------------------------------------------------------------
@ -148,4 +148,4 @@ return [
],
],
];
];

View File

@ -8,7 +8,7 @@
| request an environment variable to be created upstream or send a pull request.
*/
return [
return [
/*
|--------------------------------------------------------------------------
@ -98,4 +98,4 @@ return [
'table' => 'failed_jobs',
],
];
];

View File

@ -8,7 +8,7 @@
| request an environment variable to be created upstream or send a pull request.
*/
return [
return [
/*
|--------------------------------------------------------------------------
@ -38,4 +38,4 @@ return [
'region' => env('AWS_DEFAULT_REGION', 'us-east-1'),
],
];
];

View File

@ -8,7 +8,7 @@
| request an environment variable to be created upstream or send a pull request.
*/
return [
return [
/*
|--------------------------------------------------------------------------
@ -23,4 +23,4 @@ return [
'dont_alias' => [],
];
];

View File

@ -8,6 +8,6 @@
| request an environment variable to be created upstream or send a pull request.
*/
return [
return [
'options' => [],
];
];

View File

@ -168,7 +168,7 @@ if (isset($_GET['format']) && preg_match('/^[a-z]*$/', $_GET['format'])) {
if ($_GET['debug'] == 1) {
echo '<pre>$map</pre>';
exit();
exit;
}
switch ($_GET['format']) {
@ -179,7 +179,7 @@ if (isset($_GET['format']) && preg_match('/^[a-z]*$/', $_GET['format'])) {
break;
case 'dot':
echo $map;
exit();
exit;
default:
$_GET['format'] = 'png:gd';
}

View File

@ -123,7 +123,7 @@ function get95thagg($bill_id, $datefrom, $dateto)
$mq_sql = 'SELECT count(delta) FROM bill_data WHERE bill_id = ?';
$mq_sql .= ' AND timestamp > ? AND timestamp <= ?';
$measurements = dbFetchCell($mq_sql, [$bill_id, $datefrom, $dateto]);
$measurement_95th = (round(($measurements / 100 * 95)) - 1);
$measurement_95th = (round($measurements / 100 * 95) - 1);
$q_95_sql = 'SELECT (delta / period * 8) AS rate FROM bill_data WHERE bill_id = ?';
$q_95_sql .= ' AND timestamp > ? AND timestamp <= ? ORDER BY rate ASC';
@ -138,7 +138,7 @@ function get95thIn($bill_id, $datefrom, $dateto)
$mq_sql = 'SELECT count(delta) FROM bill_data WHERE bill_id = ?';
$mq_sql .= ' AND timestamp > ? AND timestamp <= ?';
$measurements = dbFetchCell($mq_sql, [$bill_id, $datefrom, $dateto]);
$measurement_95th = (round(($measurements / 100 * 95)) - 1);
$measurement_95th = (round($measurements / 100 * 95) - 1);
$q_95_sql = 'SELECT (in_delta / period * 8) AS rate FROM bill_data WHERE bill_id = ?';
$q_95_sql .= ' AND timestamp > ? AND timestamp <= ? ORDER BY rate ASC';
@ -153,7 +153,7 @@ function get95thout($bill_id, $datefrom, $dateto)
$mq_sql = 'SELECT count(delta) FROM bill_data WHERE bill_id = ?';
$mq_sql .= ' AND timestamp > ? AND timestamp <= ?';
$measurements = dbFetchCell($mq_sql, [$bill_id, $datefrom, $dateto]);
$measurement_95th = (round(($measurements / 100 * 95)) - 1);
$measurement_95th = (round($measurements / 100 * 95) - 1);
$q_95_sql = 'SELECT (out_delta / period * 8) AS rate FROM bill_data WHERE bill_id = ?';
$q_95_sql .= ' AND timestamp > ? AND timestamp <= ? ORDER BY rate ASC';
@ -293,8 +293,8 @@ function getBillingBitsGraphData($bill_id, $from, $to, $reducefactor)
$tot_period += $period;
if (++$iter >= $reducefactor) {
$out_data[$i] = round(($iter_out / $iter_period), 2);
$in_data[$i] = round(($iter_in / $iter_period), 2);
$out_data[$i] = round($iter_out / $iter_period, 2);
$in_data[$i] = round($iter_in / $iter_period, 2);
$tot_data[$i] = ($out_data[$i] + $in_data[$i]);
$ticks[$i] = $timestamp;
$i++;
@ -305,8 +305,8 @@ function getBillingBitsGraphData($bill_id, $from, $to, $reducefactor)
}//end foreach
if (! empty($iter_in)) { // Write last element
$out_data[$i] = round(($iter_out / $iter_period), 2);
$in_data[$i] = round(($iter_in / $iter_period), 2);
$out_data[$i] = round($iter_out / $iter_period, 2);
$in_data[$i] = round($iter_in / $iter_period, 2);
$tot_data[$i] = ($out_data[$i] + $in_data[$i]);
$ticks[$i] = $timestamp;
$i++;

View File

@ -122,7 +122,7 @@ if (Config::get('enable_bgp')) {
'bgpPeerDescr' => $value['bgpPeerDescr'] ?? '',
];
$affected = DeviceCache::getPrimary()->bgppeers()->where('bgpPeerIdentifier', $address)->where('vrf_id', $vrfId)->update($peers);
$seenPeerID[] = (DeviceCache::getPrimary()->bgppeers()->where('bgpPeerIdentifier', $address)->where('vrf_id', $vrfId)->select('bgpPeer_id')->orderBy('bgpPeer_id', 'ASC')->first()->bgpPeer_id);
$seenPeerID[] = DeviceCache::getPrimary()->bgppeers()->where('bgpPeerIdentifier', $address)->where('vrf_id', $vrfId)->select('bgpPeer_id')->orderBy('bgpPeer_id', 'ASC')->first()->bgpPeer_id;
echo str_repeat('.', $affected);
$vrp_bgp_peer_count += $affected;

View File

@ -128,7 +128,7 @@ if (($device['os'] == 'routeros') && ($device['version'] <= '7.6')) {
}//end foreach
}
echo PHP_EOL;
} elseif (($device['os'] == 'pbn' || $device['os'] == 'bdcom')) {
} elseif ($device['os'] == 'pbn' || $device['os'] == 'bdcom') {
echo ' NMS-LLDP-MIB: ';
$lldp_array = snmpwalk_group($device, 'lldpRemoteSystemsData', 'NMS-LLDP-MIB');
@ -161,7 +161,7 @@ if (($device['os'] == 'routeros') && ($device['version'] <= '7.6')) {
}
}//end foreach
echo PHP_EOL;
} elseif (($device['os'] == 'timos')) {
} elseif ($device['os'] == 'timos') {
echo ' TIMETRA-LLDP-MIB: ';
$lldp_array = snmpwalk_group($device, 'tmnxLldpRemoteSystemsData', 'TIMETRA-LLDP-MIB');
foreach ($lldp_array as $key => $lldp) {
@ -195,7 +195,7 @@ if (($device['os'] == 'routeros') && ($device['version'] <= '7.6')) {
}
}//end foreach
echo PHP_EOL;
} elseif (($device['os'] == 'jetstream')) {
} elseif ($device['os'] == 'jetstream') {
echo ' JETSTREAM-LLDP MIB: ';
$lldp_array = snmpwalk_group($device, 'lldpNeighborInfoEntry', 'TPLINK-LLDPINFO-MIB');
@ -259,7 +259,7 @@ if (($device['os'] == 'routeros') && ($device['version'] <= '7.6')) {
}
}
}
if (($device['os'] == 'aos7')) {
if ($device['os'] == 'aos7') {
$lldp_local = snmpwalk_cache_oid($device, 'lldpLocPortEntry', [], 'LLDP-MIB');
$lldp_ports = snmpwalk_group($device, 'lldpLocPortId', 'LLDP-MIB');
} else {
@ -270,14 +270,14 @@ if (($device['os'] == 'routeros') && ($device['version'] <= '7.6')) {
foreach ($lldp_array as $key => $lldp_if_array) {
foreach ($lldp_if_array as $entry_key => $lldp_instance) {
if (($device['os'] == 'aos7')) {
if ($device['os'] == 'aos7') {
$ifName = $lldp_local[$entry_key]['lldpLocPortDesc'];
} elseif (is_numeric($dot1d_array[$entry_key]['dot1dBasePortIfIndex'])) {
$ifIndex = $dot1d_array[$entry_key]['dot1dBasePortIfIndex'];
} else {
$ifIndex = $entry_key;
}
if (($device['os'] == 'aos7')) {
if ($device['os'] == 'aos7') {
$local_port_id = find_port_id($ifName, null, $device['device_id']);
} else {
$local_port_id = find_port_id($lldp_ports[$entry_key]['lldpLocPortId'], $ifIndex, $device['device_id']);

View File

@ -51,11 +51,11 @@ foreach ($entity_array as $entPhysicalIndex => $entry) {
echo "\n";
unset(
$physical_name,
$serial_number,
$card_array,
$card,
$entry,
$entity_array,
$id
$physical_name,
$serial_number,
$card_array,
$card,
$entry,
$entity_array,
$id
);

View File

@ -294,7 +294,7 @@ if (is_null($tblUCSObjects)) {
// Old Firmware returns 4294967296 as 1 MB.
// The if below assumes we will never have < 1 Gb on old firmware or > 4 Pb on new firmware
if (($array[13][$key]) > 4294967296000) {
if ($array[13][$key] > 4294967296000) {
// Old Firmware
$result['string'] = $array[14][$key] . ' ' . $array[7][$key] . ', Rev: ' . $array[11][$key] . ', Size: ' . round($array[13][$key] / 4294967296000, 2) . ' GB';
d_echo('Disk: ' . $array[2][$key] . ', Raw Size: ' . $array[13][$key] . ', converted (old FW): ' . round($array[13][$key] / 4294967296000, 2) . "GB\n");
@ -342,7 +342,7 @@ if (is_null($tblUCSObjects)) {
// Old Firmware returns 4294967296 as 1 MB.
// The if below assumes we will never have < 1 Gb on old firmware or > 4 Pb on new firmware
if (($array[13][$key]) > 4294967296000) {
if ($array[13][$key] > 4294967296000) {
// Old Firmware
$result['string'] = $array[3][$key] . ', Size: ' . round($array[13][$key] / 4294967296000, 2) . ' GB';
d_echo('LUN: ' . $array[2][$key] . ', Raw Size: ' . $array[13][$key] . ', converted (Old FW): ' . round($array[13][$key] / 4294967296000, 2) . "GB\n");

View File

@ -78,8 +78,8 @@ foreach ($entity_array as $entPhysicalIndex => $entry) {
echo "\n";
unset(
$update_data,
$insert_data,
$entry,
$entity_array
$update_data,
$insert_data,
$entry,
$entity_array
);

View File

@ -38,7 +38,7 @@ if (Config::get('enable_libvirt') && $device['os'] == 'linux') {
exec(Config::get('virsh') . ' -rc ' . $uri . ' list', $domlist);
foreach ($domlist as $dom) {
[$dom_id,] = explode(' ', trim($dom), 2);
[$dom_id] = explode(' ', trim($dom), 2);
if (is_numeric($dom_id)) {
// Fetch the Virtual Machine information.

View File

@ -45,7 +45,7 @@ $components = $keep;
// Begin our master array, all other values will be processed into this array.
$tblBigIP = [];
if ((snmp_get($device, 'sysModuleAllocationProvisionLevel.3.103.116.109', '-Ovqs', 'F5-BIGIP-SYSTEM-MIB')) != false) {
if (snmp_get($device, 'sysModuleAllocationProvisionLevel.3.103.116.109', '-Ovqs', 'F5-BIGIP-SYSTEM-MIB') != false) {
$gtmWideIPEntry = snmpwalk_array_num($device, '1.3.6.1.4.1.3375.2.3.12.1.2.1', 0);
if (! is_null($gtmWideIPEntry)) {
$gtmWideStatusEntry = snmpwalk_array_num($device, '1.3.6.1.4.1.3375.2.3.12.3.2.1', 0);

View File

@ -30,7 +30,7 @@ $ipForwardNb = snmp_get_multi($device, ['inetCidrRouteNumber.0', 'ipCidrRouteNum
//Get the configured max routes number
$max_routes = 1000;
if (null != (Config::get('routes_max_number'))) {
if (null != Config::get('routes_max_number')) {
$max_routes = Config::get('routes_max_number');
}

View File

@ -27,7 +27,7 @@ foreach ($pre_cache['junos_ifotn_oids'] as $index => $entry) {
$limit = null;
$warn_limit = null;
$tmp_exp = $pre_cache['junos_ifotn_oids'][$index . '.1']['jnxoptIfOTNPMCurrentFECBERExponent'];
$current = ($entry['jnxoptIfOTNPMCurrentFECBERMantissa']) * pow(10, (-$tmp_exp));
$current = $entry['jnxoptIfOTNPMCurrentFECBERMantissa'] * pow(10, -$tmp_exp);
$entPhysicalIndex = $index;
$entPhysicalIndex_measured = 'ports';
discover_sensor($valid['sensor'], 'ber', $device, $oid, $index, 'junos', $descr, $divisor, $multiplier, $limit_low, $warn_limit_low, $warn_limit, $limit, $current, 'snmp', $entPhysicalIndex, $entPhysicalIndex_measured);

View File

@ -20,8 +20,8 @@
// ***** Sensors for ADVA FSP3000 R7
// *************************************************************
$multiplier = 1;
$divisor = 1000;
$multiplier = 1;
$divisor = 1000;
if (is_array($pre_cache['adva_fsp3kr7_Card'])) {
foreach (array_keys($pre_cache['adva_fsp3kr7_Card']) as $index) {

View File

@ -15,7 +15,7 @@ if (isset($oids) && $oids) {
if ($data) {
[$oid,$kind] = explode(' ', $data);
$split_oid = explode('.', $oid);
$index = $split_oid[(count($split_oid) - 1)];
$index = $split_oid[count($split_oid) - 1];
$current_oid = '.1.3.6.1.4.1.318.1.1.12.2.3.1.1.2.' . $index;
// rPDULoadStatusLoad
$phase_oid = '.1.3.6.1.4.1.318.1.1.12.2.3.1.1.4.' . $index;
@ -62,7 +62,7 @@ if (isset($oids) && $oids) {
continue;
}
$split_oid = explode('.', $oid);
$index = $split_oid[(count($split_oid) - 1)];
$index = $split_oid[count($split_oid) - 1];
$current_oid = '.1.3.6.1.4.1.318.1.1.12.2.3.1.1.2.' . $index;
// rPDULoadStatusLoad
$phase_oid = '.1.3.6.1.4.1.318.1.1.12.2.3.1.1.4.' . $index;
@ -112,7 +112,7 @@ if (isset($oids) && $oids) {
continue;
}
$split_oid = explode('.', $oid);
$index = $split_oid[(count($split_oid) - 1)];
$index = $split_oid[count($split_oid) - 1];
$descr = 'Bank ' . $banknum;
$current_oid = '.1.3.6.1.4.1.318.1.1.12.2.3.1.1.2.' . $index;
// rPDULoadStatusLoad
@ -150,7 +150,7 @@ if (isset($oids) && $oids) {
if ($data) {
[$oid,$kind] = explode(' ', $data);
$split_oid = explode('.', $oid);
$index = $split_oid[(count($split_oid) - 1)];
$index = $split_oid[count($split_oid) - 1];
$voltage_oid = '.1.3.6.1.4.1.318.1.1.26.6.3.1.6';
// rPDU2PhaseStatusVoltage
$current_oid = '.1.3.6.1.4.1.318.1.1.26.9.4.3.1.6.' . $index;
@ -238,8 +238,8 @@ if (isset($in_oids)) {
}
}
}
unset($index);
unset($data);
unset($index);
unset($data);
foreach ($oids as $index => $data) {
$type = 'apcUPS';
$descr = 'Phase ' . substr($index, -1) . ' Output';
@ -256,5 +256,5 @@ foreach ($oids as $index => $data) {
discover_sensor($valid['sensor'], 'current', $device, $current_oid, $index, $type, $descr, $divisor, 1, null, null, null, null, $current);
}
}
unset($index);
unset($data);
unset($index);
unset($data);

View File

@ -13,7 +13,7 @@ if ($inlet_oids) {
if ($inlet_data) {
[$inlet_oid,$inlet_descr] = explode(' ', $inlet_data, 2);
$inlet_split_oid = explode('.', $inlet_oid);
$inlet_index = $inlet_split_oid[(count($inlet_split_oid) - 2)] . '.' . $inlet_split_oid[(count($inlet_split_oid) - 1)];
$inlet_index = $inlet_split_oid[count($inlet_split_oid) - 2] . '.' . $inlet_split_oid[count($inlet_split_oid) - 1];
$inlet_oid = ".1.3.6.1.4.1.13742.6.5.2.3.1.4.$inlet_index.1";
$inlet_divisor = pow(10, snmp_get($device, "inletSensorDecimalDigits.$inlet_index.rmsCurrent", '-Ovq', 'PDU2-MIB'));
$inlet_current = (snmp_get($device, "measurementsInletSensorValue.$inlet_index.1", '-Ovq', 'PDU2-MIB') / $inlet_divisor);
@ -34,7 +34,7 @@ if ($outlet_oids) {
if ($outlet_data) {
[$outlet_oid,$outlet_descr] = explode(' ', $outlet_data, 2);
$outlet_split_oid = explode('.', $outlet_oid);
$outlet_index = $outlet_split_oid[(count($outlet_split_oid) - 1)];
$outlet_index = $outlet_split_oid[count($outlet_split_oid) - 1];
$outletsuffix = "$outlet_index";
$outlet_insert_index = $outlet_index;
// outletLoadValue: "A non-negative value indicates the measured load in milli Amps"
@ -62,7 +62,7 @@ if ($outlet_oids) {
if ($outlet_data) {
[$outlet_oid,$outlet_descr] = explode(' ', $outlet_data, 2);
$outlet_split_oid = explode('.', $outlet_oid);
$outlet_index = $outlet_split_oid[(count($outlet_split_oid) - 1)];
$outlet_index = $outlet_split_oid[count($outlet_split_oid) - 1];
$outletsuffix = "$outlet_index";
$outlet_insert_index = $outlet_index;
$outlet_oid = ".1.3.6.1.4.1.13742.6.5.4.3.1.4.1.$outletsuffix.1";

View File

@ -23,7 +23,7 @@ while ($towers <= $tower_count) {
if ($infeed_data) {
[$infeed_oid,$descr] = explode(' ', $infeed_data, 2);
$split_oid = explode('.', $infeed_oid);
$infeed_index = $split_oid[(count($split_oid) - 1)];
$infeed_index = $split_oid[count($split_oid) - 1];
// infeedLoadValue
$infeed_oid = '.1.3.6.1.4.1.1718.3.2.2.1.7.' . $towers . '.' . $infeed_index;
@ -55,7 +55,7 @@ while ($towers <= $tower_count) {
if ($outlet_data) {
[$outlet_oid,$outlet_descr] = explode(' ', $outlet_data, 2);
$outlet_split_oid = explode('.', $outlet_oid);
$outlet_index = $outlet_split_oid[(count($outlet_split_oid) - 1)];
$outlet_index = $outlet_split_oid[count($outlet_split_oid) - 1];
$outletsuffix = "$towers.$infeed_index.$outlet_index";

View File

@ -18,8 +18,8 @@
//********* ADVA FSP3000 R7 Series
$multiplier = 1;
$divisor = 10;
$multiplier = 1;
$divisor = 10;
foreach ($pre_cache['adva_fsp3kr7'] as $index => $entry) {
if ($entry['entityFacilityAidString'] and $entry['pmSnapshotCurrentInputPower']) {

View File

@ -83,7 +83,7 @@ if (! empty($entity_oids)) {
if ($device['os'] === 'arista_eos') {
$descr = $entity_array[$index]['entPhysicalDescr'];
if (preg_match('/(Input|Output) (voltage|current) sensor/i', $descr) || Str::startsWith($descr, 'Power supply') || preg_match('/^(Power Supply|Hotspot|Inlet|Board)/i', $descr)) {
$descr = (ucwords($entity_array[substr_replace($index, '000', -3)]['entPhysicalDescr'] ?? ''))
$descr = ucwords($entity_array[substr_replace($index, '000', -3)]['entPhysicalDescr'] ?? '')
. ' '
. preg_replace(
'/(Voltage|Current|Power Supply) Sensor$/i',

View File

@ -12,7 +12,7 @@ foreach (explode("\n", $oids) as $data) {
if ($data) {
[$oid,$descr] = explode(' ', $data, 2);
$split_oid = explode('.', $oid);
$index = $split_oid[(count($split_oid) - 1)];
$index = $split_oid[count($split_oid) - 1];
$oid = '.1.3.6.1.4.1.18928.1.2.2.1.9.1.3.' . $index;
$current = snmp_get($device, $oid, '-Oqv', '');

View File

@ -13,7 +13,7 @@ foreach (explode("\n", $oids) as $data) {
if ($data) {
[$oid,$kind] = explode(' ', $data);
$split_oid = explode('.', $oid);
$index = $split_oid[(count($split_oid) - 1)];
$index = $split_oid[count($split_oid) - 1];
$fan_oid = ".1.3.6.1.4.1.674.10892.5.4.700.12.1.6.1.$index";
$descr_oid = "coolingDeviceLocationName.1.$index";
$limit_oid = "coolingDeviceLowerCriticalThreshold.1.$index";

View File

@ -17,9 +17,9 @@ if (! empty($oids)) {
if (! empty($data)) {
[$oid,$descr] = explode(' = ', $data, 2);
$split_oid = explode('.', $oid);
$num_index = $split_oid[(count($split_oid) - 1)];
$num_index = $split_oid[count($split_oid) - 1];
$index = $num_index;
$part_oid = $split_oid[(count($split_oid) - 2)];
$part_oid = $split_oid[count($split_oid) - 2];
$num_index = $part_oid . '.' . $num_index;
$base_oid = '.1.3.6.1.4.1.12740.2.1.7.1.3.1.';
$oid = $base_oid . $num_index;

View File

@ -13,7 +13,7 @@ foreach (explode("\n", $oids) as $data) {
if ($data) {
[$oid,$kind] = explode(' ', $data);
$split_oid = explode('.', $oid);
$index = $split_oid[(count($split_oid) - 1)];
$index = $split_oid[count($split_oid) - 1];
if ($kind == 0) {
$fan_oid = ".1.3.6.1.4.1.10876.2.1.1.1.1.4.$index";
$descr_oid = ".1.3.6.1.4.1.10876.2.1.1.1.1.2.$index";

View File

@ -13,7 +13,7 @@ foreach (explode("\n", $oids) as $data) {
if ($data) {
[$oid,$descr] = explode(' ', $data, 2);
$split_oid = explode('.', $oid);
$index = $split_oid[(count($split_oid) - 1)];
$index = $split_oid[count($split_oid) - 1];
$oid = '.1.3.6.1.4.1.2021.13.16.3.1.3.' . $index;
$current = snmp_get($device, $oid, '-Oqv', 'LM-SENSORS-MIB');
$descr = trim(str_ireplace('fan-', '', $descr));

View File

@ -16,10 +16,10 @@ foreach ($oids as $index => $entry) {
$value = snmp_get($device, $oid, '-Oqv', 'EXTREME-SYSTEM-MIB');
$descr = "Fan Speed $modindex";
// round function used to round limit values to hundreds to avoid h/w/l limits being changed on every discovery as a change of 1rpm for fan speed would cause the limit values to change since they're dynamically calculated
$high_limit = round_Nth(($value * 1.5), 100);
$high_warn_limit = round_Nth(($value * 1.25), 100);
$low_warn_limit = round_Nth(($value * 0.75), 100);
$low_limit = round_Nth(($value * 0.5), 100);
$high_limit = round_Nth($value * 1.5, 100);
$high_warn_limit = round_Nth($value * 1.25, 100);
$low_warn_limit = round_Nth($value * 0.75, 100);
$low_limit = round_Nth($value * 0.5, 100);
if (is_numeric($value)) {
discover_sensor($valid['sensor'], 'fanspeed', $device, $oid, $index, 'extreme-fanspeed', $descr, '1', '1', $low_limit, $low_warn_limit, $high_warn_limit, $high_limit, $value);
}

View File

@ -14,7 +14,7 @@ foreach (explode("\n", $oids) as $data) {
if ($data) {
[$oid,$current] = explode(' ', $data, 2);
$split_oid = explode('.', $oid);
$index = $split_oid[(count($split_oid) - 1)];
$index = $split_oid[count($split_oid) - 1];
$oid = '.1.3.6.1.4.1.318.1.1.8.5.3.2.1.4.' . $index;
$descr = 'Input Feed ' . chr(64 + $index);
discover_sensor($valid['sensor'], 'frequency', $device, $oid, "3.2.1.4.$index", $type, $descr, $divisor, '1', null, null, null, null, $current);
@ -35,7 +35,7 @@ foreach (explode("\n", $oids) as $data) {
if ($data) {
[$oid,$current] = explode(' ', $data, 2);
$split_oid = explode('.', $oid);
$index = $split_oid[(count($split_oid) - 3)];
$index = $split_oid[count($split_oid) - 3];
$oid = '.1.3.6.1.4.1.318.1.1.8.5.4.2.1.4.' . $index;
$descr = 'Output Feed';
if (count(explode("\n", $oids)) > 1) {

View File

@ -29,9 +29,9 @@
*/
// Detect type of UPS (Signle-Phase/3 Phase)
// Number of input lines
$upsInputNumLines_oid = '.1.3.6.1.2.1.33.1.3.2.0';
$in_phaseNum = snmp_get($device, $upsInputNumLines_oid, '-Oqv');
// Number of input lines
$upsInputNumLines_oid = '.1.3.6.1.2.1.33.1.3.2.0';
$in_phaseNum = snmp_get($device, $upsInputNumLines_oid, '-Oqv');
// Single-phase system
if ($in_phaseNum == '1') {

View File

@ -12,7 +12,7 @@ foreach (explode("\n", $inlet_oids) as $inlet_data) {
if ($inlet_data) {
[$inlet_oid,$inlet_descr] = explode(' ', $inlet_data, 2);
$inlet_split_oid = explode('.', $inlet_oid);
$inlet_index = $inlet_split_oid[(count($inlet_split_oid) - 2)] . '.' . $inlet_split_oid[(count($inlet_split_oid) - 1)];
$inlet_index = $inlet_split_oid[count($inlet_split_oid) - 2] . '.' . $inlet_split_oid[count($inlet_split_oid) - 1];
$inlet_oid = ".1.3.6.1.4.1.13742.6.5.2.3.1.4.$inlet_index.23";
$inlet_divisor = pow(10, snmp_get($device, "inletSensorDecimalDigits.$inlet_index.frequency", '-Ovq', 'PDU2-MIB'));

View File

@ -15,7 +15,7 @@ foreach (explode("\n", $oids) as $data) {
if ($status == 2) {
// 2 = normal, 0 = not connected
$split_oid = explode('.', $oid);
$index = $split_oid[(count($split_oid) - 1)];
$index = $split_oid[count($split_oid) - 1];
$descr_oid = ".1.3.6.1.4.1.3854.1.2.2.1.17.1.1.$index";
$oid = ".1.3.6.1.4.1.3854.1.2.2.1.17.1.3.$index";
$warnlimit_oid = ".1.3.6.1.4.1.3854.1.2.2.1.17.1.7.$index";

View File

@ -44,7 +44,7 @@ if (! empty($dhcp_networks[$dhcp_networks_base_oid])) {
foreach ($dhcp_networks[$dhcp_networks_base_oid] as $dhcp_type_index => $ignore_this) {
if (! empty($dhcp_networks[$dhcp_networks_base_oid][$dhcp_type_index])) {
foreach ($dhcp_networks[$dhcp_networks_base_oid][$dhcp_type_index] as $index => $entry) {
$description = (explode('[', $entry));
$description = explode('[', $entry);
$data_array[$array_index]['index'] = $index;
if ($dhcp_type_index === intval($auth_dhcp_index)) {
$data_array[$array_index]['type'] = 'dhcpatriotAuthDHCP';

View File

@ -27,9 +27,9 @@
*/
// Detect type of UPS (Signle-Phase/3 Phase)
// Number of input lines
$upsInputNumLines_oid = '.1.3.6.1.2.1.33.1.3.2.0';
$in_phaseNum = snmp_get($device, $upsInputNumLines_oid, '-Oqv');
// Number of input lines
$upsInputNumLines_oid = '.1.3.6.1.2.1.33.1.3.2.0';
$in_phaseNum = snmp_get($device, $upsInputNumLines_oid, '-Oqv');
// Single-phase system
if ($in_phaseNum == '1') {

View File

@ -13,7 +13,7 @@ foreach (explode("\n", $psus) as $psu) {
[$oid, $presence] = explode(' ', $psu, 2);
if ($presence != 2) {
$split_oid = explode('.', $oid);
$current_id = $split_oid[(count($split_oid) - 1)];
$current_id = $split_oid[count($split_oid) - 1];
$current_oid = $psu_usage_oid . $current_id;
$psu_max_oid = $psu_max_usage_oid . $current_id;
$descr = 'PSU ' . $current_id . ' output';

View File

@ -13,7 +13,7 @@ if ($inlet_oids) {
if ($inlet_data) {
[$inlet_oid,$inlet_descr] = explode(' ', $inlet_data, 2);
$inlet_split_oid = explode('.', $inlet_oid);
$inlet_index = $inlet_split_oid[(count($inlet_split_oid) - 2)] . '.' . $inlet_split_oid[(count($inlet_split_oid) - 1)];
$inlet_index = $inlet_split_oid[count($inlet_split_oid) - 2] . '.' . $inlet_split_oid[count($inlet_split_oid) - 1];
$inlet_oid = ".1.3.6.1.4.1.13742.6.5.2.3.1.4.$inlet_index.5";
$inlet_divisor = pow(10, snmp_get($device, "inletSensorDecimalDigits.$inlet_index.activePower", '-Ovq', 'PDU2-MIB'));
$inlet_power = (snmp_get($device, "measurementsInletSensorValue.$inlet_index.activePower", '-Ovq', 'PDU2-MIB') / $inlet_divisor);
@ -34,12 +34,12 @@ if ($outlet_oids) {
if ($outlet_data) {
[$outlet_oid,$outlet_descr] = explode(' ', $outlet_data, 2);
$outlet_split_oid = explode('.', $outlet_oid);
$outlet_index = $outlet_split_oid[(count($outlet_split_oid) - 1)];
$outlet_index = $outlet_split_oid[count($outlet_split_oid) - 1];
$outletsuffix = "$outlet_index";
$outlet_insert_index = $outlet_index;
$outlet_oid = ".1.3.6.1.4.1.13742.4.1.2.2.1.8.$outletsuffix";
$outlet_descr = snmp_get($device, "outletLabel.$outletsuffix", '-Ovq', 'PDU-MIB');
$outlet_power = (snmp_get($device, "outletApparentPower.$outletsuffix", '-Ovq', 'PDU-MIB'));
$outlet_power = snmp_get($device, "outletApparentPower.$outletsuffix", '-Ovq', 'PDU-MIB');
if ($outlet_power >= 0) {
discover_sensor($valid['sensor'], 'power', $device, $outlet_oid, $outlet_insert_index, 'raritan', $outlet_descr, $divisor, $multiplier, null, null, null, null, $outlet_power);
}
@ -57,7 +57,7 @@ if ($outlet_oids) {
if ($outlet_data) {
[$outlet_oid,$outlet_descr] = explode(' ', $outlet_data, 2);
$outlet_split_oid = explode('.', $outlet_oid);
$outlet_index = $outlet_split_oid[(count($outlet_split_oid) - 1)];
$outlet_index = $outlet_split_oid[count($outlet_split_oid) - 1];
$outletsuffix = "$outlet_index";
$outlet_insert_index = $outlet_index;
$outlet_oid = ".1.3.6.1.4.1.13742.6.5.4.3.1.4.1.$outletsuffix.5";

View File

@ -23,7 +23,7 @@
* @author Ben Gibbons <axemann@gmail.com>
*/
// Input Contact discovery
// Input Contact discovery
$contacts['emu2_contacts'] = snmpwalk_group($device, 'emsInputContactStatusEntry', 'PowerNet-MIB');

View File

@ -14,7 +14,7 @@ foreach ($aos6_fan_oids as $index => $data) {
$oid = '.1.3.6.1.4.1.6486.800.1.1.1.3.1.1.11.1.2.' . $index;
$state_name = 'alaChasEntPhysFanStatus';
$current = $data['alaChasEntPhysFanStatus'];
[$revindex, $revchass, $revdata,] = explode('.', strrev($oid), 4);
[$revindex, $revchass, $revdata] = explode('.', strrev($oid), 4);
$chassis = strrev($revchass);
$indexName = strrev($revindex);
$descr = 'Chassis-' . ($chassis - 568) . " Fan $indexName";

View File

@ -53,7 +53,7 @@ if (! empty($oids)) {
if (! empty($data)) {
[$oid,$current] = explode(' = ', $data, 2);
$split_oid = explode('.', $oid);
$num_index = $split_oid[(count($split_oid) - 1)];
$num_index = $split_oid[count($split_oid) - 1];
$index = (int) cast_number($num_index);
$low_limit = 0.5;
$high_limit = 2.5;
@ -97,9 +97,9 @@ if (! empty($oids1)) {
if (! empty($data)) {
[$oid,$descr] = explode(' = ', $data, 2);
$split_oid = explode('.', $oid);
$num_index = $split_oid[(count($split_oid) - 1)];
$num_index = $split_oid[count($split_oid) - 1];
$index = (int) cast_number($num_index);
$member_id = $split_oid[(count($split_oid) - 2)];
$member_id = $split_oid[count($split_oid) - 2];
$num_index = $member_id . '.' . $num_index;
$oid = $base_oid . $num_index;
$extra = snmp_get_multi($device, $oid, '-OQne', 'EQLMEMBER-MIB', 'equallogic');
@ -142,8 +142,8 @@ if (! empty($oids_disks)) {
if (! empty($data)) {
[$oid,$descr] = explode(' = ', $data, 2);
$split_oid = explode('.', $oid);
$disk_index = $split_oid[(count($split_oid) - 1)];
$member_id = $split_oid[(count($split_oid) - 2)];
$disk_index = $split_oid[count($split_oid) - 1];
$member_id = $split_oid[count($split_oid) - 2];
$num_index = $member_id . '.' . $disk_index;
$oid = $disks_base_oid . $num_index;
$extra = snmp_get($device, $oid, '-OQne', 'EQLDISK-MIB', 'equallogic');

View File

@ -20,7 +20,7 @@ if ($device['os'] == 'hirschmann') {
foreach ($oid as $index => $entry) {
//Discover Sensors
discover_sensor($valid['sensor'], 'state', $device, $cur_oid . $index, 'hmPowerSupplyStatus' . $index, $state_name, 'Power Supply ' . $oid[$index]['hmPSID'], 1, 1, null, null, null, null, ($oid[$index]['hmPowerSupplyStatus'] ?? null), 'snmp', 'hmPowerSupplyStatus' . $index);
discover_sensor($valid['sensor'], 'state', $device, $cur_oid . $index, 'hmPowerSupplyStatus' . $index, $state_name, 'Power Supply ' . $oid[$index]['hmPSID'], 1, 1, null, null, null, null, $oid[$index]['hmPowerSupplyStatus'] ?? null, 'snmp', 'hmPowerSupplyStatus' . $index);
//Create Sensor To State Index
create_sensor_to_state_index($device, $state_name, 'hmPowerSupplyStatus' . $index);

View File

@ -13,7 +13,7 @@ foreach (explode("\n", $fans) as $fan) {
[$oid, $presence] = explode(' ', $fan, 2);
if ($presence != 2) {
$split_oid = explode('.', $oid);
$current_id = $split_oid[(count($split_oid) - 1)];
$current_id = $split_oid[count($split_oid) - 1];
$current_oid = $fan_state_oid . $current_id;
$descr = $fan_state_descr . $current_id;
$state = snmp_get($device, $current_oid, '-Oqv');
@ -45,7 +45,7 @@ foreach (explode("\n", $psus) as $psu) {
[$oid, $presence] = explode(' ', $psu, 2);
if ($presence != 2) {
$split_oid = explode('.', $oid);
$current_id = $split_oid[(count($split_oid) - 1)];
$current_id = $split_oid[count($split_oid) - 1];
$current_oid = $psu_state_oid . $current_id;
$descr = $psu_state_descr . $current_id;
$state = snmp_get($device, $current_oid, '-Oqv');

View File

@ -24,7 +24,7 @@ if (is_array($fan_trays)) {
foreach ($fan_trays as $oid => $array) {
$state = current($array);
$split_oid = explode('.', $oid);
$index = $split_oid[(count($split_oid) - 1)];
$index = $split_oid[count($split_oid) - 1];
$current_oid = "$fan_tray_oid.$index";
$entity_oid = '.1.3.6.1.2.1.47.1.1.1.1.7';

View File

@ -34,7 +34,7 @@ $serverscheck_oids = [
];
foreach ($pre_cache['serverscheck_control'] as $oid_name => $oid_value) {
if ((Str::contains($oid_name, 'name')) && (Str::contains($oid_value, ['Flooding', 'Leckage']))) {
if (Str::contains($oid_name, 'name') && Str::contains($oid_value, ['Flooding', 'Leckage'])) {
preg_match("/(\d+)/", $oid_name, $temp_x);
$tmp_oid = 'sensor' . $temp_x[0] . 'Value.0';
$current = $pre_cache['serverscheck_control'][$tmp_oid];

View File

@ -26,8 +26,8 @@ if (is_array($voss_fan)) {
foreach ($voss_fan as $oid => $array) {
$state = current($array);
$split_oid = explode('.', $oid);
$tray_num = $split_oid[(count($split_oid) - 2)];
$fan_num = $split_oid[(count($split_oid) - 1)];
$tray_num = $split_oid[count($split_oid) - 2];
$fan_num = $split_oid[count($split_oid) - 1];
$current_oid = ".1.3.6.1.4.1.2272.1.101.1.1.4.1.4.$tray_num.$fan_num";
$descr = "VOSS Tray $tray_num Fan $fan_num";
@ -47,7 +47,7 @@ if (is_array($voss_fan)) {
foreach ($fan as $oid => $array) {
$state = current($array);
$split_oid = explode('.', $oid);
$index = $split_oid[(count($split_oid) - 1)];
$index = $split_oid[count($split_oid) - 1];
$current_oid = ".1.3.6.1.4.1.2272.1.4.7.1.1.2.$index";
$descr = "VOSS Fan $index";
@ -78,7 +78,7 @@ if (is_array($power_supply)) {
foreach ($power_supply as $oid => $array) {
$state = current($array);
$split_oid = explode('.', $oid);
$index = $split_oid[(count($split_oid) - 1)];
$index = $split_oid[count($split_oid) - 1];
$current_oid = ".1.3.6.1.4.1.2272.1.4.8.1.1.2.$index";
$descr = "VOSS Power Supply $index";

View File

@ -20,8 +20,8 @@
// ***** Temperature Sensors for ADVA FSP3000 R7
// *************************************************************
$multiplier = 1;
$divisor = 10;
$multiplier = 1;
$divisor = 10;
if (is_array($pre_cache['adva_fsp3kr7_Card'])) {
foreach (array_keys($pre_cache['adva_fsp3kr7_Card']) as $index) {

View File

@ -13,7 +13,7 @@ foreach (explode("\n", $oids) as $data) {
if ($data) {
[$oid,$descr] = explode(' ', $data, 2);
$split_oid = explode('.', $oid);
$temperature_id = $split_oid[(count($split_oid) - 1)];
$temperature_id = $split_oid[count($split_oid) - 1];
$temperature_oid = ".1.3.6.1.4.1.18928.1.1.2.14.1.2.$temperature_id";
$temperature = snmp_get($device, $temperature_oid, '-Oqv', '');
$descr = "Hard disk $temperature_id";
@ -37,7 +37,7 @@ foreach (explode("\n", $oids) as $data) {
if ($data) {
[$oid,$descr] = explode(' ', $data, 2);
$split_oid = explode('.', $oid);
$index = $split_oid[(count($split_oid) - 1)];
$index = $split_oid[count($split_oid) - 1];
$oid = '.1.3.6.1.4.1.18928.1.2.2.1.10.1.3.' . $index;
$current = snmp_get($device, $oid, '-Oqv', '');

View File

@ -22,7 +22,7 @@ foreach (explode("\n", $oids) as $data) {
if ($status == 'ok') {
$split_oid = explode('.', $oid);
$temperature_id = $split_oid[(count($split_oid) - 2)] . '.' . $split_oid[(count($split_oid) - 1)];
$temperature_id = $split_oid[count($split_oid) - 2] . '.' . $split_oid[count($split_oid) - 1];
$descr_oid = ".1.3.6.1.4.1.674.10892.5.4.700.20.1.8.$temperature_id";
$temperature_oid = ".1.3.6.1.4.1.674.10892.5.4.700.20.1.6.$temperature_id";
$limit_oid = ".1.3.6.1.4.1.674.10892.5.4.700.20.1.10.$temperature_id";
@ -37,7 +37,7 @@ foreach (explode("\n", $oids) as $data) {
$limit = snmp_get($device, $limit_oid, '-Oqv', 'IDRAC-MIB-SMIv2');
$lowlimit = snmp_get($device, $lowlimit_oid, '-Oqv', 'IDRAC-MIB-SMIv2');
discover_sensor($valid['sensor'], 'temperature', $device, $temperature_oid, $temperature_id, 'drac', $descr, '10', '1', ($lowlimit / 10), ($lowwarnlimit / 10), ($warnlimit / 10), ($limit / 10), ($temperature / 10));
discover_sensor($valid['sensor'], 'temperature', $device, $temperature_oid, $temperature_id, 'drac', $descr, '10', '1', $lowlimit / 10, $lowwarnlimit / 10, $warnlimit / 10, $limit / 10, $temperature / 10);
}
}//end if
}

View File

@ -23,9 +23,9 @@ if (! empty($oids)) {
if (! empty($data)) {
[$oid,$descr] = explode(' = ', $data, 2);
$split_oid = explode('.', $oid);
$num_index = $split_oid[(count($split_oid) - 1)];
$num_index = $split_oid[count($split_oid) - 1];
$index = $num_index;
$part_oid = $split_oid[(count($split_oid) - 2)];
$part_oid = $split_oid[count($split_oid) - 2];
$num_index = $part_oid . '.' . $num_index;
$base_oid = '.1.3.6.1.4.1.12740.2.1.6.1.3.1.';
$oid = $base_oid . $num_index;

View File

@ -12,7 +12,7 @@ foreach (explode("\n", $temps) as $temp) {
[$oid, $descr] = explode(' ', $temp, 2);
if ($descr != '') {
$split_oid = explode('.', $oid);
$current_id = $split_oid[(count($split_oid) - 1)];
$current_id = $split_oid[count($split_oid) - 1];
$current_oid = $sensor_value_oid . $current_id;
$value = snmp_get($device, $current_oid, '-Oqve');
if ($value > 0) {

View File

@ -25,7 +25,7 @@ if (Str::startsWith($device['sysObjectID'], '.1.3.6.1.4.1.232.')) {
if ($data != '') {
[$oid] = explode(' ', $data);
$split_oid = explode('.', $oid);
$temperature_id = $split_oid[(count($split_oid) - 2)] . '.' . $split_oid[(count($split_oid) - 1)];
$temperature_id = $split_oid[count($split_oid) - 2] . '.' . $split_oid[count($split_oid) - 1];
$descr_oid = ".1.3.6.1.4.1.232.6.2.6.8.1.3.$temperature_id";
$descr = snmp_get($device, $descr_oid, '-Oqnv', 'CPQHLTH-MIB', 'hp');

View File

@ -49,5 +49,5 @@ foreach (array_keys($mge_env_data) as $index) {
d_echo("low_limit : $low_limit\nlow_warn_limit : $low_warn_limit\nhigh_warn_limit : $high_warn_limit\nhigh_limit : $high_limit\n");
discover_sensor($valid['sensor'], 'temperature', $device, $oid, $index, $sensorType, $descr, '10', '1', $low_limit, $low_warn_limit, $high_warn_limit, $high_limit, ($current / 10));
discover_sensor($valid['sensor'], 'temperature', $device, $oid, $index, $sensorType, $descr, '10', '1', $low_limit, $low_warn_limit, $high_warn_limit, $high_limit, $current / 10);
}

View File

@ -15,7 +15,7 @@ foreach (explode("\n", $oids) as $data) {
if ($status == 2) {
// 2 = normal, 0 = not connected
$split_oid = explode('.', $oid);
$temperature_id = $split_oid[(count($split_oid) - 1)];
$temperature_id = $split_oid[count($split_oid) - 1];
$descr_oid = ".1.3.6.1.4.1.3854.1.2.2.1.16.1.1.$temperature_id";
$temperature_oid = ".1.3.6.1.4.1.3854.1.2.2.1.16.1.3.$temperature_id";
$warnlimit_oid = ".1.3.6.1.4.1.3854.1.2.2.1.16.1.7.$temperature_id";

View File

@ -12,7 +12,7 @@ foreach (explode("\n", $oids) as $data) {
if ($data) {
[$oid,$descr] = explode(' ', $data, 2);
$split_oid = explode('.', $oid);
$index = $split_oid[(count($split_oid) - 2)] . '.' . $split_oid[(count($split_oid) - 1)];
$index = $split_oid[count($split_oid) - 2] . '.' . $split_oid[count($split_oid) - 1];
$oid = '.1.3.6.1.4.1.2352.2.4.1.4.1.3.' . $index;
$temperature = snmp_get($device, $oid, '-Oqv');
$descr = str_replace('"', '', $descr);
@ -29,7 +29,7 @@ foreach (explode("\n", $oids) as $data) {
if ($data) {
[$oid,$descr] = explode(' ', $data, 2);
$split_oid = explode('.', $oid);
$index = $split_oid[(count($split_oid) - 2)] . '.' . $split_oid[(count($split_oid) - 1)];
$index = $split_oid[count($split_oid) - 2] . '.' . $split_oid[count($split_oid) - 1];
$oid = '.1.3.6.1.4.1.2352.2.4.1.6.1.3.' . $index;
$temperature = snmp_get($device, $oid, '-Oqv');
$descr = str_replace('"', '', $descr);

View File

@ -10,7 +10,7 @@ if ($oids) {
if ($data) {
[$oid, $type] = explode(' ', $data);
$oid_ex = explode('.', $oid);
$index = $oid_ex[(count($oid_ex) - 1)];
$index = $oid_ex[count($oid_ex) - 1];
if ($type == 2) {
$temperature_oid = ".1.3.6.1.4.1.10876.2.1.1.1.1.4.$index";
$descr_oid = ".1.3.6.1.4.1.10876.2.1.1.1.1.2.$index";

View File

@ -12,7 +12,7 @@ if ($oids) {
$divisor = 1000;
[$oid,$descr] = explode(' ', $data, 2);
$split_oid = explode('.', $oid);
$temperature_id = $split_oid[(count($split_oid) - 1)];
$temperature_id = $split_oid[count($split_oid) - 1];
$temperature_oid = ".1.3.6.1.4.1.2021.13.16.2.1.3.$temperature_id";
$temperature = floatval(snmp_get($device, $temperature_oid, '-Ovq')) / $divisor;
$descr = str_ireplace('temperature-', '', $descr);

View File

@ -29,7 +29,7 @@ $index = 'rcSingleCpSystemCpuTemperature.0';
$oid = '.1.3.6.1.4.1.2272.1.212.1.0';
$descr = 'VOSS CPU temperature';
$value = snmp_get($device, $index, '-OvqU', 'RAPID-CITY');
if ((is_numeric($value) && $value != 0)) {
if (is_numeric($value) && $value != 0) {
discover_sensor($valid['sensor'], 'temperature', $device, $oid, $index, 'avaya-vsp', $descr, '1', '1', null, null, null, null, $value);
}
@ -37,7 +37,7 @@ $index = 'rcSingleCpSystemMacTemperature.0';
$oid = '.1.3.6.1.4.1.2272.1.212.2.0';
$descr = 'VOSS MAC temperature';
$value = snmp_get($device, $index, '-OvqU', 'RAPID-CITY');
if ((is_numeric($value) && $value != 0)) {
if (is_numeric($value) && $value != 0) {
discover_sensor($valid['sensor'], 'temperature', $device, $oid, $index, 'avaya-vsp', $descr, '1', '1', null, null, null, null, $value);
}
@ -45,7 +45,7 @@ $index = 'rcSingleCpSystemPhy1Temperature.0';
$oid = '.1.3.6.1.4.1.2272.1.212.3.0';
$descr = 'VOSS PHY1 temperature';
$value = snmp_get($device, $index, '-OvqU', 'RAPID-CITY');
if ((is_numeric($value) && $value != 0)) {
if (is_numeric($value) && $value != 0) {
discover_sensor($valid['sensor'], 'temperature', $device, $oid, $index, 'avaya-vsp', $descr, '1', '1', null, null, null, null, $value);
}
@ -54,7 +54,7 @@ $oid = '.1.3.6.1.4.1.2272.1.212.4.0';
$descr = 'VOSS PHY2 temperature';
$value = snmp_get($device, $index, '-OvqU', 'RAPID-CITY');
d_echo("VOSS $var1: $value\n");
if ((is_numeric($value) && $value != 0)) {
if (is_numeric($value) && $value != 0) {
discover_sensor($valid['sensor'], 'temperature', $device, $oid, $index, 'avaya-vsp', $descr, '1', '1', null, null, null, null, $value);
}
@ -63,6 +63,6 @@ $oid = '.1.3.6.1.4.1.2272.1.212.5.0';
$descr = 'VOSS MAC2 temperature';
$value = snmp_get($device, $index, '-OvqU', 'RAPID-CITY');
d_echo("VOSS $var1: $value\n");
if ((is_numeric($value) && $value != 0)) {
if (is_numeric($value) && $value != 0) {
discover_sensor($valid['sensor'], 'temperature', $device, $oid, $index, 'avaya-vsp', $descr, '1', '1', null, null, null, null, $value);
}

View File

@ -20,8 +20,8 @@
// ***** Sensors for ADVA FSP150
// ******************************************
// Define Sensors
$sensors_adva = [
// Define Sensors
$sensors_adva = [
['sensor_oid' => '.1.3.6.1.4.1.2544.1.12.3.1.4.1.6', 'sensor_name' => 'psuOutputVoltage'],
['sensor_oid' => '.1.3.6.1.4.1.2544.1.12.3.1.6.1.5', 'sensor_name' => 'scuVoltage'],
['sensor_oid' => '.1.3.6.1.4.1.2544.1.12.3.1.7.1.5', 'sensor_name' => 'nemiVoltage'],
@ -80,12 +80,12 @@
['sensor_oid' => '.1.3.6.1.4.1.2544.1.12.3.1.95.1.5', 'sensor_name' => 'ethernetNTEGE114ProVmSHCardVoltage'],
['sensor_oid' => '.1.3.6.1.4.1.2544.1.12.3.1.96.1.5', 'sensor_name' => 'ethernetNTEGE104CardVoltage'],
['sensor_oid' => '.1.3.6.1.4.1.2544.1.12.3.1.97.1.5', 'sensor_name' => 'ethernetNTEXG120PROSHCardVoltage'],
];
];
$multiplier = 1;
$divisor = 1000;
$multiplier = 1;
$divisor = 1000;
foreach (array_keys($pre_cache['adva_fsp150']) as $index) {
foreach (array_keys($pre_cache['adva_fsp150']) as $index) {
foreach ($sensors_adva as $entry) {
$sensor_name = $entry['sensor_name'];
if (isset($pre_cache['adva_fsp150'][$index][$sensor_name])) {
@ -112,6 +112,6 @@
);
}//End if sensor exists
}//End foreach $entry
}//End foreach $index
unset($sensors_adva, $entry);
}//End foreach $index
unset($sensors_adva, $entry);
// ************** End of Sensors for ADVA FSP150CC Series **********

View File

@ -20,8 +20,8 @@
// ***** Sensors for ADVA FSP3000 R7
// *************************************************************
$multiplier = 1;
$divisor = 1000;
$multiplier = 1;
$divisor = 1000;
if (is_array($pre_cache['adva_fsp3kr7_Card'])) {
foreach (array_keys($pre_cache['adva_fsp3kr7_Card']) as $index) {

View File

@ -28,8 +28,8 @@ unset($oids);
//Three Phase Detection & Support
$phasecount = $pre_cache['apcups_phase_count'];
d_echo($phasecount);
d_echo($pre_cache['apcups_phase_count']);
d_echo($phasecount);
d_echo($pre_cache['apcups_phase_count']);
// Check for three phase UPS devices - else skip to normal discovery
if ($phasecount > 1) {
$oids = snmpwalk_cache_oid($device, 'upsPhaseOutputVoltage', $oids, 'PowerNet-MIB');
@ -72,7 +72,7 @@ if ($phasecount > 1) {
if ($data) {
[$oid, $current] = explode(' ', $data, 2);
$split_oid = explode('.', $oid);
$index = $split_oid[(count($split_oid) - 3)];
$index = $split_oid[count($split_oid) - 3];
$oid = '.1.3.6.1.4.1.318.1.1.8.5.3.3.1.3.' . $index . '.1.1';
$descr = 'Input Feed ' . chr(64 + $index);
discover_sensor($valid['sensor'], 'voltage', $device, $oid, "3.3.1.3.$index", $type, $descr, $divisor, '1', null, null, null, null, $current);
@ -90,7 +90,7 @@ if ($phasecount > 1) {
if ($data) {
[$oid, $current] = explode(' ', $data, 2);
$split_oid = explode('.', $oid);
$index = $split_oid[(count($split_oid) - 3)];
$index = $split_oid[count($split_oid) - 3];
$oid = '.1.3.6.1.4.1.318.1.1.8.5.4.3.1.3.' . $index . '.1.1';
$descr = 'Output Feed';
if (count(explode("\n", $oids)) > 1) {

Some files were not shown because too many files have changed in this diff Show More