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

@ -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,7 +13,6 @@ class Ruckuswireless extends OS implements
{
public function discoverWirelessClients()
{
// Find Per SSID Client Count
$sensors = [];
$ssids = $this->getCacheByIndex('ruckusZDWLANSSID', '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

@ -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

@ -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

@ -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

@ -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;

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

@ -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

@ -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

@ -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

@ -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

@ -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

@ -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) {

View File

@ -13,7 +13,7 @@ if ($oids) {
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.8.1.3.' . $index;
$current = (snmp_get($device, $oid, '-Oqv', '') / $divisor);
if (trim($descr, '"') != 'Battery Status') {

View File

@ -45,7 +45,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 == 1) {
$volt_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

@ -14,7 +14,7 @@ if ($oids) {
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.4.1.3.' . $index;
$current = floatval(snmp_get($device, $oid, '-Oqv', 'LM-SENSORS-MIB')) / $divisor;

View File

@ -26,7 +26,7 @@ if (Config::get('discover_services')) {
[$oid, $tcpstatus] = explode(' ', $data);
if (trim($tcpstatus) == 'listen') {
$split_oid = explode('.', $oid);
$tcp_port = $split_oid[(count($split_oid) - 6)];
$tcp_port = $split_oid[count($split_oid) - 6];
if ($known_services[$tcp_port]) {
discover_service($device, $known_services[$tcp_port]);
}

View File

@ -67,7 +67,7 @@ if (Config::get('enable_vrfs')) {
$t = explode(' ', $port);
$dotpos = strrpos($t[0], '.');
$vrf_oid = substr($t[0], 0, $dotpos);
$port_id = substr($t[0], ($dotpos + 1));
$port_id = substr($t[0], $dotpos + 1);
if (empty($port_table[$vrf_oid])) {
$port_table[$vrf_oid][0] = $port_id;

View File

@ -245,7 +245,7 @@ function addHost($host, $snmp_version = '', $port = 161, $transport = 'udp', $po
// Test reachability
if (! $force_add) {
if (! ((new \LibreNMS\Polling\ConnectivityHelper(new Device(['hostname' => $ip])))->isPingable()->success())) {
if (! (new \LibreNMS\Polling\ConnectivityHelper(new Device(['hostname' => $ip])))->isPingable()->success()) {
throw new HostUnreachablePingException($host);
}
}
@ -970,7 +970,7 @@ function create_sensor_to_state_index($device, $state_name, $index)
function delta_to_bits($delta, $period)
{
return round(($delta * 8 / $period), 2);
return round($delta * 8 / $period, 2);
}
function report_this($message)

View File

@ -139,7 +139,7 @@ function collectd_list_pinsts($arg_host, $arg_plugin)
if ($dent != '.' && $dent != '..' && is_dir($datadir . '/' . $arg_host . '/' . $dent)) {
if ($i = strpos($dent, '-')) {
$plugin = substr($dent, 0, $i);
$pinst = substr($dent, ($i + 1));
$pinst = substr($dent, $i + 1);
} else {
$plugin = $dent;
$pinst = '';
@ -165,7 +165,9 @@ function collectd_list_pinsts($arg_host, $arg_plugin)
* Fetch list of types found in collectd's datadirs for given host+plugin+instance
*
* @arg_host Name of host
*
* @arg_plugin Name of plugin
*
* @arg_pinst Plugin instance
*
* @return array Sorted list of types (sorted alphabetically)
@ -181,8 +183,8 @@ function collectd_list_types($arg_host, $arg_plugin, $arg_pinst)
foreach (Config::get('datadirs') as $datadir) {
if (preg_match(REGEXP_HOST, $arg_host) && ($d = @opendir($datadir . '/' . $arg_host . '/' . $my_plugin))) {
while (($dent = readdir($d)) !== false) {
if ($dent != '.' && $dent != '..' && is_file($datadir . '/' . $arg_host . '/' . $my_plugin . '/' . $dent) && substr($dent, (strlen($dent) - 4)) == '.rrd') {
$dent = substr($dent, 0, (strlen($dent) - 4));
if ($dent != '.' && $dent != '..' && is_file($datadir . '/' . $arg_host . '/' . $my_plugin . '/' . $dent) && substr($dent, strlen($dent) - 4) == '.rrd') {
$dent = substr($dent, 0, strlen($dent) - 4);
if ($i = strpos($dent, '-')) {
$types[] = substr($dent, 0, $i);
} else {
@ -205,8 +207,11 @@ function collectd_list_types($arg_host, $arg_plugin, $arg_pinst)
* Fetch list of type instances found in collectd's datadirs for given host+plugin+instance+type
*
* @arg_host Name of host
*
* @arg_plugin Name of plugin
*
* @arg_pinst Plugin instance
*
* @arg_type Type
*
* @return array Sorted list of type instances (sorted alphabetically)
@ -222,11 +227,11 @@ function collectd_list_tinsts($arg_host, $arg_plugin, $arg_pinst, $arg_type)
foreach (Config::get('datadirs') as $datadir) {
if (preg_match(REGEXP_HOST, $arg_host) && ($d = @opendir($datadir . '/' . $arg_host . '/' . $my_plugin))) {
while (($dent = readdir($d)) !== false) {
if ($dent != '.' && $dent != '..' && is_file($datadir . '/' . $arg_host . '/' . $my_plugin . '/' . $dent) && substr($dent, (strlen($dent) - 4)) == '.rrd') {
$dent = substr($dent, 0, (strlen($dent) - 4));
if ($dent != '.' && $dent != '..' && is_file($datadir . '/' . $arg_host . '/' . $my_plugin . '/' . $dent) && substr($dent, strlen($dent) - 4) == '.rrd') {
$dent = substr($dent, 0, strlen($dent) - 4);
if ($i = strpos($dent, '-')) {
$type = substr($dent, 0, $i);
$tinst = substr($dent, ($i + 1));
$tinst = substr($dent, $i + 1);
} else {
$type = $dent;
$tinst = '';
@ -275,7 +280,7 @@ function collectd_identifier($host, $plugin, $type, $pinst, $tinst)
if ($rrd_realpath) {
$identifier = basename($rrd_realpath);
$identifier = substr($identifier, 0, (strlen($identifier) - 4));
$identifier = substr($identifier, 0, strlen($identifier) - 4);
$rrd_realpath = dirname($rrd_realpath);
$identifier = basename($rrd_realpath) . '/' . $identifier;
$rrd_realpath = dirname($rrd_realpath);
@ -351,8 +356,8 @@ function collectd_flush($identifier)
*/
function rrd_strip_quotes($str)
{
if ($str[0] == '"' && $str[(strlen($str) - 1)] == '"') {
return substr($str, 1, (strlen($str) - 2));
if ($str[0] == '"' && $str[strlen($str) - 1] == '"') {
return substr($str, 1, strlen($str) - 2);
} else {
return $str;
}
@ -377,16 +382,16 @@ function _rrd_info($file)
}
$key = trim(substr($s, 0, $p));
$value = trim(substr($s, ($p + 1)));
$value = trim(substr($s, $p + 1));
if (strncmp($key, 'ds[', 3) == 0) {
// DS definition
$p = strpos($key, ']');
$ds = substr($key, 3, ($p - 3));
$ds = substr($key, 3, $p - 3);
if (! isset($info['DS'])) {
$info['DS'] = [];
}
$ds_key = substr($key, ($p + 2));
$ds_key = substr($key, $p + 2);
if (strpos($ds_key, '[') === false) {
if (! isset($info['DS']["$ds"])) {
@ -398,12 +403,12 @@ function _rrd_info($file)
} elseif (strncmp($key, 'rra[', 4) == 0) {
// RRD definition
$p = strpos($key, ']');
$rra = substr($key, 4, ($p - 4));
$rra = substr($key, 4, $p - 4);
if (! isset($info['RRA'])) {
$info['RRA'] = [];
}
$rra_key = substr($key, ($p + 2));
$rra_key = substr($key, $p + 2);
if (strpos($rra_key, '[') === false) {
if (! isset($info['RRA']["$rra"])) {
@ -552,7 +557,7 @@ function collectd_draw_rrd($host, $plugin, $type, $pinst = null, $tinst = null,
reset($rrdinfo['DS']);
$n = 1;
foreach ($rrdinfo['DS'] as $k => $v) {
$graph[] = sprintf('LINE1:%s_avg#%s:%s ', $k, rrd_get_color($n++, true), $k . substr(' ', 0, ($l_max - strlen($k))));
$graph[] = sprintf('LINE1:%s_avg#%s:%s ', $k, rrd_get_color($n++, true), $k . substr(' ', 0, $l_max - strlen($k)));
if (isset($opts['tinylegend']) && $opts['tinylegend']) {
continue;
}

View File

@ -58,7 +58,7 @@ $mute = isset($_POST['mute']) ? $_POST['mute'] : null;
$invert = isset($_POST['invert']) ? $_POST['invert'] : null;
$name = strip_tags($_POST['name']);
$proc = $_POST['proc'];
$recovery = ($vars['recovery']);
$recovery = $vars['recovery'];
$invert_map = isset($_POST['invert_map']) ? $_POST['invert_map'] : null;
$severity = $_POST['severity'];

View File

@ -18,7 +18,7 @@ $action = $_POST['action'];
$name = strip_tags($_POST['name']);
$oid = strip_tags($_POST['oid']);
$datatype = strip_tags($_POST['datatype']);
if (! empty(($_POST['unit']))) {
if (! empty($_POST['unit'])) {
$unit = $_POST['unit'];
} else {
$unit = ['NULL'];
@ -31,7 +31,7 @@ $alerts = ($_POST['alerts'] == 'on' ? 1 : 0);
$passed = ($_POST['passed'] == 'on' ? 1 : 0);
$divisor = set_numeric($_POST['divisor'], 1);
$multiplier = set_numeric($_POST['multiplier'], 1);
if (! empty(($_POST['user_func']))) {
if (! empty($_POST['user_func'])) {
$user_func = $_POST['user_func'];
} else {
$user_func = ['NULL'];

View File

@ -17,7 +17,7 @@ if (! Auth::user()->hasGlobalAdmin()) {
exit('ERROR: You need to be admin');
}
$group_id = ($_POST['group_id']);
$group_id = $_POST['group_id'];
if (is_numeric($group_id) && $group_id > 0) {
$group = dbFetchRow('SELECT * FROM `poller_groups` WHERE `id` = ? LIMIT 1', [$group_id]);

View File

@ -30,15 +30,15 @@ if ($width > '500') {
}
if ($width > '500') {
$rrd_options .= ' COMMENT:"' . substr(str_pad($unit_text, ($descr_len + 2)), 0, ($descr_len + 2)) . ' Current Unique Average Peak\\n"';
$rrd_options .= ' COMMENT:"' . substr(str_pad($unit_text, $descr_len + 2), 0, $descr_len + 2) . ' Current Unique Average Peak\\n"';
} else {
$rrd_options .= ' COMMENT:"' . substr(str_pad($unit_text, ($descr_len + 5)), 0, ($descr_len + 5)) . ' Now Unique Average Peak\\n"';
$rrd_options .= ' COMMENT:"' . substr(str_pad($unit_text, $descr_len + 5), 0, $descr_len + 5) . ' Now Unique Average Peak\\n"';
}
foreach ($rrd_list as $rrd) {
$colours = (isset($rrd['colour']) ? $rrd['colour'] : 'default');
$strlen = ((strlen($rrd['descr']) < $descr_len) ? ($descr_len - strlen($rrd['descr'])) : '0');
$descr = (isset($rrd['descr']) ? \LibreNMS\Data\Store\Rrd::fixedSafeDescr($rrd['descr'], ($desc_len + $strlen)) : 'Unknown');
$descr = (isset($rrd['descr']) ? \LibreNMS\Data\Store\Rrd::fixedSafeDescr($rrd['descr'], $desc_len + $strlen) : 'Unknown');
for ($z = 0; $z < $strlen; $z++) {
$descr .= ' ';
}
@ -70,7 +70,7 @@ foreach ($rrd_list as $rrd) {
if (! $nototal) {
$strlen = ((strlen($total_text) < $descr_len) ? ($descr_len - strlen($total_text)) : '0');
$descr = (isset($total_text) ? \LibreNMS\Data\Store\Rrd::fixedSafeDescr($total_text, ($desc_len + $strlen)) : 'Total');
$descr = (isset($total_text) ? \LibreNMS\Data\Store\Rrd::fixedSafeDescr($total_text, $desc_len + $strlen) : 'Total');
$colour = \LibreNMS\Config::get("graph_colours.$colours.$x");
for ($z = 0; $z < $strlen; $z++) {
$descr .= ' ';

View File

@ -10,7 +10,7 @@ if (is_numeric($bill_hist_id)) {
if ($reducefactor < 2) {
$extents = dbFetchRow('SELECT UNIX_TIMESTAMP(bill_datefrom) as `from`, UNIX_TIMESTAMP(bill_dateto) AS `to`FROM bill_history WHERE bill_id = ? AND bill_hist_id = ?', [$bill_id, $bill_hist_id]);
$dur = $extents['to'] - $extents['from'];
$reducefactor = round(($dur / 300 / (($vars['height'] - 100) * 3)), 0);
$reducefactor = round($dur / 300 / (($vars['height'] - 100) * 3), 0);
if ($reducefactor < 2) {
$reducefactor = 2;
@ -20,7 +20,7 @@ if (is_numeric($bill_hist_id)) {
} else {
if ($reducefactor < 2) {
$dur = $vars['to'] - $vars['from'];
$reducefactor = round(($dur / 300 / (($vars['height'] - 100) * 3)), 0);
$reducefactor = round($dur / 300 / (($vars['height'] - 100) * 3), 0);
if ($reducefactor < 2) {
$reducefactor = 2;
@ -35,7 +35,7 @@ if (is_numeric($bill_hist_id)) {
$n = count($graph_data['ticks']);
$xmin = $graph_data['ticks'][0];
$xmax = $graph_data['ticks'][($n - 1)];
$xmax = $graph_data['ticks'][$n - 1];
function TimeCallback($aVal)
{

View File

@ -48,8 +48,11 @@ function makeTextBlock($text, $fontfile, $fontsize, $width)
* No RRD files found that could match request
*
* @code HTTP error code
*
* @code_msg Short text description of HTTP error code
*
* @title Title for fake RRD graph
*
* @msg Complete error message to display in place of graph content
*/
function error($code, $code_msg, $title, $msg)
@ -76,30 +79,30 @@ function error($code, $code_msg, $title, $msg)
}
imagefilledrectangle($png, 0, 0, $w, $h, $c_bkgnd);
imagefilledrectangle($png, 51, 33, ($w - 31), ($h - 47), $c_fgnd);
imageline($png, 51, 30, 51, ($h - 43), $c_grln);
imageline($png, 48, ($h - 46), ($w - 28), ($h - 46), $c_grln);
imagefilledrectangle($png, 51, 33, $w - 31, $h - 47, $c_fgnd);
imageline($png, 51, 30, 51, $h - 43, $c_grln);
imageline($png, 48, $h - 46, $w - 28, $h - 46, $c_grln);
imagefilledpolygon($png, [49, 30, 51, 26, 53, 30], 3, $c_grarr);
imagefilledpolygon($png, [$w - 28, $h - 48, $w - 24, $h - 46, $w - 28, $h - 44], 3, $c_grarr);
imageline($png, 0, 0, $w, 0, $c_blt);
imageline($png, 0, 1, $w, 1, $c_blt);
imageline($png, 0, 0, 0, $h, $c_blt);
imageline($png, 1, 0, 1, $h, $c_blt);
imageline($png, ($w - 1), 0, ($w - 1), $h, $c_brb);
imageline($png, ($w - 2), 1, ($w - 2), $h, $c_brb);
imageline($png, 1, ($h - 2), $w, ($h - 2), $c_brb);
imageline($png, 0, ($h - 1), $w, ($h - 1), $c_brb);
imageline($png, $w - 1, 0, $w - 1, $h, $c_brb);
imageline($png, $w - 2, 1, $w - 2, $h, $c_brb);
imageline($png, 1, $h - 2, $w, $h - 2, $c_brb);
imageline($png, 0, $h - 1, $w, $h - 1, $c_brb);
imagestring($png, 4, ceil(($w - strlen($title) * imagefontwidth(4)) / 2), 10, $title, $c_txt);
imagestring($png, 5, 60, 35, sprintf('%s [%d]', $code_msg, $code), $c_etxt);
if (function_exists('imagettfbbox') && is_file(Config::get('error_font'))) {
// Detailled error message
$errorfont = Config::get('error_font');
$fmt_msg = makeTextBlock($msg, $errorfont, 10, ($w - 86));
$fmt_msg = makeTextBlock($msg, $errorfont, 10, $w - 86);
$fmtbox = imagettfbbox(12, 0, $errorfont, $fmt_msg);
imagettftext($png, 10, 0, 55, (35 + 3 + imagefontwidth(5) - $fmtbox[7] + $fmtbox[1]), $c_txt, $errorfont, $fmt_msg);
imagettftext($png, 10, 0, 55, 35 + 3 + imagefontwidth(5) - $fmtbox[7] + $fmtbox[1], $c_txt, $errorfont, $fmt_msg);
} else {
imagestring($png, 4, 53, (35 + 6 + imagefontwidth(5)), $msg, $c_txt);
imagestring($png, 4, 53, 35 + 6 + imagefontwidth(5), $msg, $c_txt);
}
imagepng($png);

View File

@ -3,7 +3,7 @@
$simple_rrd = true;
foreach ((array) \LibreNMS\Config::get('nfsen_rrds', []) as $nfsenrrds) {
if ($nfsenrrds[(strlen($nfsenrrds) - 1)] != '/') {
if ($nfsenrrds[strlen($nfsenrrds) - 1] != '/') {
$nfsenrrds .= '/';
}

View File

@ -3,7 +3,7 @@
$simple_rrd = true;
foreach ((array) \LibreNMS\Config::get('nfsen_rrds', []) as $nfsenrrds) {
if ($nfsenrrds[(strlen($nfsenrrds) - 1)] != '/') {
if ($nfsenrrds[strlen($nfsenrrds) - 1] != '/') {
$nfsenrrds .= '/';
}

View File

@ -22,9 +22,9 @@ if ($width > '500') {
}
if ($width > '500') {
$rrd_options .= " COMMENT:'" . substr(str_pad($unit_text, ($descr_len + 5)), 0, ($descr_len + 5)) . " RTT Loss SDev RTT\:SDev\l'";
$rrd_options .= " COMMENT:'" . substr(str_pad($unit_text, $descr_len + 5), 0, $descr_len + 5) . " RTT Loss SDev RTT\:SDev\l'";
} else {
$rrd_options .= " COMMENT:'" . substr(str_pad($unit_text, ($descr_len + 5)), 0, ($descr_len + 5)) . " RTT Loss SDev RTT\:SDev\l'";
$rrd_options .= " COMMENT:'" . substr(str_pad($unit_text, $descr_len + 5), 0, $descr_len + 5) . " RTT Loss SDev RTT\:SDev\l'";
}
foreach ($smokeping_files[$direction][$device['hostname']] as $source => $filename) {

View File

@ -23,9 +23,9 @@ if ($width > '500') {
// FIXME str_pad really needs a "limit to length" so we can rid of all the substrs all over the code to limit the length as below...
if ($width > '500') {
$rrd_options .= " COMMENT:'" . substr(str_pad($unit_text, ($descr_len + 5)), 0, ($descr_len + 5)) . " RTT Loss SDev RTT\:SDev\l'";
$rrd_options .= " COMMENT:'" . substr(str_pad($unit_text, $descr_len + 5), 0, $descr_len + 5) . " RTT Loss SDev RTT\:SDev\l'";
} else {
$rrd_options .= " COMMENT:'" . substr(str_pad($unit_text, ($descr_len + 5)), 0, ($descr_len + 5)) . " RTT Loss SDev RTT\:SDev\l'";
$rrd_options .= " COMMENT:'" . substr(str_pad($unit_text, $descr_len + 5), 0, $descr_len + 5) . " RTT Loss SDev RTT\:SDev\l'";
}
foreach ($smokeping_files[$direction][$device['hostname']] as $source => $filename) {

View File

@ -29,14 +29,14 @@ if ($nototal) {
}
if ($width > '500') {
$rrd_options .= " COMMENT:'" . substr(str_pad($unit_text, ($descr_len + 5)), 0, ($descr_len + 5)) . "Now Min Max Avg\l'";
$rrd_options .= " COMMENT:'" . substr(str_pad($unit_text, $descr_len + 5), 0, $descr_len + 5) . "Now Min Max Avg\l'";
if (! $nototal) {
$rrd_options .= " COMMENT:'Total '";
}
$rrd_options .= " COMMENT:'\l'";
} else {
$rrd_options .= " COMMENT:'" . substr(str_pad($unit_text, ($descr_len + 5)), 0, ($descr_len + 5)) . "Now Min Max Avg\l'";
$rrd_options .= " COMMENT:'" . substr(str_pad($unit_text, $descr_len + 5), 0, $descr_len + 5) . "Now Min Max Avg\l'";
}
$i = 0;

View File

@ -32,7 +32,7 @@ $unit_text = 'Bits/sec';
if (! $noagg || ! $nodetails) {
if ($width > '500') {
$rrd_options .= sprintf(" COMMENT:'%s'", substr(str_pad($unit_text, ($descr_len + 5)), 0, ($descr_len + 5)));
$rrd_options .= sprintf(" COMMENT:'%s'", substr(str_pad($unit_text, $descr_len + 5), 0, $descr_len + 5));
$rrd_options .= sprintf(" COMMENT:'%12s'", 'Current');
$rrd_options .= sprintf(" COMMENT:'%10s'", 'Average');
$rrd_options .= sprintf(" COMMENT:'%10s'", 'Maximum');
@ -42,7 +42,7 @@ if (! $noagg || ! $nodetails) {
$rrd_options .= " COMMENT:'\l'";
} else {
$nototal = true;
$rrd_options .= sprintf(" COMMENT:'%s'", substr(str_pad($unit_text, ($descr_len + 5)), 0, ($descr_len + 5)));
$rrd_options .= sprintf(" COMMENT:'%s'", substr(str_pad($unit_text, $descr_len + 5), 0, $descr_len + 5));
$rrd_options .= sprintf(" COMMENT:'%12s'", 'Now');
$rrd_options .= sprintf(" COMMENT:'%10s'", 'Avg');
$rrd_options .= sprintf(" COMMENT:'%10s\l'", 'Max');
@ -140,7 +140,7 @@ if (! $noagg) {
$rrd_options .= ' VDEF:totalin=aggrinbytes,TOTAL';
$rrd_options .= ' VDEF:totalout=aggroutbytes,TOTAL';
$rrd_options .= " COMMENT:' \\n'";
$rrd_options .= " COMMENT:'" . substr(str_pad('Aggregate', ($descr_len + 5)), 0, ($descr_len + 5)) . 'In' . "'";
$rrd_options .= " COMMENT:'" . substr(str_pad('Aggregate', $descr_len + 5), 0, $descr_len + 5) . 'In' . "'";
$rrd_options .= ' GPRINT:aggrinbits:LAST:%6.' . $float_precision . "lf%s$units";
$rrd_options .= ' GPRINT:aggrinbits:AVERAGE:%6.' . $float_precision . "lf%s$units";
$rrd_options .= ' GPRINT:aggrinbits:MAX:%6.' . $float_precision . "lf%s$units";
@ -149,7 +149,7 @@ if (! $noagg) {
}
$rrd_options .= '\\n';
$rrd_options .= " COMMENT:'" . substr(str_pad('Aggregate', ($descr_len + 4)), 0, ($descr_len + 4)) . 'Out' . "'";
$rrd_options .= " COMMENT:'" . substr(str_pad('Aggregate', $descr_len + 4), 0, $descr_len + 4) . 'Out' . "'";
$rrd_options .= ' GPRINT:aggroutbits:LAST:%6.' . $float_precision . "lf%s$units";
$rrd_options .= ' GPRINT:aggroutbits:AVERAGE:%6.' . $float_precision . "lf%s$units";
$rrd_options .= ' GPRINT:aggroutbits:MAX:%6.' . $float_precision . "lf%s$units";

View File

@ -28,14 +28,14 @@ if ($width > '500') {
$unit_text = 'Bits/sec';
if ($width > '500') {
$rrd_options .= " COMMENT:'" . substr(str_pad($unit_text, ($descr_len + 5)), 0, ($descr_len + 5)) . " Current Average Maximum '";
$rrd_options .= " COMMENT:'" . substr(str_pad($unit_text, $descr_len + 5), 0, $descr_len + 5) . " Current Average Maximum '";
if (! $nototal) {
$rrd_options .= " COMMENT:'Total '";
}
$rrd_options .= " COMMENT:'\l'";
} else {
$rrd_options .= " COMMENT:'" . substr(str_pad($unit_text, ($descr_len + 5)), 0, ($descr_len + 5)) . " Now Ave Max\l'";
$rrd_options .= " COMMENT:'" . substr(str_pad($unit_text, $descr_len + 5), 0, $descr_len + 5) . " Now Ave Max\l'";
}
if (! isset($multiplier)) {

View File

@ -16,13 +16,13 @@ if ($printtotal === 1) {
$unit_text = str_pad(truncate($unit_text, $unitlen), $unitlen);
if ($width > '500') {
$rrd_options .= " COMMENT:'" . substr(str_pad($unit_text, ($descr_len + 10)), 0, ($descr_len + 10)) . "Now Min Max Avg\l'";
$rrd_options .= " COMMENT:'" . substr(str_pad($unit_text, $descr_len + 10), 0, $descr_len + 10) . "Now Min Max Avg\l'";
if ($printtotal === 1) {
$rrd_options .= " COMMENT:'Total '";
}
$rrd_options .= " COMMENT:'\l'";
} else {
$rrd_options .= " COMMENT:'" . substr(str_pad($unit_text, ($descr_len + 10)), 0, ($descr_len + 10)) . "Now Min Max Avg\l'";
$rrd_options .= " COMMENT:'" . substr(str_pad($unit_text, $descr_len + 10), 0, $descr_len + 10) . "Now Min Max Avg\l'";
}
foreach ($rrd_list as $rrd) {

View File

@ -16,13 +16,13 @@ if ($printtotal === 1) {
$unit_text = str_pad(truncate($unit_text, $unitlen), $unitlen);
if ($width > '500') {
$rrd_options .= " COMMENT:'" . substr(str_pad($unit_text, ($descr_len + 10)), 0, ($descr_len + 10)) . "Now Min Max Avg\l'";
$rrd_options .= " COMMENT:'" . substr(str_pad($unit_text, $descr_len + 10), 0, $descr_len + 10) . "Now Min Max Avg\l'";
if ($printtotal === 1) {
$rrd_options .= " COMMENT:'Total '";
}
$rrd_options .= " COMMENT:'\l'";
} else {
$rrd_options .= " COMMENT:'" . substr(str_pad($unit_text, ($descr_len + 10)), 0, ($descr_len + 10)) . "Now Min Max Avg\l'";
$rrd_options .= " COMMENT:'" . substr(str_pad($unit_text, $descr_len + 10), 0, $descr_len + 10) . "Now Min Max Avg\l'";
}
foreach ($rrd_list as $rrd) {

View File

@ -16,13 +16,13 @@ if ($printtotal === 1) {
$unit_text = str_pad(truncate($unit_text, $unitlen), $unitlen);
if ($width > '500') {
$rrd_options .= " COMMENT:'" . substr(str_pad($unit_text, ($descr_len + 10)), 0, ($descr_len + 10)) . "Now Min Max Avg\l'";
$rrd_options .= " COMMENT:'" . substr(str_pad($unit_text, $descr_len + 10), 0, $descr_len + 10) . "Now Min Max Avg\l'";
if ($printtotal === 1) {
$rrd_options .= " COMMENT:'Total '";
}
$rrd_options .= " COMMENT:'\l'";
} else {
$rrd_options .= " COMMENT:'" . substr(str_pad($unit_text, ($descr_len + 10)), 0, ($descr_len + 10)) . "Now Min Max Avg\l'";
$rrd_options .= " COMMENT:'" . substr(str_pad($unit_text, $descr_len + 10), 0, $descr_len + 10) . "Now Min Max Avg\l'";
}
foreach ($rrd_list as $rrd) {

View File

@ -18,10 +18,10 @@ if ($width > '500') {
}
if ($width > '500') {
$rrd_options .= " COMMENT:'" . substr(str_pad($unit_text, ($descr_len + 5)), 0, ($descr_len + 5)) . "Total Used Free( Min Max Ave)'";
$rrd_options .= " COMMENT:'" . substr(str_pad($unit_text, $descr_len + 5), 0, $descr_len + 5) . "Total Used Free( Min Max Ave)'";
$rrd_options .= " COMMENT:'\l'";
} else {
$rrd_options .= " COMMENT:'" . substr(str_pad($unit_text, ($descr_len + 5)), 0, ($descr_len + 5)) . "Total Used Free\l'";
$rrd_options .= " COMMENT:'" . substr(str_pad($unit_text, $descr_len + 5), 0, $descr_len + 5) . "Total Used Free\l'";
}
$descr = \LibreNMS\Data\Store\Rrd::fixedSafeDescr(short_hrDeviceDescr($mempool['mempool_descr']), $descr_len);
@ -44,7 +44,7 @@ if ($width > '500') {
$rrd_options .= " GPRINT:{$mempool['mempool_id']}free:MIN:%5.2lf%sB";
$rrd_options .= " GPRINT:{$mempool['mempool_id']}free:MAX:%5.2lf%sB";
$rrd_options .= " GPRINT:{$mempool['mempool_id']}free:AVERAGE:%5.2lf%sB\\n";
$rrd_options .= " COMMENT:'" . substr(str_pad('', ($descr_len + 12)), 0, ($descr_len + 12)) . " '";
$rrd_options .= " COMMENT:'" . substr(str_pad('', $descr_len + 12), 0, $descr_len + 12) . " '";
$rrd_options .= " GPRINT:{$mempool['mempool_id']}perc:LAST:'%5.2lf%% '";
$rrd_options .= " GPRINT:{$mempool['mempool_id']}percx:LAST:'%5.2lf%% '";
$rrd_options .= " GPRINT:{$mempool['mempool_id']}perc:MIN:'%5.2lf%% '";
@ -56,7 +56,7 @@ if ($width > '500') {
$rrd_options .= " GPRINT:{$mempool['mempool_id']}used:LAST:%6.2lf%sB";
$rrd_options .= " GPRINT:{$mempool['mempool_id']}free:LAST:%6.2lf%sB";
$rrd_options .= " COMMENT:'\l'";
$rrd_options .= " COMMENT:'" . substr(str_pad('', ($descr_len + 12)), 0, ($descr_len + 12)) . " '";
$rrd_options .= " COMMENT:'" . substr(str_pad('', $descr_len + 12), 0, $descr_len + 12) . " '";
$rrd_options .= " GPRINT:{$mempool['mempool_id']}perc:LAST:'%5.2lf%% '";
$rrd_options .= " GPRINT:{$mempool['mempool_id']}percx:LAST:'%5.2lf%% '";
$rrd_options .= " COMMENT:'\l'";

View File

@ -25,10 +25,10 @@ if ($width > '500') {
}
if ($width > '500') {
$rrd_options .= " COMMENT:'" . substr(str_pad($unit_text, ($descr_len + 5)), 0, ($descr_len + 5)) . "Total Used Free (Min Max Ave)'";
$rrd_options .= " COMMENT:'" . substr(str_pad($unit_text, $descr_len + 5), 0, $descr_len + 5) . "Total Used Free (Min Max Ave)'";
$rrd_options .= " COMMENT:'\l'";
} else {
$rrd_options .= " COMMENT:'" . substr(str_pad($unit_text, ($descr_len + 5)), 0, ($descr_len + 5)) . "Total Used Free\l'";
$rrd_options .= " COMMENT:'" . substr(str_pad($unit_text, $descr_len + 5), 0, $descr_len + 5) . "Total Used Free\l'";
}
$descr = \LibreNMS\Data\Store\Rrd::fixedSafeDescr(short_hrDeviceDescr($components['name']), $descr_len);
@ -57,7 +57,7 @@ if ($width > '500') {
$rrd_options .= ' GPRINT:qfp_free:MIN:%5.2lf%sB';
$rrd_options .= ' GPRINT:qfp_free:MAX:%5.2lf%sB';
$rrd_options .= ' GPRINT:qfp_free:AVERAGE:%5.2lf%sB\\n';
$rrd_options .= " COMMENT:'" . substr(str_pad('', ($descr_len + 12)), 0, ($descr_len + 12)) . " '";
$rrd_options .= " COMMENT:'" . substr(str_pad('', $descr_len + 12), 0, $descr_len + 12) . " '";
$rrd_options .= " GPRINT:qfp_perc:LAST:'%6.2lf%% '";
$rrd_options .= " GPRINT:qfp_percx:LAST:'%6.2lf%% '";
$rrd_options .= " GPRINT:qfp_perc:MIN:'%5.2lf%% '";
@ -72,7 +72,7 @@ if ($width > '500') {
$rrd_options .= ' GPRINT:qfp_used:LAST:%6.2lf%sB';
$rrd_options .= ' GPRINT:qfp_free:LAST:%6.2lf%sB';
$rrd_options .= " COMMENT:'\l'";
$rrd_options .= " COMMENT:'" . substr(str_pad('', ($descr_len + 12)), 0, ($descr_len + 12)) . " '";
$rrd_options .= " COMMENT:'" . substr(str_pad('', $descr_len + 12), 0, $descr_len + 12) . " '";
$rrd_options .= " GPRINT:qfp_perc:LAST:'%5.2lf%% '";
$rrd_options .= " GPRINT:qfp_percx:LAST:'%5.2lf%% '";
$rrd_options .= " COMMENT:'\l'";

View File

@ -24,9 +24,9 @@ if ($width > '500') {
}
if ($width > '500') {
$rrd_options .= " COMMENT:'" . substr(str_pad($unit_text, ($descr_len + 5)), 0, ($descr_len + 5)) . " RTT Loss SDev RTT\:SDev \l'";
$rrd_options .= " COMMENT:'" . substr(str_pad($unit_text, $descr_len + 5), 0, $descr_len + 5) . " RTT Loss SDev RTT\:SDev \l'";
} else {
$rrd_options .= " COMMENT:'" . substr(str_pad($unit_text, ($descr_len + 5)), 0, ($descr_len + 5)) . " RTT Loss SDev RTT\:SDev \l'";
$rrd_options .= " COMMENT:'" . substr(str_pad($unit_text, $descr_len + 5), 0, $descr_len + 5) . " RTT Loss SDev RTT\:SDev \l'";
}
$filename_dir = generate_smokeping_file($device);

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