diff --git a/discovery.php b/discovery.php index 336f91ad08..c708780544 100755 --- a/discovery.php +++ b/discovery.php @@ -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'; diff --git a/includes/alerts.inc.php b/includes/alerts.inc.php index 1d5c5c91ce..f57c102b36 100644 --- a/includes/alerts.inc.php +++ b/includes/alerts.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; diff --git a/includes/common.php b/includes/common.php index 03b239e85c..32e6e65af1 100644 --- a/includes/common.php +++ b/includes/common.php @@ -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; } diff --git a/includes/definitions.inc.php b/includes/definitions.inc.php index 0fc20c740d..11151148c2 100644 --- a/includes/definitions.inc.php +++ b/includes/definitions.inc.php @@ -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"; diff --git a/includes/functions.php b/includes/functions.php index 10499c0864..0027748eec 100644 --- a/includes/functions.php +++ b/includes/functions.php @@ -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. diff --git a/includes/include-dir.inc.php b/includes/include-dir.inc.php index d5c0a7eabf..2d6c1456d3 100644 --- a/includes/include-dir.inc.php +++ b/includes/include-dir.inc.php @@ -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; } diff --git a/includes/port-descr-parser.inc.php b/includes/port-descr-parser.inc.php index 2b0f475aaa..144790c124 100644 --- a/includes/port-descr-parser.inc.php +++ b/includes/port-descr-parser.inc.php @@ -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); diff --git a/includes/rrdtool.inc.php b/includes/rrdtool.inc.php index afbd2f7ad4..a8a7e99369 100644 --- a/includes/rrdtool.inc.php +++ b/includes/rrdtool.inc.php @@ -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); diff --git a/includes/sql-schema/update.php b/includes/sql-schema/update.php index 6497d1ca55..4bb7df7211 100644 --- a/includes/sql-schema/update.php +++ b/includes/sql-schema/update.php @@ -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') { diff --git a/poller.php b/poller.php index 623c000440..62bb94cd74 100755 --- a/poller.php +++ b/poller.php @@ -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]');