mirror of
https://github.com/librenms/librenms.git
synced 2024-10-07 16:52:45 +00:00
Apply fixes from StyleCI (#12117)
* Apply fixes from StyleCI * Disable style check
This commit is contained in:
@@ -1,15 +1,15 @@
|
||||
#!/usr/bin/env php
|
||||
<?php
|
||||
|
||||
use LibreNMS\Config;
|
||||
use Illuminate\Support\Str;
|
||||
use LibreNMS\Config;
|
||||
|
||||
$install_dir = realpath(__DIR__ . '/..');
|
||||
chdir($install_dir);
|
||||
|
||||
$init_modules = array();
|
||||
$init_modules = [];
|
||||
require $install_dir . '/includes/init.php';
|
||||
$options = getopt('dh:e:', array("help"));
|
||||
$options = getopt('dh:e:', ["help"]);
|
||||
|
||||
Config::set('rrd.enable', false);
|
||||
Config::set('influxdb.enable', false);
|
||||
@@ -36,7 +36,7 @@ $params = [];
|
||||
if (isset($options['h'])) {
|
||||
if (is_numeric($options['h'])) {
|
||||
$where = "AND `device_id` = ?";
|
||||
$params = array($options['h']);
|
||||
$params = [$options['h']];
|
||||
} elseif (Str::contains($options['h'], ',')) {
|
||||
$device_ids = array_map('trim', explode(',', $options['h']));
|
||||
$device_ids = array_filter($device_ids, 'is_numeric');
|
||||
@@ -44,13 +44,13 @@ if (isset($options['h'])) {
|
||||
$params = $device_ids;
|
||||
} else {
|
||||
$where = "AND `hostname` LIKE ?";
|
||||
$params = array(str_replace('*', '%', mres($options['h'])));
|
||||
$params = [str_replace('*', '%', mres($options['h']))];
|
||||
}
|
||||
}
|
||||
$devices = dbFetchRows("SELECT * FROM `devices` WHERE status = 1 AND disabled = 0 $where ORDER BY `hostname` ASC", $params);
|
||||
|
||||
if (isset($options['e'])) {
|
||||
if (!is_numeric($options['e']) || $options['e'] < 0) {
|
||||
if (! is_numeric($options['e']) || $options['e'] < 0) {
|
||||
print_help();
|
||||
exit(1);
|
||||
}
|
||||
@@ -61,7 +61,7 @@ echo "Full Polling: ";
|
||||
Config::set('polling.selected_ports', false);
|
||||
foreach ($devices as $index => $device) {
|
||||
echo $device['device_id'] . ' ';
|
||||
if (!$debug) {
|
||||
if (! $debug) {
|
||||
ob_start();
|
||||
}
|
||||
|
||||
@@ -76,7 +76,7 @@ Config::set('polling.selected_ports', true);
|
||||
echo "Selective Polling: ";
|
||||
foreach ($devices as $index => $device) {
|
||||
echo $device['device_id'] . ' ';
|
||||
if (!$debug) {
|
||||
if (! $debug) {
|
||||
ob_start();
|
||||
}
|
||||
|
||||
@@ -87,15 +87,14 @@ foreach ($devices as $index => $device) {
|
||||
}
|
||||
echo PHP_EOL;
|
||||
|
||||
|
||||
// collect port counts
|
||||
$inactive_sql = "`deleted` = 1 OR `ifAdminStatus` != 'up' OR `disabled` = 1";
|
||||
$set_count = 0;
|
||||
foreach ($devices as &$device) {
|
||||
$count = dbFetchCell('SELECT COUNT(*) FROM `ports` WHERE `device_id`=?', array($device['device_id']));
|
||||
$count = dbFetchCell('SELECT COUNT(*) FROM `ports` WHERE `device_id`=?', [$device['device_id']]);
|
||||
$inactive = dbFetchCell(
|
||||
"SELECT COUNT(*) FROM `ports` WHERE `device_id`=? AND ($inactive_sql)",
|
||||
array($device['device_id'])
|
||||
[$device['device_id']]
|
||||
);
|
||||
|
||||
$device['port_count'] = $count;
|
||||
@@ -120,7 +119,7 @@ foreach ($devices as &$device) {
|
||||
unset($device); // will edit the wrong thing after using $device by reference
|
||||
|
||||
// print out the results
|
||||
$stats = array(
|
||||
$stats = [
|
||||
'device_id',
|
||||
'os',
|
||||
'port_count',
|
||||
@@ -129,12 +128,12 @@ $stats = array(
|
||||
'selective_time',
|
||||
'diff',
|
||||
'diff',
|
||||
'set'
|
||||
);
|
||||
'set',
|
||||
];
|
||||
|
||||
echo PHP_EOL;
|
||||
$header = "| %9.9s | %-11.11s | %10.10s | %14.14s | %10.10s | %14.14s | %8.10s | %5.9s | %5.5s |\n";
|
||||
call_user_func_array('printf', array_merge(array($header), $stats));
|
||||
call_user_func_array('printf', array_merge([$header], $stats));
|
||||
|
||||
$mask = "| %9.9s | %-11.11s | %10.10s | %14.3f | %9.3fs | %13.3fs | %s%+7.3fs\e[0m | %s%+4.0f%%\e[0m | %5.5s |\n";
|
||||
foreach ($devices as $device) {
|
||||
|
Reference in New Issue
Block a user