Improved Logging and Debugging (#8870)
Use Log facility when Laravel is booted. Update init.php so we can easily boot Laravel for CLI scripts. (and just Eloquent, but that may go away) Move all debug setup into set_debug() function and use that across all scripts. Log Laravel database queries. Send debug output to librenms log file when enabling debug in the webui. Allow for colorized Log CLI output. (currently will leave % tags in log file output) ** Needs testing and perhaps tweaking still. DO NOT DELETE THIS TEXT #### Please note > Please read this information carefully. You can run `./scripts/pre-commit.php` to check your code before submitting. - [x] Have you followed our [code guidelines?](http://docs.librenms.org/Developing/Code-Guidelines/) #### Testers If you would like to test this pull request then please run: `./scripts/github-apply <pr_id>`, i.e `./scripts/github-apply 5926`
This commit is contained in:
parent
46eef4412c
commit
eeb3d58f5b
|
@ -294,7 +294,7 @@ class Component
|
||||||
|
|
||||||
$OLD = $this->getComponents($device_id);
|
$OLD = $this->getComponents($device_id);
|
||||||
// Loop over each component.
|
// Loop over each component.
|
||||||
foreach ($ARRAY as $COMPONENT => $AVP) {
|
foreach ((array)$ARRAY as $COMPONENT => $AVP) {
|
||||||
// Make sure the component already exists.
|
// Make sure the component already exists.
|
||||||
if (!isset($OLD[$device_id][$COMPONENT])) {
|
if (!isset($OLD[$device_id][$COMPONENT])) {
|
||||||
// Error. Component doesn't exist in the database.
|
// Error. Component doesn't exist in the database.
|
||||||
|
|
|
@ -304,7 +304,7 @@ class Sensor implements DiscoveryModule, PollerModule
|
||||||
}
|
}
|
||||||
|
|
||||||
// pre-fetch all standard sensors
|
// pre-fetch all standard sensors
|
||||||
$standard_sensors = call_user_func_array('array_merge', $sensors);
|
$standard_sensors = collect($sensors)->flatten(1)->all();
|
||||||
$pre_fetch = self::fetchSnmpData($os->getDevice(), $standard_sensors);
|
$pre_fetch = self::fetchSnmpData($os->getDevice(), $standard_sensors);
|
||||||
|
|
||||||
// poll standard sensors
|
// poll standard sensors
|
||||||
|
|
|
@ -0,0 +1,58 @@
|
||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* CliColorFormatter.php
|
||||||
|
*
|
||||||
|
* -Description-
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*
|
||||||
|
* @package LibreNMS
|
||||||
|
* @link http://librenms.org
|
||||||
|
* @copyright 2018 Tony Murray
|
||||||
|
* @author Tony Murray <murraytony@gmail.com>
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace LibreNMS\Util;
|
||||||
|
|
||||||
|
class CliColorFormatter extends \Monolog\Formatter\LineFormatter
|
||||||
|
{
|
||||||
|
private $console_color;
|
||||||
|
private $console;
|
||||||
|
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
$this->console_color = new \Console_Color2();
|
||||||
|
$this->console = \App::runningInConsole();
|
||||||
|
|
||||||
|
parent::__construct(
|
||||||
|
"%message%\n",
|
||||||
|
null,
|
||||||
|
true
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function format(array $record)
|
||||||
|
{
|
||||||
|
// only format messages where color is enabled
|
||||||
|
if (isset($record['context']['color']) && $record['context']['color']) {
|
||||||
|
if ($this->console) {
|
||||||
|
$record['message'] = $this->console_color->convert($record['message']);
|
||||||
|
} else {
|
||||||
|
$record['message'] = $this->console_color->strip($record['message']);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return parent::format($record);
|
||||||
|
}
|
||||||
|
}
|
|
@ -63,7 +63,7 @@ class FileLock implements Lock
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($this->handle !== false) {
|
if (is_resource($this->handle)) {
|
||||||
flock($this->handle, LOCK_UN);
|
flock($this->handle, LOCK_UN);
|
||||||
fclose($this->handle);
|
fclose($this->handle);
|
||||||
}
|
}
|
||||||
|
|
13
alerts.php
13
alerts.php
|
@ -34,19 +34,8 @@ $options = getopt('d::');
|
||||||
|
|
||||||
$alerts_lock = FileLock::lockOrDie('alerts');
|
$alerts_lock = FileLock::lockOrDie('alerts');
|
||||||
|
|
||||||
if (isset($options['d'])) {
|
if (set_debug(isset($options['d']))) {
|
||||||
echo "DEBUG!\n";
|
echo "DEBUG!\n";
|
||||||
$debug = true;
|
|
||||||
ini_set('display_errors', 1);
|
|
||||||
ini_set('display_startup_errors', 1);
|
|
||||||
ini_set('log_errors', 1);
|
|
||||||
ini_set('error_reporting', 1);
|
|
||||||
} else {
|
|
||||||
$debug = false;
|
|
||||||
// ini_set('display_errors', 0);
|
|
||||||
ini_set('display_startup_errors', 0);
|
|
||||||
ini_set('log_errors', 0);
|
|
||||||
// ini_set('error_reporting', 0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!defined('TEST') && $config['alert']['disable'] != 'true') {
|
if (!defined('TEST') && $config['alert']['disable'] != 'true') {
|
||||||
|
|
|
@ -38,7 +38,8 @@ class AppServiceProvider extends ServiceProvider
|
||||||
Config::load();
|
Config::load();
|
||||||
|
|
||||||
// direct log output to librenms.log
|
// direct log output to librenms.log
|
||||||
Log::useFiles(Config::get('log_file', base_path('logs/librenms.log')));
|
Log::getMonolog()->popHandler(); // remove existing errorlog logger
|
||||||
|
Log::useFiles(Config::get('log_file', base_path('logs/librenms.log')), 'error');
|
||||||
|
|
||||||
|
|
||||||
// Blade directives (Yucky because of < L5.5)
|
// Blade directives (Yucky because of < L5.5)
|
||||||
|
|
|
@ -17,19 +17,8 @@ $init_modules = array();
|
||||||
require __DIR__ . '/includes/init.php';
|
require __DIR__ . '/includes/init.php';
|
||||||
|
|
||||||
$options = getopt('d::h:f:;');
|
$options = getopt('d::h:f:;');
|
||||||
if (isset($options['d'])) {
|
if (set_debug(isset($options['d']))) {
|
||||||
echo "DEBUG!\n";
|
echo "DEBUG!\n";
|
||||||
$debug = true;
|
|
||||||
ini_set('display_errors', 1);
|
|
||||||
ini_set('display_startup_errors', 1);
|
|
||||||
ini_set('log_errors', 1);
|
|
||||||
ini_set('error_reporting', 1);
|
|
||||||
} else {
|
|
||||||
$debug = false;
|
|
||||||
// ini_set('display_errors', 0);
|
|
||||||
ini_set('display_startup_errors', 0);
|
|
||||||
ini_set('log_errors', 0);
|
|
||||||
// ini_set('error_reporting', 0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isset($options['f'])) {
|
if (isset($options['f'])) {
|
||||||
|
|
|
@ -64,7 +64,7 @@ if (isset($options['i']) && $options['i'] && isset($options['n'])) {
|
||||||
$doing = $options['n'].'/'.$options['i'];
|
$doing = $options['n'].'/'.$options['i'];
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isset($options['d']) || isset($options['v'])) {
|
if (set_debug(isset($options['d'])) || isset($options['v'])) {
|
||||||
$versions = version_info();
|
$versions = version_info();
|
||||||
echo <<<EOH
|
echo <<<EOH
|
||||||
===================================
|
===================================
|
||||||
|
@ -83,18 +83,7 @@ EOH;
|
||||||
if (isset($options['v'])) {
|
if (isset($options['v'])) {
|
||||||
$vdebug = true;
|
$vdebug = true;
|
||||||
}
|
}
|
||||||
$debug = true;
|
|
||||||
update_os_cache(true); // Force update of OS Cache
|
update_os_cache(true); // Force update of OS Cache
|
||||||
ini_set('display_errors', 1);
|
|
||||||
ini_set('display_startup_errors', 1);
|
|
||||||
ini_set('log_errors', 1);
|
|
||||||
ini_set('error_reporting', 1);
|
|
||||||
} else {
|
|
||||||
$debug = false;
|
|
||||||
// ini_set('display_errors', 0);
|
|
||||||
ini_set('display_startup_errors', 0);
|
|
||||||
ini_set('log_errors', 0);
|
|
||||||
// ini_set('error_reporting', 0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!$where) {
|
if (!$where) {
|
||||||
|
|
16
html/csv.php
16
html/csv.php
|
@ -12,23 +12,11 @@
|
||||||
* the source code distribution for details.
|
* the source code distribution for details.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if (strpos($_SERVER['PATH_INFO'], 'debug')) {
|
|
||||||
$debug = '1';
|
|
||||||
ini_set('display_errors', 1);
|
|
||||||
ini_set('display_startup_errors', 1);
|
|
||||||
ini_set('log_errors', 1);
|
|
||||||
ini_set('error_reporting', E_ALL);
|
|
||||||
} else {
|
|
||||||
$debug = false;
|
|
||||||
ini_set('display_errors', 0);
|
|
||||||
ini_set('display_startup_errors', 0);
|
|
||||||
ini_set('log_errors', 0);
|
|
||||||
ini_set('error_reporting', 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
$init_modules = array('web', 'auth');
|
$init_modules = array('web', 'auth');
|
||||||
require realpath(__DIR__ . '/..') . '/includes/init.php';
|
require realpath(__DIR__ . '/..') . '/includes/init.php';
|
||||||
|
|
||||||
|
set_debug(strpos($_SERVER['PATH_INFO'], 'debug'));
|
||||||
|
|
||||||
$report = mres($vars['report']);
|
$report = mres($vars['report']);
|
||||||
if (!empty($report) && file_exists("includes/reports/$report.csv.inc.php")) {
|
if (!empty($report) && file_exists("includes/reports/$report.csv.inc.php")) {
|
||||||
if ($debug === false) {
|
if ($debug === false) {
|
||||||
|
|
|
@ -48,7 +48,7 @@ if (is_numeric($_GET['interval'])) {
|
||||||
$time_interval=1; //Refresh time Interval
|
$time_interval=1; //Refresh time Interval
|
||||||
}
|
}
|
||||||
|
|
||||||
$fetch_link = "data.php?id=".$_GET[id];
|
$fetch_link = "data.php?id=".$_GET['id'];
|
||||||
|
|
||||||
//SVG attributes
|
//SVG attributes
|
||||||
$attribs['axis']='fill="black" stroke="black"';
|
$attribs['axis']='fill="black" stroke="black"';
|
||||||
|
|
|
@ -13,23 +13,11 @@
|
||||||
|
|
||||||
$start = microtime(true);
|
$start = microtime(true);
|
||||||
|
|
||||||
if (isset($_GET['debug'])) {
|
|
||||||
$debug = true;
|
|
||||||
ini_set('display_errors', 1);
|
|
||||||
ini_set('display_startup_errors', 0);
|
|
||||||
ini_set('log_errors', 0);
|
|
||||||
ini_set('error_reporting', E_ALL);
|
|
||||||
} else {
|
|
||||||
$debug = false;
|
|
||||||
ini_set('display_errors', 0);
|
|
||||||
ini_set('display_startup_errors', 0);
|
|
||||||
ini_set('log_errors', 0);
|
|
||||||
ini_set('error_reporting', 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
$init_modules = array('web', 'graphs');
|
$init_modules = array('web', 'graphs');
|
||||||
require realpath(__DIR__ . '/..') . '/includes/init.php';
|
require realpath(__DIR__ . '/..') . '/includes/init.php';
|
||||||
|
|
||||||
|
set_debug(isset($_GET['debug']));
|
||||||
|
|
||||||
rrdtool_initialize(false);
|
rrdtool_initialize(false);
|
||||||
|
|
||||||
require $config['install_dir'] . '/html/includes/graphs/graph.inc.php';
|
require $config['install_dir'] . '/html/includes/graphs/graph.inc.php';
|
||||||
|
|
|
@ -455,7 +455,7 @@ function del_device()
|
||||||
$device = device_by_id_cache($device_id);
|
$device = device_by_id_cache($device_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!device) {
|
if (!$device) {
|
||||||
api_error(404, "Device $hostname not found");
|
api_error(404, "Device $hostname not found");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
$rrd_filename = rrd_name($device['hostname'], array('arubaap', $ap[name].$ap[radio_number]));
|
$rrd_filename = rrd_name($device['hostname'], array('arubaap', $ap['name'].$ap['radio_number']));
|
||||||
|
|
||||||
$rrd_list[0]['filename'] = $rrd_filename;
|
$rrd_list[0]['filename'] = $rrd_filename;
|
||||||
$rrd_list[0]['descr'] = 'MonBSSIDs';
|
$rrd_list[0]['descr'] = 'MonBSSIDs';
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
require 'includes/graphs/common.inc.php';
|
require 'includes/graphs/common.inc.php';
|
||||||
|
|
||||||
$mysql_rrd = rrd_name($device['hostname'], array('app', mysql, $app['app_id']));
|
$mysql_rrd = rrd_name($device['hostname'], ['app', 'mysql', $app['app_id']]);
|
||||||
|
|
||||||
if (rrdtool_check_rrd_exists($mysql_rrd)) {
|
if (rrdtool_check_rrd_exists($mysql_rrd)) {
|
||||||
$rrd_filename = $mysql_rrd;
|
$rrd_filename = $mysql_rrd;
|
||||||
|
|
|
@ -29,13 +29,13 @@ foreach (dbFetchRows('SELECT * FROM storage where device_id = ?', array($device[
|
||||||
|
|
||||||
$descr = rrdtool_escape($storage['storage_descr'], 12);
|
$descr = rrdtool_escape($storage['storage_descr'], 12);
|
||||||
$rrd = rrd_name($device['hostname'], array('storage', $storage['storage_mib'], $storage['storage_descr']));
|
$rrd = rrd_name($device['hostname'], array('storage', $storage['storage_mib'], $storage['storage_descr']));
|
||||||
$rrd_options .= " DEF:$storage[storage_id]used=$rrd:used:AVERAGE";
|
$rrd_options .= " DEF:{$storage['storage_id']}used=$rrd:used:AVERAGE";
|
||||||
$rrd_options .= " DEF:$storage[storage_id]free=$rrd:free:AVERAGE";
|
$rrd_options .= " DEF:{$storage['storage_id']}free=$rrd:free:AVERAGE";
|
||||||
$rrd_options .= " CDEF:$storage[storage_id]size=$storage[storage_id]used,$storage[storage_id]free,+";
|
$rrd_options .= " CDEF:{$storage['storage_id']}size={$storage['storage_id']}used,{$storage['storage_id']}free,+";
|
||||||
$rrd_options .= " CDEF:$storage[storage_id]perc=$storage[storage_id]used,$storage[storage_id]size,/,100,*";
|
$rrd_options .= " CDEF:{$storage['storage_id']}perc={$storage['storage_id']}used,{$storage['storage_id']}size,/,100,*";
|
||||||
$rrd_options .= " LINE1.25:$storage[storage_id]perc#".$colour.":'$descr'";
|
$rrd_options .= " LINE1.25:{$storage['storage_id']}perc#".$colour.":'$descr'";
|
||||||
$rrd_options .= " GPRINT:$storage[storage_id]size:LAST:%6.2lf%sB";
|
$rrd_options .= " GPRINT:{$storage['storage_id']}size:LAST:%6.2lf%sB";
|
||||||
$rrd_options .= " GPRINT:$storage[storage_id]used:LAST:%6.2lf%sB";
|
$rrd_options .= " GPRINT:{$storage['storage_id']}used:LAST:%6.2lf%sB";
|
||||||
$rrd_options .= " GPRINT:$storage[storage_id]perc:LAST:%5.2lf%%\\l";
|
$rrd_options .= " GPRINT:{$storage['storage_id']}perc:LAST:%5.2lf%%\\l";
|
||||||
$iter++;
|
$iter++;
|
||||||
}//end foreach
|
}//end foreach
|
||||||
|
|
|
@ -28,35 +28,35 @@ $descr = rrdtool_escape(short_hrDeviceDescr($mempool['mempool_descr']), $descr_l
|
||||||
$perc = round($mempool['mempool_perc'], 0);
|
$perc = round($mempool['mempool_perc'], 0);
|
||||||
$background = get_percentage_colours($perc, $mempool['mempool_perc_warn']);
|
$background = get_percentage_colours($perc, $mempool['mempool_perc_warn']);
|
||||||
|
|
||||||
$rrd_options .= " DEF:$mempool[mempool_id]used=$rrd_filename:used:AVERAGE";
|
$rrd_options .= " DEF:{$mempool['mempool_id']}used=$rrd_filename:used:AVERAGE";
|
||||||
$rrd_options .= " DEF:$mempool[mempool_id]free=$rrd_filename:free:AVERAGE";
|
$rrd_options .= " DEF:{$mempool['mempool_id']}free=$rrd_filename:free:AVERAGE";
|
||||||
$rrd_options .= " CDEF:$mempool[mempool_id]size=$mempool[mempool_id]used,$mempool[mempool_id]free,+";
|
$rrd_options .= " CDEF:{$mempool['mempool_id']}size={$mempool['mempool_id']}used,{$mempool['mempool_id']}free,+";
|
||||||
$rrd_options .= " CDEF:$mempool[mempool_id]perc=$mempool[mempool_id]used,$mempool[mempool_id]size,/,100,*";
|
$rrd_options .= " CDEF:{$mempool['mempool_id']}perc={$mempool['mempool_id']}used,{$mempool['mempool_id']}size,/,100,*";
|
||||||
$rrd_options .= " CDEF:$mempool[mempool_id]percx=100,$mempool[mempool_id]perc,-";
|
$rrd_options .= " CDEF:{$mempool['mempool_id']}percx=100,{$mempool['mempool_id']}perc,-";
|
||||||
$rrd_options .= " AREA:$mempool[mempool_id]perc#".$background['right'].':';
|
$rrd_options .= " AREA:{$mempool['mempool_id']}perc#".$background['right'].':';
|
||||||
|
|
||||||
if ($width > '500') {
|
if ($width > '500') {
|
||||||
$rrd_options .= " LINE1.25:$mempool[mempool_id]perc#".$background['left'].":'$descr'";
|
$rrd_options .= " LINE1.25:{$mempool['mempool_id']}perc#".$background['left'].":'$descr'";
|
||||||
$rrd_options .= " GPRINT:$mempool[mempool_id]size:LAST:%6.2lf%sB";
|
$rrd_options .= " GPRINT:{$mempool['mempool_id']}size:LAST:%6.2lf%sB";
|
||||||
$rrd_options .= " GPRINT:$mempool[mempool_id]used:LAST:%6.2lf%sB";
|
$rrd_options .= " GPRINT:{$mempool['mempool_id']}used:LAST:%6.2lf%sB";
|
||||||
$rrd_options .= " GPRINT:$mempool[mempool_id]free:LAST:%6.2lf%sB";
|
$rrd_options .= " GPRINT:{$mempool['mempool_id']}free:LAST:%6.2lf%sB";
|
||||||
$rrd_options .= " GPRINT:$mempool[mempool_id]free:MIN:%5.2lf%sB";
|
$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:MAX:%5.2lf%sB";
|
||||||
$rrd_options .= " GPRINT:$mempool[mempool_id]free:AVERAGE:%5.2lf%sB\\n";
|
$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']}perc:LAST:'%5.2lf%% '";
|
||||||
$rrd_options .= " GPRINT:$mempool[mempool_id]percx:LAST:'%5.2lf%% '";
|
$rrd_options .= " GPRINT:{$mempool['mempool_id']}percx:LAST:'%5.2lf%% '";
|
||||||
$rrd_options .= " GPRINT:$mempool[mempool_id]perc:MIN:'%5.2lf%% '";
|
$rrd_options .= " GPRINT:{$mempool['mempool_id']}perc:MIN:'%5.2lf%% '";
|
||||||
$rrd_options .= " GPRINT:$mempool[mempool_id]perc:MAX:'%5.2lf%% '";
|
$rrd_options .= " GPRINT:{$mempool['mempool_id']}perc:MAX:'%5.2lf%% '";
|
||||||
$rrd_options .= " GPRINT:$mempool[mempool_id]perc:AVERAGE:%5.2lf%%\\n";
|
$rrd_options .= " GPRINT:{$mempool['mempool_id']}perc:AVERAGE:%5.2lf%%\\n";
|
||||||
} else {
|
} else {
|
||||||
$rrd_options .= " LINE1.25:$mempool[mempool_id]perc#".$background['left'].":'$descr'";
|
$rrd_options .= " LINE1.25:{$mempool['mempool_id']}perc#".$background['left'].":'$descr'";
|
||||||
$rrd_options .= " GPRINT:$mempool[mempool_id]size:LAST:%6.2lf%sB";
|
$rrd_options .= " GPRINT:{$mempool['mempool_id']}size:LAST:%6.2lf%sB";
|
||||||
$rrd_options .= " GPRINT:$mempool[mempool_id]used:LAST:%6.2lf%sB";
|
$rrd_options .= " GPRINT:{$mempool['mempool_id']}used:LAST:%6.2lf%sB";
|
||||||
$rrd_options .= " GPRINT:$mempool[mempool_id]free:LAST:%6.2lf%sB";
|
$rrd_options .= " GPRINT:{$mempool['mempool_id']}free:LAST:%6.2lf%sB";
|
||||||
$rrd_options .= " COMMENT:'\l'";
|
$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']}perc:LAST:'%5.2lf%% '";
|
||||||
$rrd_options .= " GPRINT:$mempool[mempool_id]percx:LAST:'%5.2lf%% '";
|
$rrd_options .= " GPRINT:{$mempool['mempool_id']}percx:LAST:'%5.2lf%% '";
|
||||||
$rrd_options .= " COMMENT:'\l'";
|
$rrd_options .= " COMMENT:'\l'";
|
||||||
}//end if
|
}//end if
|
||||||
|
|
|
@ -37,9 +37,9 @@ echo "<br>\n";
|
||||||
|
|
||||||
echo '</td><td width=120>';
|
echo '</td><td width=120>';
|
||||||
|
|
||||||
echo "<i class='fa fa-wifi fa-lg icon-theme' aria-hidden='true'></i> ".format_bi($ap[numasoclients]).' Clients<br />';
|
echo "<i class='fa fa-wifi fa-lg icon-theme' aria-hidden='true'></i> ".format_bi($ap['numasoclients']).' Clients<br />';
|
||||||
echo "<i class='fa fa-wifi fa-lg icon-theme' aria-hidden='true'></i> ".format_bi($ap[radioutil]).' % busy<br />';
|
echo "<i class='fa fa-wifi fa-lg icon-theme' aria-hidden='true'></i> ".format_bi($ap['radioutil']).' % busy<br />';
|
||||||
echo "<i class='fa fa-wifi fa-lg icon-theme' aria-hidden='true'></i> ".format_bi($ap[interference]).' interference index<br />';
|
echo "<i class='fa fa-wifi fa-lg icon-theme' aria-hidden='true'></i> ".format_bi($ap['interference']).' interference index<br />';
|
||||||
|
|
||||||
echo '</td></tr>';
|
echo '</td></tr>';
|
||||||
|
|
||||||
|
|
|
@ -1,86 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
$total_queries = count($sql_debug);
|
|
||||||
$total_php_issues = count($php_debug);
|
|
||||||
?>
|
|
||||||
|
|
||||||
<div class="modal fade" id="sql_debug" tabindex="-1" role="dialog" aria-labelledby="sql_debug_label" aria-hidden="true">
|
|
||||||
<div class="modal-dialog">
|
|
||||||
<div class="modal-content">
|
|
||||||
<div class="modal-header">
|
|
||||||
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
|
|
||||||
<h4 class="modal-title" id="myModalLabel">SQL Debug</h4>
|
|
||||||
</div>
|
|
||||||
<div class="modal-body">
|
|
||||||
<table class="table table-condensed table-hover">
|
|
||||||
<?php
|
|
||||||
foreach ($sql_debug as $sql_error) {
|
|
||||||
echo "
|
|
||||||
<tr>
|
|
||||||
<td>
|
|
||||||
$sql_error
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
";
|
|
||||||
}
|
|
||||||
|
|
||||||
echo "
|
|
||||||
<tr>
|
|
||||||
<td>
|
|
||||||
$total_queries total SQL queries run.
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
";
|
|
||||||
?>
|
|
||||||
</table>
|
|
||||||
</div>
|
|
||||||
<div class="modal-footer">
|
|
||||||
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="modal fade" id="php_debug" tabindex="-1" role="dialog" aria-labelledby="php_debug_label" aria-hidden="true">
|
|
||||||
<div class="modal-dialog">
|
|
||||||
<div class="modal-content">
|
|
||||||
<div class="modal-header">
|
|
||||||
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
|
|
||||||
<h4 class="modal-title" id="myModalLabel">PHP Debug</h4>
|
|
||||||
</div>
|
|
||||||
<div class="modal-body">
|
|
||||||
<table class="table table-condensed table-hover">
|
|
||||||
<?php
|
|
||||||
foreach ($php_debug as $php_error) {
|
|
||||||
echo '
|
|
||||||
<tr>
|
|
||||||
<td>
|
|
||||||
';
|
|
||||||
print_r($php_error);
|
|
||||||
echo '
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
';
|
|
||||||
}
|
|
||||||
|
|
||||||
echo "
|
|
||||||
<tr>
|
|
||||||
<td>
|
|
||||||
$total_php_issues total PHP issues / errors.
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
";
|
|
||||||
|
|
||||||
?>
|
|
||||||
</table>
|
|
||||||
</div>
|
|
||||||
<div class="modal-footer">
|
|
||||||
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<nav class="navbar navbar-default navbar-fixed-bottom navbar-debug">
|
|
||||||
<div class="container-fluid">
|
|
||||||
<p><strong>Debug options:</strong> <a href="#" data-toggle="modal" data-target="#sql_debug">Show SQL Debug</a> / <a href="#" data-toggle="modal" data-target="#php_debug">Show PHP Debug</a></p>
|
|
||||||
</div>
|
|
||||||
</nav>
|
|
|
@ -103,7 +103,7 @@ if ($port['ifSpeed']) {
|
||||||
|
|
||||||
echo '<br />';
|
echo '<br />';
|
||||||
|
|
||||||
if ($port[ifDuplex] != 'unknown') {
|
if ($port['ifDuplex'] != 'unknown') {
|
||||||
echo '<span class=box-desc>'.$port['ifDuplex'].'</span>';
|
echo '<span class=box-desc>'.$port['ifDuplex'].'</span>';
|
||||||
} else {
|
} else {
|
||||||
echo '-';
|
echo '-';
|
||||||
|
|
|
@ -93,7 +93,7 @@ foreach (dbFetchRows($sql, $param) as $interface) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($interface['in_errors'] > 0 || $interface['out_errors'] > 0) {
|
if ($interface['in_errors'] > 0 || $interface['out_errors'] > 0) {
|
||||||
$error_img = generate_port_link($interface, "<i class='fa fa-flag fa-lg' style='color:red' aria-hidden='true'></i>", errors);
|
$error_img = generate_port_link($interface, "<i class='fa fa-flag fa-lg' style='color:red' aria-hidden='true'></i>", 'errors');
|
||||||
} else {
|
} else {
|
||||||
$error_img = '';
|
$error_img = '';
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,32 +22,6 @@ if (empty($_SERVER['PATH_INFO'])) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (strpos($_SERVER['REQUEST_URI'], "debug")) {
|
|
||||||
$debug = true;
|
|
||||||
ini_set('display_errors', 0);
|
|
||||||
ini_set('display_startup_errors', 1);
|
|
||||||
ini_set('log_errors', 1);
|
|
||||||
ini_set('error_reporting', E_ALL);
|
|
||||||
set_error_handler(function ($errno, $errstr, $errfile, $errline) {
|
|
||||||
global $php_debug;
|
|
||||||
$php_debug[] = array('errno' => $errno, 'errstr' => $errstr, 'errfile' => $errfile, 'errline' => $errline);
|
|
||||||
});
|
|
||||||
register_shutdown_function(function () {
|
|
||||||
$last_error = error_get_last();
|
|
||||||
if ($last_error['type'] == 1) {
|
|
||||||
$log_error = array($last_error['type'], $last_error['message'], $last_error['file'], $last_error['line']);
|
|
||||||
print_r($log_error);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
$sql_debug = array();
|
|
||||||
$php_debug = array();
|
|
||||||
} else {
|
|
||||||
$debug = false;
|
|
||||||
ini_set('display_errors', 0);
|
|
||||||
ini_set('display_startup_errors', 0);
|
|
||||||
ini_set('log_errors', 0);
|
|
||||||
ini_set('error_reporting', 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Set variables
|
// Set variables
|
||||||
$msg_box = array();
|
$msg_box = array();
|
||||||
|
@ -61,6 +35,8 @@ if (!file_exists('../config.php') && $_SERVER['PATH_INFO'] != '/install.php') {
|
||||||
$init_modules = array('web', 'auth');
|
$init_modules = array('web', 'auth');
|
||||||
require realpath(__DIR__ . '/..') . '/includes/init.php';
|
require realpath(__DIR__ . '/..') . '/includes/init.php';
|
||||||
|
|
||||||
|
set_debug(str_contains($_SERVER['REQUEST_URI'], 'debug'));
|
||||||
|
|
||||||
LibreNMS\Plugins::start();
|
LibreNMS\Plugins::start();
|
||||||
|
|
||||||
$runtime_start = microtime(true);
|
$runtime_start = microtime(true);
|
||||||
|
@ -68,7 +44,6 @@ $runtime_start = microtime(true);
|
||||||
ob_start();
|
ob_start();
|
||||||
|
|
||||||
ini_set('allow_url_fopen', 0);
|
ini_set('allow_url_fopen', 0);
|
||||||
ini_set('display_errors', 0);
|
|
||||||
|
|
||||||
if (strstr($_SERVER['REQUEST_URI'], 'widescreen=yes')) {
|
if (strstr($_SERVER['REQUEST_URI'], 'widescreen=yes')) {
|
||||||
$_SESSION['widescreen'] = 1;
|
$_SESSION['widescreen'] = 1;
|
||||||
|
@ -341,10 +316,6 @@ if (is_array($msg_box)) {
|
||||||
echo("</script>");
|
echo("</script>");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (is_array($sql_debug) && is_array($php_debug) && Auth::check()) {
|
|
||||||
require_once "includes/print-debug.php";
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($no_refresh !== true && $config['page_refresh'] != 0) {
|
if ($no_refresh !== true && $config['page_refresh'] != 0) {
|
||||||
$refresh = $config['page_refresh'] * 1000;
|
$refresh = $config['page_refresh'] * 1000;
|
||||||
echo('<script type="text/javascript">
|
echo('<script type="text/javascript">
|
||||||
|
|
|
@ -13,18 +13,12 @@
|
||||||
use LibreNMS\Authentication\Auth;
|
use LibreNMS\Authentication\Auth;
|
||||||
|
|
||||||
ini_set('allow_url_fopen', 0);
|
ini_set('allow_url_fopen', 0);
|
||||||
ini_set('display_errors', 0);
|
|
||||||
|
|
||||||
if ($_GET[debug]) {
|
|
||||||
ini_set('display_errors', 1);
|
|
||||||
ini_set('display_startup_errors', 1);
|
|
||||||
ini_set('log_errors', 1);
|
|
||||||
ini_set('error_reporting', E_ALL);
|
|
||||||
}
|
|
||||||
|
|
||||||
$init_modules = array('web', 'auth');
|
$init_modules = array('web', 'auth');
|
||||||
require realpath(__DIR__ . '/..') . '/includes/init.php';
|
require realpath(__DIR__ . '/..') . '/includes/init.php';
|
||||||
|
|
||||||
|
set_debug($_GET['debug']);
|
||||||
|
|
||||||
if (!Auth::check()) {
|
if (!Auth::check()) {
|
||||||
echo 'unauthenticated';
|
echo 'unauthenticated';
|
||||||
exit;
|
exit;
|
||||||
|
|
|
@ -13,16 +13,17 @@
|
||||||
|
|
||||||
use LibreNMS\Authentication\Auth;
|
use LibreNMS\Authentication\Auth;
|
||||||
|
|
||||||
ini_set('display_errors', 1);
|
|
||||||
ini_set('display_startup_errors', 1);
|
|
||||||
ini_set('log_errors', 1);
|
|
||||||
ini_set('error_reporting', E_ALL);
|
|
||||||
|
|
||||||
$links = 1;
|
$links = 1;
|
||||||
|
|
||||||
$init_modules = array('web', 'auth');
|
$init_modules = array('web', 'auth');
|
||||||
require realpath(__DIR__ . '/..') . '/includes/init.php';
|
require realpath(__DIR__ . '/..') . '/includes/init.php';
|
||||||
|
|
||||||
|
$options = getopt('d::');
|
||||||
|
|
||||||
|
if (set_debug(isset($options['d']))) {
|
||||||
|
echo "DEBUG!\n";
|
||||||
|
}
|
||||||
|
|
||||||
if (strpos($_SERVER['REQUEST_URI'], 'anon')) {
|
if (strpos($_SERVER['REQUEST_URI'], 'anon')) {
|
||||||
$anon = 1;
|
$anon = 1;
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,9 +18,9 @@ if (bill_permitted($bill_id)) {
|
||||||
$tomorrow = str_replace('-', '', dbFetchCell('SELECT DATE_ADD(CURDATE(), INTERVAL 1 DAY)'));
|
$tomorrow = str_replace('-', '', dbFetchCell('SELECT DATE_ADD(CURDATE(), INTERVAL 1 DAY)'));
|
||||||
$last_month = str_replace('-', '', dbFetchCell('SELECT DATE_SUB(CURDATE(), INTERVAL 1 MONTH)'));
|
$last_month = str_replace('-', '', dbFetchCell('SELECT DATE_SUB(CURDATE(), INTERVAL 1 MONTH)'));
|
||||||
|
|
||||||
$rightnow = $today.date(His);
|
$rightnow = $today.date('His');
|
||||||
$before = $yesterday.date(His);
|
$before = $yesterday.date('His');
|
||||||
$lastmonth = $last_month.date(His);
|
$lastmonth = $last_month.date('His');
|
||||||
|
|
||||||
$bill_name = $bill_data['bill_name'];
|
$bill_name = $bill_data['bill_name'];
|
||||||
$dayofmonth = $bill_data['bill_day'];
|
$dayofmonth = $bill_data['bill_day'];
|
||||||
|
@ -215,7 +215,7 @@ if ($vars['view'] == 'edit' && Auth::user()->hasGlobalAdmin()) {
|
||||||
|
|
||||||
$lastmonth = dbFetchCell('SELECT UNIX_TIMESTAMP(DATE_SUB(NOW(), INTERVAL 1 MONTH))');
|
$lastmonth = dbFetchCell('SELECT UNIX_TIMESTAMP(DATE_SUB(NOW(), INTERVAL 1 MONTH))');
|
||||||
$yesterday = dbFetchCell('SELECT UNIX_TIMESTAMP(DATE_SUB(NOW(), INTERVAL 1 DAY))');
|
$yesterday = dbFetchCell('SELECT UNIX_TIMESTAMP(DATE_SUB(NOW(), INTERVAL 1 DAY))');
|
||||||
$rightnow = date(U);
|
$rightnow = date('U');
|
||||||
|
|
||||||
if ($vars['view'] == 'accurate') {
|
if ($vars['view'] == 'accurate') {
|
||||||
$bi = "<img src='billing-graph.php?bill_id=".$bill_id.'&bill_code='.$_GET['bill_code'];
|
$bi = "<img src='billing-graph.php?bill_id=".$bill_id.'&bill_code='.$_GET['bill_code'];
|
||||||
|
|
|
@ -28,7 +28,7 @@ $unix_prev_from = dbFetchCell("SELECT UNIX_TIMESTAMP('$lastfrom')");
|
||||||
$unix_prev_to = dbFetchCell("SELECT UNIX_TIMESTAMP('$lastto')");
|
$unix_prev_to = dbFetchCell("SELECT UNIX_TIMESTAMP('$lastto')");
|
||||||
$lastmonth = dbFetchCell('SELECT UNIX_TIMESTAMP(DATE_SUB(NOW(), INTERVAL 1 MONTH))');
|
$lastmonth = dbFetchCell('SELECT UNIX_TIMESTAMP(DATE_SUB(NOW(), INTERVAL 1 MONTH))');
|
||||||
$yesterday = dbFetchCell('SELECT UNIX_TIMESTAMP(DATE_SUB(NOW(), INTERVAL 1 DAY))');
|
$yesterday = dbFetchCell('SELECT UNIX_TIMESTAMP(DATE_SUB(NOW(), INTERVAL 1 DAY))');
|
||||||
$rightnow = date(U);
|
$rightnow = date('U');
|
||||||
|
|
||||||
$cur_days = date('d', (strtotime('now') - strtotime($datefrom)));
|
$cur_days = date('d', (strtotime('now') - strtotime($datefrom)));
|
||||||
$total_days = date('d', (strtotime($dateto) - strtotime($datefrom)));
|
$total_days = date('d', (strtotime($dateto) - strtotime($datefrom)));
|
||||||
|
|
|
@ -50,7 +50,7 @@ if ($vars['view'] == 'incoming') {
|
||||||
|
|
||||||
$graph_array['type'] = 'device_smokeping_in_all';
|
$graph_array['type'] = 'device_smokeping_in_all';
|
||||||
$graph_array['device'] = $device['device_id'];
|
$graph_array['device'] = $device['device_id'];
|
||||||
$graph_array['legend'] = no;
|
$graph_array['legend'] = 'no';
|
||||||
echo '<tr><td>';
|
echo '<tr><td>';
|
||||||
echo '<h3>Aggregate</h3>';
|
echo '<h3>Aggregate</h3>';
|
||||||
|
|
||||||
|
@ -94,7 +94,7 @@ if ($vars['view'] == 'incoming') {
|
||||||
echo '</td></tr>';
|
echo '</td></tr>';
|
||||||
|
|
||||||
$graph_array['type'] = 'device_smokeping_out_all';
|
$graph_array['type'] = 'device_smokeping_out_all';
|
||||||
$graph_array['legend'] = no;
|
$graph_array['legend'] = 'no';
|
||||||
echo '<tr><td>';
|
echo '<tr><td>';
|
||||||
echo '<h3>Aggregate</h3>';
|
echo '<h3>Aggregate</h3>';
|
||||||
|
|
||||||
|
|
|
@ -204,7 +204,7 @@ if (empty($vars['dtpickerto'])) {
|
||||||
zoomMax: <?php
|
zoomMax: <?php
|
||||||
$first_date = reset($data);
|
$first_date = reset($data);
|
||||||
$last_date = end($data);
|
$last_date = end($data);
|
||||||
$milisec_diff = abs(strtotime($first_date[x]) - strtotime($last_date[x])) * 1000;
|
$milisec_diff = abs(strtotime($first_date['x']) - strtotime($last_date['x'])) * 1000;
|
||||||
echo $milisec_diff;
|
echo $milisec_diff;
|
||||||
?>,
|
?>,
|
||||||
orientation: 'top'
|
orientation: 'top'
|
||||||
|
|
|
@ -50,13 +50,13 @@ echo '</table></div>';
|
||||||
|
|
||||||
$pos = strpos(strtolower($ifname), 'vlan');
|
$pos = strpos(strtolower($ifname), 'vlan');
|
||||||
if ($pos !== false) {
|
if ($pos !== false) {
|
||||||
$broke = yes;
|
$broke = 'yes';
|
||||||
}
|
}
|
||||||
|
|
||||||
$pos = strpos(strtolower($ifname), 'loopback');
|
$pos = strpos(strtolower($ifname), 'loopback');
|
||||||
|
|
||||||
if ($pos !== false) {
|
if ($pos !== false) {
|
||||||
$broke = yes;
|
$broke = 'yes';
|
||||||
}
|
}
|
||||||
|
|
||||||
echo "<div style='clear: both;'>";
|
echo "<div style='clear: both;'>";
|
||||||
|
|
|
@ -47,32 +47,32 @@ if ($vars['subview'] == 'top10') {
|
||||||
<div style='margin: 0px 10px 5px 0px; padding:5px; background: #e5e5e5;'>
|
<div style='margin: 0px 10px 5px 0px; padding:5px; background: #e5e5e5;'>
|
||||||
<span class=device-head>Day</span><br />
|
<span class=device-head>Day</span><br />
|
||||||
|
|
||||||
<a href='".generate_url($link_array, array('view' => 'macaccounting', 'subview' => 'top10', 'graph' => $vars['graph'], sort => $vars['sort'], 'period' => 'day'))."'>
|
<a href='".generate_url($link_array, array('view' => 'macaccounting', 'subview' => 'top10', 'graph' => $vars['graph'], 'sort' => $vars['sort'], 'period' => 'day'))."'>
|
||||||
|
|
||||||
<img style='border: #5e5e5e 2px;' valign=middle src='graph.php?id=".$port['port_id'].'&stat='.$vars['graph'].'&type=port_mac_acc_total&sort='.$vars['sort'].'&from='.$config['time']['day'].'&to='.$config['time']['now']."&width=150&height=50' />
|
<img style='border: #5e5e5e 2px;' valign=middle src='graph.php?id=".$port['port_id'].'&stat='.$vars['graph'].'&type=port_mac_acc_total&sort='.$vars['sort'].'&from='.$config['time']['day'].'&to='.$config['time']['now']."&width=150&height=50' />
|
||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
<div style='margin: 0px 10px 5px 0px; padding:5px; background: #e5e5e5;'>
|
<div style='margin: 0px 10px 5px 0px; padding:5px; background: #e5e5e5;'>
|
||||||
<span class=device-head>Two Day</span><br />
|
<span class=device-head>Two Day</span><br />
|
||||||
<a href='".generate_url($link_array, array('view' => 'macaccounting', 'subview' => 'top10', 'graph' => $vars['graph'], sort => $vars['sort'], 'period' => 'twoday'))."/'>
|
<a href='".generate_url($link_array, array('view' => 'macaccounting', 'subview' => 'top10', 'graph' => $vars['graph'], 'sort' => $vars['sort'], 'period' => 'twoday'))."/'>
|
||||||
<img style='border: #5e5e5e 2px;' valign=middle src='graph.php?id=".$port['port_id'].'&stat='.$vars['graph'].'&type=port_mac_acc_total&sort='.$vars['sort'].'&from='.$config['time']['twoday'].'&to='.$config['time']['now']."&width=150&height=50' />
|
<img style='border: #5e5e5e 2px;' valign=middle src='graph.php?id=".$port['port_id'].'&stat='.$vars['graph'].'&type=port_mac_acc_total&sort='.$vars['sort'].'&from='.$config['time']['twoday'].'&to='.$config['time']['now']."&width=150&height=50' />
|
||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
<div style='margin: 0px 10px 5px 0px; padding:5px; background: #e5e5e5;'>
|
<div style='margin: 0px 10px 5px 0px; padding:5px; background: #e5e5e5;'>
|
||||||
<span class=device-head>Week</span><br />
|
<span class=device-head>Week</span><br />
|
||||||
<a href='".generate_url($link_array, array('view' => 'macaccounting', 'subview' => 'top10', 'graph' => $vars['graph'], sort => $vars['sort'], 'period' => 'week'))."/'>
|
<a href='".generate_url($link_array, array('view' => 'macaccounting', 'subview' => 'top10', 'graph' => $vars['graph'], 'sort' => $vars['sort'], 'period' => 'week'))."/'>
|
||||||
<img style='border: #5e5e5e 2px;' valign=middle src='graph.php?id=".$port['port_id'].'&type=port_mac_acc_total&sort='.$vars['sort'].'&stat='.$vars['graph'].'&from='.$config['time']['week'].'&to='.$config['time']['now']."&width=150&height=50' />
|
<img style='border: #5e5e5e 2px;' valign=middle src='graph.php?id=".$port['port_id'].'&type=port_mac_acc_total&sort='.$vars['sort'].'&stat='.$vars['graph'].'&from='.$config['time']['week'].'&to='.$config['time']['now']."&width=150&height=50' />
|
||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
<div style='margin: 0px 10px 5px 0px; padding:5px; background: #e5e5e5;'>
|
<div style='margin: 0px 10px 5px 0px; padding:5px; background: #e5e5e5;'>
|
||||||
<span class=device-head>Month</span><br />
|
<span class=device-head>Month</span><br />
|
||||||
<a href='".generate_url($link_array, array('view' => 'macaccounting', 'subview' => 'top10', 'graph' => $vars['graph'], sort => $vars['sort'], 'period' => 'month'))."/'>
|
<a href='".generate_url($link_array, array('view' => 'macaccounting', 'subview' => 'top10', 'graph' => $vars['graph'], 'sort' => $vars['sort'], 'period' => 'month'))."/'>
|
||||||
<img style='border: #5e5e5e 2px;' valign=middle src='graph.php?id=".$port['port_id'].'&type=port_mac_acc_total&sort='.$vars['sort'].'&stat='.$vars['graph'].'&from='.$config['time']['month'].'&to='.$config['time']['now']."&width=150&height=50' />
|
<img style='border: #5e5e5e 2px;' valign=middle src='graph.php?id=".$port['port_id'].'&type=port_mac_acc_total&sort='.$vars['sort'].'&stat='.$vars['graph'].'&from='.$config['time']['month'].'&to='.$config['time']['now']."&width=150&height=50' />
|
||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
<div style='margin: 0px 10px 5px 0px; padding:5px; background: #e5e5e5;'>
|
<div style='margin: 0px 10px 5px 0px; padding:5px; background: #e5e5e5;'>
|
||||||
<span class=device-head>Year</span><br />
|
<span class=device-head>Year</span><br />
|
||||||
<a href='".generate_url($link_array, array('view' => 'macaccounting', 'subview' => 'top10', 'graph' => $vars['graph'], sort => $vars['sort'], 'period' => 'year'))."/'>
|
<a href='".generate_url($link_array, array('view' => 'macaccounting', 'subview' => 'top10', 'graph' => $vars['graph'], 'sort' => $vars['sort'], 'period' => 'year'))."/'>
|
||||||
<img style='border: #5e5e5e 2px;' valign=middle src='graph.php?id=".$port['port_id'].'&type=port_mac_acc_total&sort='.$vars['sort'].'&stat='.$vars['graph'].'&from='.$config['time']['year'].'&to='.$config['time']['now']."&width=150&height=50' />
|
<img style='border: #5e5e5e 2px;' valign=middle src='graph.php?id=".$port['port_id'].'&type=port_mac_acc_total&sort='.$vars['sort'].'&stat='.$vars['graph'].'&from='.$config['time']['year'].'&to='.$config['time']['now']."&width=150&height=50' />
|
||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
|
@ -83,31 +83,31 @@ if ($vars['subview'] == 'top10') {
|
||||||
<div style=' margin:0px; float: left;';>
|
<div style=' margin:0px; float: left;';>
|
||||||
<div style='margin: 0px 0px 5px 10px; padding:5px; background: #e5e5e5;'>
|
<div style='margin: 0px 0px 5px 10px; padding:5px; background: #e5e5e5;'>
|
||||||
<span class=device-head>Traffic</span><br />
|
<span class=device-head>Traffic</span><br />
|
||||||
<a href='".generate_url($link_array, array('view' => 'macaccounting', 'subview' => 'top10', 'graph' => 'bits', sort => $vars['sort'], 'period' => $vars['period']))."'>
|
<a href='".generate_url($link_array, array('view' => 'macaccounting', 'subview' => 'top10', 'graph' => 'bits', 'sort' => $vars['sort'], 'period' => $vars['period']))."'>
|
||||||
<img style='border: #5e5e5e 2px;' valign=middle src='graph.php?id=".$port['port_id'].'&stat=bits&type=port_mac_acc_total&sort='.$vars['sort']."&from=$from&to=".$config['time']['now']."&width=150&height=50' />
|
<img style='border: #5e5e5e 2px;' valign=middle src='graph.php?id=".$port['port_id'].'&stat=bits&type=port_mac_acc_total&sort='.$vars['sort']."&from=$from&to=".$config['time']['now']."&width=150&height=50' />
|
||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
<div style='margin: 0px 0px 5px 10px; padding:5px; background: #e5e5e5;'>
|
<div style='margin: 0px 0px 5px 10px; padding:5px; background: #e5e5e5;'>
|
||||||
<span class=device-head>Packets</span><br />
|
<span class=device-head>Packets</span><br />
|
||||||
<a href='".generate_url($link_array, array('view' => 'macaccounting', 'subview' => 'top10', 'graph' => 'pkts', sort => $vars['sort'], 'period' => $vars['period']))."/'>
|
<a href='".generate_url($link_array, array('view' => 'macaccounting', 'subview' => 'top10', 'graph' => 'pkts', 'sort' => $vars['sort'], 'period' => $vars['period']))."/'>
|
||||||
<img style='border: #5e5e5e 2px;' valign=middle src='graph.php?id=".$port['port_id'].'&stat=pkts&type=port_mac_acc_total&sort='.$vars['sort']."&from=$from&to=".$config['time']['now']."&width=150&height=50' />
|
<img style='border: #5e5e5e 2px;' valign=middle src='graph.php?id=".$port['port_id'].'&stat=pkts&type=port_mac_acc_total&sort='.$vars['sort']."&from=$from&to=".$config['time']['now']."&width=150&height=50' />
|
||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
<div style='margin: 0px 0px 5px 10px; padding:5px; background: #e5e5e5;'>
|
<div style='margin: 0px 0px 5px 10px; padding:5px; background: #e5e5e5;'>
|
||||||
<span class=device-head>Top Input</span><br />
|
<span class=device-head>Top Input</span><br />
|
||||||
<a href='".generate_url($link_array, array('view' => 'macaccounting', 'subview' => 'top10', 'graph' => $vars['graph'], sort => 'in', 'period' => $vars['period']))."'>
|
<a href='".generate_url($link_array, array('view' => 'macaccounting', 'subview' => 'top10', 'graph' => $vars['graph'], 'sort' => 'in', 'period' => $vars['period']))."'>
|
||||||
<img style='border: #5e5e5e 2px;' valign=middle src='graph.php?id=".$port['port_id'].'&stat='.$vars['graph']."&type=port_mac_acc_total&sort=in&from=$from&to=".$config['time']['now']."&width=150&height=50' />
|
<img style='border: #5e5e5e 2px;' valign=middle src='graph.php?id=".$port['port_id'].'&stat='.$vars['graph']."&type=port_mac_acc_total&sort=in&from=$from&to=".$config['time']['now']."&width=150&height=50' />
|
||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
<div style='margin: 0px 0px 5px 10px; padding:5px; background: #e5e5e5;'>
|
<div style='margin: 0px 0px 5px 10px; padding:5px; background: #e5e5e5;'>
|
||||||
<span class=device-head>Top Output</span><br />
|
<span class=device-head>Top Output</span><br />
|
||||||
<a href='".generate_url($link_array, array('view' => 'macaccounting', 'subview' => 'top10', 'graph' => $vars['graph'], sort => 'out', 'period' => $vars['period']))."'>
|
<a href='".generate_url($link_array, array('view' => 'macaccounting', 'subview' => 'top10', 'graph' => $vars['graph'], 'sort' => 'out', 'period' => $vars['period']))."'>
|
||||||
<img style='border: #5e5e5e 2px;' valign=middle src='graph.php?id=".$port['port_id'].'&stat='.$vars['graph']."&type=port_mac_acc_total&sort=out&from=$from&to=".$config['time']['now']."&width=150&height=50' />
|
<img style='border: #5e5e5e 2px;' valign=middle src='graph.php?id=".$port['port_id'].'&stat='.$vars['graph']."&type=port_mac_acc_total&sort=out&from=$from&to=".$config['time']['now']."&width=150&height=50' />
|
||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
<div style='margin: 0px 0px 5px 10px; padding:5px; background: #e5e5e5;'>
|
<div style='margin: 0px 0px 5px 10px; padding:5px; background: #e5e5e5;'>
|
||||||
<span class=device-head>Top Aggregate</span><br />
|
<span class=device-head>Top Aggregate</span><br />
|
||||||
<a href='".generate_url($link_array, array('view' => 'macaccounting', 'subview' => 'top10', 'graph' => $vars['graph'], sort => 'both', 'period' => $vars['period']))."'>
|
<a href='".generate_url($link_array, array('view' => 'macaccounting', 'subview' => 'top10', 'graph' => $vars['graph'], 'sort' => 'both', 'period' => $vars['period']))."'>
|
||||||
<img style='border: #5e5e5e 2px;' valign=middle src='graph.php?id=".$port['port_id'].'&stat='.$vars['graph']."&type=port_mac_acc_total&sort=both&from=$from&to=".$config['time']['now']."&width=150&height=50' />
|
<img style='border: #5e5e5e 2px;' valign=middle src='graph.php?id=".$port['port_id'].'&stat='.$vars['graph']."&type=port_mac_acc_total&sort=both&from=$from&to=".$config['time']['now']."&width=150&height=50' />
|
||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -37,7 +37,7 @@ foreach ($vlans as $vlan) {
|
||||||
if ($otherport['untagged']) {
|
if ($otherport['untagged']) {
|
||||||
$traverse_ifvlan = false;
|
$traverse_ifvlan = false;
|
||||||
}
|
}
|
||||||
$vlan_ports[$otherport[ifIndex]] = $otherport;
|
$vlan_ports[$otherport['ifIndex']] = $otherport;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($traverse_ifvlan) {
|
if ($traverse_ifvlan) {
|
||||||
|
@ -46,7 +46,7 @@ foreach ($vlans as $vlan) {
|
||||||
array($device['device_id'], $vlan['vlan'])
|
array($device['device_id'], $vlan['vlan'])
|
||||||
);
|
);
|
||||||
foreach ($otherports as $otherport) {
|
foreach ($otherports as $otherport) {
|
||||||
$vlan_ports[$otherport[ifIndex]] = array_merge($otherport, array('untagged' => '1'));
|
$vlan_ports[$otherport['ifIndex']] = array_merge($otherport, array('untagged' => '1'));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -14,7 +14,7 @@ foreach ($ports as $port) {
|
||||||
$port['out_rate'] = formatRates(($port['ifOutOctets_rate'] * 8));
|
$port['out_rate'] = formatRates(($port['ifOutOctets_rate'] * 8));
|
||||||
|
|
||||||
if ($port['in_errors'] > 0 || $port['out_errors'] > 0) {
|
if ($port['in_errors'] > 0 || $port['out_errors'] > 0) {
|
||||||
$error_img = generate_port_link($port, "<i class='fa fa-flag fa-lg' style='color:red' aria-hidden='true'></i>", errors);
|
$error_img = generate_port_link($port, "<i class='fa fa-flag fa-lg' style='color:red' aria-hidden='true'></i>", 'errors');
|
||||||
} else {
|
} else {
|
||||||
$error_img = '';
|
$error_img = '';
|
||||||
}
|
}
|
||||||
|
|
16
html/pdf.php
16
html/pdf.php
|
@ -12,23 +12,11 @@
|
||||||
* the source code distribution for details.
|
* the source code distribution for details.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if (strpos($_SERVER['PATH_INFO'], 'debug')) {
|
|
||||||
$debug = '1';
|
|
||||||
ini_set('display_errors', 1);
|
|
||||||
ini_set('display_startup_errors', 1);
|
|
||||||
ini_set('log_errors', 1);
|
|
||||||
ini_set('error_reporting', E_ALL);
|
|
||||||
} else {
|
|
||||||
$debug = false;
|
|
||||||
ini_set('display_errors', 0);
|
|
||||||
ini_set('display_startup_errors', 0);
|
|
||||||
ini_set('log_errors', 0);
|
|
||||||
ini_set('error_reporting', 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
$init_modules = array('web', 'auth');
|
$init_modules = array('web', 'auth');
|
||||||
require realpath(__DIR__ . '/..') . '/includes/init.php';
|
require realpath(__DIR__ . '/..') . '/includes/init.php';
|
||||||
|
|
||||||
|
set_debug(strpos($_SERVER['PATH_INFO'], 'debug'));
|
||||||
|
|
||||||
$pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false);
|
$pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false);
|
||||||
|
|
||||||
$pdf->SetCreator($config['project_name']);
|
$pdf->SetCreator($config['project_name']);
|
||||||
|
|
|
@ -94,14 +94,14 @@ function getLastPortCounter($port_id, $bill_id)
|
||||||
$return = array();
|
$return = array();
|
||||||
$row = dbFetchRow("SELECT timestamp, in_counter, in_delta, out_counter, out_delta FROM bill_port_counters WHERE `port_id` = ? AND `bill_id` = ?", array($port_id, $bill_id));
|
$row = dbFetchRow("SELECT timestamp, in_counter, in_delta, out_counter, out_delta FROM bill_port_counters WHERE `port_id` = ? AND `bill_id` = ?", array($port_id, $bill_id));
|
||||||
if (!is_null($row)) {
|
if (!is_null($row)) {
|
||||||
$return[timestamp] = $row['timestamp'];
|
$return['timestamp'] = $row['timestamp'];
|
||||||
$return[in_counter] = $row['in_counter'];
|
$return['in_counter'] = $row['in_counter'];
|
||||||
$return[in_delta] = $row['in_delta'];
|
$return['in_delta'] = $row['in_delta'];
|
||||||
$return[out_counter] = $row['out_counter'];
|
$return['out_counter'] = $row['out_counter'];
|
||||||
$return[out_delta] = $row['out_delta'];
|
$return['out_delta'] = $row['out_delta'];
|
||||||
$return[state] = 'ok';
|
$return['state'] = 'ok';
|
||||||
} else {
|
} else {
|
||||||
$return[state] = 'failed';
|
$return['state'] = 'failed';
|
||||||
}
|
}
|
||||||
return $return;
|
return $return;
|
||||||
}//end getLastPortCounter()
|
}//end getLastPortCounter()
|
||||||
|
@ -112,13 +112,13 @@ function getLastMeasurement($bill_id)
|
||||||
$return = array();
|
$return = array();
|
||||||
$row = dbFetchRow("SELECT timestamp,delta,in_delta,out_delta FROM bill_data WHERE bill_id = ? ORDER BY timestamp DESC LIMIT 1", array($bill_id));
|
$row = dbFetchRow("SELECT timestamp,delta,in_delta,out_delta FROM bill_data WHERE bill_id = ? ORDER BY timestamp DESC LIMIT 1", array($bill_id));
|
||||||
if (!is_null($row)) {
|
if (!is_null($row)) {
|
||||||
$return[delta] = $row['delta'];
|
$return['delta'] = $row['delta'];
|
||||||
$return[delta_in] = $row['delta_in'];
|
$return['delta_in'] = $row['delta_in'];
|
||||||
$return[delta_out] = $row['delta_out'];
|
$return['delta_out'] = $row['delta_out'];
|
||||||
$return[timestamp] = $row['timestamp'];
|
$return['timestamp'] = $row['timestamp'];
|
||||||
$return[state] = 'ok';
|
$return['state'] = 'ok';
|
||||||
} else {
|
} else {
|
||||||
$return[state] = 'failed';
|
$return['state'] = 'failed';
|
||||||
}
|
}
|
||||||
return ($return);
|
return ($return);
|
||||||
}//end getLastMeasurement()
|
}//end getLastMeasurement()
|
||||||
|
@ -260,7 +260,7 @@ function getBillingBitsGraphData($bill_id, $from, $to, $reducefactor)
|
||||||
$out_data = array();
|
$out_data = array();
|
||||||
$tot_data = array();
|
$tot_data = array();
|
||||||
$ticks = array();
|
$ticks = array();
|
||||||
|
|
||||||
if (!isset($reducefactor) || !is_numeric($reducefactor) || $reducefactor < 1) {
|
if (!isset($reducefactor) || !is_numeric($reducefactor) || $reducefactor < 1) {
|
||||||
// Auto calculate reduce factor
|
// Auto calculate reduce factor
|
||||||
$expectedpoints = ceil(($to - $from) / 300);
|
$expectedpoints = ceil(($to - $from) / 300);
|
||||||
|
@ -316,7 +316,7 @@ function getBillingBitsGraphData($bill_id, $from, $to, $reducefactor)
|
||||||
'to' => $to,
|
'to' => $to,
|
||||||
'first' => $first,
|
'first' => $first,
|
||||||
'last' => $last,
|
'last' => $last,
|
||||||
|
|
||||||
'in_data' => $in_data,
|
'in_data' => $in_data,
|
||||||
'out_data' => $out_data,
|
'out_data' => $out_data,
|
||||||
'tot_data' => $tot_data,
|
'tot_data' => $tot_data,
|
||||||
|
@ -379,7 +379,7 @@ function getHistoricTransferGraphData($bill_id)
|
||||||
}
|
}
|
||||||
|
|
||||||
$graph_name = 'Historical bandwidth over the last 12 billing periods';
|
$graph_name = 'Historical bandwidth over the last 12 billing periods';
|
||||||
|
|
||||||
return array(
|
return array(
|
||||||
'graph_name' => $graph_name,
|
'graph_name' => $graph_name,
|
||||||
'in_data' => $in_data,
|
'in_data' => $in_data,
|
||||||
|
|
|
@ -667,14 +667,15 @@ function is_valid_hostname($hostname)
|
||||||
*/
|
*/
|
||||||
function d_echo($text, $no_debug_text = null)
|
function d_echo($text, $no_debug_text = null)
|
||||||
{
|
{
|
||||||
global $debug, $php_debug;
|
global $debug;
|
||||||
if ($debug) {
|
|
||||||
if (isset($php_debug)) {
|
if (class_exists('\Log')) {
|
||||||
$php_debug[] = $text;
|
\Log::debug(is_string($text) ? rtrim($text) : $text);
|
||||||
} else {
|
} elseif ($debug) {
|
||||||
print_r($text);
|
print_r($text);
|
||||||
}
|
}
|
||||||
} elseif ($no_debug_text) {
|
|
||||||
|
if (!$debug && $no_debug_text) {
|
||||||
echo "$no_debug_text";
|
echo "$no_debug_text";
|
||||||
}
|
}
|
||||||
} // d_echo
|
} // d_echo
|
||||||
|
@ -1684,12 +1685,12 @@ function uw_to_dbm($value)
|
||||||
*/
|
*/
|
||||||
function set_null($value, $default = null, $min = null)
|
function set_null($value, $default = null, $min = null)
|
||||||
{
|
{
|
||||||
if (is_nan($value)) {
|
if (!is_numeric($value)) {
|
||||||
|
return $default;
|
||||||
|
} elseif (is_nan($value)) {
|
||||||
return $default;
|
return $default;
|
||||||
} elseif (is_infinite($value)) {
|
} elseif (is_infinite($value)) {
|
||||||
return $default;
|
return $default;
|
||||||
} elseif (!is_numeric($value)) {
|
|
||||||
return $default;
|
|
||||||
} elseif (isset($min) && $value < $min) {
|
} elseif (isset($min) && $value < $min) {
|
||||||
return $default;
|
return $default;
|
||||||
}
|
}
|
||||||
|
@ -1702,10 +1703,9 @@ function set_null($value, $default = null, $min = null)
|
||||||
*/
|
*/
|
||||||
function set_numeric($value, $default = 0)
|
function set_numeric($value, $default = 0)
|
||||||
{
|
{
|
||||||
if (is_nan($value) ||
|
if (!is_numeric($value) ||
|
||||||
is_infinite($value) ||
|
is_nan($value) ||
|
||||||
!isset($value) ||
|
is_infinite($value)
|
||||||
!is_numeric($value)
|
|
||||||
) {
|
) {
|
||||||
$value = $default;
|
$value = $default;
|
||||||
}
|
}
|
||||||
|
|
|
@ -114,18 +114,17 @@ function dbConnect($db_host = null, $db_user = '', $db_pass = '', $db_name = '',
|
||||||
|
|
||||||
function dbQuery($sql, $parameters = array())
|
function dbQuery($sql, $parameters = array())
|
||||||
{
|
{
|
||||||
global $fullSql, $debug, $sql_debug, $database_link, $config;
|
global $fullSql, $debug, $database_link, $config;
|
||||||
$fullSql = dbMakeQuery($sql, $parameters);
|
$fullSql = dbMakeQuery($sql, $parameters);
|
||||||
if ($debug) {
|
if ($debug) {
|
||||||
if (php_sapi_name() == 'cli' && empty($_SERVER['REMOTE_ADDR'])) {
|
$fullSql = str_replace(PHP_EOL, '', $fullSql);
|
||||||
$fullSql = str_replace(PHP_EOL, '', $fullSql);
|
|
||||||
if (preg_match('/(INSERT INTO `alert_log`).*(details)/i', $fullSql)) {
|
// hide binary field updates and inserts
|
||||||
echo "\nINSERT INTO `alert_log` entry masked due to binary data\n";
|
$fullSql = preg_replace("/(.*alert_log.*details[` ]*= *')[^']*('.*)/i", '$1<binary data>$2', $fullSql);
|
||||||
} else {
|
if (class_exists('Log')) {
|
||||||
c_echo('SQL[%y'.$fullSql."%n] \n");
|
Log::info("SQL[%y$fullSql%n]", ['color' => true]);
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
$sql_debug[] = $fullSql;
|
c_echo("SQL[%y$fullSql%n] \n");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -374,26 +373,28 @@ function dbDeleteOrphans($target_table, $parents)
|
||||||
function dbFetchRows($sql, $parameters = array())
|
function dbFetchRows($sql, $parameters = array())
|
||||||
{
|
{
|
||||||
$time_start = microtime(true);
|
$time_start = microtime(true);
|
||||||
$result = dbQuery($sql, $parameters);
|
$result = dbQuery($sql, $parameters);
|
||||||
|
|
||||||
if (mysqli_num_rows($result) > 0) {
|
if ($result !== false) {
|
||||||
$rows = array();
|
if (mysqli_num_rows($result) > 0) {
|
||||||
while ($row = mysqli_fetch_assoc($result)) {
|
$rows = [];
|
||||||
$rows[] = $row;
|
while ($row = mysqli_fetch_assoc($result)) {
|
||||||
|
$rows[] = $row;
|
||||||
|
}
|
||||||
|
|
||||||
|
mysqli_free_result($result);
|
||||||
|
|
||||||
|
recordDbStatistic('fetchrows', $time_start);
|
||||||
|
return $rows;
|
||||||
}
|
}
|
||||||
|
|
||||||
mysqli_free_result($result);
|
mysqli_free_result($result);
|
||||||
|
|
||||||
recordDbStatistic('fetchrows', $time_start);
|
|
||||||
return $rows;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
mysqli_free_result($result);
|
|
||||||
|
|
||||||
// no records, thus return empty array
|
// no records, thus return empty array
|
||||||
// which should evaluate to false, and will prevent foreach notices/warnings
|
// which should evaluate to false, and will prevent foreach notices/warnings
|
||||||
recordDbStatistic('fetchrows', $time_start);
|
recordDbStatistic('fetchrows', $time_start);
|
||||||
return array();
|
return [];
|
||||||
}//end dbFetchRows()
|
}//end dbFetchRows()
|
||||||
|
|
||||||
|
|
||||||
|
@ -654,7 +655,7 @@ function dbGenPlaceholders($count)
|
||||||
*/
|
*/
|
||||||
function recordDbStatistic($stat, $start_time)
|
function recordDbStatistic($stat, $start_time)
|
||||||
{
|
{
|
||||||
global $db_stats;
|
global $db_stats, $db_stats_last;
|
||||||
|
|
||||||
if (!isset($db_stats)) {
|
if (!isset($db_stats)) {
|
||||||
$db_stats = array(
|
$db_stats = array(
|
||||||
|
@ -677,6 +678,7 @@ function recordDbStatistic($stat, $start_time)
|
||||||
'fetchrows' => 0.0,
|
'fetchrows' => 0.0,
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
$db_stats_last = $db_stats;
|
||||||
}
|
}
|
||||||
|
|
||||||
$runtime = microtime(true) - $start_time;
|
$runtime = microtime(true) - $start_time;
|
||||||
|
|
|
@ -769,7 +769,6 @@ $config['poller_modules']['applications'] = true;
|
||||||
$config['poller_modules']['mib'] = false;
|
$config['poller_modules']['mib'] = false;
|
||||||
$config['poller_modules']['stp'] = true;
|
$config['poller_modules']['stp'] = true;
|
||||||
$config['poller_modules']['ntp'] = true;
|
$config['poller_modules']['ntp'] = true;
|
||||||
$config['poller_modules']['services'] = true;
|
|
||||||
$config['poller_modules']['loadbalancers'] = false;
|
$config['poller_modules']['loadbalancers'] = false;
|
||||||
$config['poller_modules']['mef'] = false;
|
$config['poller_modules']['mef'] = false;
|
||||||
|
|
||||||
|
|
|
@ -25,6 +25,8 @@
|
||||||
* @subpackage Devices
|
* @subpackage Devices
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
use LibreNMS\Config;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add a new device group
|
* Add a new device group
|
||||||
* @param $pattern
|
* @param $pattern
|
||||||
|
@ -263,9 +265,10 @@ function GetGroupsFromDevice($device_id, $extra = 0)
|
||||||
*/
|
*/
|
||||||
function RunGroupMacros($rule, $x = 1)
|
function RunGroupMacros($rule, $x = 1)
|
||||||
{
|
{
|
||||||
global $config;
|
$macros = Config::get('alert.macros.group', []);
|
||||||
krsort($config['alert']['macros']['group']);
|
|
||||||
foreach ($config['alert']['macros']['group'] as $macro => $value) {
|
krsort($macros);
|
||||||
|
foreach ($macros as $macro => $value) {
|
||||||
if (!strstr($macro, " ")) {
|
if (!strstr($macro, " ")) {
|
||||||
$rule = str_replace('%macros.'.$macro, '('.$value.')', $rule);
|
$rule = str_replace('%macros.'.$macro, '('.$value.')', $rule);
|
||||||
}
|
}
|
||||||
|
|
|
@ -84,7 +84,7 @@ if ($device['os_group'] == 'cisco') {
|
||||||
// No Error, lets process things.
|
// No Error, lets process things.
|
||||||
|
|
||||||
// Add each overlay to the array.
|
// Add each overlay to the array.
|
||||||
foreach ($tblOverlayEntry['1.3.6.1.4.1.9.9.810.1.2.1.1.2'] as $index => $name) {
|
foreach ((array)$tblOverlayEntry['1.3.6.1.4.1.9.9.810.1.2.1.1.2'] as $index => $name) {
|
||||||
$result = array();
|
$result = array();
|
||||||
$message = false;
|
$message = false;
|
||||||
$result['index'] = $index;
|
$result['index'] = $index;
|
||||||
|
@ -132,7 +132,7 @@ if ($device['os_group'] == 'cisco') {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add each adjacency to the array.
|
// Add each adjacency to the array.
|
||||||
foreach ($tblAdjacentDevName as $key => $value) {
|
foreach ((array)$tblAdjacentDevName as $key => $value) {
|
||||||
preg_match('/^1.3.6.1.4.1.9.9.810.1.3.1.1.4.(\d+).1.4.(\d+.\d+.\d+.\d+)$/', $key, $matches);
|
preg_match('/^1.3.6.1.4.1.9.9.810.1.3.1.1.4.(\d+).1.4.(\d+.\d+.\d+.\d+)$/', $key, $matches);
|
||||||
$result = array();
|
$result = array();
|
||||||
$result['index'] = $matches[1];
|
$result['index'] = $matches[1];
|
||||||
|
@ -202,7 +202,7 @@ if ($device['os_group'] == 'cisco') {
|
||||||
$component_key = false;
|
$component_key = false;
|
||||||
|
|
||||||
// Loop over our components to determine if the component exists, or we need to add it.
|
// Loop over our components to determine if the component exists, or we need to add it.
|
||||||
foreach ($components as $compid => $child) {
|
foreach ((array)$components as $compid => $child) {
|
||||||
if ($child['UID'] === $array['UID']) {
|
if ($child['UID'] === $array['UID']) {
|
||||||
$component_key = $compid;
|
$component_key = $compid;
|
||||||
}
|
}
|
||||||
|
@ -224,7 +224,7 @@ if ($device['os_group'] == 'cisco') {
|
||||||
/*
|
/*
|
||||||
* Loop over the Component data to see if we need to DELETE any components.
|
* Loop over the Component data to see if we need to DELETE any components.
|
||||||
*/
|
*/
|
||||||
foreach ($components as $key => $array) {
|
foreach ((array)$components as $key => $array) {
|
||||||
// Guilty until proven innocent
|
// Guilty until proven innocent
|
||||||
$found = false;
|
$found = false;
|
||||||
|
|
||||||
|
|
|
@ -3,18 +3,13 @@
|
||||||
use LibreNMS\Config;
|
use LibreNMS\Config;
|
||||||
|
|
||||||
if (Config::get('enable_pseudowires') && $device['os_group'] == 'cisco') {
|
if (Config::get('enable_pseudowires') && $device['os_group'] == 'cisco') {
|
||||||
unset($cpw_count);
|
$pws_db = [];
|
||||||
unset($cpw_exists);
|
|
||||||
|
|
||||||
// Pre-cache the existing state of pseudowires for this device from the database
|
// Pre-cache the existing state of pseudowires for this device from the database
|
||||||
$pws_db_raw = dbFetchRows('SELECT * FROM `pseudowires` WHERE `device_id` = ?', array($device['device_id']));
|
$pws_db_raw = dbFetchRows('SELECT * FROM `pseudowires` WHERE `device_id` = ?', array($device['device_id']));
|
||||||
foreach ($pws_db_raw as $pw_db) {
|
foreach ($pws_db_raw as $pw_db) {
|
||||||
$device['pws_db'][$pw_db['cpwVcID']] = $pw_db['pseudowire_id'];
|
$pws_db[$pw_db['cpwVcID']] = $pw_db['pseudowire_id'];
|
||||||
}
|
}
|
||||||
|
|
||||||
unset($pws_db_raw);
|
|
||||||
unset($pw_db);
|
|
||||||
|
|
||||||
$pws = snmpwalk_cache_oid($device, 'cpwVcID', array(), 'CISCO-IETF-PW-MPLS-MIB');
|
$pws = snmpwalk_cache_oid($device, 'cpwVcID', array(), 'CISCO-IETF-PW-MPLS-MIB');
|
||||||
$pws = snmpwalk_cache_oid($device, 'cpwVcName', $pws, 'CISCO-IETF-PW-MPLS-MIB');
|
$pws = snmpwalk_cache_oid($device, 'cpwVcName', $pws, 'CISCO-IETF-PW-MPLS-MIB');
|
||||||
$pws = snmpwalk_cache_oid($device, 'cpwVcType', $pws, 'CISCO-IETF-PW-MPLS-MIB');
|
$pws = snmpwalk_cache_oid($device, 'cpwVcType', $pws, 'CISCO-IETF-PW-MPLS-MIB');
|
||||||
|
@ -28,8 +23,8 @@ if (Config::get('enable_pseudowires') && $device['os_group'] == 'cisco') {
|
||||||
list($cpw_remote_id) = explode(':', $pw['cpwVcMplsPeerLdpID']);
|
list($cpw_remote_id) = explode(':', $pw['cpwVcMplsPeerLdpID']);
|
||||||
$cpw_remote_device = dbFetchCell('SELECT device_id from ipv4_addresses AS A, ports AS I WHERE A.ipv4_address=? AND A.port_id=I.port_id', array($cpw_remote_id));
|
$cpw_remote_device = dbFetchCell('SELECT device_id from ipv4_addresses AS A, ports AS I WHERE A.ipv4_address=? AND A.port_id=I.port_id', array($cpw_remote_id));
|
||||||
$if_id = dbFetchCell('SELECT port_id from ports WHERE `ifDescr`=? AND `device_id`=?', array($pw['cpwVcName'], $device['device_id']));
|
$if_id = dbFetchCell('SELECT port_id from ports WHERE `ifDescr`=? AND `device_id`=?', array($pw['cpwVcName'], $device['device_id']));
|
||||||
if (!empty($device['pws_db'][$pw['cpwVcID']])) {
|
if (!empty($pws_db[$pw['cpwVcID']])) {
|
||||||
$pseudowire_id = $device['pws_db'][$pw['cpwVcID']];
|
$pseudowire_id = $pws_db[$pw['cpwVcID']];
|
||||||
echo '.';
|
echo '.';
|
||||||
} else {
|
} else {
|
||||||
$pseudowire_id = dbInsert(
|
$pseudowire_id = dbInsert(
|
||||||
|
@ -53,7 +48,7 @@ if (Config::get('enable_pseudowires') && $device['os_group'] == 'cisco') {
|
||||||
}//end foreach
|
}//end foreach
|
||||||
|
|
||||||
// Cycle the list of pseudowires we cached earlier and make sure we saw them again.
|
// Cycle the list of pseudowires we cached earlier and make sure we saw them again.
|
||||||
foreach ($device['pws_db'] as $pw_id => $pseudowire_id) {
|
foreach ($pws_db as $pw_id => $pseudowire_id) {
|
||||||
if (empty($device['pws'][$pw_id])) {
|
if (empty($device['pws'][$pw_id])) {
|
||||||
dbDelete('pseudowires', '`pseudowire_id` = ?', array($pseudowire_id));
|
dbDelete('pseudowires', '`pseudowire_id` = ?', array($pseudowire_id));
|
||||||
}
|
}
|
||||||
|
@ -61,3 +56,5 @@ if (Config::get('enable_pseudowires') && $device['os_group'] == 'cisco') {
|
||||||
|
|
||||||
echo "\n";
|
echo "\n";
|
||||||
} //end if
|
} //end if
|
||||||
|
|
||||||
|
unset($pws_db, $pws_db_raw, $pw_db);
|
||||||
|
|
|
@ -62,7 +62,7 @@ if (Config::get('enable_vrf_lite_cisco')) {
|
||||||
}
|
}
|
||||||
unset($listIntance);
|
unset($listIntance);
|
||||||
|
|
||||||
foreach ($tableVrf as $context => $vrf) {
|
foreach ((array)$tableVrf as $context => $vrf) {
|
||||||
if ($debug) {
|
if ($debug) {
|
||||||
echo ("\n[DEBUG]\nRelation:t" . $context . "t" . $vrf['intance'] . "t" . $vrf['vrf'] . "\n[/DEBUG]\n");
|
echo ("\n[DEBUG]\nRelation:t" . $context . "t" . $vrf['intance'] . "t" . $vrf['vrf'] . "\n[/DEBUG]\n");
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,7 +30,7 @@ foreach ($vtpdomains as $vtpdomain_id => $vtpdomain) {
|
||||||
$portid_dict[$portLocal] = $port['port_id'];
|
$portid_dict[$portLocal] = $port['port_id'];
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach ($fdbPort_table['dot1dTpFdbPort'] as $mac => $dot1dBasePort) {
|
foreach ((array)$fdbPort_table['dot1dTpFdbPort'] as $mac => $dot1dBasePort) {
|
||||||
$mac_address = implode(array_map('zeropad', explode(':', $mac)));
|
$mac_address = implode(array_map('zeropad', explode(':', $mac)));
|
||||||
if (strlen($mac_address) != 12) {
|
if (strlen($mac_address) != 12) {
|
||||||
d_echo("MAC address padding failed for $mac\n");
|
d_echo("MAC address padding failed for $mac\n");
|
||||||
|
|
|
@ -947,7 +947,7 @@ function can_skip_sensor($value, $data, $group, $pre_cache = array())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$skip_value_gt = array_reduce((array)$group['skip_value_gt'], (array)$data['skip_value_gt']);
|
$skip_value_gt = array_replace((array)$group['skip_value_gt'], (array)$data['skip_value_gt']);
|
||||||
foreach ($skip_value_gt as $skip_value) {
|
foreach ($skip_value_gt as $skip_value) {
|
||||||
if ($value > $skip_value) {
|
if ($value > $skip_value) {
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -45,7 +45,7 @@ $components = $keep;
|
||||||
// Begin our master array, all other values will be processed into this array.
|
// Begin our master array, all other values will be processed into this array.
|
||||||
$tblBigIP = array();
|
$tblBigIP = array();
|
||||||
|
|
||||||
if ((snmp_get($device, 'sysModuleAllocationProvisionLevel.3.103.116.109', '-Ovqs', 'F5-BIGIP-SYSTEM-MIB')) !=none) {
|
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);
|
$gtmWideIPEntry = snmpwalk_array_num($device, '1.3.6.1.4.1.3375.2.3.12.1.2.1', 0);
|
||||||
if (!is_null($gtmWideIPEntry)) {
|
if (!is_null($gtmWideIPEntry)) {
|
||||||
$gtmWideStatusEntry = snmpwalk_array_num($device, '1.3.6.1.4.1.3375.2.3.12.3.2.1', 0);
|
$gtmWideStatusEntry = snmpwalk_array_num($device, '1.3.6.1.4.1.3375.2.3.12.3.2.1', 0);
|
||||||
|
|
|
@ -46,18 +46,18 @@ $tblBigIP = array();
|
||||||
|
|
||||||
// Virtual Server Data
|
// Virtual Server Data
|
||||||
$ltmVirtualServOID = array(
|
$ltmVirtualServOID = array(
|
||||||
ip => '1.3.6.1.4.1.3375.2.2.10.1.2.1.3',
|
'ip' => '1.3.6.1.4.1.3375.2.2.10.1.2.1.3',
|
||||||
port => '1.3.6.1.4.1.3375.2.2.10.1.2.1.6',
|
'port' => '1.3.6.1.4.1.3375.2.2.10.1.2.1.6',
|
||||||
defaultpool => '1.3.6.1.4.1.3375.2.2.10.1.2.1.19',
|
'defaultpool' => '1.3.6.1.4.1.3375.2.2.10.1.2.1.19',
|
||||||
state => '1.3.6.1.4.1.3375.2.2.10.13.2.1.2',
|
'state' => '1.3.6.1.4.1.3375.2.2.10.13.2.1.2',
|
||||||
errorcode => '1.3.6.1.4.1.3375.2.2.10.13.2.1.5',
|
'errorcode' => '1.3.6.1.4.1.3375.2.2.10.13.2.1.5',
|
||||||
);
|
);
|
||||||
|
|
||||||
$ltmVirtualServEntry = [];
|
$ltmVirtualServEntry = [];
|
||||||
//Check for Virtual Server Enries
|
//Check for Virtual Server Enries
|
||||||
$ltmVirtualServEntry[name] = snmpwalk_array_num($device, '1.3.6.1.4.1.3375.2.2.10.1.2.1.1', 0);
|
$ltmVirtualServEntry['name'] = snmpwalk_array_num($device, '1.3.6.1.4.1.3375.2.2.10.1.2.1.1', 0);
|
||||||
//If no Virtual Servers are found don't look for statistics
|
//If no Virtual Servers are found don't look for statistics
|
||||||
if (!empty($ltmVirtualServEntry[name])) {
|
if (!empty($ltmVirtualServEntry['name'])) {
|
||||||
foreach ($ltmVirtualServOID as $key => $value) {
|
foreach ($ltmVirtualServOID as $key => $value) {
|
||||||
$ltmVirtualServEntry[$key] = snmpwalk_array_num($device, $value, 0);
|
$ltmVirtualServEntry[$key] = snmpwalk_array_num($device, $value, 0);
|
||||||
}
|
}
|
||||||
|
@ -67,40 +67,40 @@ if (!empty($ltmVirtualServEntry[name])) {
|
||||||
|
|
||||||
// Pool Data
|
// Pool Data
|
||||||
$ltmPoolEntryOID = array(
|
$ltmPoolEntryOID = array(
|
||||||
mode => '1.3.6.1.4.1.3375.2.2.5.1.2.1.2',
|
'mode' => '1.3.6.1.4.1.3375.2.2.5.1.2.1.2',
|
||||||
minup => '1.3.6.1.4.1.3375.2.2.5.1.2.1.4',
|
'minup' => '1.3.6.1.4.1.3375.2.2.5.1.2.1.4',
|
||||||
minupstatus => '1.3.6.1.4.1.3375.2.2.5.1.2.1.5',
|
'minupstatus' => '1.3.6.1.4.1.3375.2.2.5.1.2.1.5',
|
||||||
minupaction => '1.3.6.1.4.1.3375.2.2.5.1.2.1.6',
|
'minupaction' => '1.3.6.1.4.1.3375.2.2.5.1.2.1.6',
|
||||||
currentup => '1.3.6.1.4.1.3375.2.2.5.1.2.1.8',
|
'currentup' => '1.3.6.1.4.1.3375.2.2.5.1.2.1.8',
|
||||||
monitor => '1.3.6.1.4.1.3375.2.2.5.1.2.1.17',
|
'monitor' => '1.3.6.1.4.1.3375.2.2.5.1.2.1.17',
|
||||||
);
|
);
|
||||||
|
|
||||||
// Pool Member Data
|
// Pool Member Data
|
||||||
$ltmPoolMemberEntryOID = array(
|
$ltmPoolMemberEntryOID = array(
|
||||||
ip => '1.3.6.1.4.1.3375.2.2.5.3.2.1.3',
|
'ip' => '1.3.6.1.4.1.3375.2.2.5.3.2.1.3',
|
||||||
port => '1.3.6.1.4.1.3375.2.2.5.3.2.1.4',
|
'port' => '1.3.6.1.4.1.3375.2.2.5.3.2.1.4',
|
||||||
ratio => '1.3.6.1.4.1.3375.2.2.5.3.2.1.6',
|
'ratio' => '1.3.6.1.4.1.3375.2.2.5.3.2.1.6',
|
||||||
weight => '1.3.6.1.4.1.3375.2.2.5.3.2.1.7',
|
'weight' => '1.3.6.1.4.1.3375.2.2.5.3.2.1.7',
|
||||||
priority => '1.3.6.1.4.1.3375.2.2.5.3.2.1.8',
|
'priority' => '1.3.6.1.4.1.3375.2.2.5.3.2.1.8',
|
||||||
state => '1.3.6.1.4.1.3375.2.2.5.6.2.1.5',
|
'state' => '1.3.6.1.4.1.3375.2.2.5.6.2.1.5',
|
||||||
available => '1.3.6.1.4.1.3375.2.2.5.6.2.1.6',
|
'available' => '1.3.6.1.4.1.3375.2.2.5.6.2.1.6',
|
||||||
errorcode => '1.3.6.1.4.1.3375.2.2.5.6.2.1.8',
|
'errorcode' => '1.3.6.1.4.1.3375.2.2.5.6.2.1.8',
|
||||||
);
|
);
|
||||||
|
|
||||||
//Check for Pool Enries
|
//Check for Pool Enries
|
||||||
$ltmPoolEntry = [];
|
$ltmPoolEntry = [];
|
||||||
$ltmPoolMemberEntry = [];
|
$ltmPoolMemberEntry = [];
|
||||||
$ltmPoolEntry[name] = snmpwalk_array_num($device, '1.3.6.1.4.1.3375.2.2.5.1.2.1.1', 0);
|
$ltmPoolEntry['name'] = snmpwalk_array_num($device, '1.3.6.1.4.1.3375.2.2.5.1.2.1.1', 0);
|
||||||
|
|
||||||
//If no Pools are found don't look for statistics or pool members
|
//If no Pools are found don't look for statistics or pool members
|
||||||
if (!empty($ltmPoolEntry[name])) {
|
if (!empty($ltmPoolEntry['name'])) {
|
||||||
// If there are pools gather Pool Member Data
|
// If there are pools gather Pool Member Data
|
||||||
foreach ($ltmPoolEntryOID as $key => $value) {
|
foreach ($ltmPoolEntryOID as $key => $value) {
|
||||||
$ltmPoolEntry[$key] = snmpwalk_array_num($device, $value, 0);
|
$ltmPoolEntry[$key] = snmpwalk_array_num($device, $value, 0);
|
||||||
}
|
}
|
||||||
// Gather Pool Member Data if pool members found
|
// Gather Pool Member Data if pool members found
|
||||||
$ltmPoolMemberEntry[name] = snmpwalk_array_num($device, '1.3.6.1.4.1.3375.2.2.5.3.2.1.1', 0);
|
$ltmPoolMemberEntry['name'] = snmpwalk_array_num($device, '1.3.6.1.4.1.3375.2.2.5.3.2.1.1', 0);
|
||||||
if (!empty($ltmPoolMemberEntry[name])) {
|
if (!empty($ltmPoolMemberEntry['name'])) {
|
||||||
foreach ($ltmPoolMemberEntryOID as $key => $value) {
|
foreach ($ltmPoolMemberEntryOID as $key => $value) {
|
||||||
$ltmPoolMemberEntry[$key] = snmpwalk_array_num($device, $value, 0);
|
$ltmPoolMemberEntry[$key] = snmpwalk_array_num($device, $value, 0);
|
||||||
}
|
}
|
||||||
|
@ -118,8 +118,8 @@ if (!empty($ltmVirtualServEntry) || !empty($ltmPoolEntry) || !empty($ltmPoolMemb
|
||||||
d_echo("Objects Found:\n");
|
d_echo("Objects Found:\n");
|
||||||
|
|
||||||
// Process the Virtual Servers
|
// Process the Virtual Servers
|
||||||
if (is_array($ltmVirtualServEntry[name])) {
|
if (is_array($ltmVirtualServEntry['name'])) {
|
||||||
foreach ($ltmVirtualServEntry[name] as $oid => $value) {
|
foreach ($ltmVirtualServEntry['name'] as $oid => $value) {
|
||||||
$result = array();
|
$result = array();
|
||||||
|
|
||||||
// Find all Virtual server names and UID's, then we can find everything else we need.
|
// Find all Virtual server names and UID's, then we can find everything else we need.
|
||||||
|
@ -132,25 +132,25 @@ if (!empty($ltmVirtualServEntry) || !empty($ltmPoolEntry) || !empty($ltmPoolMemb
|
||||||
$result['hash'] = hash('crc32', $result['UID']);
|
$result['hash'] = hash('crc32', $result['UID']);
|
||||||
|
|
||||||
// Trim IPv4 response to remove route domain ID
|
// Trim IPv4 response to remove route domain ID
|
||||||
if (strlen($ltmVirtualServEntry[ip]['1.3.6.1.4.1.3375.2.2.10.1.2.1.3.'.$index]) == 23) {
|
if (strlen($ltmVirtualServEntry['ip']['1.3.6.1.4.1.3375.2.2.10.1.2.1.3.'.$index]) == 23) {
|
||||||
$ltmVirtualServEntry[ip]['1.3.6.1.4.1.3375.2.2.10.1.2.1.3.'.$index] = substr($ltmVirtualServEntry[ip]['1.3.6.1.4.1.3375.2.2.10.1.2.1.3.'.$index], 0, 11);
|
$ltmVirtualServEntry['ip']['1.3.6.1.4.1.3375.2.2.10.1.2.1.3.'.$index] = substr($ltmVirtualServEntry['ip']['1.3.6.1.4.1.3375.2.2.10.1.2.1.3.'.$index], 0, 11);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Now that we have our UID we can pull all the other data we need.
|
// Now that we have our UID we can pull all the other data we need.
|
||||||
$result['IP'] = IP::fromHexString($ltmVirtualServEntry[ip]['1.3.6.1.4.1.3375.2.2.10.1.2.1.3.'.$index], true);
|
$result['IP'] = IP::fromHexString($ltmVirtualServEntry['ip']['1.3.6.1.4.1.3375.2.2.10.1.2.1.3.'.$index], true);
|
||||||
$result['port'] = $ltmVirtualServEntry[port]['1.3.6.1.4.1.3375.2.2.10.1.2.1.6.'.$index];
|
$result['port'] = $ltmVirtualServEntry['port']['1.3.6.1.4.1.3375.2.2.10.1.2.1.6.'.$index];
|
||||||
$result['pool'] = $ltmVirtualServEntry[defaultpool]['1.3.6.1.4.1.3375.2.2.10.1.2.1.19.'.$index];
|
$result['pool'] = $ltmVirtualServEntry['defaultpool']['1.3.6.1.4.1.3375.2.2.10.1.2.1.19.'.$index];
|
||||||
|
|
||||||
// 0 = None, 1 = Green, 2 = Yellow, 3 = Red, 4 = Blue
|
// 0 = None, 1 = Green, 2 = Yellow, 3 = Red, 4 = Blue
|
||||||
$result['state'] = $ltmVirtualServEntry[state]['1.3.6.1.4.1.3375.2.2.10.13.2.1.2.'.$index];
|
$result['state'] = $ltmVirtualServEntry['state']['1.3.6.1.4.1.3375.2.2.10.13.2.1.2.'.$index];
|
||||||
if ($result['state'] == 2) {
|
if ($result['state'] == 2) {
|
||||||
// Looks like one of the VS Pool members is down.
|
// Looks like one of the VS Pool members is down.
|
||||||
$result['status'] = 1;
|
$result['status'] = 1;
|
||||||
$result['error'] = $ltmVirtualServEntry[errorcode]['1.3.6.1.4.1.3375.2.2.10.13.2.1.5.'.$index];
|
$result['error'] = $ltmVirtualServEntry['errorcode']['1.3.6.1.4.1.3375.2.2.10.13.2.1.5.'.$index];
|
||||||
} elseif ($result['state'] == 3) {
|
} elseif ($result['state'] == 3) {
|
||||||
// Looks like ALL of the VS Pool members is down.
|
// Looks like ALL of the VS Pool members is down.
|
||||||
$result['status'] = 2;
|
$result['status'] = 2;
|
||||||
$result['error'] = $ltmVirtualServEntry[errorcode]['1.3.6.1.4.1.3375.2.2.10.13.2.1.5.'.$index];
|
$result['error'] = $ltmVirtualServEntry['errorcode']['1.3.6.1.4.1.3375.2.2.10.13.2.1.5.'.$index];
|
||||||
} else {
|
} else {
|
||||||
// All is good.
|
// All is good.
|
||||||
$result['status'] = 0;
|
$result['status'] = 0;
|
||||||
|
@ -172,8 +172,8 @@ if (!empty($ltmVirtualServEntry) || !empty($ltmPoolEntry) || !empty($ltmPoolMemb
|
||||||
}
|
}
|
||||||
|
|
||||||
// Process the Pools
|
// Process the Pools
|
||||||
if (is_array($ltmPoolEntry[name])) {
|
if (is_array($ltmPoolEntry['name'])) {
|
||||||
foreach ($ltmPoolEntry[name] as $oid => $value) {
|
foreach ($ltmPoolEntry['name'] as $oid => $value) {
|
||||||
$result = array ();
|
$result = array ();
|
||||||
|
|
||||||
// Find all Pool names and UID's, then we can find everything else we need.
|
// Find all Pool names and UID's, then we can find everything else we need.
|
||||||
|
@ -186,12 +186,12 @@ if (!empty($ltmVirtualServEntry) || !empty($ltmPoolEntry) || !empty($ltmPoolMemb
|
||||||
$result['hash'] = hash('crc32', $result['UID']);
|
$result['hash'] = hash('crc32', $result['UID']);
|
||||||
|
|
||||||
// Now that we have our UID we can pull all the other data we need.
|
// Now that we have our UID we can pull all the other data we need.
|
||||||
$result['mode'] = $ltmPoolEntry[mode]['1.3.6.1.4.1.3375.2.2.5.1.2.1.2.'.$index];
|
$result['mode'] = $ltmPoolEntry['mode']['1.3.6.1.4.1.3375.2.2.5.1.2.1.2.'.$index];
|
||||||
$result['minup'] = $ltmPoolEntry[minup]['1.3.6.1.4.1.3375.2.2.5.1.2.1.4.'.$index];
|
$result['minup'] = $ltmPoolEntry['minup']['1.3.6.1.4.1.3375.2.2.5.1.2.1.4.'.$index];
|
||||||
$result['minupstatus'] = $ltmPoolEntry[minupstatus]['1.3.6.1.4.1.3375.2.2.5.1.2.1.5.'.$index];
|
$result['minupstatus'] = $ltmPoolEntry['minupstatus']['1.3.6.1.4.1.3375.2.2.5.1.2.1.5.'.$index];
|
||||||
$result['currentup'] = $ltmPoolEntry[currentup]['1.3.6.1.4.1.3375.2.2.5.1.2.1.8.'.$index];
|
$result['currentup'] = $ltmPoolEntry['currentup']['1.3.6.1.4.1.3375.2.2.5.1.2.1.8.'.$index];
|
||||||
$result['minupaction'] = $ltmPoolEntry[minupaction]['1.3.6.1.4.1.3375.2.2.5.1.2.1.6.'.$index];
|
$result['minupaction'] = $ltmPoolEntry['minupaction']['1.3.6.1.4.1.3375.2.2.5.1.2.1.6.'.$index];
|
||||||
$result['monitor'] = $ltmPoolEntry[monitor]['1.3.6.1.4.1.3375.2.2.5.1.2.1.17.'.$index];
|
$result['monitor'] = $ltmPoolEntry['monitor']['1.3.6.1.4.1.3375.2.2.5.1.2.1.17.'.$index];
|
||||||
|
|
||||||
// If we have less pool members than the minimum, we should error.
|
// If we have less pool members than the minimum, we should error.
|
||||||
if ($result['currentup'] < $result['minup']) {
|
if ($result['currentup'] < $result['minup']) {
|
||||||
|
@ -219,8 +219,8 @@ if (!empty($ltmVirtualServEntry) || !empty($ltmPoolEntry) || !empty($ltmPoolMemb
|
||||||
}
|
}
|
||||||
|
|
||||||
// Process the Pool Members
|
// Process the Pool Members
|
||||||
if (is_array($ltmPoolMemberEntry[name])) {
|
if (is_array($ltmPoolMemberEntry['name'])) {
|
||||||
foreach ($ltmPoolMemberEntry[name] as $oid => $value) {
|
foreach ($ltmPoolMemberEntry['name'] as $oid => $value) {
|
||||||
$result = array ();
|
$result = array ();
|
||||||
|
|
||||||
// Find all Pool member names and UID's, then we can find everything else we need.
|
// Find all Pool member names and UID's, then we can find everything else we need.
|
||||||
|
@ -233,25 +233,25 @@ if (!empty($ltmVirtualServEntry) || !empty($ltmPoolEntry) || !empty($ltmPoolMemb
|
||||||
$result['hash'] = hash('crc32', $result['UID']);
|
$result['hash'] = hash('crc32', $result['UID']);
|
||||||
|
|
||||||
//Remove route domain ID from v4 IPs
|
//Remove route domain ID from v4 IPs
|
||||||
if (strlen($ltmPoolMemberEntry[ip]['1.3.6.1.4.1.3375.2.2.5.3.2.1.3.'.$index]) == 23) {
|
if (strlen($ltmPoolMemberEntry['ip']['1.3.6.1.4.1.3375.2.2.5.3.2.1.3.'.$index]) == 23) {
|
||||||
$ltmPoolMemberEntry[ip]['1.3.6.1.4.1.3375.2.2.5.3.2.1.3.'.$index] = substr($ltmPoolMemberEntry[ip]['1.3.6.1.4.1.3375.2.2.5.3.2.1.3.'.$index], 0, 11);
|
$ltmPoolMemberEntry['ip']['1.3.6.1.4.1.3375.2.2.5.3.2.1.3.'.$index] = substr($ltmPoolMemberEntry['ip']['1.3.6.1.4.1.3375.2.2.5.3.2.1.3.'.$index], 0, 11);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Now that we have our UID we can pull all the other data we need.
|
// Now that we have our UID we can pull all the other data we need.
|
||||||
$result['IP'] = IP::fromHexString($ltmPoolMemberEntry[ip]['1.3.6.1.4.1.3375.2.2.5.3.2.1.3.'.$index], true);
|
$result['IP'] = IP::fromHexString($ltmPoolMemberEntry['ip']['1.3.6.1.4.1.3375.2.2.5.3.2.1.3.'.$index], true);
|
||||||
$result['port'] = $ltmPoolMemberEntry[port]['1.3.6.1.4.1.3375.2.2.5.3.2.1.4.'.$index];
|
$result['port'] = $ltmPoolMemberEntry['port']['1.3.6.1.4.1.3375.2.2.5.3.2.1.4.'.$index];
|
||||||
$result['ratio'] = $ltmPoolMemberEntry[ratio]['1.3.6.1.4.1.3375.2.2.5.3.2.1.6.'.$index];
|
$result['ratio'] = $ltmPoolMemberEntry['ratio']['1.3.6.1.4.1.3375.2.2.5.3.2.1.6.'.$index];
|
||||||
$result['weight'] = $ltmPoolMemberEntry[weight]['1.3.6.1.4.1.3375.2.2.5.3.2.1.7.'.$index];
|
$result['weight'] = $ltmPoolMemberEntry['weight']['1.3.6.1.4.1.3375.2.2.5.3.2.1.7.'.$index];
|
||||||
$result['priority'] = $ltmPoolMemberEntry[priority]['1.3.6.1.4.1.3375.2.2.5.3.2.1.8.'.$index];
|
$result['priority'] = $ltmPoolMemberEntry['priority']['1.3.6.1.4.1.3375.2.2.5.3.2.1.8.'.$index];
|
||||||
$result['state'] = $ltmPoolMemberEntry[state]['1.3.6.1.4.1.3375.2.2.5.6.2.1.5.'.$index];
|
$result['state'] = $ltmPoolMemberEntry['state']['1.3.6.1.4.1.3375.2.2.5.6.2.1.5.'.$index];
|
||||||
$result['available'] = $ltmPoolMemberEntry[available]['1.3.6.1.4.1.3375.2.2.5.6.2.1.6.'.$index];
|
$result['available'] = $ltmPoolMemberEntry['available']['1.3.6.1.4.1.3375.2.2.5.6.2.1.6.'.$index];
|
||||||
|
|
||||||
// If available and bad state
|
// If available and bad state
|
||||||
// 0 = None, 1 = Green, 2 = Yellow, 3 = Red, 4 = Blue
|
// 0 = None, 1 = Green, 2 = Yellow, 3 = Red, 4 = Blue
|
||||||
if (($result['available'] == 1) && ($result['state'] == 3)) {
|
if (($result['available'] == 1) && ($result['state'] == 3)) {
|
||||||
// Warning Alarm, the pool member is down.
|
// Warning Alarm, the pool member is down.
|
||||||
$result['status'] = 1;
|
$result['status'] = 1;
|
||||||
$result['error'] = "Pool Member is Down: ".$ltmPoolMemberEntry[errorcode]['1.3.6.1.4.1.3375.2.2.5.6.2.1.8.'.$index];
|
$result['error'] = "Pool Member is Down: ".$ltmPoolMemberEntry['errorcode']['1.3.6.1.4.1.3375.2.2.5.6.2.1.8.'.$index];
|
||||||
} else {
|
} else {
|
||||||
// All is good.
|
// All is good.
|
||||||
$result['status'] = 0;
|
$result['status'] = 0;
|
||||||
|
|
|
@ -7,7 +7,7 @@ if ($device['os'] == 'pbn') {
|
||||||
d_echo($version);
|
d_echo($version);
|
||||||
|
|
||||||
// specified MIB supported since build 16607
|
// specified MIB supported since build 16607
|
||||||
if ($version[build] >= 16607) {
|
if ($version['build'] >= 16607) {
|
||||||
$usage = snmp_get($device, 'nmsMemoryPoolUtilization.0', '-OUvQ', 'NMS-MEMORY-POOL-MIB', 'pbn');
|
$usage = snmp_get($device, 'nmsMemoryPoolUtilization.0', '-OUvQ', 'NMS-MEMORY-POOL-MIB', 'pbn');
|
||||||
|
|
||||||
if (is_numeric($usage)) {
|
if (is_numeric($usage)) {
|
||||||
|
|
|
@ -42,7 +42,7 @@ if (is_null($cntpPeersVarEntry)) {
|
||||||
d_echo("Objects Found:\n");
|
d_echo("Objects Found:\n");
|
||||||
|
|
||||||
// Let's grab the index for each NTP peer
|
// Let's grab the index for each NTP peer
|
||||||
foreach ($cntpPeersVarEntry['1.3.6.1.4.1.9.9.168.1.2.1.1'][2] as $index => $value) {
|
foreach ((array)$cntpPeersVarEntry['1.3.6.1.4.1.9.9.168.1.2.1.1'][2] as $index => $value) {
|
||||||
$result = array();
|
$result = array();
|
||||||
$result['UID'] = (string)$index; // This is cast as a string so it can be compared with the database value.
|
$result['UID'] = (string)$index; // This is cast as a string so it can be compared with the database value.
|
||||||
$result['peer'] = $cntpPeersVarEntry['1.3.6.1.4.1.9.9.168.1.2.1.1'][3][$index];
|
$result['peer'] = $cntpPeersVarEntry['1.3.6.1.4.1.9.9.168.1.2.1.1'][3][$index];
|
||||||
|
@ -97,7 +97,7 @@ if (is_null($cntpPeersVarEntry)) {
|
||||||
/*
|
/*
|
||||||
* Loop over the Component data to see if we need to DELETE any components.
|
* Loop over the Component data to see if we need to DELETE any components.
|
||||||
*/
|
*/
|
||||||
foreach ($components as $key => $array) {
|
foreach ((array)$components as $key => $array) {
|
||||||
// Guilty until proven innocent
|
// Guilty until proven innocent
|
||||||
$found = false;
|
$found = false;
|
||||||
|
|
||||||
|
@ -121,7 +121,7 @@ if (is_null($cntpPeersVarEntry)) {
|
||||||
} // End if not error
|
} // End if not error
|
||||||
|
|
||||||
$module = strtolower($module);
|
$module = strtolower($module);
|
||||||
if (count($components) > 0) {
|
if (!empty($components)) {
|
||||||
if (dbFetchCell('SELECT COUNT(*) FROM `applications` WHERE `device_id` = ? AND `app_type` = ?', array($device['device_id'], $module)) == '0') {
|
if (dbFetchCell('SELECT COUNT(*) FROM `applications` WHERE `device_id` = ? AND `app_type` = ?', array($device['device_id'], $module)) == '0') {
|
||||||
dbInsert(array('device_id' => $device['device_id'], 'app_type' => $module, 'app_status' => '', 'app_instance' => ''), 'applications');
|
dbInsert(array('device_id' => $device['device_id'], 'app_type' => $module, 'app_status' => '', 'app_instance' => ''), 'applications');
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
|
|
||||||
$sql = "SELECT * FROM `ports_stack` WHERE `device_id` = '".$device['device_id']."'";
|
$sql = "SELECT * FROM `ports_stack` WHERE `device_id` = '".$device['device_id']."'";
|
||||||
|
|
||||||
|
$stack_db_array = [];
|
||||||
foreach (dbFetchRows($sql) as $entry) {
|
foreach (dbFetchRows($sql) as $entry) {
|
||||||
$stack_db_array[$entry['port_id_high']][$entry['port_id_low']]['ifStackStatus'] = $entry['ifStackStatus'];
|
$stack_db_array[$entry['port_id_high']][$entry['port_id_low']]['ifStackStatus'] = $entry['ifStackStatus'];
|
||||||
}
|
}
|
||||||
|
|
|
@ -64,9 +64,6 @@ foreach ($port_stats as $ifIndex => $port) {
|
||||||
} else {
|
} else {
|
||||||
echo '.';
|
echo '.';
|
||||||
}
|
}
|
||||||
|
|
||||||
// We've seen it. Remove it from the cache.
|
|
||||||
unset($ports_l[$ifIndex]);
|
|
||||||
} else {
|
} else {
|
||||||
// Port vanished (mark as deleted)
|
// Port vanished (mark as deleted)
|
||||||
if (is_array($ports_db[$port_id])) {
|
if (is_array($ports_db[$port_id])) {
|
||||||
|
@ -86,17 +83,6 @@ unset(
|
||||||
$port
|
$port
|
||||||
);
|
);
|
||||||
|
|
||||||
// End New interface detection
|
|
||||||
// Interface Deletion
|
|
||||||
// If it's in our $ports_l list, that means it's not been seen. Mark it deleted.
|
|
||||||
foreach ($ports_l as $ifIndex => $port_id) {
|
|
||||||
if ($ports_db[$ifIndex]['deleted'] == '0') {
|
|
||||||
dbUpdate(array('deleted' => '1'), 'ports', '`port_id` = ?', array($port_id));
|
|
||||||
echo '-'.$ifIndex;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// End interface deletion
|
|
||||||
echo "\n";
|
echo "\n";
|
||||||
|
|
||||||
// Clear Variables Here
|
// Clear Variables Here
|
||||||
|
|
|
@ -18,7 +18,7 @@ foreach ($pre_cache['ciscosb_rlPhyTestGetResult'] as $index => $ciscosb_data) {
|
||||||
foreach ($ciscosb_data as $key => $value) {
|
foreach ($ciscosb_data as $key => $value) {
|
||||||
$oid = '.1.3.6.1.4.1.9.6.1.101.90.1.2.1.3.'.$index.'.7';
|
$oid = '.1.3.6.1.4.1.9.6.1.101.90.1.2.1.3.'.$index.'.7';
|
||||||
$sensor_type = 'rlPhyTestTableTxBias';
|
$sensor_type = 'rlPhyTestTableTxBias';
|
||||||
$port_descr = get_port_by_index_cache($device, str_replace('1.', '', $index));
|
$port_descr = get_port_by_index_cache($device['device_id'], str_replace('1.', '', $index));
|
||||||
$descr = $port_descr['ifDescr'] . ' Bias Current';
|
$descr = $port_descr['ifDescr'] . ' Bias Current';
|
||||||
$current = $value['rlPhyTestTableTxBias'] / $divisor;
|
$current = $value['rlPhyTestTableTxBias'] / $divisor;
|
||||||
$entPhysicalIndex = $index;
|
$entPhysicalIndex = $index;
|
||||||
|
|
|
@ -19,7 +19,7 @@ foreach ($pre_cache['ciscosb_rlPhyTestGetResult'] as $index => $ciscosb_data) {
|
||||||
if (is_numeric($value['rlPhyTestTableTxOutput']) && ($value['rlPhyTestTableRxOpticalPower'] != 0)) {
|
if (is_numeric($value['rlPhyTestTableTxOutput']) && ($value['rlPhyTestTableRxOpticalPower'] != 0)) {
|
||||||
$oid = '.1.3.6.1.4.1.9.6.1.101.90.1.2.1.3.'.$index.'.8';
|
$oid = '.1.3.6.1.4.1.9.6.1.101.90.1.2.1.3.'.$index.'.8';
|
||||||
$sensor_type = 'rlPhyTestTableTxOutput';
|
$sensor_type = 'rlPhyTestTableTxOutput';
|
||||||
$port_descr = get_port_by_index_cache($device, str_replace('1.', '', $index));
|
$port_descr = get_port_by_index_cache($device['device_id'], str_replace('1.', '', $index));
|
||||||
$descr = $port_descr['ifDescr'] . ' Transmit Power';
|
$descr = $port_descr['ifDescr'] . ' Transmit Power';
|
||||||
$dbm = $value['rlPhyTestTableTxOutput'] / $divisor;
|
$dbm = $value['rlPhyTestTableTxOutput'] / $divisor;
|
||||||
$entPhysicalIndex = $index;
|
$entPhysicalIndex = $index;
|
||||||
|
@ -29,7 +29,7 @@ foreach ($pre_cache['ciscosb_rlPhyTestGetResult'] as $index => $ciscosb_data) {
|
||||||
if (is_numeric($value['rlPhyTestTableRxOpticalPower']) && ($value['rlPhyTestTableTxOutput'] != 0)) {
|
if (is_numeric($value['rlPhyTestTableRxOpticalPower']) && ($value['rlPhyTestTableTxOutput'] != 0)) {
|
||||||
$oid = '.1.3.6.1.4.1.9.6.1.101.90.1.2.1.3.'.$index.'.9';
|
$oid = '.1.3.6.1.4.1.9.6.1.101.90.1.2.1.3.'.$index.'.9';
|
||||||
$sensor_type = 'rlPhyTestTableRxOpticalPower';
|
$sensor_type = 'rlPhyTestTableRxOpticalPower';
|
||||||
$port_descr = get_port_by_index_cache($device, str_replace('1.', '', $index));
|
$port_descr = get_port_by_index_cache($device['device_id'], str_replace('1.', '', $index));
|
||||||
$descr = $port_descr['ifDescr'] . ' Receive Power';
|
$descr = $port_descr['ifDescr'] . ' Receive Power';
|
||||||
$dbm = $value['rlPhyTestTableRxOpticalPower'] / $divisor;
|
$dbm = $value['rlPhyTestTableRxOpticalPower'] / $divisor;
|
||||||
$entPhysicalIndex = $index;
|
$entPhysicalIndex = $index;
|
||||||
|
|
|
@ -12,21 +12,20 @@ if (empty($entity_array)) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!empty($entity_array)) {
|
if (!empty($entity_array)) {
|
||||||
$oids = array();
|
|
||||||
echo ' entPhySensorType';
|
echo ' entPhySensorType';
|
||||||
$oids = snmpwalk_cache_multi_oid($device, 'entPhySensorType', $oids, 'ENTITY-SENSOR-MIB');
|
$entity_oids = snmpwalk_cache_multi_oid($device, 'entPhySensorType', [], 'ENTITY-SENSOR-MIB');
|
||||||
echo ' entPhySensorScale';
|
echo ' entPhySensorScale';
|
||||||
$oids = snmpwalk_cache_multi_oid($device, 'entPhySensorScale', $oids, 'ENTITY-SENSOR-MIB');
|
$entity_oids = snmpwalk_cache_multi_oid($device, 'entPhySensorScale', $entity_oids, 'ENTITY-SENSOR-MIB');
|
||||||
echo ' entPhySensorPrecision';
|
echo ' entPhySensorPrecision';
|
||||||
$oids = snmpwalk_cache_multi_oid($device, 'entPhySensorPrecision', $oids, 'ENTITY-SENSOR-MIB');
|
$entity_oids = snmpwalk_cache_multi_oid($device, 'entPhySensorPrecision', $entity_oids, 'ENTITY-SENSOR-MIB');
|
||||||
echo ' entPhySensorValue';
|
echo ' entPhySensorValue';
|
||||||
$oids = snmpwalk_cache_multi_oid($device, 'entPhySensorValue', $oids, 'ENTITY-SENSOR-MIB');
|
$entity_oids = snmpwalk_cache_multi_oid($device, 'entPhySensorValue', $entity_oids, 'ENTITY-SENSOR-MIB');
|
||||||
if ($device['os'] === 'arista_eos') {
|
if ($device['os'] === 'arista_eos') {
|
||||||
require 'includes/discovery/sensors/misc/arista-eos-limits.inc.php';
|
require 'includes/discovery/sensors/misc/arista-eos-limits.inc.php';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!empty($oids)) {
|
if (!empty($entity_oids)) {
|
||||||
$entitysensor = array(
|
$entitysensor = array(
|
||||||
'voltsDC' => 'voltage',
|
'voltsDC' => 'voltage',
|
||||||
'voltsAC' => 'voltage',
|
'voltsAC' => 'voltage',
|
||||||
|
@ -39,7 +38,7 @@ if (!empty($oids)) {
|
||||||
'dBm' => 'dbm',
|
'dBm' => 'dbm',
|
||||||
);
|
);
|
||||||
|
|
||||||
foreach ($oids as $index => $entry) {
|
foreach ($entity_oids as $index => $entry) {
|
||||||
$low_limit = null;
|
$low_limit = null;
|
||||||
$low_warn_limit = null;
|
$low_warn_limit = null;
|
||||||
$warn_limit = null;
|
$warn_limit = null;
|
||||||
|
|
|
@ -2,4 +2,4 @@
|
||||||
|
|
||||||
use LibreNMS\Config;
|
use LibreNMS\Config;
|
||||||
|
|
||||||
include_once Config::get('install_dir') . '/includes/discovery/sensors/fanspeeds/supermicro.inc.php';
|
include_once Config::get('install_dir') . '/includes/discovery/sensors/fanspeed/supermicro.inc.php';
|
||||||
|
|
|
@ -3,22 +3,24 @@
|
||||||
* raspberry pi frequencies
|
* raspberry pi frequencies
|
||||||
* requires snmp extend agent script from librenms-agent
|
* requires snmp extend agent script from librenms-agent
|
||||||
*/
|
*/
|
||||||
$sensor_type = "raspberry_freq";
|
if (!empty($pre_cache['raspberry_pi_sensors'])) {
|
||||||
$oid = '.1.3.6.1.4.1.8072.1.3.2.4.1.2.9.114.97.115.112.98.101.114.114.121.';
|
$sensor_type = "raspberry_freq";
|
||||||
|
$oid = '.1.3.6.1.4.1.8072.1.3.2.4.1.2.9.114.97.115.112.98.101.114.114.121.';
|
||||||
|
|
||||||
for ($freq = 6; $freq < 8; $freq++) {
|
for ($freq = 6; $freq < 8; $freq++) {
|
||||||
switch ($freq) {
|
switch ($freq) {
|
||||||
case "6":
|
case "6":
|
||||||
$descr = "ARM";
|
$descr = "ARM";
|
||||||
|
break;
|
||||||
|
case "7":
|
||||||
|
$descr = "Core";
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
$value = isset($pre_cache['raspberry_pi_sensors']["raspberry." . $freq]);
|
||||||
|
if (is_numeric($value)) {
|
||||||
|
discover_sensor($valid['sensor'], 'frequency', $device, $oid . $freq, $freq, $sensor_type, $descr, 1, 1, null, null, null, null, $value);
|
||||||
|
} else {
|
||||||
break;
|
break;
|
||||||
case "7":
|
}
|
||||||
$descr = "Core";
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
$value = current($pre_cache['raspberry_pi_sensors']["raspberry.".$freq]);
|
|
||||||
if (is_numeric($value)) {
|
|
||||||
discover_sensor($valid['sensor'], 'frequency', $device, $oid.$freq, $freq, $sensor_type, $descr, 1, 1, null, null, null, null, $value);
|
|
||||||
} else {
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
/*
|
/*
|
||||||
* LibreNMS
|
* LibreNMS
|
||||||
*
|
*
|
||||||
* Copyright (c) 2016 Søren Friis Rosiak <sorenrosiak@gmail.com>
|
* Copyright (c) 2016 Søren Friis Rosiak <sorenrosiak@gmail.com>
|
||||||
* This program is free software: you can redistribute it and/or modify it
|
* This program is free software: you can redistribute it and/or modify it
|
||||||
* under the terms of the GNU General Public License as published by the
|
* under the terms of the GNU General Public License as published by the
|
||||||
* Free Software Foundation, either version 3 of the License, or (at your
|
* Free Software Foundation, either version 3 of the License, or (at your
|
||||||
|
@ -17,7 +17,7 @@ if (is_array($temp)) {
|
||||||
$divisor = '1000';
|
$divisor = '1000';
|
||||||
foreach ($temp as $index => $entry) {
|
foreach ($temp as $index => $entry) {
|
||||||
if (is_numeric($temp[$index]['rlPethPsePortOutputPower']) && $temp[$index]['rlPethPsePortOutputPower'] > 0) {
|
if (is_numeric($temp[$index]['rlPethPsePortOutputPower']) && $temp[$index]['rlPethPsePortOutputPower'] > 0) {
|
||||||
$port_descr = get_port_by_index_cache($device, str_replace('1.', '', $index));
|
$port_descr = get_port_by_index_cache($device['device_id'], str_replace('1.', '', $index));
|
||||||
$descr = $port_descr['ifDescr'] . ' PoE';
|
$descr = $port_descr['ifDescr'] . ' PoE';
|
||||||
$highlimit = $temp[$index]['rlPethPsePortOperPowerLimit'] / $divisor;
|
$highlimit = $temp[$index]['rlPethPsePortOperPowerLimit'] / $divisor;
|
||||||
discover_sensor($valid['sensor'], 'power', $device, $cur_oid . $index, $index, 'ciscosb', $descr, $divisor, '1', null, null, null, $highlimit, $temp[$index]['rlPethPsePortOutputPower'] / $divisor, 'snmp', $index);
|
discover_sensor($valid['sensor'], 'power', $device, $cur_oid . $index, $index, 'ciscosb', $descr, $divisor, '1', null, null, null, $highlimit, $temp[$index]['rlPethPsePortOutputPower'] / $divisor, 'snmp', $index);
|
||||||
|
|
|
@ -41,11 +41,11 @@ if ($device['os'] === 'boss') {
|
||||||
);
|
);
|
||||||
dbInsert($insert, 'state_translations');
|
dbInsert($insert, 'state_translations');
|
||||||
}
|
}
|
||||||
|
|
||||||
// get fans (6) and temp (5) sensor only from walk
|
// get fans (6) and temp (5) sensor only from walk
|
||||||
$ers_sensors = array();
|
$ers_sensors = array();
|
||||||
foreach ($oid as $key => $value) {
|
foreach ($oid as $key => $value) {
|
||||||
if ($key[s5ChasComGrpIndx] == 5 || $key[s5ChasComGrpIndx] == 6) {
|
if ($key['s5ChasComGrpIndx'] == 5 || $key['s5ChasComGrpIndx'] == 6) {
|
||||||
$ers_sensors[$key] = $value;
|
$ers_sensors[$key] = $value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -56,7 +56,7 @@ if ($device['os'] === 'boss') {
|
||||||
$unit = floor($unit_array[1]/10);
|
$unit = floor($unit_array[1]/10);
|
||||||
$descr = "Unit $unit: $entry[s5ChasComDescr]";
|
$descr = "Unit $unit: $entry[s5ChasComDescr]";
|
||||||
//Discover Sensors
|
//Discover Sensors
|
||||||
discover_sensor($valid['sensor'], 'state', $device, $cur_oid.$index, "s5ChasComOperState.$index", $state_name, $descr, '1', '1', null, null, null, null, $entry[s5ChasComOperState]);
|
discover_sensor($valid['sensor'], 'state', $device, $cur_oid.$index, "s5ChasComOperState.$index", $state_name, $descr, '1', '1', null, null, null, null, $entry['s5ChasComOperState']);
|
||||||
//Create Sensor To State Index
|
//Create Sensor To State Index
|
||||||
create_sensor_to_state_index($device, $state_name, "s5ChasComOperState.$index");
|
create_sensor_to_state_index($device, $state_name, "s5ChasComOperState.$index");
|
||||||
}
|
}
|
||||||
|
|
|
@ -157,7 +157,7 @@ foreach ($tables as $tablevalue) {
|
||||||
$swstatenumber++;
|
$swstatenumber++;
|
||||||
$descr = $tablevalue[3] . $swstatenumber;
|
$descr = $tablevalue[3] . $swstatenumber;
|
||||||
} elseif ($state_name == 'cswStackPortOperStatus') {
|
} elseif ($state_name == 'cswStackPortOperStatus') {
|
||||||
$stack_port_descr = get_port_by_index_cache($device, $index);
|
$stack_port_descr = get_port_by_index_cache($device['device_id'], $index);
|
||||||
$descr = $tablevalue[3] . $stack_port_descr['ifDescr'];
|
$descr = $tablevalue[3] . $stack_port_descr['ifDescr'];
|
||||||
} elseif ($state_name == 'cefcFRUPowerOperStatus') {
|
} elseif ($state_name == 'cefcFRUPowerOperStatus') {
|
||||||
$descr = snmp_get($device, 'entPhysicalName.'.$index, '-Oqv', 'ENTITY-MIB');
|
$descr = snmp_get($device, 'entPhysicalName.'.$index, '-Oqv', 'ENTITY-MIB');
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
/*
|
/*
|
||||||
* LibreNMS
|
* LibreNMS
|
||||||
*
|
*
|
||||||
* Copyright (c) 2017 Søren Friis Rosiak <sorenrosiak@gmail.com>
|
* Copyright (c) 2017 Søren Friis Rosiak <sorenrosiak@gmail.com>
|
||||||
* This program is free software: you can redistribute it and/or modify it
|
* This program is free software: you can redistribute it and/or modify it
|
||||||
* under the terms of the GNU General Public License as published by the
|
* under the terms of the GNU General Public License as published by the
|
||||||
* Free Software Foundation, either version 3 of the License, or (at your
|
* Free Software Foundation, either version 3 of the License, or (at your
|
||||||
|
@ -37,7 +37,7 @@ if (is_array($temp)) {
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach ($temp as $index => $entry) {
|
foreach ($temp as $index => $entry) {
|
||||||
$port_descr = get_port_by_index_cache($device, str_replace('1.', '', $index));
|
$port_descr = get_port_by_index_cache($device['device_id'], str_replace('1.', '', $index));
|
||||||
$descr = $port_descr['ifDescr'] . ' Suspended Status';
|
$descr = $port_descr['ifDescr'] . ' Suspended Status';
|
||||||
if (str_contains($descr, 'ethernet')) {
|
if (str_contains($descr, 'ethernet')) {
|
||||||
//Discover Sensors
|
//Discover Sensors
|
||||||
|
|
|
@ -3,52 +3,54 @@
|
||||||
* codec states for raspberry pi
|
* codec states for raspberry pi
|
||||||
* requires snmp extend agent script from librenms-agent
|
* requires snmp extend agent script from librenms-agent
|
||||||
*/
|
*/
|
||||||
$state = "raspberry_codec";
|
if (!empty($pre_cache['raspberry_pi_sensors'])) {
|
||||||
$oid = '.1.3.6.1.4.1.8072.1.3.2.4.1.2.9.114.97.115.112.98.101.114.114.121.';
|
$state = "raspberry_codec";
|
||||||
for ($codec = 8; $codec < 14; $codec++) {
|
$oid = '.1.3.6.1.4.1.8072.1.3.2.4.1.2.9.114.97.115.112.98.101.114.114.121.';
|
||||||
switch ($codec) {
|
for ($codec = 8; $codec < 14; $codec++) {
|
||||||
case "8":
|
switch ($codec) {
|
||||||
$descr = "H264 codec";
|
case "8":
|
||||||
break;
|
$descr = "H264 codec";
|
||||||
case "9":
|
break;
|
||||||
$descr = "MPG2 codec";
|
case "9":
|
||||||
break;
|
$descr = "MPG2 codec";
|
||||||
case "10":
|
break;
|
||||||
$descr = "WVC1 codec";
|
case "10":
|
||||||
break;
|
$descr = "WVC1 codec";
|
||||||
case "11":
|
break;
|
||||||
$descr = "MPG4 codec";
|
case "11":
|
||||||
break;
|
$descr = "MPG4 codec";
|
||||||
case "12":
|
break;
|
||||||
$descr = "MJPG codec";
|
case "12":
|
||||||
break;
|
$descr = "MJPG codec";
|
||||||
case "13":
|
break;
|
||||||
$descr = "WMV9 codec";
|
case "13":
|
||||||
break;
|
$descr = "WMV9 codec";
|
||||||
}
|
break;
|
||||||
$value = current($pre_cache['raspberry_pi_sensors']["raspberry.".$codec]);
|
|
||||||
if (stripos($value, 'abled') !== false) {
|
|
||||||
$state_index_id = create_state_index($state);
|
|
||||||
if ($state_index_id) {
|
|
||||||
$states = array(
|
|
||||||
array($state_index_id, 'enabled', 1, 2, 0),
|
|
||||||
array($state_index_id, 'disabled', 1, 3 , 2),
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
$value = current($pre_cache['raspberry_pi_sensors']["raspberry." . $codec]);
|
||||||
|
if (stripos($value, 'abled') !== false) {
|
||||||
|
$state_index_id = create_state_index($state);
|
||||||
|
if ($state_index_id) {
|
||||||
|
$states = [
|
||||||
|
[$state_index_id, 'enabled', 1, 2, 0],
|
||||||
|
[$state_index_id, 'disabled', 1, 3, 2],
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
foreach ($states as $value) {
|
foreach ($states as $value) {
|
||||||
$insert = array(
|
$insert = [
|
||||||
'state_index_id' => $value[0],
|
'state_index_id' => $value[0],
|
||||||
'state_descr' => $value[1],
|
'state_descr' => $value[1],
|
||||||
'state_draw_graph' => $value[2],
|
'state_draw_graph' => $value[2],
|
||||||
'state_value' => $value[3],
|
'state_value' => $value[3],
|
||||||
'state_generic_value' => $value[4]
|
'state_generic_value' => $value[4]
|
||||||
);
|
];
|
||||||
dbInsert($insert, 'state_translations');
|
dbInsert($insert, 'state_translations');
|
||||||
|
}
|
||||||
|
discover_sensor($valid['sensor'], 'state', $device, $oid . $codec, $codec, $state, $descr, '1', '1', null, null, null, null, $value, 'snmp', $codec);
|
||||||
|
create_sensor_to_state_index($device, $state, $codec);
|
||||||
|
} else {
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
discover_sensor($valid['sensor'], 'state', $device, $oid.$codec, $codec, $state, $descr, '1', '1', null, null, null, null, $value, 'snmp', $codec);
|
|
||||||
create_sensor_to_state_index($device, $state, $codec);
|
|
||||||
} else {
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,7 +18,7 @@ foreach ($pre_cache['ciscosb_rlPhyTestGetResult'] as $index => $ciscosb_data) {
|
||||||
foreach ($ciscosb_data as $key => $value) {
|
foreach ($ciscosb_data as $key => $value) {
|
||||||
$oid = '.1.3.6.1.4.1.9.6.1.101.90.1.2.1.3.'.$index.'.5';
|
$oid = '.1.3.6.1.4.1.9.6.1.101.90.1.2.1.3.'.$index.'.5';
|
||||||
$sensor_type = 'rlPhyTestTableTransceiverTemp';
|
$sensor_type = 'rlPhyTestTableTransceiverTemp';
|
||||||
$port_descr = get_port_by_index_cache($device, str_replace('1.', '', $index));
|
$port_descr = get_port_by_index_cache($device['device_id'], str_replace('1.', '', $index));
|
||||||
$descr = $port_descr['ifDescr'] . ' Module';
|
$descr = $port_descr['ifDescr'] . ' Module';
|
||||||
$temperature = $value['rlPhyTestTableTransceiverTemp'];
|
$temperature = $value['rlPhyTestTableTransceiverTemp'];
|
||||||
$entPhysicalIndex = $index;
|
$entPhysicalIndex = $index;
|
||||||
|
|
|
@ -18,7 +18,7 @@ foreach ($pre_cache['ciscosb_rlPhyTestGetResult'] as $index => $ciscosb_data) {
|
||||||
foreach ($ciscosb_data as $key => $value) {
|
foreach ($ciscosb_data as $key => $value) {
|
||||||
$oid = '.1.3.6.1.4.1.9.6.1.101.90.1.2.1.3.'.$index.'.6';
|
$oid = '.1.3.6.1.4.1.9.6.1.101.90.1.2.1.3.'.$index.'.6';
|
||||||
$sensor_type = 'rlPhyTestTableTransceiverSupply';
|
$sensor_type = 'rlPhyTestTableTransceiverSupply';
|
||||||
$port_descr = get_port_by_index_cache($device, str_replace('1.', '', $index));
|
$port_descr = get_port_by_index_cache($device['device_id'], str_replace('1.', '', $index));
|
||||||
$descr = $port_descr['ifDescr'] . ' Supply Voltage';
|
$descr = $port_descr['ifDescr'] . ' Supply Voltage';
|
||||||
$voltage = $value['rlPhyTestTableTransceiverSupply'] / $divisor;
|
$voltage = $value['rlPhyTestTableTransceiverSupply'] / $divisor;
|
||||||
$entPhysicalIndex = $index;
|
$entPhysicalIndex = $index;
|
||||||
|
|
|
@ -3,28 +3,30 @@
|
||||||
* voltages for raspberry pi
|
* voltages for raspberry pi
|
||||||
* requires snmp extend agent script from librenms-agent
|
* requires snmp extend agent script from librenms-agent
|
||||||
*/
|
*/
|
||||||
$sensor_type = "rasbperry_volts";
|
if (!empty($pre_cache['raspberry_pi_sensors'])) {
|
||||||
$oid = '.1.3.6.1.4.1.8072.1.3.2.4.1.2.9.114.97.115.112.98.101.114.114.121.';
|
$sensor_type = "rasbperry_volts";
|
||||||
for ($volt = 2; $volt < 6; $volt++) {
|
$oid = '.1.3.6.1.4.1.8072.1.3.2.4.1.2.9.114.97.115.112.98.101.114.114.121.';
|
||||||
switch ($volt) {
|
for ($volt = 2; $volt < 6; $volt++) {
|
||||||
case "2":
|
switch ($volt) {
|
||||||
$descr = "Core";
|
case "2":
|
||||||
|
$descr = "Core";
|
||||||
|
break;
|
||||||
|
case "3":
|
||||||
|
$descr = "SDRAMc";
|
||||||
|
break;
|
||||||
|
case "4":
|
||||||
|
$descr = "SDRAMi";
|
||||||
|
break;
|
||||||
|
case "5":
|
||||||
|
$descr = "SDRAMp";
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
$value = current($pre_cache['raspberry_pi_sensors']["raspberry." . $volt]);
|
||||||
|
if (is_numeric($value)) {
|
||||||
|
discover_sensor($valid['sensor'], 'voltage', $device, $oid . $volt, $volt, $sensor_type, $descr, '1', '1', null, null, null, null, $value);
|
||||||
|
} else {
|
||||||
break;
|
break;
|
||||||
case "3":
|
}
|
||||||
$descr = "SDRAMc";
|
|
||||||
break;
|
|
||||||
case "4":
|
|
||||||
$descr = "SDRAMi";
|
|
||||||
break;
|
|
||||||
case "5":
|
|
||||||
$descr = "SDRAMp";
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
$value = current($pre_cache['raspberry_pi_sensors']["raspberry.".$volt]);
|
|
||||||
if (is_numeric($value)) {
|
|
||||||
discover_sensor($valid['sensor'], 'voltage', $device, $oid.$volt, $volt, $sensor_type, $descr, '1', '1', null, null, null, null, $value);
|
|
||||||
} else {
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
<?php
|
<?php
|
||||||
/*
|
/*
|
||||||
* LibreNMS
|
* LibreNMS
|
||||||
*
|
*
|
||||||
* Copyright (c) 2015 Vitali Kari <vitali.kari@gmail.com>
|
* Copyright (c) 2015 Vitali Kari <vitali.kari@gmail.com>
|
||||||
*
|
*
|
||||||
|
@ -29,7 +29,7 @@ if ($stpprotocol == 'ieee8021d' || $stpprotocol == 'unknown') {
|
||||||
// some vendors like PBN dont follow the 802.1D implementation and use seconds in SNMP
|
// some vendors like PBN dont follow the 802.1D implementation and use seconds in SNMP
|
||||||
if ($device['os'] == 'pbn') {
|
if ($device['os'] == 'pbn') {
|
||||||
preg_match('/^.* Build (?<build>\d+)/', $device['version'], $version);
|
preg_match('/^.* Build (?<build>\d+)/', $device['version'], $version);
|
||||||
if ($version[build] <= 16607) { // Buggy version :-(
|
if ($version['build'] <= 16607) { // Buggy version :-(
|
||||||
$tm = '1';
|
$tm = '1';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -56,7 +56,7 @@ if ($stpprotocol == 'ieee8021d' || $stpprotocol == 'unknown') {
|
||||||
|
|
||||||
// read the 802.1D bridge address and set as MAC in database
|
// read the 802.1D bridge address and set as MAC in database
|
||||||
$mac_raw = snmp_get($device, 'dot1dBaseBridgeAddress.0', '-Oqv', 'RSTP-MIB');
|
$mac_raw = snmp_get($device, 'dot1dBaseBridgeAddress.0', '-Oqv', 'RSTP-MIB');
|
||||||
|
|
||||||
// read Time as timetics (in hundredths of a seconds) since last topology change and convert to seconds
|
// read Time as timetics (in hundredths of a seconds) since last topology change and convert to seconds
|
||||||
$time_since_change = snmp_get($device, 'dot1dStpTimeSinceTopologyChange.0', '-Ovt', 'RSTP-MIB');
|
$time_since_change = snmp_get($device, 'dot1dStpTimeSinceTopologyChange.0', '-Ovt', 'RSTP-MIB');
|
||||||
if ($time_since_change > '100') {
|
if ($time_since_change > '100') {
|
||||||
|
@ -100,7 +100,7 @@ if ($stpprotocol == 'ieee8021d' || $stpprotocol == 'unknown') {
|
||||||
log_event('STP added, bridge address: ' . $stp['bridgeAddress'], $device, 'stp', 3);
|
log_event('STP added, bridge address: ' . $stp['bridgeAddress'], $device, 'stp', 3);
|
||||||
echo '+';
|
echo '+';
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($stp_db['bridgeAddress'] && !$stp['bridgeAddress']) {
|
if ($stp_db['bridgeAddress'] && !$stp['bridgeAddress']) {
|
||||||
dbDelete('stp', 'device_id = ?', array($device['device_id']));
|
dbDelete('stp', 'device_id = ?', array($device['device_id']));
|
||||||
log_event('STP removed', $device, 'stp', 4);
|
log_event('STP removed', $device, 'stp', 4);
|
||||||
|
@ -119,17 +119,17 @@ if ($stpprotocol == 'ieee8021d' || $stpprotocol == 'unknown') {
|
||||||
'designatedPort' => $stp_raw[$port]['dot1dStpPortDesignatedPort'],
|
'designatedPort' => $stp_raw[$port]['dot1dStpPortDesignatedPort'],
|
||||||
'forwardTransitions' => $stp_raw[$port]['dot1dStpPortForwardTransitions']
|
'forwardTransitions' => $stp_raw[$port]['dot1dStpPortForwardTransitions']
|
||||||
);
|
);
|
||||||
|
|
||||||
// set device binding
|
// set device binding
|
||||||
$stp_port['device_id'] = $device['device_id'];
|
$stp_port['device_id'] = $device['device_id'];
|
||||||
|
|
||||||
// set port binding
|
// set port binding
|
||||||
$stp_port['port_id'] = dbFetchCell('SELECT port_id FROM `ports` WHERE `device_id` = ? AND `ifIndex` = ?', array($device['device_id'], $stp_raw[$port]['dot1dStpPort']));
|
$stp_port['port_id'] = dbFetchCell('SELECT port_id FROM `ports` WHERE `device_id` = ? AND `ifIndex` = ?', array($device['device_id'], $stp_raw[$port]['dot1dStpPort']));
|
||||||
|
|
||||||
$dr = str_replace(array(' ', ':', '-'), '', strtolower($stp_raw[$port]['dot1dStpPortDesignatedRoot']));
|
$dr = str_replace(array(' ', ':', '-'), '', strtolower($stp_raw[$port]['dot1dStpPortDesignatedRoot']));
|
||||||
$dr = substr($dr, -12); //remove first two octets
|
$dr = substr($dr, -12); //remove first two octets
|
||||||
$stp_port['designatedRoot'] = $dr;
|
$stp_port['designatedRoot'] = $dr;
|
||||||
|
|
||||||
$db = str_replace(array(' ', ':', '-'), '', strtolower($stp_raw[$port]['dot1dStpPortDesignatedBridge']));
|
$db = str_replace(array(' ', ':', '-'), '', strtolower($stp_raw[$port]['dot1dStpPortDesignatedBridge']));
|
||||||
$db = substr($db, -12); //remove first two octets
|
$db = substr($db, -12); //remove first two octets
|
||||||
$stp_port['designatedBridge'] = $db;
|
$stp_port['designatedBridge'] = $db;
|
||||||
|
@ -149,7 +149,7 @@ if ($stpprotocol == 'ieee8021d' || $stpprotocol == 'unknown') {
|
||||||
$dp = substr($stp_raw[$port]['dot1dStpPortDesignatedPort'], -2); //discard the first octet (priority part)
|
$dp = substr($stp_raw[$port]['dot1dStpPortDesignatedPort'], -2); //discard the first octet (priority part)
|
||||||
$stp_port['designatedPort'] = hexdec($dp);
|
$stp_port['designatedPort'] = hexdec($dp);
|
||||||
}
|
}
|
||||||
|
|
||||||
d_echo($stp_port);
|
d_echo($stp_port);
|
||||||
|
|
||||||
// Write to db
|
// Write to db
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
// Pre-cache the existing state of VLANs for this device from the database
|
// Pre-cache the existing state of VLANs for this device from the database
|
||||||
use LibreNMS\Config;
|
use LibreNMS\Config;
|
||||||
|
|
||||||
|
$vlans_db = [];
|
||||||
$vlans_db_raw = dbFetchRows('SELECT * FROM `vlans` WHERE `device_id` = ?', array($device['device_id']));
|
$vlans_db_raw = dbFetchRows('SELECT * FROM `vlans` WHERE `device_id` = ?', array($device['device_id']));
|
||||||
foreach ($vlans_db_raw as $vlan_db) {
|
foreach ($vlans_db_raw as $vlan_db) {
|
||||||
$vlans_db[$vlan_db['vlan_domain']][$vlan_db['vlan_vlan']] = $vlan_db;
|
$vlans_db[$vlan_db['vlan_domain']][$vlan_db['vlan_vlan']] = $vlan_db;
|
||||||
|
@ -46,8 +47,8 @@ foreach ($device['vlans'] as $domain_id => $vlans) {
|
||||||
echo str_pad('dot1d id', 10).str_pad('ifIndex', 10).str_pad('Port Name', 25).str_pad('Priority', 10).str_pad('State', 15).str_pad('Cost', 10)."\n";
|
echo str_pad('dot1d id', 10).str_pad('ifIndex', 10).str_pad('Port Name', 25).str_pad('Priority', 10).str_pad('State', 15).str_pad('Cost', 10)."\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach ($vlan_data as $ifIndex => $vlan_port) {
|
foreach ((array)$vlan_data as $ifIndex => $vlan_port) {
|
||||||
$port = get_port_by_index_cache($device, $ifIndex);
|
$port = get_port_by_index_cache($device['device_id'], $ifIndex);
|
||||||
echo str_pad($vlan_port_id, 10).str_pad($ifIndex, 10).str_pad($port['ifDescr'], 25).str_pad($vlan_port['dot1dStpPortPriority'], 10).str_pad($vlan_port['dot1dStpPortState'], 15).str_pad($vlan_port['dot1dStpPortPathCost'], 10);
|
echo str_pad($vlan_port_id, 10).str_pad($ifIndex, 10).str_pad($port['ifDescr'], 25).str_pad($vlan_port['dot1dStpPortPriority'], 10).str_pad($vlan_port['dot1dStpPortState'], 15).str_pad($vlan_port['dot1dStpPortPathCost'], 10);
|
||||||
|
|
||||||
$db_w = array(
|
$db_w = array(
|
||||||
|
|
|
@ -20,7 +20,7 @@ if (($device['os'] == 'vmware') || ($device['os'] == 'linux')) {
|
||||||
* Fetch information about Virtual Machines.
|
* Fetch information about Virtual Machines.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
$oids = snmpwalk_cache_multi_oid($device, 'vmwVmTable', $oids, '+VMWARE-ROOT-MIB:VMWARE-VMINFO-MIB', 'vmware');
|
$oids = snmpwalk_cache_multi_oid($device, 'vmwVmTable', [], '+VMWARE-ROOT-MIB:VMWARE-VMINFO-MIB', 'vmware');
|
||||||
|
|
||||||
foreach ($oids as $index => $entry) {
|
foreach ($oids as $index => $entry) {
|
||||||
$vmwVmDisplayName = $entry['vmwVmDisplayName'];
|
$vmwVmDisplayName = $entry['vmwVmDisplayName'];
|
||||||
|
|
|
@ -11,6 +11,7 @@
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
use Illuminate\Database\Events\QueryExecuted;
|
||||||
use LibreNMS\Authentication\Auth;
|
use LibreNMS\Authentication\Auth;
|
||||||
use LibreNMS\Config;
|
use LibreNMS\Config;
|
||||||
use LibreNMS\Exceptions\HostExistsException;
|
use LibreNMS\Exceptions\HostExistsException;
|
||||||
|
@ -24,15 +25,101 @@ use LibreNMS\Exceptions\SnmpVersionUnsupportedException;
|
||||||
use LibreNMS\Util\IP;
|
use LibreNMS\Util\IP;
|
||||||
use LibreNMS\Util\MemcacheLock;
|
use LibreNMS\Util\MemcacheLock;
|
||||||
|
|
||||||
function set_debug($debug)
|
/**
|
||||||
|
* Set debugging output
|
||||||
|
*
|
||||||
|
* @param bool $state If debug is enabled or not
|
||||||
|
* @param bool $silence When not debugging, silence every php error
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
function set_debug($state = true, $silence = false)
|
||||||
{
|
{
|
||||||
if (isset($debug)) {
|
global $debug;
|
||||||
|
|
||||||
|
$debug = $state; // set to global
|
||||||
|
|
||||||
|
$db = \LibreNMS\DB\Eloquent::DB();
|
||||||
|
|
||||||
|
restore_error_handler(); // disable Laravel error handler
|
||||||
|
|
||||||
|
if ($debug) {
|
||||||
ini_set('display_errors', 1);
|
ini_set('display_errors', 1);
|
||||||
ini_set('display_startup_errors', 0);
|
ini_set('display_startup_errors', 1);
|
||||||
ini_set('log_errors', 0);
|
ini_set('log_errors', 0);
|
||||||
ini_set('allow_url_fopen', 0);
|
error_reporting(E_ALL & ~E_NOTICE);
|
||||||
ini_set('error_reporting', E_ALL);
|
|
||||||
|
if (class_exists('Log')) {
|
||||||
|
$logger = Log::getMonolog();
|
||||||
|
|
||||||
|
// only install if not existing
|
||||||
|
$install = true;
|
||||||
|
$logfile = Config::get('log_file', base_path('logs/librenms.log'));
|
||||||
|
foreach ($logger->getHandlers() as $handler) {
|
||||||
|
if ($handler instanceof \Monolog\Handler\StreamHandler) {
|
||||||
|
if ($handler->getUrl() == 'php://stdout') {
|
||||||
|
$install = false;
|
||||||
|
} elseif ($handler->getUrl() == $logfile) {
|
||||||
|
// send to librenms log file if not a cli app
|
||||||
|
if (!App::runningInConsole()) {
|
||||||
|
set_error_handler(function ($errno, $errstr, $errfile, $errline) {
|
||||||
|
Log::error("$errno $errfile:$errline $errstr");
|
||||||
|
});
|
||||||
|
$handler->setLevel(\Monolog\Logger::DEBUG);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($install) {
|
||||||
|
$handler = new \Monolog\Handler\StreamHandler(
|
||||||
|
'php://stdout',
|
||||||
|
\Monolog\Logger::DEBUG
|
||||||
|
);
|
||||||
|
|
||||||
|
$handler->setFormatter(new LibreNMS\Util\CliColorFormatter());
|
||||||
|
|
||||||
|
$logger->pushHandler($handler);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($db && !$db->getEventDispatcher()->hasListeners('Illuminate\Database\Events\QueryExecuted')) {
|
||||||
|
$db->listen(function (QueryExecuted $query) {
|
||||||
|
// collect bindings and make them a little more readable
|
||||||
|
$bindings = collect($query->bindings)->map(function ($item) {
|
||||||
|
if ($item instanceof \Carbon\Carbon) {
|
||||||
|
return $item->toDateTimeString();
|
||||||
|
}
|
||||||
|
|
||||||
|
return $item;
|
||||||
|
})->toJson();
|
||||||
|
|
||||||
|
if (class_exists('Log')) {
|
||||||
|
Log::debug("SQL[%Y{$query->sql} %y$bindings%n {$query->time}ms] \n", ['color' => true]);
|
||||||
|
} else {
|
||||||
|
c_echo("SQL[%Y{$query->sql} %y$bindings%n {$query->time}ms] \n");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
ini_set('display_errors', 0);
|
||||||
|
ini_set('display_startup_errors', 0);
|
||||||
|
ini_set('log_errors', 1);
|
||||||
|
error_reporting($silence ? 0 : E_ERROR);
|
||||||
|
|
||||||
|
if (class_exists('Log')) {
|
||||||
|
$handlers = Log::getMonolog()->getHandlers();
|
||||||
|
if (isset($handlers[0]) && $handlers[0]->getUrl() == 'php://stdout') {
|
||||||
|
Log::getMonolog()->popHandler();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($db) {
|
||||||
|
// remove all query executed event handlers
|
||||||
|
$db->getEventDispatcher()->flush('Illuminate\Database\Events\QueryExecuted');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return $debug;
|
||||||
}//end set_debug()
|
}//end set_debug()
|
||||||
|
|
||||||
function array_sort_by_column($array, $on, $order = SORT_ASC)
|
function array_sort_by_column($array, $on, $order = SORT_ASC)
|
||||||
|
@ -689,12 +776,12 @@ function isSNMPable($device)
|
||||||
* Check if the given host responds to ICMP echo requests ("pings").
|
* Check if the given host responds to ICMP echo requests ("pings").
|
||||||
*
|
*
|
||||||
* @param string $hostname The hostname or IP address to send ping requests to.
|
* @param string $hostname The hostname or IP address to send ping requests to.
|
||||||
* @param int $address_family The address family (AF_INET for IPv4 or AF_INET6 for IPv6) to use. Defaults to IPv4. Will *not* be autodetected for IP addresses, so it has to be set to AF_INET6 when pinging an IPv6 address or an IPv6-only host.
|
* @param int $address_family The address family ('ipv4' or 'ipv6') to use. Defaults to IPv4. Will *not* be autodetected for IP addresses, so it has to be set to 'ipv6' when pinging an IPv6 address or an IPv6-only host.
|
||||||
* @param array $attribs The device attributes
|
* @param array $attribs The device attributes
|
||||||
*
|
*
|
||||||
* @return array 'result' => bool pingable, 'last_ping_timetaken' => int time for last ping, 'db' => fping results
|
* @return array 'result' => bool pingable, 'last_ping_timetaken' => int time for last ping, 'db' => fping results
|
||||||
*/
|
*/
|
||||||
function isPingable($hostname, $address_family = AF_INET, $attribs = array())
|
function isPingable($hostname, $address_family = 'ipv4', $attribs = array())
|
||||||
{
|
{
|
||||||
global $config;
|
global $config;
|
||||||
|
|
||||||
|
@ -1444,7 +1531,7 @@ function ip_exists($ip)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
function fping($host, $params, $address_family = AF_INET)
|
function fping($host, $params, $address_family = 'ipv4')
|
||||||
{
|
{
|
||||||
|
|
||||||
global $config;
|
global $config;
|
||||||
|
@ -1455,9 +1542,9 @@ function fping($host, $params, $address_family = AF_INET)
|
||||||
2 => array("pipe", "w")
|
2 => array("pipe", "w")
|
||||||
);
|
);
|
||||||
|
|
||||||
// Default to AF_INET (IPv4)
|
// Default to ipv4
|
||||||
$fping_path = $config['fping'];
|
$fping_path = $config['fping'];
|
||||||
if ($address_family == AF_INET6) {
|
if ($address_family == 'ipv6') {
|
||||||
$fping_path = $config['fping6'];
|
$fping_path = $config['fping6'];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1533,23 +1620,19 @@ function force_influx_data($data)
|
||||||
* "udp6", "tcp", or "tcp6". See `man snmpcmd`,
|
* "udp6", "tcp", or "tcp6". See `man snmpcmd`,
|
||||||
* section "Agent Specification" for a full list.
|
* section "Agent Specification" for a full list.
|
||||||
*
|
*
|
||||||
* @return int The address family associated with the given transport
|
* @return string The address family associated with the given transport
|
||||||
* specifier: AF_INET for IPv4 (or local connections not associated
|
* specifier: 'ipv4' (or local connections not associated
|
||||||
* with an IP stack), AF_INET6 for IPv6.
|
* with an IP stack) or 'ipv6'.
|
||||||
*/
|
*/
|
||||||
function snmpTransportToAddressFamily($transport)
|
function snmpTransportToAddressFamily($transport)
|
||||||
{
|
{
|
||||||
if (!isset($transport)) {
|
$ipv6_snmp_transport_specifiers = ['udp6', 'udpv6', 'udpipv6', 'tcp6', 'tcpv6', 'tcpipv6'];
|
||||||
$transport = 'udp';
|
|
||||||
}
|
|
||||||
|
|
||||||
$ipv6_snmp_transport_specifiers = array('udp6', 'udpv6', 'udpipv6', 'tcp6', 'tcpv6', 'tcpipv6');
|
|
||||||
|
|
||||||
if (in_array($transport, $ipv6_snmp_transport_specifiers)) {
|
if (in_array($transport, $ipv6_snmp_transport_specifiers)) {
|
||||||
return AF_INET6;
|
return 'ipv6';
|
||||||
} else {
|
|
||||||
return AF_INET;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return 'ipv4';
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -2033,6 +2116,7 @@ function get_toner_levels($device, $raw_value, $capacity)
|
||||||
function initStats()
|
function initStats()
|
||||||
{
|
{
|
||||||
global $snmp_stats, $rrd_stats;
|
global $snmp_stats, $rrd_stats;
|
||||||
|
global $snmp_stats_last, $rrd_stats_last;
|
||||||
|
|
||||||
if (!isset($snmp_stats, $rrd_stats)) {
|
if (!isset($snmp_stats, $rrd_stats)) {
|
||||||
$snmp_stats = array(
|
$snmp_stats = array(
|
||||||
|
@ -2047,6 +2131,7 @@ function initStats()
|
||||||
'snmpwalk' => 0.0,
|
'snmpwalk' => 0.0,
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
$snmp_stats_last = $snmp_stats;
|
||||||
|
|
||||||
$rrd_stats = array(
|
$rrd_stats = array(
|
||||||
'ops' => array(
|
'ops' => array(
|
||||||
|
@ -2060,6 +2145,7 @@ function initStats()
|
||||||
'other' => 0.0,
|
'other' => 0.0,
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
$rrd_stats_last = $rrd_stats;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2098,47 +2184,55 @@ function printStats()
|
||||||
{
|
{
|
||||||
global $snmp_stats, $db_stats, $rrd_stats;
|
global $snmp_stats, $db_stats, $rrd_stats;
|
||||||
|
|
||||||
printf(
|
if ($snmp_stats) {
|
||||||
"SNMP [%d/%.2fs]: Get[%d/%.2fs] Getnext[%d/%.2fs] Walk[%d/%.2fs]\n",
|
printf(
|
||||||
array_sum($snmp_stats['ops']),
|
"SNMP [%d/%.2fs]: Get[%d/%.2fs] Getnext[%d/%.2fs] Walk[%d/%.2fs]\n",
|
||||||
array_sum($snmp_stats['time']),
|
array_sum($snmp_stats['ops']),
|
||||||
$snmp_stats['ops']['snmpget'],
|
array_sum($snmp_stats['time']),
|
||||||
$snmp_stats['time']['snmpget'],
|
$snmp_stats['ops']['snmpget'],
|
||||||
$snmp_stats['ops']['snmpgetnext'],
|
$snmp_stats['time']['snmpget'],
|
||||||
$snmp_stats['time']['snmpgetnext'],
|
$snmp_stats['ops']['snmpgetnext'],
|
||||||
$snmp_stats['ops']['snmpwalk'],
|
$snmp_stats['time']['snmpgetnext'],
|
||||||
$snmp_stats['time']['snmpwalk']
|
$snmp_stats['ops']['snmpwalk'],
|
||||||
);
|
$snmp_stats['time']['snmpwalk']
|
||||||
printf(
|
);
|
||||||
"MySQL [%d/%.2fs]: Cell[%d/%.2fs] Row[%d/%.2fs] Rows[%d/%.2fs] Column[%d/%.2fs] Update[%d/%.2fs] Insert[%d/%.2fs] Delete[%d/%.2fs]\n",
|
}
|
||||||
array_sum($db_stats['ops']),
|
|
||||||
array_sum($db_stats['time']),
|
if ($db_stats) {
|
||||||
$db_stats['ops']['fetchcell'],
|
printf(
|
||||||
$db_stats['time']['fetchcell'],
|
"MySQL [%d/%.2fs]: Cell[%d/%.2fs] Row[%d/%.2fs] Rows[%d/%.2fs] Column[%d/%.2fs] Update[%d/%.2fs] Insert[%d/%.2fs] Delete[%d/%.2fs]\n",
|
||||||
$db_stats['ops']['fetchrow'],
|
array_sum($db_stats['ops']),
|
||||||
$db_stats['time']['fetchrow'],
|
array_sum($db_stats['time']),
|
||||||
$db_stats['ops']['fetchrows'],
|
$db_stats['ops']['fetchcell'],
|
||||||
$db_stats['time']['fetchrows'],
|
$db_stats['time']['fetchcell'],
|
||||||
$db_stats['ops']['fetchcolumn'],
|
$db_stats['ops']['fetchrow'],
|
||||||
$db_stats['time']['fetchcolumn'],
|
$db_stats['time']['fetchrow'],
|
||||||
$db_stats['ops']['update'],
|
$db_stats['ops']['fetchrows'],
|
||||||
$db_stats['time']['update'],
|
$db_stats['time']['fetchrows'],
|
||||||
$db_stats['ops']['insert'],
|
$db_stats['ops']['fetchcolumn'],
|
||||||
$db_stats['time']['insert'],
|
$db_stats['time']['fetchcolumn'],
|
||||||
$db_stats['ops']['delete'],
|
$db_stats['ops']['update'],
|
||||||
$db_stats['time']['delete']
|
$db_stats['time']['update'],
|
||||||
);
|
$db_stats['ops']['insert'],
|
||||||
printf(
|
$db_stats['time']['insert'],
|
||||||
"RRD [%d/%.2fs]: Update[%d/%.2fs] Create [%d/%.2fs] Other[%d/%.2fs]\n",
|
$db_stats['ops']['delete'],
|
||||||
array_sum($rrd_stats['ops']),
|
$db_stats['time']['delete']
|
||||||
array_sum($rrd_stats['time']),
|
);
|
||||||
$rrd_stats['ops']['update'],
|
}
|
||||||
$rrd_stats['time']['update'],
|
|
||||||
$rrd_stats['ops']['create'],
|
if ($rrd_stats) {
|
||||||
$rrd_stats['time']['create'],
|
printf(
|
||||||
$rrd_stats['ops']['other'],
|
"RRD [%d/%.2fs]: Update[%d/%.2fs] Create [%d/%.2fs] Other[%d/%.2fs]\n",
|
||||||
$rrd_stats['time']['other']
|
array_sum($rrd_stats['ops']),
|
||||||
);
|
array_sum($rrd_stats['time']),
|
||||||
|
$rrd_stats['ops']['update'],
|
||||||
|
$rrd_stats['time']['update'],
|
||||||
|
$rrd_stats['ops']['create'],
|
||||||
|
$rrd_stats['time']['create'],
|
||||||
|
$rrd_stats['ops']['other'],
|
||||||
|
$rrd_stats['time']['other']
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -99,8 +99,6 @@ ini_set('display_errors', 1);
|
||||||
if (!module_selected('nodb', $init_modules)) {
|
if (!module_selected('nodb', $init_modules)) {
|
||||||
// Connect to database
|
// Connect to database
|
||||||
try {
|
try {
|
||||||
// \LibreNMS\DB\Eloquent::boot();
|
|
||||||
|
|
||||||
dbConnect();
|
dbConnect();
|
||||||
} catch (\LibreNMS\Exceptions\DatabaseConnectException $e) {
|
} catch (\LibreNMS\Exceptions\DatabaseConnectException $e) {
|
||||||
if (isCli()) {
|
if (isCli()) {
|
||||||
|
@ -113,6 +111,17 @@ if (!module_selected('nodb', $init_modules)) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (module_selected('laravel', $init_modules)) {
|
||||||
|
// make sure Laravel isn't already booted
|
||||||
|
if (!class_exists('App') || !App::isBooted()) {
|
||||||
|
$app = require_once $install_dir . '/bootstrap/app.php';
|
||||||
|
$kernel = $app->make(Illuminate\Contracts\Console\Kernel::class);
|
||||||
|
$kernel->bootstrap();
|
||||||
|
}
|
||||||
|
} elseif (module_selected('eloquent', $init_modules)) {
|
||||||
|
\LibreNMS\DB\Eloquent::boot();
|
||||||
|
}
|
||||||
|
|
||||||
// Load config if not already loaded (which is the case if inside Laravel)
|
// Load config if not already loaded (which is the case if inside Laravel)
|
||||||
if (!Config::has('install_dir')) {
|
if (!Config::has('install_dir')) {
|
||||||
Config::load();
|
Config::load();
|
||||||
|
|
|
@ -33,7 +33,7 @@ try {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$f2b = $f2b[data];
|
$f2b = $f2b['data'];
|
||||||
|
|
||||||
$metrics = [];
|
$metrics = [];
|
||||||
|
|
||||||
|
|
|
@ -13,7 +13,7 @@ $json = snmp_get($device, $oid, $options, $mib);
|
||||||
|
|
||||||
$zfs=json_decode(stripslashes($json), true);
|
$zfs=json_decode(stripslashes($json), true);
|
||||||
|
|
||||||
$rrd_name = array('app', $name, $app_id);
|
$rrd_name = ['app', $name, $app_id];
|
||||||
$rrd_def = RrdDefinition::make()
|
$rrd_def = RrdDefinition::make()
|
||||||
->addDataset('deleted', 'DERIVE', 0)
|
->addDataset('deleted', 'DERIVE', 0)
|
||||||
->addDataset('evict_skip', 'DERIVE', 0)
|
->addDataset('evict_skip', 'DERIVE', 0)
|
||||||
|
@ -69,70 +69,70 @@ $rrd_def = RrdDefinition::make()
|
||||||
->addDataset('meta_misses_per', 'GAUGE', 0)
|
->addDataset('meta_misses_per', 'GAUGE', 0)
|
||||||
->addDataset('pre_meta_misses_per', 'GAUGE', 0);
|
->addDataset('pre_meta_misses_per', 'GAUGE', 0);
|
||||||
|
|
||||||
$fields = array(
|
$fields = [
|
||||||
'deleted' => $zfs{deleted},
|
'deleted' => $zfs['deleted'],
|
||||||
'evict_skip' => $zfs{evict_skip},
|
'evict_skip' => $zfs['evict_skip'],
|
||||||
'mutex_skip' => $zfs{mutex_skip},
|
'mutex_skip' => $zfs['mutex_skip'],
|
||||||
'recycle_miss' => $zfs{recycle_miss},
|
'recycle_miss' => $zfs['recycle_miss'],
|
||||||
'arc_size' => $zfs{arc_size},
|
'arc_size' => $zfs['arc_size'],
|
||||||
'target_size_max' => $zfs{target_size_max},
|
'target_size_max' => $zfs['target_size_max'],
|
||||||
'target_size_min' => $zfs{target_size_min},
|
'target_size_min' => $zfs['target_size_min'],
|
||||||
'target_size' => $zfs{target_size},
|
'target_size' => $zfs['target_size'],
|
||||||
'target_size_per' => $zfs{target_size_per},
|
'target_size_per' => $zfs['target_size_per'],
|
||||||
'arc_size_per' => $zfs{arc_size_per},
|
'arc_size_per' => $zfs['arc_size_per'],
|
||||||
'target_size_arat' => $zfs{target_size_arat},
|
'target_size_arat' => $zfs['target_size_arat'],
|
||||||
'min_size_per' => $zfs{min_size_per},
|
'min_size_per' => $zfs['min_size_per'],
|
||||||
'mfu_size' => $zfs{mfu_size},
|
'mfu_size' => $zfs['mfu_size'],
|
||||||
'p' => $zfs{p},
|
'p' => $zfs['p'],
|
||||||
'rec_used_per' => $zfs{rec_used_per},
|
'rec_used_per' => $zfs['rec_used_per'],
|
||||||
'freq_used_per' => $zfs{freq_used_per},
|
'freq_used_per' => $zfs['freq_used_per'],
|
||||||
'arc_hits' => $zfs{arc_hits},
|
'arc_hits' => $zfs['arc_hits'],
|
||||||
'arc_misses' => $zfs{arc_misses},
|
'arc_misses' => $zfs['arc_misses'],
|
||||||
'demand_data_hits' => $zfs{demand_data_hits},
|
'demand_data_hits' => $zfs['demand_data_hits'],
|
||||||
'demand_data_misses' => $zfs{demand_data_misses},
|
'demand_data_misses' => $zfs['demand_data_misses'],
|
||||||
'demand_meta_hits' => $zfs{demand_meta_hits},
|
'demand_meta_hits' => $zfs['demand_meta_hits'],
|
||||||
'demand_meta_misses' => $zfs{demand_meta_misses},
|
'demand_meta_misses' => $zfs['demand_meta_misses'],
|
||||||
'mfu_ghost_hits' => $zfs{mfu_ghost_hits},
|
'mfu_ghost_hits' => $zfs['mfu_ghost_hits'],
|
||||||
'mfu_hits' => $zfs{mfu_hits},
|
'mfu_hits' => $zfs['mfu_hits'],
|
||||||
'mru_ghost_hits' => $zfs{mru_ghost_hits},
|
'mru_ghost_hits' => $zfs['mru_ghost_hits'],
|
||||||
'mru_hits' => $zfs{mru_hits},
|
'mru_hits' => $zfs['mru_hits'],
|
||||||
'pre_data_hits' => $zfs{pre_data_hits},
|
'pre_data_hits' => $zfs['pre_data_hits'],
|
||||||
'pre_data_misses' => $zfs{pre_data_misses},
|
'pre_data_misses' => $zfs['pre_data_misses'],
|
||||||
'pre_meta_hits' => $zfs{pre_meta_hits},
|
'pre_meta_hits' => $zfs['pre_meta_hits'],
|
||||||
'pre_meta_misses' => $zfs{pre_meta_misses},
|
'pre_meta_misses' => $zfs['pre_meta_misses'],
|
||||||
'anon_hits' => $zfs{anon_hits},
|
'anon_hits' => $zfs['anon_hits'],
|
||||||
'arc_accesses_total' => $zfs{arc_accesses_total},
|
'arc_accesses_total' => $zfs['arc_accesses_total'],
|
||||||
'demand_data_total' => $zfs{demand_data_total},
|
'demand_data_total' => $zfs['demand_data_total'],
|
||||||
'pre_data_total' => $zfs{pre_data_total},
|
'pre_data_total' => $zfs['pre_data_total'],
|
||||||
'real_hits' => $zfs{real_hits},
|
'real_hits' => $zfs['real_hits'],
|
||||||
'cache_hits_per' => $zfs{cache_hits_per},
|
'cache_hits_per' => $zfs['cache_hits_per'],
|
||||||
'cache_miss_per' => $zfs{cache_miss_per},
|
'cache_miss_per' => $zfs['cache_miss_per'],
|
||||||
'actual_hit_per' => $zfs{actual_hit_per},
|
'actual_hit_per' => $zfs['actual_hit_per'],
|
||||||
'data_demand_per' => $zfs{data_demand_per},
|
'data_demand_per' => $zfs['data_demand_per'],
|
||||||
'data_pre_per' => $zfs{data_pre_per},
|
'data_pre_per' => $zfs['data_pre_per'],
|
||||||
'anon_hits_per' => $zfs{anon_hits_per},
|
'anon_hits_per' => $zfs['anon_hits_per'],
|
||||||
'mru_per' => $zfs{mru_per},
|
'mru_per' => $zfs['mru_per'],
|
||||||
'mfu_per' => $zfs{mfu_per},
|
'mfu_per' => $zfs['mfu_per'],
|
||||||
'mru_ghost_per' => $zfs{mru_ghost_per},
|
'mru_ghost_per' => $zfs['mru_ghost_per'],
|
||||||
'mfu_ghost_per' => $zfs{mfu_ghost_per},
|
'mfu_ghost_per' => $zfs['mfu_ghost_per'],
|
||||||
'demand_hits_per' => $zfs{demand_hits_per},
|
'demand_hits_per' => $zfs['demand_hits_per'],
|
||||||
'pre_hits_per' => $zfs{pre_hits_per},
|
'pre_hits_per' => $zfs['pre_hits_per'],
|
||||||
'meta_hits_per' => $zfs{meta_hits_per},
|
'meta_hits_per' => $zfs['meta_hits_per'],
|
||||||
'pre_meta_hits_per' => $zfs{pre_meta_hits_per},
|
'pre_meta_hits_per' => $zfs['pre_meta_hits_per'],
|
||||||
'demand_misses_per' => $zfs{demand_misses_per},
|
'demand_misses_per' => $zfs['demand_misses_per'],
|
||||||
'pre_misses_per' => $zfs{pre_misses_per},
|
'pre_misses_per' => $zfs['pre_misses_per'],
|
||||||
'meta_misses_per' => $zfs{meta_misses_per},
|
'meta_misses_per' => $zfs['meta_misses_per'],
|
||||||
'pre_meta_misses_per' => $zfs{pre_meta_misses_per},
|
'pre_meta_misses_per' => $zfs['pre_meta_misses_per'],
|
||||||
);
|
];
|
||||||
|
|
||||||
$tags = array('name' => $name, 'app_id' => $app_id, 'rrd_def' => $rrd_def, 'rrd_name' => $rrd_name);
|
$tags = ['name' => $name, 'app_id' => $app_id, 'rrd_def' => $rrd_def, 'rrd_name' => $rrd_name];
|
||||||
data_update($device, 'app', $tags, $fields);
|
data_update($device, 'app', $tags, $fields);
|
||||||
|
|
||||||
//
|
//
|
||||||
// process additional info returned
|
// process additional info returned
|
||||||
//
|
//
|
||||||
|
|
||||||
$pools=array();
|
$pools = [];
|
||||||
$pool_rrd_def = RrdDefinition::make()
|
$pool_rrd_def = RrdDefinition::make()
|
||||||
->addDataset('size', 'GAUGE', 0)
|
->addDataset('size', 'GAUGE', 0)
|
||||||
->addDataset('alloc', 'GAUGE', 0)
|
->addDataset('alloc', 'GAUGE', 0)
|
||||||
|
@ -143,21 +143,21 @@ $pool_rrd_def = RrdDefinition::make()
|
||||||
->addDataset('dedup', 'GAUGE', 0);
|
->addDataset('dedup', 'GAUGE', 0);
|
||||||
|
|
||||||
$pools_int=0;
|
$pools_int=0;
|
||||||
$pools_for_metrics=array(); // used later for replacing pools when inserting into the metrics table
|
$pools_for_metrics = []; // used later for replacing pools when inserting into the metrics table
|
||||||
while (isset($zfs{'pools'}{$pools_int})) {
|
while (isset($zfs['pools'][$pools_int])) {
|
||||||
$pools[]=$zfs{'pools'}{$pools_int}{'name'};
|
$pools[] = $zfs['pools'][$pools_int]['name'];
|
||||||
$pools_for_mertrics[$zfs{'pools'}{$pools_int}{'name'}]=$zfs{'pools'}{$pools_int}; // copy the pool over later
|
$pools_for_metrics[$zfs['pools'][$pools_int]['name']] = $zfs['pools'][$pools_int]; // copy the pool over later
|
||||||
$rrd_name = array('app', $name, $app_id, $zfs{'pools'}{$pools_int}{'name'});
|
$rrd_name = ['app', $name, $app_id, $zfs['pools'][$pools_int]['name']];
|
||||||
$fields = array(
|
$fields = [
|
||||||
'size' => $zfs{'pools'}{$pools_int}{'size'},
|
'size' => $zfs['pools'][$pools_int]['size'],
|
||||||
'alloc' => $zfs{'pools'}{$pools_int}{'alloc'},
|
'alloc' => $zfs['pools'][$pools_int]['alloc'],
|
||||||
'free' => $zfs{'pools'}{$pools_int}{'free'},
|
'free' => $zfs['pools'][$pools_int]['free'],
|
||||||
'expandsz' => $zfs{'pools'}{$pools_int}{'expandsz'},
|
'expandsz' => $zfs['pools'][$pools_int]['expandsz'],
|
||||||
'frag' => $zfs{'pools'}{$pools_int}{'frag'},
|
'frag' => $zfs['pools'][$pools_int]['frag'],
|
||||||
'cap' => $zfs{'pools'}{$pools_int}{'cap'},
|
'cap' => $zfs['pools'][$pools_int]['cap'],
|
||||||
'dedup' => $zfs{'pools'}{$pools_int}{'dedup'},
|
'dedup' => $zfs['pools'][$pools_int]['dedup'],
|
||||||
);
|
];
|
||||||
$tags = array('name' => $name, 'app_id' => $app_id, 'rrd_def' => $pool_rrd_def, 'rrd_name' => $rrd_name);
|
$tags = ['name' => $name, 'app_id' => $app_id, 'rrd_def' => $pool_rrd_def, 'rrd_name' => $rrd_name];
|
||||||
data_update($device, 'app', $tags, $fields);
|
data_update($device, 'app', $tags, $fields);
|
||||||
|
|
||||||
$pools_int++;
|
$pools_int++;
|
||||||
|
@ -167,12 +167,12 @@ while (isset($zfs{'pools'}{$pools_int})) {
|
||||||
// component processing for ZFS
|
// component processing for ZFS
|
||||||
//
|
//
|
||||||
$device_id=$device['device_id'];
|
$device_id=$device['device_id'];
|
||||||
$options=array(
|
$options= [
|
||||||
'filter' => array(
|
'filter' => [
|
||||||
'device_id' => array('=', $device_id),
|
'device_id' => ['=', $device_id],
|
||||||
'type' => array('=', 'zfs'),
|
'type' => ['=', 'zfs'],
|
||||||
),
|
],
|
||||||
);
|
];
|
||||||
|
|
||||||
$component=new LibreNMS\Component();
|
$component=new LibreNMS\Component();
|
||||||
$components=$component->getComponents($device_id, $options);
|
$components=$component->getComponents($device_id, $options);
|
||||||
|
@ -199,5 +199,5 @@ if (empty($pools)) {
|
||||||
}
|
}
|
||||||
|
|
||||||
//replace $zfs{'pools'} with a array where the keys are the pool names and update metrics
|
//replace $zfs{'pools'} with a array where the keys are the pool names and update metrics
|
||||||
$zfs{'pools'}=$pools_for_mertrics;
|
$zfs['pools'] = $pools_for_metrics;
|
||||||
update_application($app, $json, $zfs);
|
update_application($app, $json, $zfs);
|
||||||
|
|
|
@ -338,8 +338,6 @@ if ($config['enable_bgp']) {
|
||||||
$safis['multicast'] = 2;
|
$safis['multicast'] = 2;
|
||||||
$afis['ipv4'] = 1;
|
$afis['ipv4'] = 1;
|
||||||
$afis['ipv6'] = 2;
|
$afis['ipv6'] = 2;
|
||||||
$type['ipv4'] = 4;
|
|
||||||
$type['ipv6'] = 16;
|
|
||||||
if (preg_match('/:/', $peer['bgpPeerIdentifier'])) {
|
if (preg_match('/:/', $peer['bgpPeerIdentifier'])) {
|
||||||
$tmp_peer = str_replace(':', '', $peer['bgpPeerIdentifier']);
|
$tmp_peer = str_replace(':', '', $peer['bgpPeerIdentifier']);
|
||||||
$tmp_peer = preg_replace('/([\w\d]{2})/', '\1:', $tmp_peer);
|
$tmp_peer = preg_replace('/([\w\d]{2})/', '\1:', $tmp_peer);
|
||||||
|
|
|
@ -26,7 +26,7 @@ if ($device['os_group'] == "cisco") {
|
||||||
$components = $components[$device['device_id']];
|
$components = $components[$device['device_id']];
|
||||||
|
|
||||||
// Only collect SNMP data if we have enabled components
|
// Only collect SNMP data if we have enabled components
|
||||||
if (count($components > 0)) {
|
if (is_array($components) && count($components) > 0) {
|
||||||
// Let's gather the stats..
|
// Let's gather the stats..
|
||||||
$tblcbQosClassMapStats = snmpwalk_array_num($device, '.1.3.6.1.4.1.9.9.166.1.15.1.1', 2);
|
$tblcbQosClassMapStats = snmpwalk_array_num($device, '.1.3.6.1.4.1.9.9.166.1.15.1.1', 2);
|
||||||
|
|
||||||
|
|
|
@ -96,7 +96,7 @@ if ($device['os_group'] == 'cisco') {
|
||||||
// FIXME - need to delete old ones. FIXME REALLY.
|
// FIXME - need to delete old ones. FIXME REALLY.
|
||||||
print_r($cefs_db);
|
print_r($cefs_db);
|
||||||
|
|
||||||
foreach ($cefs_db as $cef_switching_id) {
|
foreach ((array)$cefs_db as $cef_switching_id) {
|
||||||
dbDelete('cef_switching', '`cef_switching_id` = ?', array($cef_switching_id));
|
dbDelete('cef_switching', '`cef_switching_id` = ?', array($cef_switching_id));
|
||||||
echo '-';
|
echo '-';
|
||||||
}
|
}
|
||||||
|
|
|
@ -69,7 +69,7 @@ if ($device['os_group'] == "cisco") {
|
||||||
$components = $components[$device['device_id']];
|
$components = $components[$device['device_id']];
|
||||||
|
|
||||||
// Only collect SNMP data if we have enabled components
|
// Only collect SNMP data if we have enabled components
|
||||||
if (count($components) > 0) {
|
if (is_array($components) && count($components) > 0) {
|
||||||
// Let's gather the stats..
|
// Let's gather the stats..
|
||||||
$tblOverlayEntry = snmpwalk_array_num($device, '.1.3.6.1.4.1.9.9.810.1.2.1.1');
|
$tblOverlayEntry = snmpwalk_array_num($device, '.1.3.6.1.4.1.9.9.810.1.2.1.1');
|
||||||
$tblAdjacencyDatabaseEntry = snmpwalk_array_num($device, '.1.3.6.1.4.1.9.9.810.1.3.1.1', 0);
|
$tblAdjacencyDatabaseEntry = snmpwalk_array_num($device, '.1.3.6.1.4.1.9.9.810.1.3.1.1', 0);
|
||||||
|
|
|
@ -12,7 +12,7 @@ use LibreNMS\RRD\RrdDefinition;
|
||||||
if ($device['os_group'] == 'cisco') {
|
if ($device['os_group'] == 'cisco') {
|
||||||
$data = snmpwalk_cache_oid($device, 'cvpdnSystemEntry', null, 'CISCO-VPDN-MGMT-MIB');
|
$data = snmpwalk_cache_oid($device, 'cvpdnSystemEntry', null, 'CISCO-VPDN-MGMT-MIB');
|
||||||
|
|
||||||
foreach ($data as $type => $vpdn) {
|
foreach ((array)$data as $type => $vpdn) {
|
||||||
if ($vpdn['cvpdnSystemTunnelTotal'] || $vpdn['cvpdnSystemSessionTotal']) {
|
if ($vpdn['cvpdnSystemTunnelTotal'] || $vpdn['cvpdnSystemSessionTotal']) {
|
||||||
$rrd_name = array('vpdn', $type);
|
$rrd_name = array('vpdn', $type);
|
||||||
$rrd_def = RrdDefinition::make()
|
$rrd_def = RrdDefinition::make()
|
||||||
|
|
|
@ -25,7 +25,7 @@ foreach (dbFetch('SELECT * FROM `entPhysical_state` WHERE `device_id` = ?', arra
|
||||||
|
|
||||||
// End Set Entity Attrivs
|
// End Set Entity Attrivs
|
||||||
// Delete Entity state
|
// Delete Entity state
|
||||||
foreach ($entPhysical_state as $epi => $entity) {
|
foreach ((array)$entPhysical_state as $epi => $entity) {
|
||||||
foreach ($entity as $subindex => $si) {
|
foreach ($entity as $subindex => $si) {
|
||||||
foreach ($si as $group => $ti) {
|
foreach ($si as $group => $ti) {
|
||||||
foreach ($ti as $key => $value) {
|
foreach ($ti as $key => $value) {
|
||||||
|
|
|
@ -244,7 +244,8 @@ function poll_device($device, $force_module = false)
|
||||||
echo 'Device ID: ' . $device['device_id'] . PHP_EOL;
|
echo 'Device ID: ' . $device['device_id'] . PHP_EOL;
|
||||||
echo 'OS: ' . $device['os'];
|
echo 'OS: ' . $device['os'];
|
||||||
$ip = dnslookup($device);
|
$ip = dnslookup($device);
|
||||||
$db_ip = inet_pton($ip);
|
|
||||||
|
$db_ip = isset($ip) ? inet_pton($ip) : null;
|
||||||
|
|
||||||
if (!empty($db_ip) && inet6_ntop($db_ip) != inet6_ntop($device['ip'])) {
|
if (!empty($db_ip) && inet6_ntop($db_ip) != inet6_ntop($device['ip'])) {
|
||||||
log_event('Device IP changed to ' . $ip, $device, 'system', 3);
|
log_event('Device IP changed to ' . $ip, $device, 'system', 3);
|
||||||
|
|
|
@ -23,7 +23,7 @@ if (!is_array($mempool_cache['fiberhome-switch'])) {
|
||||||
d_echo($mempool_cache);
|
d_echo($mempool_cache);
|
||||||
}
|
}
|
||||||
|
|
||||||
$entry = $mempool_cache['fiberhome-switch'][$mempool[mempool_index]];
|
$entry = $mempool_cache['fiberhome-switch'][$mempool['mempool_index']];
|
||||||
|
|
||||||
if ($entry['memoryPoolTotalBytes'] < 0) {
|
if ($entry['memoryPoolTotalBytes'] < 0) {
|
||||||
$entry['memoryPoolTotalBytes'] = ($entry['memoryPoolTotalBytes'] * -1);
|
$entry['memoryPoolTotalBytes'] = ($entry['memoryPoolTotalBytes'] * -1);
|
||||||
|
|
|
@ -14,7 +14,7 @@ if (!is_array($mempool_cache['hpGlobal'])) {
|
||||||
d_echo('Cached!');
|
d_echo('Cached!');
|
||||||
}
|
}
|
||||||
|
|
||||||
$entry = $mempool_cache['hpGlobal'][$mempool[mempool_index]];
|
$entry = $mempool_cache['hpGlobal'][$mempool['mempool_index']];
|
||||||
|
|
||||||
$mempool['units'] = '1';
|
$mempool['units'] = '1';
|
||||||
$mempool['used'] = $entry['hpGlobalMemAllocBytes'];
|
$mempool['used'] = $entry['hpGlobalMemAllocBytes'];
|
||||||
|
|
|
@ -14,7 +14,7 @@ if (!is_array($mempool_cache['hpLocal'])) {
|
||||||
d_echo('Cached!');
|
d_echo('Cached!');
|
||||||
}
|
}
|
||||||
|
|
||||||
$entry = $mempool_cache['hpLocal'][$mempool[mempool_index]];
|
$entry = $mempool_cache['hpLocal'][$mempool['mempool_index']];
|
||||||
|
|
||||||
$mempool['units'] = '1';
|
$mempool['units'] = '1';
|
||||||
$mempool['used'] = $entry['hpLocalMemAllocBytes'];
|
$mempool['used'] = $entry['hpLocalMemAllocBytes'];
|
||||||
|
|
|
@ -8,7 +8,7 @@ if (!is_array($storage_cache['hrstorage'])) {
|
||||||
d_echo('Cached!');
|
d_echo('Cached!');
|
||||||
}
|
}
|
||||||
|
|
||||||
$entry = $storage_cache['hrstorage'][$mempool[mempool_index]];
|
$entry = $storage_cache['hrstorage'][$mempool['mempool_index']];
|
||||||
|
|
||||||
$mempool['units'] = $entry['hrStorageAllocationUnits'];
|
$mempool['units'] = $entry['hrStorageAllocationUnits'];
|
||||||
$mempool['used'] = ($entry['hrStorageUsed'] * $mempool['units']);
|
$mempool['used'] = ($entry['hrStorageUsed'] * $mempool['units']);
|
||||||
|
|
|
@ -27,7 +27,7 @@ else {
|
||||||
$mempool_cache['ironware-dyn'] = snmpwalk_cache_multi_oid($device, 'snAgentBrdMemoryTotal', $mempool_cache['ironware-dyn'], 'FOUNDRY-SN-AGENT-MIB');
|
$mempool_cache['ironware-dyn'] = snmpwalk_cache_multi_oid($device, 'snAgentBrdMemoryTotal', $mempool_cache['ironware-dyn'], 'FOUNDRY-SN-AGENT-MIB');
|
||||||
d_echo($mempool_cache);
|
d_echo($mempool_cache);
|
||||||
|
|
||||||
$entry = $mempool_cache['ironware-dyn'][$mempool[mempool_index]];
|
$entry = $mempool_cache['ironware-dyn'][$mempool['mempool_index']];
|
||||||
|
|
||||||
$perc = $entry['snAgentBrdMemoryUtil100thPercent'];
|
$perc = $entry['snAgentBrdMemoryUtil100thPercent'];
|
||||||
|
|
||||||
|
|
|
@ -14,7 +14,7 @@ if (!is_array($mempool_cache['junos'])) {
|
||||||
d_echo($mempool_cache);
|
d_echo($mempool_cache);
|
||||||
}
|
}
|
||||||
|
|
||||||
$entry = $mempool_cache['junos'][$mempool[mempool_index]];
|
$entry = $mempool_cache['junos'][$mempool['mempool_index']];
|
||||||
|
|
||||||
$perc = $entry['jnxOperatingBuffer'];
|
$perc = $entry['jnxOperatingBuffer'];
|
||||||
// FIX ME -- Maybe another OID? Some equipment do not provide jnxOperatingDRAMSize like MX960
|
// FIX ME -- Maybe another OID? Some equipment do not provide jnxOperatingDRAMSize like MX960
|
||||||
|
|
|
@ -7,7 +7,7 @@ preg_match('/^.* Build (?<build>\d+)/', $device['version'], $version);
|
||||||
d_echo($version);
|
d_echo($version);
|
||||||
|
|
||||||
// specified MIB supported since build 16607
|
// specified MIB supported since build 16607
|
||||||
if ($version[build] >= 16607) {
|
if ($version['build'] >= 16607) {
|
||||||
$perc = snmp_get($device, 'nmsMemoryPoolUtilization.0', '-OUvQ', 'NMS-MEMORY-POOL-MIB', 'pbn');
|
$perc = snmp_get($device, 'nmsMemoryPoolUtilization.0', '-OUvQ', 'NMS-MEMORY-POOL-MIB', 'pbn');
|
||||||
$memory_available = snmp_get($device, 'nmsMemoryPoolTotalMemorySize.0', '-OUvQ', 'NMS-MEMORY-POOL-MIB', 'pbn');
|
$memory_available = snmp_get($device, 'nmsMemoryPoolTotalMemorySize.0', '-OUvQ', 'NMS-MEMORY-POOL-MIB', 'pbn');
|
||||||
$mempool['total'] = $memory_available;
|
$mempool['total'] = $memory_available;
|
||||||
|
|
|
@ -13,7 +13,7 @@ if (!is_array($mempool_cache['vrp'])) {
|
||||||
d_echo($mempool_cache);
|
d_echo($mempool_cache);
|
||||||
}
|
}
|
||||||
|
|
||||||
$entry = $mempool_cache['vrp'][$mempool[mempool_index]];
|
$entry = $mempool_cache['vrp'][$mempool['mempool_index']];
|
||||||
|
|
||||||
if ($entry['hwEntityMemSize'] < 0) {
|
if ($entry['hwEntityMemSize'] < 0) {
|
||||||
$entry['hwEntityMemSize'] = ($entry['hwEntityMemSize'] * -1);
|
$entry['hwEntityMemSize'] = ($entry['hwEntityMemSize'] * -1);
|
||||||
|
|
|
@ -26,7 +26,7 @@ $components = $component->getComponents($device['device_id'], $options);
|
||||||
$components = $components[$device['device_id']];
|
$components = $components[$device['device_id']];
|
||||||
|
|
||||||
// Only collect SNMP data if we have enabled components
|
// Only collect SNMP data if we have enabled components
|
||||||
if (count($components > 0)) {
|
if (is_array($components) && count($components) > 0) {
|
||||||
// Let's gather the stats..
|
// Let's gather the stats..
|
||||||
$cntpPeersVarEntry = snmpwalk_array_num($device, '.1.3.6.1.4.1.9.9.168.1.2.1.1', 2);
|
$cntpPeersVarEntry = snmpwalk_array_num($device, '.1.3.6.1.4.1.9.9.168.1.2.1.1', 2);
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
// Build SNMP Cache Array
|
// Build SNMP Cache Array
|
||||||
|
use LibreNMS\Config;
|
||||||
use LibreNMS\RRD\RrdDefinition;
|
use LibreNMS\RRD\RrdDefinition;
|
||||||
|
|
||||||
$data_oids = array(
|
$data_oids = array(
|
||||||
|
@ -214,7 +215,8 @@ if ($device['os'] === 'f5' && (version_compare($device['version'], '11.2.0', '>=
|
||||||
unset($data);
|
unset($data);
|
||||||
} else {
|
} else {
|
||||||
// For devices that are on the bad_ifXentry list, try fetching ifAlias to have nice interface descriptions.
|
// For devices that are on the bad_ifXentry list, try fetching ifAlias to have nice interface descriptions.
|
||||||
if (!in_array(strtolower($device['hardware']), array_map('strtolower', $config['os'][$device['os']]['bad_ifXEntry']))) {
|
|
||||||
|
if (!in_array(strtolower($device['hardware']), array_map('strtolower', (array)Config::getOsSetting($device['os'], 'bad_ifXEntry', [])))) {
|
||||||
$port_stats = snmpwalk_cache_oid($device, 'ifXEntry', $port_stats, 'IF-MIB');
|
$port_stats = snmpwalk_cache_oid($device, 'ifXEntry', $port_stats, 'IF-MIB');
|
||||||
} else {
|
} else {
|
||||||
$port_stats = snmpwalk_cache_oid($device, 'ifAlias', $port_stats, 'IF-MIB', null, '-OQUst');
|
$port_stats = snmpwalk_cache_oid($device, 'ifAlias', $port_stats, 'IF-MIB', null, '-OQUst');
|
||||||
|
@ -731,7 +733,7 @@ foreach ($ports as $port) {
|
||||||
$port['stats']['ifOutBits_rate'] = round(($port['stats']['ifOutOctets_rate'] * 8));
|
$port['stats']['ifOutBits_rate'] = round(($port['stats']['ifOutOctets_rate'] * 8));
|
||||||
|
|
||||||
// If we have a valid ifSpeed we should populate the stats for checking.
|
// If we have a valid ifSpeed we should populate the stats for checking.
|
||||||
if (is_numeric($this_port['ifSpeed'])) {
|
if (is_numeric($this_port['ifSpeed']) && $this_port['ifSpeed'] > 0) {
|
||||||
$port['stats']['ifInBits_perc'] = round(($port['stats']['ifInBits_rate'] / $this_port['ifSpeed'] * 100));
|
$port['stats']['ifInBits_perc'] = round(($port['stats']['ifInBits_rate'] / $this_port['ifSpeed'] * 100));
|
||||||
$port['stats']['ifOutBits_perc'] = round(($port['stats']['ifOutBits_rate'] / $this_port['ifSpeed'] * 100));
|
$port['stats']['ifOutBits_perc'] = round(($port['stats']['ifOutBits_rate'] / $this_port['ifSpeed'] * 100));
|
||||||
}
|
}
|
||||||
|
|
|
@ -60,8 +60,8 @@ foreach ($storage_cache2['eql-storage'] as $index => $vsentry) {
|
||||||
}
|
}
|
||||||
d_echo($storage_cache20);
|
d_echo($storage_cache20);
|
||||||
|
|
||||||
$entry1 = $storage_cache10[$storage[storage_index]];
|
$entry1 = $storage_cache10[$storage['storage_index']];
|
||||||
$entry2 = $storage_cache20[$storage[storage_index]];
|
$entry2 = $storage_cache20[$storage['storage_index']];
|
||||||
|
|
||||||
$storage['units'] = 1000000;
|
$storage['units'] = 1000000;
|
||||||
$storage['size'] = ($entry1['eqliscsiVolumeSize'] * $storage['units']);
|
$storage['size'] = ($entry1['eqliscsiVolumeSize'] * $storage['units']);
|
||||||
|
|
|
@ -6,7 +6,7 @@ if (!is_array($storage_cache['hpe-ilo'])) {
|
||||||
echo("HPE ILO4 ");
|
echo("HPE ILO4 ");
|
||||||
}
|
}
|
||||||
|
|
||||||
$entry = $storage_cache['hpe-ilo'][$storage[storage_index]];
|
$entry = $storage_cache['hpe-ilo'][$storage['storage_index']];
|
||||||
|
|
||||||
$storage['units'] = 1024*1024;
|
$storage['units'] = 1024*1024;
|
||||||
$storage['size'] = ($entry['cpqHoFileSysSpaceTotal'] * $storage['units']);
|
$storage['size'] = ($entry['cpqHoFileSysSpaceTotal'] * $storage['units']);
|
||||||
|
|
|
@ -6,7 +6,7 @@ if (!is_array($storage_cache['hrstorage'])) {
|
||||||
d_echo($storage_cache);
|
d_echo($storage_cache);
|
||||||
}
|
}
|
||||||
|
|
||||||
$entry = $storage_cache['hrstorage'][$storage[storage_index]];
|
$entry = $storage_cache['hrstorage'][$storage['storage_index']];
|
||||||
|
|
||||||
$storage['units'] = $entry['hrStorageAllocationUnits'];
|
$storage['units'] = $entry['hrStorageAllocationUnits'];
|
||||||
$entry['hrStorageUsed'] = fix_integer_value($entry['hrStorageUsed']);
|
$entry['hrStorageUsed'] = fix_integer_value($entry['hrStorageUsed']);
|
||||||
|
|
|
@ -27,7 +27,7 @@ if (!is_array($storage_cache['intelliflash-pl'])) {
|
||||||
d_echo($storage_cache);
|
d_echo($storage_cache);
|
||||||
}
|
}
|
||||||
//Tegile uses a high 32bit counter and a low 32bit counter to make a 64bit counter. Storage units are in bytes.
|
//Tegile uses a high 32bit counter and a low 32bit counter to make a 64bit counter. Storage units are in bytes.
|
||||||
$entry = $storage_cache['intelliflash-pl'][$storage[storage_index]];
|
$entry = $storage_cache['intelliflash-pl'][$storage['storage_index']];
|
||||||
$storage['units'] = 1;
|
$storage['units'] = 1;
|
||||||
$storage['size'] = (($entry['poolSizeHigh'] << 32 ) + $entry['poolSizeLow']) * $storage['units'];
|
$storage['size'] = (($entry['poolSizeHigh'] << 32 ) + $entry['poolSizeLow']) * $storage['units'];
|
||||||
$storage['used'] = (($entry['poolUsedSizeHigh'] << 32 ) + $entry['poolUsedSizeLow']) * $storage['units'];
|
$storage['used'] = (($entry['poolUsedSizeHigh'] << 32 ) + $entry['poolUsedSizeLow']) * $storage['units'];
|
||||||
|
|
|
@ -27,7 +27,7 @@ if (!is_array($storage_cache['intelliflash-pr'])) {
|
||||||
d_echo($storage_cache);
|
d_echo($storage_cache);
|
||||||
}
|
}
|
||||||
//Tegile uses a high 32bit counter and a low 32bit counter to make a 64bit counter. Storage units are in bytes.
|
//Tegile uses a high 32bit counter and a low 32bit counter to make a 64bit counter. Storage units are in bytes.
|
||||||
$entry = $storage_cache['intelliflash-pr'][$storage[storage_index]];
|
$entry = $storage_cache['intelliflash-pr'][$storage['storage_index']];
|
||||||
$storage['units'] = 1;
|
$storage['units'] = 1;
|
||||||
$pdsh = ($entry['projectDataSizeHigh'] << 32 );
|
$pdsh = ($entry['projectDataSizeHigh'] << 32 );
|
||||||
$pdsl = ($entry['projectDataSizeLow']);
|
$pdsl = ($entry['projectDataSizeLow']);
|
||||||
|
|
|
@ -5,7 +5,7 @@ if (!is_array($storage_cache['netapp-storage'])) {
|
||||||
d_echo($storage_cache);
|
d_echo($storage_cache);
|
||||||
}
|
}
|
||||||
|
|
||||||
$entry = $storage_cache['netapp-storage'][$storage[storage_index]];
|
$entry = $storage_cache['netapp-storage'][$storage['storage_index']];
|
||||||
|
|
||||||
$storage['units'] = 1024;
|
$storage['units'] = 1024;
|
||||||
if (isset($entry['df64TotalKBytes']) && is_numeric($entry['df64TotalKBytes'])) {
|
if (isset($entry['df64TotalKBytes']) && is_numeric($entry['df64TotalKBytes'])) {
|
||||||
|
|
|
@ -26,7 +26,7 @@ if (!is_array($storage_cache['nimbleos'])) {
|
||||||
$storage_cache['nimbleos'] = snmpwalk_cache_oid($device, 'volEntry', null, 'NIMBLE-MIB');
|
$storage_cache['nimbleos'] = snmpwalk_cache_oid($device, 'volEntry', null, 'NIMBLE-MIB');
|
||||||
d_echo($storage_cache);
|
d_echo($storage_cache);
|
||||||
}
|
}
|
||||||
$entry = $storage_cache['nimbleos'][$storage[storage_index]];
|
$entry = $storage_cache['nimbleos'][$storage['storage_index']];
|
||||||
$storage['units'] = 1024*1024;
|
$storage['units'] = 1024*1024;
|
||||||
//nimble uses a high 32bit counter and a low 32bit counter to make a 64bit counter
|
//nimble uses a high 32bit counter and a low 32bit counter to make a 64bit counter
|
||||||
$storage['size'] = (($entry['volSizeHigh'] << 32 ) + $entry['volSizeLow']) * $storage['units'];
|
$storage['size'] = (($entry['volSizeHigh'] << 32 ) + $entry['volSizeLow']) * $storage['units'];
|
||||||
|
|
|
@ -5,7 +5,7 @@ if (!is_array($storage_cache['dsk'])) {
|
||||||
d_echo($storage_cache);
|
d_echo($storage_cache);
|
||||||
}
|
}
|
||||||
|
|
||||||
$entry = $storage_cache['dsk'][$storage[storage_index]];
|
$entry = $storage_cache['dsk'][$storage['storage_index']];
|
||||||
|
|
||||||
$storage['units'] = 1024;
|
$storage['units'] = 1024;
|
||||||
$storage['size'] = ($entry['dskTotal'] * $storage['units']);
|
$storage['size'] = ($entry['dskTotal'] * $storage['units']);
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
<?php
|
<?php
|
||||||
/*
|
/*
|
||||||
* LibreNMS
|
* LibreNMS
|
||||||
*
|
*
|
||||||
* Copyright (c) 2015 Vitali Kari <vitali.kari@gmail.com>
|
* Copyright (c) 2015 Vitali Kari <vitali.kari@gmail.com>
|
||||||
*
|
*
|
||||||
|
@ -28,11 +28,11 @@ if ($stpprotocol == 'ieee8021d' || $stpprotocol == 'unknown') {
|
||||||
// some vendors like PBN dont follow the 802.1D implementation and use seconds in SNMP
|
// some vendors like PBN dont follow the 802.1D implementation and use seconds in SNMP
|
||||||
if ($device['os'] == 'pbn') {
|
if ($device['os'] == 'pbn') {
|
||||||
preg_match('/^.* Build (?<build>\d+)/', $device['version'], $version);
|
preg_match('/^.* Build (?<build>\d+)/', $device['version'], $version);
|
||||||
if ($version[build] <= 16607) { // Buggy version :-(
|
if ($version['build'] <= 16607) { // Buggy version :-(
|
||||||
$tm = '1';
|
$tm = '1';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// read the 802.1D subtree
|
// read the 802.1D subtree
|
||||||
$stp_raw = snmpwalk_cache_oid($device, 'dot1dStp', array(), 'RSTP-MIB');
|
$stp_raw = snmpwalk_cache_oid($device, 'dot1dStp', array(), 'RSTP-MIB');
|
||||||
d_echo($stp_raw);
|
d_echo($stp_raw);
|
||||||
|
@ -56,7 +56,7 @@ if ($stpprotocol == 'ieee8021d' || $stpprotocol == 'unknown') {
|
||||||
|
|
||||||
// read the 802.1D bridge address and set as MAC in database
|
// read the 802.1D bridge address and set as MAC in database
|
||||||
$mac_raw = snmp_get($device, 'dot1dBaseBridgeAddress.0', '-Oqv', 'RSTP-MIB');
|
$mac_raw = snmp_get($device, 'dot1dBaseBridgeAddress.0', '-Oqv', 'RSTP-MIB');
|
||||||
|
|
||||||
// read Time as timetics (in hundredths of a seconds) since last topology change and convert to seconds
|
// read Time as timetics (in hundredths of a seconds) since last topology change and convert to seconds
|
||||||
$time_since_change = snmp_get($device, 'dot1dStpTimeSinceTopologyChange.0', '-Ovt', 'RSTP-MIB');
|
$time_since_change = snmp_get($device, 'dot1dStpTimeSinceTopologyChange.0', '-Ovt', 'RSTP-MIB');
|
||||||
if ($time_since_change > '100') {
|
if ($time_since_change > '100') {
|
||||||
|
@ -94,12 +94,12 @@ if ($stpprotocol == 'ieee8021d' || $stpprotocol == 'unknown') {
|
||||||
if ($stp_db['designatedRoot'] != $stp['designatedRoot']) {
|
if ($stp_db['designatedRoot'] != $stp['designatedRoot']) {
|
||||||
log_event('STP designated root changed: ' . $stp_db['designatedRoot'] . ' > ' . $stp['designatedRoot'], $device, 'stp', 4);
|
log_event('STP designated root changed: ' . $stp_db['designatedRoot'] . ' > ' . $stp['designatedRoot'], $device, 'stp', 4);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Logging if designated root port changed since last db update
|
// Logging if designated root port changed since last db update
|
||||||
if (isset($stp['rootPort']) && $stp_db['rootPort'] != $stp['rootPort']) {
|
if (isset($stp['rootPort']) && $stp_db['rootPort'] != $stp['rootPort']) {
|
||||||
log_event('STP root port changed: ' . $stp_db['rootPort'] . ' > ' . $stp['rootPort'], $device, 'stp', 4);
|
log_event('STP root port changed: ' . $stp_db['rootPort'] . ' > ' . $stp['rootPort'], $device, 'stp', 4);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Logging if topology changed since last db update
|
// Logging if topology changed since last db update
|
||||||
if ($stp_db['timeSinceTopologyChange'] > $stp['timeSinceTopologyChange']) {
|
if ($stp_db['timeSinceTopologyChange'] > $stp['timeSinceTopologyChange']) {
|
||||||
// FIXME log_event should log really changing time, not polling time
|
// FIXME log_event should log really changing time, not polling time
|
||||||
|
@ -129,17 +129,17 @@ if ($stpprotocol == 'ieee8021d' || $stpprotocol == 'unknown') {
|
||||||
'designatedPort' => $stp_raw[$port]['dot1dStpPortDesignatedPort'],
|
'designatedPort' => $stp_raw[$port]['dot1dStpPortDesignatedPort'],
|
||||||
'forwardTransitions' => $stp_raw[$port]['dot1dStpPortForwardTransitions']
|
'forwardTransitions' => $stp_raw[$port]['dot1dStpPortForwardTransitions']
|
||||||
);
|
);
|
||||||
|
|
||||||
// set device binding
|
// set device binding
|
||||||
$stp_port['device_id'] = $device['device_id'];
|
$stp_port['device_id'] = $device['device_id'];
|
||||||
|
|
||||||
// set port binding
|
// set port binding
|
||||||
$stp_port['port_id'] = dbFetchCell('SELECT port_id FROM `ports` WHERE `device_id` = ? AND `ifIndex` = ?', array($device['device_id'], $stp_raw[$port]['dot1dStpPort']));
|
$stp_port['port_id'] = dbFetchCell('SELECT port_id FROM `ports` WHERE `device_id` = ? AND `ifIndex` = ?', array($device['device_id'], $stp_raw[$port]['dot1dStpPort']));
|
||||||
|
|
||||||
$dr = str_replace(array(' ', ':', '-'), '', strtolower($stp_raw[$port]['dot1dStpPortDesignatedRoot']));
|
$dr = str_replace(array(' ', ':', '-'), '', strtolower($stp_raw[$port]['dot1dStpPortDesignatedRoot']));
|
||||||
$dr = substr($dr, -12); //remove first two octets
|
$dr = substr($dr, -12); //remove first two octets
|
||||||
$stp_port['designatedRoot'] = $dr;
|
$stp_port['designatedRoot'] = $dr;
|
||||||
|
|
||||||
$db = str_replace(array(' ', ':', '-'), '', strtolower($stp_raw[$port]['dot1dStpPortDesignatedBridge']));
|
$db = str_replace(array(' ', ':', '-'), '', strtolower($stp_raw[$port]['dot1dStpPortDesignatedBridge']));
|
||||||
$db = substr($db, -12); //remove first two octets
|
$db = substr($db, -12); //remove first two octets
|
||||||
$stp_port['designatedBridge'] = $db;
|
$stp_port['designatedBridge'] = $db;
|
||||||
|
@ -159,7 +159,7 @@ if ($stpprotocol == 'ieee8021d' || $stpprotocol == 'unknown') {
|
||||||
$dp = substr($stp_raw[$port]['dot1dStpPortDesignatedPort'], -2); //discard the first octet (priority part)
|
$dp = substr($stp_raw[$port]['dot1dStpPortDesignatedPort'], -2); //discard the first octet (priority part)
|
||||||
$stp_port['designatedPort'] = hexdec($dp);
|
$stp_port['designatedPort'] = hexdec($dp);
|
||||||
}
|
}
|
||||||
|
|
||||||
//d_echo($stp_port);
|
//d_echo($stp_port);
|
||||||
|
|
||||||
// Update db
|
// Update db
|
||||||
|
|
|
@ -64,10 +64,10 @@ function CollectData($bill_id)
|
||||||
|
|
||||||
$last_counters = getLastPortCounter($port_id, $bill_id);
|
$last_counters = getLastPortCounter($port_id, $bill_id);
|
||||||
if ($last_counters['state'] == 'ok') {
|
if ($last_counters['state'] == 'ok') {
|
||||||
$port_data['last_in_measurement'] = $last_counters[in_counter];
|
$port_data['last_in_measurement'] = $last_counters['in_counter'];
|
||||||
$port_data['last_in_delta'] = $last_counters[in_delta];
|
$port_data['last_in_delta'] = $last_counters['in_delta'];
|
||||||
$port_data['last_out_measurement'] = $last_counters[out_counter];
|
$port_data['last_out_measurement'] = $last_counters['out_counter'];
|
||||||
$port_data['last_out_delta'] = $last_counters[out_delta];
|
$port_data['last_out_delta'] = $last_counters['out_delta'];
|
||||||
|
|
||||||
$tmp_period = dbFetchCell("SELECT UNIX_TIMESTAMP(CURRENT_TIMESTAMP()) - UNIX_TIMESTAMP('".mres($last_counters['timestamp'])."')");
|
$tmp_period = dbFetchCell("SELECT UNIX_TIMESTAMP(CURRENT_TIMESTAMP()) - UNIX_TIMESTAMP('".mres($last_counters['timestamp'])."')");
|
||||||
|
|
||||||
|
@ -78,7 +78,7 @@ function CollectData($bill_id)
|
||||||
} else {
|
} else {
|
||||||
$port_data['in_delta'] = $port_data['last_in_delta'];
|
$port_data['in_delta'] = $port_data['last_in_delta'];
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($port_data['ifSpeed'] > 0 && (delta_to_bits($port_data['out_measurement'], $tmp_period)-delta_to_bits($port_data['last_out_measurement'], $tmp_period)) > $port_data['ifSpeed']) {
|
if ($port_data['ifSpeed'] > 0 && (delta_to_bits($port_data['out_measurement'], $tmp_period)-delta_to_bits($port_data['last_out_measurement'], $tmp_period)) > $port_data['ifSpeed']) {
|
||||||
$port_data['out_delta'] = $port_data['last_out_delta'];
|
$port_data['out_delta'] = $port_data['last_out_delta'];
|
||||||
} elseif ($port_data['out_measurement'] >= $port_data['last_out_measurement']) {
|
} elseif ($port_data['out_measurement'] >= $port_data['last_out_measurement']) {
|
||||||
|
@ -105,11 +105,11 @@ function CollectData($bill_id)
|
||||||
|
|
||||||
$last_data = getLastMeasurement($bill_id);
|
$last_data = getLastMeasurement($bill_id);
|
||||||
|
|
||||||
if ($last_data[state] == 'ok') {
|
if ($last_data['state'] == 'ok') {
|
||||||
$prev_delta = $last_data[delta];
|
$prev_delta = $last_data['delta'];
|
||||||
$prev_in_delta = $last_data[in_delta];
|
$prev_in_delta = $last_data['in_delta'];
|
||||||
$prev_out_delta = $last_data[out_delta];
|
$prev_out_delta = $last_data['out_delta'];
|
||||||
$prev_timestamp = $last_data[timestamp];
|
$prev_timestamp = $last_data['timestamp'];
|
||||||
$period = dbFetchCell("SELECT UNIX_TIMESTAMP(CURRENT_TIMESTAMP()) - UNIX_TIMESTAMP('".mres($prev_timestamp)."')");
|
$period = dbFetchCell("SELECT UNIX_TIMESTAMP(CURRENT_TIMESTAMP()) - UNIX_TIMESTAMP('".mres($prev_timestamp)."')");
|
||||||
} else {
|
} else {
|
||||||
$prev_delta = '0';
|
$prev_delta = '0';
|
||||||
|
|
13
poller.php
13
poller.php
|
@ -77,7 +77,7 @@ if (!$where) {
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isset($options['d']) || isset($options['v'])) {
|
if (set_debug(isset($options['d'])) || isset($options['v'])) {
|
||||||
$versions = version_info();
|
$versions = version_info();
|
||||||
echo <<<EOH
|
echo <<<EOH
|
||||||
===================================
|
===================================
|
||||||
|
@ -96,18 +96,7 @@ EOH;
|
||||||
if (isset($options['v'])) {
|
if (isset($options['v'])) {
|
||||||
$vdebug = true;
|
$vdebug = true;
|
||||||
}
|
}
|
||||||
$debug = true;
|
|
||||||
update_os_cache(true); // Force update of OS Cache
|
update_os_cache(true); // Force update of OS Cache
|
||||||
ini_set('display_errors', 1);
|
|
||||||
ini_set('display_startup_errors', 1);
|
|
||||||
ini_set('log_errors', 1);
|
|
||||||
ini_set('error_reporting', 1);
|
|
||||||
} else {
|
|
||||||
$debug = false;
|
|
||||||
// ini_set('display_errors', 0);
|
|
||||||
ini_set('display_startup_errors', 0);
|
|
||||||
ini_set('log_errors', 0);
|
|
||||||
// ini_set('error_reporting', 0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isset($options['r'])) {
|
if (isset($options['r'])) {
|
||||||
|
|
|
@ -9,14 +9,7 @@ $options = getopt('h:o:t:v:d::');
|
||||||
if ($options['h'] && $options['o'] && $options['t'] && $options['v']) {
|
if ($options['h'] && $options['o'] && $options['t'] && $options['v']) {
|
||||||
$type = $options['t'];
|
$type = $options['t'];
|
||||||
$vendor = $options['v'];
|
$vendor = $options['v'];
|
||||||
if (isset($options['d'])) {
|
set_debug(isset($options['d']));
|
||||||
$debug = true;
|
|
||||||
$vdebug = true;
|
|
||||||
ini_set('display_errors', 1);
|
|
||||||
ini_set('display_startup_errors', 1);
|
|
||||||
ini_set('log_errors', 1);
|
|
||||||
ini_set('error_reporting', 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
$device_id = ctype_digit($options['h']) ? $options['h'] : getidbyname($options['h']);
|
$device_id = ctype_digit($options['h']) ? $options['h'] : getidbyname($options['h']);
|
||||||
$device = device_by_id_cache($device_id);
|
$device = device_by_id_cache($device_id);
|
||||||
|
|
|
@ -7,13 +7,8 @@ require __DIR__ . '/../includes/init.php';
|
||||||
$options = getopt('t:h:r:p:s:d::');
|
$options = getopt('t:h:r:p:s:d::');
|
||||||
|
|
||||||
if ($options['r'] && $options['h']) {
|
if ($options['r'] && $options['h']) {
|
||||||
if (isset($options['d'])) {
|
set_debug(isset($options['d']));
|
||||||
$debug = true;
|
|
||||||
ini_set('display_errors', 1);
|
|
||||||
ini_set('display_startup_errors', 1);
|
|
||||||
ini_set('log_errors', 1);
|
|
||||||
ini_set('error_reporting', 1);
|
|
||||||
}
|
|
||||||
$rule_id = (int)$options['r'];
|
$rule_id = (int)$options['r'];
|
||||||
$device_id = ctype_digit($options['h']) ? $options['h'] : getidbyname($options['h']);
|
$device_id = ctype_digit($options['h']) ? $options['h'] : getidbyname($options['h']);
|
||||||
$where = "alerts.device_id = $device_id && alerts.rule_id = $rule_id";
|
$where = "alerts.device_id = $device_id && alerts.rule_id = $rule_id";
|
||||||
|
|
|
@ -7,13 +7,8 @@ require __DIR__ . '/../includes/init.php';
|
||||||
$options = getopt('t:h:r:p:s:d::');
|
$options = getopt('t:h:r:p:s:d::');
|
||||||
|
|
||||||
if ($options['t'] && $options['h'] && $options['r']) {
|
if ($options['t'] && $options['h'] && $options['r']) {
|
||||||
if (isset($options['d'])) {
|
set_debug(isset($options['d']));
|
||||||
$debug = true;
|
|
||||||
ini_set('display_errors', 1);
|
|
||||||
ini_set('display_startup_errors', 1);
|
|
||||||
ini_set('log_errors', 1);
|
|
||||||
ini_set('error_reporting', 1);
|
|
||||||
}
|
|
||||||
$template_id = $options['t'];
|
$template_id = $options['t'];
|
||||||
$device_id = ctype_digit($options['h']) ? $options['h'] : getidbyname($options['h']);
|
$device_id = ctype_digit($options['h']) ? $options['h'] : getidbyname($options['h']);
|
||||||
$rule_id = $options['r'];
|
$rule_id = $options['r'];
|
||||||
|
|
11
snmptrap.php
11
snmptrap.php
|
@ -13,14 +13,15 @@
|
||||||
|
|
||||||
chdir(__DIR__); // cwd to the directory containing this script
|
chdir(__DIR__); // cwd to the directory containing this script
|
||||||
|
|
||||||
ini_set('display_errors', 1);
|
|
||||||
ini_set('display_startup_errors', 1);
|
|
||||||
ini_set('log_errors', 1);
|
|
||||||
ini_set('error_reporting', E_ALL);
|
|
||||||
|
|
||||||
$init_modules = array();
|
$init_modules = array();
|
||||||
require __DIR__ . '/includes/init.php';
|
require __DIR__ . '/includes/init.php';
|
||||||
|
|
||||||
|
$options = getopt('d::');
|
||||||
|
|
||||||
|
if (set_debug(isset($options['d']))) {
|
||||||
|
echo "DEBUG!\n";
|
||||||
|
}
|
||||||
|
|
||||||
$entry = explode(',', $argv[1]);
|
$entry = explode(',', $argv[1]);
|
||||||
|
|
||||||
logfile($argv[1]);
|
logfile($argv[1]);
|
||||||
|
|
Loading…
Reference in New Issue