Added verbose debugging, normal debugging will now try and mask certain information

This commit is contained in:
laf
2016-01-17 14:39:17 +00:00
parent a7c0c1b762
commit 0558275414
5 changed files with 51 additions and 9 deletions
+18
View File
@@ -28,6 +28,8 @@
require_once 'includes/defaults.inc.php'; require_once 'includes/defaults.inc.php';
require_once 'config.php'; require_once 'config.php';
$options = getopt('d::');
$lock = false; $lock = false;
if (file_exists($config['install_dir'].'/.alerts.lock')) { if (file_exists($config['install_dir'].'/.alerts.lock')) {
$pids = explode("\n", trim(`ps -e | grep php | awk '{print $1}'`)); $pids = explode("\n", trim(`ps -e | grep php | awk '{print $1}'`));
@@ -48,6 +50,22 @@ require_once $config['install_dir'].'/includes/definitions.inc.php';
require_once $config['install_dir'].'/includes/functions.php'; require_once $config['install_dir'].'/includes/functions.php';
require_once $config['install_dir'].'/includes/alerts.inc.php'; require_once $config['install_dir'].'/includes/alerts.inc.php';
if (isset($options['d'])) {
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') {
echo 'Start: '.date('r')."\r\n"; echo 'Start: '.date('r')."\r\n";
echo "RunFollowUp():\r\n"; echo "RunFollowUp():\r\n";
+6 -2
View File
@@ -23,7 +23,7 @@ require 'includes/discovery/functions.inc.php';
$start = microtime(true); $start = microtime(true);
$runtime_stats = array(); $runtime_stats = array();
$sqlparams = array(); $sqlparams = array();
$options = getopt('h:m:i:n:d::a::q',array('os:','type:')); $options = getopt('h:m:i:n:d::v::a::q',array('os:','type:'));
if (!isset($options['q'])) { if (!isset($options['q'])) {
echo $config['project_name_version']." Discovery\n"; echo $config['project_name_version']." Discovery\n";
@@ -82,8 +82,11 @@ if (isset($options['i']) && $options['i'] && isset($options['n'])) {
$doing = $options['n'].'/'.$options['i']; $doing = $options['n'].'/'.$options['i'];
} }
if (isset($options['d'])) { if (isset($options['d']) || isset($options['v'])) {
echo "DEBUG!\n"; echo "DEBUG!\n";
if (isset($options['v'])) {
$vdebug = true;
}
$debug = true; $debug = true;
ini_set('display_errors', 1); ini_set('display_errors', 1);
ini_set('display_startup_errors', 1); ini_set('display_startup_errors', 1);
@@ -111,6 +114,7 @@ if (!$where) {
echo "\n"; echo "\n";
echo "Debugging and testing options:\n"; echo "Debugging and testing options:\n";
echo "-d Enable debugging output\n"; echo "-d Enable debugging output\n";
echo "-v Enable verbose debugging output\n";
echo "-m Specify single module to be run\n"; echo "-m Specify single module to be run\n";
echo "\n"; echo "\n";
echo "Invalid arguments!\n"; echo "Invalid arguments!\n";
+16
View File
@@ -33,9 +33,25 @@ function format_number_short($number, $sf) {
} }
function external_exec($command) { function external_exec($command) {
global $debug,$vdebug;
if ($debug && !$vdebug) {
$debug_command = preg_replace('/-c [\S]+/','-c COMMUNITY',$command);
$debug_command = preg_replace('/(udp|udp6|tcp|tcp6):(.*):([\d]+)/','\1:HOSTNAME:\3',$debug_command);
d_echo($debug_command);
}
elseif ($vdebug) {
d_echo($command."\n"); d_echo($command."\n");
}
$output = shell_exec($command); $output = shell_exec($command);
if ($debug && !$vdebug) {
$debug_output = preg_replace('/(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})/', '*', $output);
d_echo("$debug_output\n");
}
elseif ($vdebug) {
d_echo($output."\n"); d_echo($output."\n");
}
return $output; return $output;
} }
+3 -3
View File
@@ -745,7 +745,7 @@ function snmp_cache_portName($device, $array) {
function snmp_gen_auth(&$device) { function snmp_gen_auth(&$device) {
global $debug; global $debug, $vdebug;
$cmd = ''; $cmd = '';
@@ -781,11 +781,11 @@ function snmp_gen_auth(&$device) {
} }
else { else {
if ($debug) { if ($debug) {
print 'DEBUG: '.$device['snmpver']." : Unsupported SNMP Version (wtf have you done ?)\n"; print 'DEBUG: '.$device['snmpver']." : Unsupported SNMP Version (shouldn't be possible to get here)\n";
} }
}//end if }//end if
if ($debug) { if ($vdebug) {
print "DEBUG: SNMP Auth options = $cmd\n"; print "DEBUG: SNMP Auth options = $cmd\n";
} }
+6 -2
View File
@@ -33,7 +33,7 @@ echo "MySQL: ".$versions['mysql_ver']."\n";
echo "RRDTool: ".$versions['rrdtool_ver']."\n"; echo "RRDTool: ".$versions['rrdtool_ver']."\n";
echo "SNMP: ".$versions['netsnmp_ver']."\n"; echo "SNMP: ".$versions['netsnmp_ver']."\n";
$options = getopt('h:m:i:n:r::d::a::f::'); $options = getopt('h:m:i:n:r::d::v::a::f::');
if ($options['h'] == 'odd') { if ($options['h'] == 'odd') {
$options['n'] = '1'; $options['n'] = '1';
@@ -83,14 +83,18 @@ if (!$where) {
echo "-r Do not create or update RRDs\n"; echo "-r Do not create or update RRDs\n";
echo "-f Do not insert data into InfluxDB\n"; echo "-f Do not insert data into InfluxDB\n";
echo "-d Enable debugging output\n"; echo "-d Enable debugging output\n";
echo "-d Enable verbose debugging output\n";
echo "-m Specify module(s) to be run\n"; echo "-m Specify module(s) to be run\n";
echo "\n"; echo "\n";
echo "No polling type specified!\n"; echo "No polling type specified!\n";
exit; exit;
} }
if (isset($options['d'])) { if (isset($options['d']) || isset($options['v'])) {
echo "DEBUG!\n"; echo "DEBUG!\n";
if (isset($options['v'])) {
$vdebug = true;
}
$debug = true; $debug = true;
ini_set('display_errors', 1); ini_set('display_errors', 1);
ini_set('display_startup_errors', 1); ini_set('display_startup_errors', 1);