mirror of
https://github.com/librenms/librenms.git
synced 2024-10-07 16:52:45 +00:00
Restore previous snmp debug/vdebug logic so -v can be specified by itself.
This commit is contained in:
@@ -70,26 +70,23 @@ function format_number_short($number, $sf)
|
|||||||
function external_exec($command)
|
function external_exec($command)
|
||||||
{
|
{
|
||||||
global $debug,$vdebug;
|
global $debug,$vdebug;
|
||||||
if ($debug) {
|
|
||||||
if ($vdebug) {
|
if ($debug && !$vdebug) {
|
||||||
c_echo('SNMP[%c'.$command."%n]\n");
|
$debug_command = preg_replace('/-c [\S]+/', '-c COMMUNITY', $command);
|
||||||
} else {
|
$debug_command = preg_replace('/(udp|udp6|tcp|tcp6):([^:]+):([\d]+)/', '\1:HOSTNAME:\3', $debug_command);
|
||||||
$debug_command = preg_replace('/-c [\S]+/', '-c COMMUNITY', $command);
|
c_echo('SNMP[%c' . $debug_command . "%n]\n");
|
||||||
$debug_command = preg_replace('/(udp|udp6|tcp|tcp6):([^:]+):([\d]+)/', '\1:HOSTNAME:\3', $debug_command);
|
} elseif ($vdebug) {
|
||||||
c_echo('SNMP[%c'.$debug_command."%n]\n");
|
c_echo('SNMP[%c'.$command."%n]\n");
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$output = shell_exec($command);
|
$output = shell_exec($command);
|
||||||
|
|
||||||
if ($debug) {
|
if ($debug && !$vdebug) {
|
||||||
if ($vdebug) {
|
$ip_regex = '/(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)/';
|
||||||
d_echo($output.PHP_EOL);
|
$debug_output = preg_replace($ip_regex, '*', $output);
|
||||||
} else {
|
d_echo($debug_output . PHP_EOL);
|
||||||
$ip_regex = '/(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)/';
|
} elseif ($vdebug) {
|
||||||
$debug_output = preg_replace($ip_regex, '*', $output);
|
d_echo($output . PHP_EOL);
|
||||||
d_echo($debug_output.PHP_EOL);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return $output;
|
return $output;
|
||||||
|
|||||||
Reference in New Issue
Block a user