mirror of
https://github.com/librenms/librenms.git
synced 2024-09-21 10:28:13 +00:00
Remove all unneeded if($debug)-statements and replace them with d_echo in the rest of the directories...
This commit is contained in:
parent
677a4f3f5f
commit
4792879ce5
@ -118,9 +118,7 @@ if ($discovered_devices) {
|
||||
}
|
||||
|
||||
$string = $argv[0]." $doing ".date($config['dateformat']['compact'])." - $discovered_devices devices discovered in $proctime secs";
|
||||
if ($debug) {
|
||||
echo "$string\n";
|
||||
}
|
||||
d_echo("$string\n");
|
||||
|
||||
if ($options['h'] != 'new' && $config['version_check']) {
|
||||
include 'includes/versioncheck.inc.php';
|
||||
|
@ -220,7 +220,6 @@ function IsMaintenance( $device ) {
|
||||
* @return void
|
||||
*/
|
||||
function RunRules($device) {
|
||||
global $debug;
|
||||
if( IsMaintenance($device) > 0 ) {
|
||||
echo "Under Maintenance, Skipping alerts.\r\n";
|
||||
return false;
|
||||
|
@ -33,15 +33,9 @@ function format_number_short($number, $sf) {
|
||||
}
|
||||
|
||||
function external_exec($command) {
|
||||
global $debug;
|
||||
|
||||
if ($debug) {
|
||||
echo($command."\n");
|
||||
}
|
||||
d_echo($command."\n");
|
||||
$output = shell_exec($command);
|
||||
if ($debug) {
|
||||
echo($output."\n");
|
||||
}
|
||||
d_echo($output."\n");
|
||||
|
||||
return $output;
|
||||
}
|
||||
|
@ -1664,9 +1664,7 @@ if ($config['memcached']['enable'] === true) {
|
||||
if (class_exists('Memcached')) {
|
||||
$memcache = new Memcached();
|
||||
$memcache->addServer($config['memcached']['host'], $config['memcached']['port']);
|
||||
if ($debug) {
|
||||
print_r($memcache->getStats());
|
||||
}
|
||||
d_echo($memcache->getStats());
|
||||
}
|
||||
else {
|
||||
echo "WARNING: You have enabled memcached but have not installed the PHP bindings. Disabling memcached support.\n";
|
||||
|
@ -95,14 +95,12 @@ function logfile($string) {
|
||||
}
|
||||
|
||||
function getHostOS($device){
|
||||
global $config, $debug;
|
||||
global $config;
|
||||
|
||||
$sysDescr = snmp_get ($device, "SNMPv2-MIB::sysDescr.0", "-Ovq");
|
||||
$sysObjectId = snmp_get ($device, "SNMPv2-MIB::sysObjectID.0", "-Ovqn");
|
||||
|
||||
if ($debug) {
|
||||
echo("| $sysDescr | $sysObjectId | ");
|
||||
}
|
||||
d_echo("| $sysDescr | $sysObjectId | ");
|
||||
|
||||
$path = $config['install_dir'] . "/includes/discovery/os";
|
||||
$dir_handle = @opendir($path) or die("Unable to open $path");
|
||||
@ -698,8 +696,6 @@ function get_astext($asn) {
|
||||
|
||||
# Use this function to write to the eventlog table
|
||||
function log_event($text, $device = NULL, $type = NULL, $reference = NULL) {
|
||||
global $debug;
|
||||
|
||||
if (!is_array($device)) {
|
||||
$device = device_by_id_cache($device);
|
||||
}
|
||||
@ -830,7 +826,7 @@ function isHexString($str) {
|
||||
|
||||
# Include all .inc.php files in $dir
|
||||
function include_dir($dir, $regex = "") {
|
||||
global $device, $config, $debug, $valid;
|
||||
global $device, $config, $valid;
|
||||
|
||||
if ($regex == "") {
|
||||
$regex = "/\.inc\.php$/";
|
||||
@ -839,9 +835,7 @@ function include_dir($dir, $regex = "") {
|
||||
if ($handle = opendir($config['install_dir'] . '/' . $dir)) {
|
||||
while (false !== ($file = readdir($handle))) {
|
||||
if (filetype($config['install_dir'] . '/' . $dir . '/' . $file) == 'file' && preg_match($regex, $file)) {
|
||||
if ($debug) {
|
||||
echo("Including: " . $config['install_dir'] . '/' . $dir . '/' . $file . "\n");
|
||||
}
|
||||
d_echo("Including: " . $config['install_dir'] . '/' . $dir . '/' . $file . "\n");
|
||||
|
||||
include($config['install_dir'] . '/' . $dir . '/' . $file);
|
||||
}
|
||||
@ -853,7 +847,7 @@ function include_dir($dir, $regex = "") {
|
||||
|
||||
function is_port_valid($port, $device) {
|
||||
|
||||
global $config, $debug;
|
||||
global $config;
|
||||
|
||||
if (strstr($port['ifDescr'], "irtual")) {
|
||||
$valid = 0;
|
||||
@ -868,9 +862,7 @@ function is_port_valid($port, $device) {
|
||||
foreach ($fringe as $bi) {
|
||||
if (strstr($if, $bi)) {
|
||||
$valid = 0;
|
||||
if ($debug) {
|
||||
echo("ignored : $bi : $if");
|
||||
}
|
||||
d_echo("ignored : $bi : $if");
|
||||
}
|
||||
}
|
||||
if (is_array($config['bad_if_regexp'])) {
|
||||
@ -881,9 +873,7 @@ function is_port_valid($port, $device) {
|
||||
foreach ($fringe as $bi) {
|
||||
if (preg_match($bi ."i", $if)) {
|
||||
$valid = 0;
|
||||
if ($debug) {
|
||||
echo("ignored : $bi : ".$if);
|
||||
}
|
||||
d_echo("ignored : $bi : ".$if);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -895,9 +885,7 @@ function is_port_valid($port, $device) {
|
||||
foreach ($fringe as $bi) {
|
||||
if (strstr($port['ifType'], $bi)) {
|
||||
$valid = 0;
|
||||
if ($debug) {
|
||||
echo("ignored ifType : ".$port['ifType']." (matched: ".$bi." )");
|
||||
}
|
||||
d_echo("ignored ifType : ".$port['ifType']." (matched: ".$bi." )");
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -917,7 +905,7 @@ function is_port_valid($port, $device) {
|
||||
|
||||
function scan_new_plugins() {
|
||||
|
||||
global $config, $debug;
|
||||
global $config;
|
||||
|
||||
$installed = 0; // Track how many plugins we install.
|
||||
|
||||
|
@ -8,9 +8,7 @@ if ($include_dir_regexp == '' || !isset($include_dir_regexp)) {
|
||||
if ($handle = opendir($config['install_dir'].'/'.$include_dir)) {
|
||||
while (false !== ($file = readdir($handle))) {
|
||||
if (filetype($config['install_dir'].'/'.$include_dir.'/'.$file) == 'file' && preg_match($include_dir_regexp, $file)) {
|
||||
if ($debug) {
|
||||
echo 'Including: '.$config['install_dir'].'/'.$include_dir.'/'.$file."\n";
|
||||
}
|
||||
d_echo('Including: '.$config['install_dir'].'/'.$include_dir.'/'.$file."\n");
|
||||
|
||||
include $config['install_dir'].'/'.$include_dir.'/'.$file;
|
||||
}
|
||||
|
@ -20,9 +20,7 @@ if ($type && $descr) {
|
||||
$port_ifAlias['speed'] = $speed;
|
||||
$port_ifAlias['notes'] = $notes;
|
||||
|
||||
if ($debug) {
|
||||
print_r($port_ifAlias);
|
||||
}
|
||||
d_echo($port_ifAlias);
|
||||
}
|
||||
|
||||
unset($port_type, $port_descr, $port_circuit, $port_notes, $port_speed);
|
||||
|
@ -23,7 +23,7 @@
|
||||
|
||||
|
||||
function rrdtool_pipe_open(&$rrd_process, &$rrd_pipes) {
|
||||
global $config, $debug;
|
||||
global $config;
|
||||
|
||||
$command = $config['rrdtool'].' -';
|
||||
|
||||
@ -74,12 +74,8 @@ function rrdtool_pipe_open(&$rrd_process, &$rrd_pipes) {
|
||||
|
||||
|
||||
function rrdtool_pipe_close($rrd_process, &$rrd_pipes) {
|
||||
global $debug;
|
||||
|
||||
if ($debug) {
|
||||
echo stream_get_contents($rrd_pipes[1]);
|
||||
echo stream_get_contents($rrd_pipes[2]);
|
||||
}
|
||||
d_echo(stream_get_contents($rrd_pipes[1]));
|
||||
d_echo(stream_get_contents($rrd_pipes[2]));
|
||||
|
||||
fclose($rrd_pipes[0]);
|
||||
fclose($rrd_pipes[1]);
|
||||
@ -210,7 +206,7 @@ function rrdtool($command, $filename, $options) {
|
||||
|
||||
|
||||
function rrdtool_create($filename, $options) {
|
||||
global $config, $debug, $console_color;
|
||||
global $config, $console_color;
|
||||
|
||||
if ($config['norrd']) {
|
||||
print $console_color->convert('[%gRRD Disabled%n] ', false);
|
||||
@ -219,9 +215,7 @@ function rrdtool_create($filename, $options) {
|
||||
$command = $config['rrdtool']." create $filename $options";
|
||||
}
|
||||
|
||||
if ($debug) {
|
||||
print $console_color->convert('RRD[%g'.$command.'%n] ');
|
||||
}
|
||||
d_echo($console_color->convert('RRD[%g'.$command.'%n] '));
|
||||
|
||||
return shell_exec($command);
|
||||
|
||||
|
@ -103,9 +103,7 @@ foreach ($filelist as $file) {
|
||||
|
||||
foreach (explode("\n", $data) as $line) {
|
||||
if (trim($line)) {
|
||||
if ($debug) {
|
||||
echo "$line \n";
|
||||
}
|
||||
d_echo("$line \n");
|
||||
|
||||
if ($line[0] != '#') {
|
||||
if ($config['db']['extension'] == 'mysqli') {
|
||||
|
@ -124,9 +124,7 @@ if ($polled_devices) {
|
||||
}
|
||||
|
||||
$string = $argv[0]." $doing ".date($config['dateformat']['compact'])." - $polled_devices devices polled in $poller_time secs";
|
||||
if ($debug) {
|
||||
echo "$string\n";
|
||||
}
|
||||
d_echo("$string\n");
|
||||
|
||||
echo ("\n".'MySQL: Cell['.($db_stats['fetchcell'] + 0).'/'.round(($db_stats['fetchcell_sec'] + 0), 2).'s]'.' Row['.($db_stats['fetchrow'] + 0).'/'.round(($db_stats['fetchrow_sec'] + 0), 2).'s]'.' Rows['.($db_stats['fetchrows'] + 0).'/'.round(($db_stats['fetchrows_sec'] + 0), 2).'s]'.' Column['.($db_stats['fetchcol'] + 0).'/'.round(($db_stats['fetchcol_sec'] + 0), 2).'s]'.' Update['.($db_stats['update'] + 0).'/'.round(($db_stats['update_sec'] + 0), 2).'s]'.' Insert['.($db_stats['insert'] + 0).'/'.round(($db_stats['insert_sec'] + 0), 2).'s]'.' Delete['.($db_stats['delete'] + 0).'/'.round(($db_stats['delete_sec'] + 0), 2).'s]');
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user