Windows: Revisión general Pandora - Discovery
This commit is contained in:
parent
8e728eed6b
commit
746f817fe4
|
@ -873,18 +873,20 @@ class ConsoleSupervisor
|
||||||
{
|
{
|
||||||
global $config;
|
global $config;
|
||||||
|
|
||||||
|
$remote_config_dir = io_safe_output($config['remote_config']);
|
||||||
|
|
||||||
if (enterprise_installed()
|
if (enterprise_installed()
|
||||||
&& isset($config['license_nms'])
|
&& isset($config['license_nms'])
|
||||||
&& $config['license_nms'] != 1
|
&& $config['license_nms'] != 1
|
||||||
) {
|
) {
|
||||||
if (is_readable($config['remote_config']) !== true) {
|
if (is_readable($remote_config_dir) !== true) {
|
||||||
$this->notify(
|
$this->notify(
|
||||||
[
|
[
|
||||||
'type' => 'NOTIF.PERMISSIONS.REMOTE_CONFIG',
|
'type' => 'NOTIF.PERMISSIONS.REMOTE_CONFIG',
|
||||||
'title' => __('Remote configuration directory is not readable'),
|
'title' => __('Remote configuration directory is not readable'),
|
||||||
'message' => __(
|
'message' => __(
|
||||||
'Remote configuration directory %s is not readable. Please, adjust configuration.',
|
'Remote configuration directory %s is not readable. Please, adjust configuration.',
|
||||||
$config['remote_config']
|
$remote_config_dir
|
||||||
),
|
),
|
||||||
'url' => ui_get_full_url('index.php?sec=general&sec2=godmode/setup/setup§ion=general'),
|
'url' => ui_get_full_url('index.php?sec=general&sec2=godmode/setup/setup§ion=general'),
|
||||||
]
|
]
|
||||||
|
@ -896,14 +898,14 @@ class ConsoleSupervisor
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (is_writable($config['remote_config'].'/conf') !== true) {
|
if (is_writable($remote_config_dir.'/conf') !== true) {
|
||||||
$this->notify(
|
$this->notify(
|
||||||
[
|
[
|
||||||
'type' => 'NOTIF.PERMISSIONS.REMOTE_CONFIG.CONF',
|
'type' => 'NOTIF.PERMISSIONS.REMOTE_CONFIG.CONF',
|
||||||
'title' => __('Remote configuration directory is not writable'),
|
'title' => __('Remote configuration directory is not writable'),
|
||||||
'message' => __(
|
'message' => __(
|
||||||
'Remote configuration directory %s is not writable. Please, adjust configuration.',
|
'Remote configuration directory %s is not writable. Please, adjust configuration.',
|
||||||
$config['remote_config'].'/conf'
|
$remote_config_dir.'/conf'
|
||||||
),
|
),
|
||||||
'url' => ui_get_full_url('index.php?sec=general&sec2=godmode/setup/setup§ion=general'),
|
'url' => ui_get_full_url('index.php?sec=general&sec2=godmode/setup/setup§ion=general'),
|
||||||
]
|
]
|
||||||
|
@ -914,14 +916,14 @@ class ConsoleSupervisor
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (is_writable($config['remote_config'].'/collections') !== true) {
|
if (is_writable($remote_config_dir.'/collections') !== true) {
|
||||||
$this->notify(
|
$this->notify(
|
||||||
[
|
[
|
||||||
'type' => 'NOTIF.PERMISSIONS.REMOTE_CONFIG.COLLECTIONS',
|
'type' => 'NOTIF.PERMISSIONS.REMOTE_CONFIG.COLLECTIONS',
|
||||||
'title' => __('Remote collections directory is not writable'),
|
'title' => __('Remote collections directory is not writable'),
|
||||||
'message' => __(
|
'message' => __(
|
||||||
'Collections directory %s is not writable. Please, adjust configuration.',
|
'Collections directory %s is not writable. Please, adjust configuration.',
|
||||||
$config['remote_config'].'/collections'
|
$remote_config_dir.'/collections'
|
||||||
),
|
),
|
||||||
'url' => ui_get_full_url('index.php?sec=general&sec2=godmode/setup/setup§ion=general'),
|
'url' => ui_get_full_url('index.php?sec=general&sec2=godmode/setup/setup§ion=general'),
|
||||||
]
|
]
|
||||||
|
@ -932,14 +934,14 @@ class ConsoleSupervisor
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (is_writable($config['remote_config'].'/md5') !== true) {
|
if (is_writable($remote_config_dir.'/md5') !== true) {
|
||||||
$this->notify(
|
$this->notify(
|
||||||
[
|
[
|
||||||
'type' => 'NOTIF.PERMISSIONS.REMOTE_CONFIG.MD5',
|
'type' => 'NOTIF.PERMISSIONS.REMOTE_CONFIG.MD5',
|
||||||
'title' => __('Remote md5 directory is not writable'),
|
'title' => __('Remote md5 directory is not writable'),
|
||||||
'message' => __(
|
'message' => __(
|
||||||
'MD5 directory %s is not writable. Please, adjust configuration.',
|
'MD5 directory %s is not writable. Please, adjust configuration.',
|
||||||
$config['remote_config'].'/md5'
|
$remote_config_dir.'/md5'
|
||||||
),
|
),
|
||||||
'url' => ui_get_full_url('index.php?sec=general&sec2=godmode/setup/setup§ion=general'),
|
'url' => ui_get_full_url('index.php?sec=general&sec2=godmode/setup/setup§ion=general'),
|
||||||
]
|
]
|
||||||
|
@ -957,7 +959,7 @@ class ConsoleSupervisor
|
||||||
$MAX_BADXML_FILES_DATA_IN = 150;
|
$MAX_BADXML_FILES_DATA_IN = 150;
|
||||||
|
|
||||||
$filecount = $this->countFiles(
|
$filecount = $this->countFiles(
|
||||||
$config['remote_config'],
|
$remote_config_dir,
|
||||||
'',
|
'',
|
||||||
$MAX_FILES_DATA_IN
|
$MAX_FILES_DATA_IN
|
||||||
);
|
);
|
||||||
|
@ -970,7 +972,7 @@ class ConsoleSupervisor
|
||||||
'message' => __(
|
'message' => __(
|
||||||
'There are more than %d files in %s. Consider checking DataServer performance',
|
'There are more than %d files in %s. Consider checking DataServer performance',
|
||||||
$MAX_FILES_DATA_IN,
|
$MAX_FILES_DATA_IN,
|
||||||
$config['remote_config']
|
$remote_config_dir
|
||||||
),
|
),
|
||||||
'url' => ui_get_full_url('index.php?sec=general&sec2=godmode/setup/setup§ion=perf'),
|
'url' => ui_get_full_url('index.php?sec=general&sec2=godmode/setup/setup§ion=perf'),
|
||||||
]
|
]
|
||||||
|
@ -980,7 +982,7 @@ class ConsoleSupervisor
|
||||||
}
|
}
|
||||||
|
|
||||||
$filecount = $this->countFiles(
|
$filecount = $this->countFiles(
|
||||||
$config['remote_config'],
|
$remote_config_dir,
|
||||||
'/^.*BADXML$/',
|
'/^.*BADXML$/',
|
||||||
$MAX_BADXML_FILES_DATA_IN
|
$MAX_BADXML_FILES_DATA_IN
|
||||||
);
|
);
|
||||||
|
@ -993,7 +995,7 @@ class ConsoleSupervisor
|
||||||
'message' => __(
|
'message' => __(
|
||||||
'There are more than %d files in %s. Consider checking software agents.',
|
'There are more than %d files in %s. Consider checking software agents.',
|
||||||
$MAX_BADXML_FILES_DATA_IN,
|
$MAX_BADXML_FILES_DATA_IN,
|
||||||
$config['remote_config']
|
$remote_config_dir
|
||||||
),
|
),
|
||||||
'url' => ui_get_full_url('index.php?sec=general&sec2=godmode/setup/setup§ion=perf'),
|
'url' => ui_get_full_url('index.php?sec=general&sec2=godmode/setup/setup§ion=perf'),
|
||||||
]
|
]
|
||||||
|
@ -1266,7 +1268,8 @@ class ConsoleSupervisor
|
||||||
$PHPSerialize_precision = ini_get('serialize_precision');
|
$PHPSerialize_precision = ini_get('serialize_precision');
|
||||||
|
|
||||||
// PhantomJS status.
|
// PhantomJS status.
|
||||||
$result_ejecution = exec($config['phantomjs_bin'].'/phantomjs --version');
|
$phantomjs_dir = io_safe_output($config['phantomjs_bin']);
|
||||||
|
$result_ejecution = exec($phantomjs_dir.'/phantomjs --version');
|
||||||
|
|
||||||
// PHP version checks.
|
// PHP version checks.
|
||||||
$php_version = phpversion();
|
$php_version = phpversion();
|
||||||
|
@ -1451,8 +1454,9 @@ class ConsoleSupervisor
|
||||||
'type' => 'NOTIF.PHP.SERIALIZE_PRECISION',
|
'type' => 'NOTIF.PHP.SERIALIZE_PRECISION',
|
||||||
'title' => sprintf(
|
'title' => sprintf(
|
||||||
__("Not recommended '%s' value in PHP configuration"),
|
__("Not recommended '%s' value in PHP configuration"),
|
||||||
'serialze_precision'
|
'serialize_precision'
|
||||||
), 'message' => sprintf(
|
),
|
||||||
|
'message' => sprintf(
|
||||||
__('Recommended value is: %s'),
|
__('Recommended value is: %s'),
|
||||||
sprintf('-1')
|
sprintf('-1')
|
||||||
).'<br><br>'.__('Please, change it on your PHP configuration file (php.ini) or contact with administrator'),
|
).'<br><br>'.__('Please, change it on your PHP configuration file (php.ini) or contact with administrator'),
|
||||||
|
@ -2061,8 +2065,10 @@ class ConsoleSupervisor
|
||||||
{
|
{
|
||||||
global $config;
|
global $config;
|
||||||
|
|
||||||
if (($config['fontpath'] == '')
|
$fontpath = io_safe_output($config['fontpath']);
|
||||||
|| (file_exists($config['fontpath']) === false)
|
|
||||||
|
if (($fontpath == '')
|
||||||
|
|| (file_exists($fontpath) === false)
|
||||||
) {
|
) {
|
||||||
$this->notify(
|
$this->notify(
|
||||||
[
|
[
|
||||||
|
|
|
@ -1500,7 +1500,7 @@ function config_process_config()
|
||||||
|
|
||||||
if (!isset($config['remote_config'])) {
|
if (!isset($config['remote_config'])) {
|
||||||
if ($is_windows) {
|
if ($is_windows) {
|
||||||
$default = 'C:\\PandoraFMS\\Pandora_Server\\data_in';
|
$default = 'C:\PandoraFMS\Pandora_Server\data_in';
|
||||||
} else {
|
} else {
|
||||||
$default = '/var/spool/pandora/data_in';
|
$default = '/var/spool/pandora/data_in';
|
||||||
}
|
}
|
||||||
|
@ -1510,7 +1510,7 @@ function config_process_config()
|
||||||
|
|
||||||
if (!isset($config['phantomjs_bin'])) {
|
if (!isset($config['phantomjs_bin'])) {
|
||||||
if ($is_windows) {
|
if ($is_windows) {
|
||||||
$default = 'C:\\PandoraFMS\\phantomjs';
|
$default = 'C:\PandoraFMS\Pandora_Server\bin';
|
||||||
} else {
|
} else {
|
||||||
$default = '/usr/bin';
|
$default = '/usr/bin';
|
||||||
}
|
}
|
||||||
|
@ -1760,7 +1760,13 @@ function config_process_config()
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!isset($config['auditdir'])) {
|
if (!isset($config['auditdir'])) {
|
||||||
config_update_value('auditdir', '/var/www/html/pandora_console');
|
$auditdir = '/var/www/html/pandora_console';
|
||||||
|
if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') {
|
||||||
|
// Windows.
|
||||||
|
$auditdir = $config['homedir'];
|
||||||
|
}
|
||||||
|
|
||||||
|
config_update_value('auditdir', $auditdir);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!isset($config['elasticsearch_ip'])) {
|
if (!isset($config['elasticsearch_ip'])) {
|
||||||
|
@ -1794,6 +1800,7 @@ function config_process_config()
|
||||||
/*
|
/*
|
||||||
* Parse the ACL IP list for access API
|
* Parse the ACL IP list for access API
|
||||||
*/
|
*/
|
||||||
|
|
||||||
$temp_list_ACL_IPs_for_API = [];
|
$temp_list_ACL_IPs_for_API = [];
|
||||||
if (isset($config['list_ACL_IPs_for_API'])) {
|
if (isset($config['list_ACL_IPs_for_API'])) {
|
||||||
if (!empty($config['list_ACL_IPs_for_API'])) {
|
if (!empty($config['list_ACL_IPs_for_API'])) {
|
||||||
|
@ -1804,13 +1811,16 @@ function config_process_config()
|
||||||
$config['list_ACL_IPs_for_API'] = $temp_list_ACL_IPs_for_API;
|
$config['list_ACL_IPs_for_API'] = $temp_list_ACL_IPs_for_API;
|
||||||
$keysConfig = array_keys($config);
|
$keysConfig = array_keys($config);
|
||||||
|
|
||||||
// This is not set here. The first time, when no
|
/*
|
||||||
// setup is done, update_manager extension manage it
|
* This is not set here. The first time, when no
|
||||||
// the first time make a conenction and disable itself
|
* setup is done, update_manager extension manage it
|
||||||
// Not Managed here !
|
* the first time make a conenction and disable itself
|
||||||
// if (!isset ($config["autoupdate"])) {
|
* Not Managed here !
|
||||||
// config_update_value ('autoupdate', true);.
|
* if (!isset ($config["autoupdate"])) {
|
||||||
// }
|
* config_update_value ('autoupdate', true);.
|
||||||
|
* }
|
||||||
|
*/
|
||||||
|
|
||||||
include_once $config['homedir'].'/include/auth/mysql.php';
|
include_once $config['homedir'].'/include/auth/mysql.php';
|
||||||
include_once $config['homedir'].'/include/functions_io.php';
|
include_once $config['homedir'].'/include/functions_io.php';
|
||||||
|
|
||||||
|
@ -1819,10 +1829,16 @@ function config_process_config()
|
||||||
// user, and should be in pandora root. By default, Pandora adds
|
// user, and should be in pandora root. By default, Pandora adds
|
||||||
// /attachment to this, so by default is the pandora console home
|
// /attachment to this, so by default is the pandora console home
|
||||||
// dir.
|
// dir.
|
||||||
|
$attachment_store_path = $config['homedir'].'/attachment';
|
||||||
|
if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') {
|
||||||
|
// Windows.
|
||||||
|
$attachment_store_path = $config['homedir'].'\attachment';
|
||||||
|
}
|
||||||
|
|
||||||
if (!isset($config['attachment_store'])) {
|
if (!isset($config['attachment_store'])) {
|
||||||
config_update_value(
|
config_update_value(
|
||||||
'attachment_store',
|
'attachment_store',
|
||||||
io_safe_input($config['homedir']).'/attachment'
|
$attachment_store_path
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
// Fixed when the user moves the pandora console to another dir
|
// Fixed when the user moves the pandora console to another dir
|
||||||
|
@ -1830,16 +1846,23 @@ function config_process_config()
|
||||||
if (!is_dir($config['attachment_store'])) {
|
if (!is_dir($config['attachment_store'])) {
|
||||||
config_update_value(
|
config_update_value(
|
||||||
'attachment_store',
|
'attachment_store',
|
||||||
$config['homedir'].'/attachment'
|
$attachment_store_path
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!isset($config['fontpath'])) {
|
if (!isset($config['fontpath'])) {
|
||||||
$home = str_replace('\\', '/', $config['homedir']);
|
if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') {
|
||||||
|
// Windows.
|
||||||
|
$fontpath = $config['homedir'].'\include\fonts\smallfont.ttf';
|
||||||
|
} else {
|
||||||
|
$home = str_replace('\\', '/', $config['homedir']);
|
||||||
|
$fontpath = $home.'/include/fonts/smallfont.ttf';
|
||||||
|
}
|
||||||
|
|
||||||
config_update_value(
|
config_update_value(
|
||||||
'fontpath',
|
'fontpath',
|
||||||
$home.'/include/fonts/smallfont.ttf'
|
$fontpath
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2077,7 +2100,7 @@ function config_process_config()
|
||||||
|
|
||||||
if (!isset($config['netflow_path'])) {
|
if (!isset($config['netflow_path'])) {
|
||||||
if ($is_windows) {
|
if ($is_windows) {
|
||||||
$default = 'C:\\PandoraFMS\\Pandora_Server\\data_in\\netflow';
|
$default = 'C:\PandoraFMS\Pandora_Server\data_in\netflow';
|
||||||
} else {
|
} else {
|
||||||
$default = '/var/spool/pandora/data_in/netflow';
|
$default = '/var/spool/pandora/data_in/netflow';
|
||||||
}
|
}
|
||||||
|
|
|
@ -104,7 +104,7 @@ class gettext_reader {
|
||||||
* @param boolean enable_cache Enable or disable caching of strings (default on)
|
* @param boolean enable_cache Enable or disable caching of strings (default on)
|
||||||
*/
|
*/
|
||||||
function gettext_reader($Reader, $enable_cache = true) {
|
function gettext_reader($Reader, $enable_cache = true) {
|
||||||
$machine = @shell_exec('uname -m');
|
$machine = php_uname("m");
|
||||||
|
|
||||||
$enabled64Bits = false;
|
$enabled64Bits = false;
|
||||||
if (preg_match('/64/', $machine)) {
|
if (preg_match('/64/', $machine)) {
|
||||||
|
|
|
@ -357,6 +357,14 @@ sub pandora_load_config {
|
||||||
# Xprobe2 for recon OS fingerprinting and tcpscan (optional)
|
# Xprobe2 for recon OS fingerprinting and tcpscan (optional)
|
||||||
$pa_config->{"xprobe2"} = "/usr/bin/xprobe2";
|
$pa_config->{"xprobe2"} = "/usr/bin/xprobe2";
|
||||||
|
|
||||||
|
# Winexe allows to exec commands on remote windows systems (optional)
|
||||||
|
$pa_config->{"winexe"} = "/usr/bin/winexe";
|
||||||
|
|
||||||
|
# PsExec allows to exec commands on remote windows systems from windows servers (optional)
|
||||||
|
$pa_config->{"psexec"} = 'C:\PandoraFMS\Pandora_Server\bin\PsExec.exe';
|
||||||
|
|
||||||
|
# plink allows to exec commands on remote linux systems from windows servers (optional)
|
||||||
|
$pa_config->{"plink"} = 'C:\PandoraFMS\Pandora_Server\bin\plink.exe';
|
||||||
|
|
||||||
# Snmpget for snmpget system command (optional)
|
# Snmpget for snmpget system command (optional)
|
||||||
$pa_config->{"snmpget"} = "/usr/bin/snmpget";
|
$pa_config->{"snmpget"} = "/usr/bin/snmpget";
|
||||||
|
@ -838,6 +846,15 @@ sub pandora_load_config {
|
||||||
elsif ($parametro =~ m/^xprobe2\s(.*)/i) {
|
elsif ($parametro =~ m/^xprobe2\s(.*)/i) {
|
||||||
$pa_config->{'xprobe2'}= clean_blank($1);
|
$pa_config->{'xprobe2'}= clean_blank($1);
|
||||||
}
|
}
|
||||||
|
elsif ($parametro =~ m/^winexe\s(.*)/i) {
|
||||||
|
$pa_config->{'winexe'}= clean_blank($1);
|
||||||
|
}
|
||||||
|
elsif ($parametro =~ m/^psexec\s(.*)/i) {
|
||||||
|
$pa_config->{'psexec'}= clean_blank($1);
|
||||||
|
}
|
||||||
|
elsif ($parametro =~ m/^plink\s(.*)/i) {
|
||||||
|
$pa_config->{'plink'}= clean_blank($1);
|
||||||
|
}
|
||||||
elsif ($parametro =~ m/^snmpget\s(.*)/i) {
|
elsif ($parametro =~ m/^snmpget\s(.*)/i) {
|
||||||
$pa_config->{'snmpget'}= clean_blank($1);
|
$pa_config->{'snmpget'}= clean_blank($1);
|
||||||
}
|
}
|
||||||
|
|
|
@ -343,6 +343,9 @@ sub exec_recon_script ($$$) {
|
||||||
sub PandoraFMS::Recon::Base::guess_os($$) {
|
sub PandoraFMS::Recon::Base::guess_os($$) {
|
||||||
my ($self, $device) = @_;
|
my ($self, $device) = @_;
|
||||||
|
|
||||||
|
$DEVNULL = '/dev/null' if (!defined($DEVNULL));
|
||||||
|
$DEVNULL = '/NUL' if ($^O =~ /win/i && !defined($DEVNULL));
|
||||||
|
|
||||||
# OS detection disabled. Use the device type.
|
# OS detection disabled. Use the device type.
|
||||||
if ($self->{'os_detection'} == 0) {
|
if ($self->{'os_detection'} == 0) {
|
||||||
my $device_type = $self->get_device_type($device);
|
my $device_type = $self->get_device_type($device);
|
||||||
|
@ -354,17 +357,20 @@ sub PandoraFMS::Recon::Base::guess_os($$) {
|
||||||
}
|
}
|
||||||
|
|
||||||
# Use xprobe2 if available
|
# Use xprobe2 if available
|
||||||
if (-e $self->{pa_config}->{xprobe2}) {
|
if (-x $self->{'pa_config'}->{'xprobe2'}) {
|
||||||
my $output = `"$self->{pa_config}->{xprobe2}" $device 2>$DEVNULL | grep 'Running OS' | head -1`;
|
my $return = `"$self->{pa_config}->{xprobe2}" $device 2>$DEVNULL`;
|
||||||
if ($? == 0) {
|
if ($? == 0) {
|
||||||
|
my ($output) = $a =~ /Running OS:(.*)/;
|
||||||
return pandora_get_os($self->{'dbh'}, $output);
|
return pandora_get_os($self->{'dbh'}, $output);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
# Use nmap by default
|
# Use nmap by default
|
||||||
if (-e $self->{pa_config}->{nmap}) {
|
if (-x $self->{'pa_config'}->{'nmap'}) {
|
||||||
my $output = `"$self->{pa_config}->{nmap}" -F -O $device 2>$DEVNULL | grep 'Aggressive OS guesses'`;
|
my $return = `"$self->{pa_config}->{nmap}" -F -O $device 2>$DEVNULL`;
|
||||||
return OS_OTHER if ($? != 0);
|
return OS_OTHER if ($? != 0);
|
||||||
|
|
||||||
|
my ($output) = $return =~ /Aggressive OS guesses:\s*(.*)/;
|
||||||
return pandora_get_os($self->{'dbh'}, $output);
|
return pandora_get_os($self->{'dbh'}, $output);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -377,7 +383,11 @@ sub PandoraFMS::Recon::Base::guess_os($$) {
|
||||||
sub PandoraFMS::Recon::Base::tcp_scan ($$) {
|
sub PandoraFMS::Recon::Base::tcp_scan ($$) {
|
||||||
my ($self, $host) = @_;
|
my ($self, $host) = @_;
|
||||||
|
|
||||||
my $open_ports = `"$self->{pa_config}->{nmap}" -p$self->{recon_ports} $host | grep open | wc -l`;
|
my $r = `"$self->{pa_config}->{nmap}" -p$self->{recon_ports} $host`;
|
||||||
|
|
||||||
|
# Same as ""| grep open | wc -l" but multi-OS;
|
||||||
|
my $open_ports = () = $r =~ /open/gm;
|
||||||
|
|
||||||
return $open_ports;
|
return $open_ports;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -36,7 +36,7 @@ use constant {
|
||||||
DISCOVERY_DEPLOY_AGENTS => 9,
|
DISCOVERY_DEPLOY_AGENTS => 9,
|
||||||
};
|
};
|
||||||
|
|
||||||
# /dev/null
|
# $DEVNULL
|
||||||
my $DEVNULL = ($^O eq 'MSWin32') ? '/Nul' : '/dev/null';
|
my $DEVNULL = ($^O eq 'MSWin32') ? '/Nul' : '/dev/null';
|
||||||
|
|
||||||
# Some useful OIDs.
|
# Some useful OIDs.
|
||||||
|
@ -852,7 +852,7 @@ sub get_routes($) {
|
||||||
$self->{'routes'} = [];
|
$self->{'routes'} = [];
|
||||||
|
|
||||||
# Parse route's output.
|
# Parse route's output.
|
||||||
my @output = `route -n 2>/dev/null`;
|
my @output = `route -n 2>$DEVNULL`;
|
||||||
foreach my $line (@output) {
|
foreach my $line (@output) {
|
||||||
chomp($line);
|
chomp($line);
|
||||||
if ($line =~ /^0\.0\.0\.0\s+(\d+\.\d+\.\d+\.\d+).*/) {
|
if ($line =~ /^0\.0\.0\.0\s+(\d+\.\d+\.\d+\.\d+).*/) {
|
||||||
|
@ -1220,7 +1220,7 @@ sub snmp_responds_v3($$) {
|
||||||
sub local_arp($) {
|
sub local_arp($) {
|
||||||
my ($self) = @_;
|
my ($self) = @_;
|
||||||
|
|
||||||
my @output = `arp -an 2>/dev/null`;
|
my @output = `arp -an 2>$DEVNULL`;
|
||||||
foreach my $line (@output) {
|
foreach my $line (@output) {
|
||||||
next unless ($line =~ m/\((\S+)\) at ([0-9a-f]+:[0-9a-f]+:[0-9a-f]+:[0-9a-f]+:[0-9a-f]+:[0-9a-f]+)/);
|
next unless ($line =~ m/\((\S+)\) at ([0-9a-f]+:[0-9a-f]+:[0-9a-f]+:[0-9a-f]+:[0-9a-f]+:[0-9a-f]+)/);
|
||||||
$self->add_mac(parse_mac($2), $1);
|
$self->add_mac(parse_mac($2), $1);
|
||||||
|
@ -1286,7 +1286,7 @@ sub ping ($$$) {
|
||||||
for (my $i = 0; $i < $retries; $i++) {
|
for (my $i = 0; $i < $retries; $i++) {
|
||||||
|
|
||||||
# Note: There is no timeout option.
|
# Note: There is no timeout option.
|
||||||
`$ping_command -s -n $host 56 $packets >/dev/null 2>&1`;
|
`$ping_command -s -n $host 56 $packets >$DEVNULL 2>&1`;
|
||||||
return 1 if ($? == 0);
|
return 1 if ($? == 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1299,7 +1299,7 @@ sub ping ($$$) {
|
||||||
for (my $i = 0; $i < $retries; $i++) {
|
for (my $i = 0; $i < $retries; $i++) {
|
||||||
|
|
||||||
# Note: There is no timeout option for ping6.
|
# Note: There is no timeout option for ping6.
|
||||||
`$ping_command -q -n -c $packets $host >/dev/null 2>&1`;
|
`$ping_command -q -n -c $packets $host >$DEVNULL 2>&1`;
|
||||||
return 1 if ($? == 0);
|
return 1 if ($? == 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1312,7 +1312,7 @@ sub ping ($$$) {
|
||||||
for (my $i = 0; $i < $retries; $i++) {
|
for (my $i = 0; $i < $retries; $i++) {
|
||||||
|
|
||||||
# Note: There is no timeout option for ping6.
|
# Note: There is no timeout option for ping6.
|
||||||
`$ping_command -q -n -c $packets $host >/dev/null 2>&1`;
|
`$ping_command -q -n -c $packets $host >$DEVNULL 2>&1`;
|
||||||
if ($? == 0) {
|
if ($? == 0) {
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
@ -1324,7 +1324,7 @@ sub ping ($$$) {
|
||||||
# Assume Linux by default.
|
# Assume Linux by default.
|
||||||
my $ping_command = $host =~ /\d+:|:\d+/ ? "ping6" : "ping";
|
my $ping_command = $host =~ /\d+:|:\d+/ ? "ping6" : "ping";
|
||||||
for (my $i = 0; $i < $retries; $i++) {
|
for (my $i = 0; $i < $retries; $i++) {
|
||||||
`$ping_command -q -W $timeout -n -c $packets $host >/dev/null 2>&1`;
|
`$ping_command -q -W $timeout -n -c $packets $host >$DEVNULL 2>&1`;
|
||||||
return 1 if ($? == 0);
|
return 1 if ($? == 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1529,99 +1529,101 @@ sub app_scan($) {
|
||||||
$self->{'task_data'}
|
$self->{'task_data'}
|
||||||
);
|
);
|
||||||
|
|
||||||
if (!$dbObj->is_connected()) {
|
if (defined($dbObj)) {
|
||||||
call('message', 'Cannot connect to target ' . $target, 3);
|
if (!$dbObj->is_connected()) {
|
||||||
$global_percent += $global_step;
|
call('message', 'Cannot connect to target ' . $target, 3);
|
||||||
$self->{'c_network_percent'} = 90;
|
$global_percent += $global_step;
|
||||||
# Update progress
|
$self->{'c_network_percent'} = 90;
|
||||||
$self->call('update_progress', $global_percent + (90 / (scalar @targets)));
|
# Update progress
|
||||||
$self->{'summary'}->{'not_alive'} += 1;
|
$self->call('update_progress', $global_percent + (90 / (scalar @targets)));
|
||||||
push @modules, {
|
$self->{'summary'}->{'not_alive'} += 1;
|
||||||
name => $type . ' connection',
|
push @modules, {
|
||||||
type => 'generic_proc',
|
name => $type . ' connection',
|
||||||
data => 0,
|
type => 'generic_proc',
|
||||||
description => $type . ' availability'
|
data => 0,
|
||||||
};
|
description => $type . ' availability'
|
||||||
|
};
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
my $dbObjCfg = $dbObj->get_config();
|
my $dbObjCfg = $dbObj->get_config();
|
||||||
|
|
||||||
$self->{'summary'}->{'discovered'} += 1;
|
$self->{'summary'}->{'discovered'} += 1;
|
||||||
$self->{'summary'}->{'alive'} += 1;
|
$self->{'summary'}->{'alive'} += 1;
|
||||||
|
|
||||||
push @modules, {
|
push @modules, {
|
||||||
name => $type . ' connection',
|
name => $type . ' connection',
|
||||||
type => 'generic_proc',
|
type => 'generic_proc',
|
||||||
data => 1,
|
data => 1,
|
||||||
description => $type . ' availability'
|
description => $type . ' availability'
|
||||||
};
|
};
|
||||||
|
|
||||||
# Analyze.
|
# Analyze.
|
||||||
$self->{'step'} = STEP_STATISTICS;
|
$self->{'step'} = STEP_STATISTICS;
|
||||||
$self->{'c_network_percent'} = 30;
|
$self->{'c_network_percent'} = 30;
|
||||||
$self->call('update_progress', $global_percent + (30 / (scalar @targets)));
|
$self->call('update_progress', $global_percent + (30 / (scalar @targets)));
|
||||||
$self->{'c_network_name'} = $dbObj->get_host();
|
$self->{'c_network_name'} = $dbObj->get_host();
|
||||||
|
|
||||||
# Retrieve connection statistics.
|
# Retrieve connection statistics.
|
||||||
# Retrieve uptime statistics
|
# Retrieve uptime statistics
|
||||||
# Retrieve query stats
|
# Retrieve query stats
|
||||||
# Retrieve connections
|
# Retrieve connections
|
||||||
# Retrieve innodb
|
# Retrieve innodb
|
||||||
# Retrieve cache
|
# Retrieve cache
|
||||||
$self->{'c_network_percent'} = 50;
|
$self->{'c_network_percent'} = 50;
|
||||||
$self->call('update_progress', $global_percent + (50 / (scalar @targets)));
|
$self->call('update_progress', $global_percent + (50 / (scalar @targets)));
|
||||||
push @modules, $dbObj->get_statistics();
|
push @modules, $dbObj->get_statistics();
|
||||||
|
|
||||||
# Custom queries.
|
# Custom queries.
|
||||||
$self->{'step'} = STEP_CUSTOM_QUERIES;
|
$self->{'step'} = STEP_CUSTOM_QUERIES;
|
||||||
$self->{'c_network_percent'} = 80;
|
$self->{'c_network_percent'} = 80;
|
||||||
$self->call('update_progress', $global_percent + (80 / (scalar @targets)));
|
$self->call('update_progress', $global_percent + (80 / (scalar @targets)));
|
||||||
push @modules, $dbObj->execute_custom_queries();
|
push @modules, $dbObj->execute_custom_queries();
|
||||||
|
|
||||||
if (defined($dbObjCfg->{'scan_databases'})
|
if (defined($dbObjCfg->{'scan_databases'})
|
||||||
&& $dbObjCfg->{'scan_databases'} == 1) {
|
&& "$dbObjCfg->{'scan_databases'}" eq "1") {
|
||||||
# Skip database scan in Oracle tasks
|
# Skip database scan in Oracle tasks
|
||||||
next if $self->{'type'} == DISCOVERY_APP_ORACLE;
|
next if $self->{'type'} == DISCOVERY_APP_ORACLE;
|
||||||
|
|
||||||
my $__data = $dbObj->scan_databases();
|
my $__data = $dbObj->scan_databases();
|
||||||
|
|
||||||
if (ref($__data) eq "ARRAY") {
|
if (ref($__data) eq "ARRAY") {
|
||||||
if (defined($dbObjCfg->{'agent_per_database'})
|
if (defined($dbObjCfg->{'agent_per_database'})
|
||||||
&& $dbObjCfg->{'agent_per_database'} == 1) {
|
&& $dbObjCfg->{'agent_per_database'} == 1) {
|
||||||
# Agent per database detected.
|
# Agent per database detected.
|
||||||
push @data, @{$__data};
|
push @data, @{$__data};
|
||||||
} else {
|
} else {
|
||||||
# Merge modules into engine agent.
|
# Merge modules into engine agent.
|
||||||
my @_modules = map {
|
my @_modules = map {
|
||||||
map { $_ } @{$_->{'module_data'}}
|
map { $_ } @{$_->{'module_data'}}
|
||||||
} @{$__data};
|
} @{$__data};
|
||||||
|
|
||||||
push @modules, @_modules;
|
push @modules, @_modules;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Put engine agent at the beginning of the list.
|
||||||
|
my $version = $dbObj->get_version();
|
||||||
|
unshift @data,{
|
||||||
|
'agent_data' => {
|
||||||
|
'agent_name' => $dbObj->get_agent_name(),
|
||||||
|
'os' => $type,
|
||||||
|
'os_version' => (defined($version) ? $version : 'Discovery'),
|
||||||
|
'interval' => $self->{'task_data'}->{'interval_sweep'},
|
||||||
|
'id_group' => $self->{'task_data'}->{'id_group'},
|
||||||
|
'address' => $dbObj->get_host(),
|
||||||
|
'description' => '',
|
||||||
|
},
|
||||||
|
'module_data' => \@modules,
|
||||||
|
};
|
||||||
|
|
||||||
|
$self->call('create_agents', \@data);
|
||||||
|
|
||||||
|
# Destroy item.
|
||||||
|
undef($dbObj);
|
||||||
}
|
}
|
||||||
|
|
||||||
# Put engine agent at the beginning of the list.
|
|
||||||
my $version = $dbObj->get_version();
|
|
||||||
unshift @data,{
|
|
||||||
'agent_data' => {
|
|
||||||
'agent_name' => $dbObj->get_agent_name(),
|
|
||||||
'os' => $type,
|
|
||||||
'os_version' => (defined($version) ? $version : 'Discovery'),
|
|
||||||
'interval' => $self->{'task_data'}->{'interval_sweep'},
|
|
||||||
'id_group' => $self->{'task_data'}->{'id_group'},
|
|
||||||
'address' => $dbObj->get_host(),
|
|
||||||
'description' => '',
|
|
||||||
},
|
|
||||||
'module_data' => \@modules,
|
|
||||||
};
|
|
||||||
|
|
||||||
$self->call('create_agents', \@data);
|
|
||||||
|
|
||||||
# Destroy item.
|
|
||||||
undef($dbObj);
|
|
||||||
|
|
||||||
$global_percent += $global_step;
|
$global_percent += $global_step;
|
||||||
$self->{'c_network_percent'} = 100;
|
$self->{'c_network_percent'} = 100;
|
||||||
$self->call('update_progress', $global_percent);
|
$self->call('update_progress', $global_percent);
|
||||||
|
@ -1674,7 +1676,7 @@ sub deploy_scan($) {
|
||||||
##########################################################################
|
##########################################################################
|
||||||
sub scan($) {
|
sub scan($) {
|
||||||
my ($self) = @_;
|
my ($self) = @_;
|
||||||
my ($progress, $step);
|
my ($progress, $step) = 1, 0;
|
||||||
|
|
||||||
# 1%
|
# 1%
|
||||||
$self->call('update_progress', 1);
|
$self->call('update_progress', 1);
|
||||||
|
@ -1697,7 +1699,7 @@ sub scan($) {
|
||||||
}
|
}
|
||||||
|
|
||||||
# Find devices.
|
# Find devices.
|
||||||
$self->call('message', "[1/5] Scanning the network...", 3);
|
$self->call('message', "[1/4] Scanning the network...", 3);
|
||||||
$self->{'step'} = STEP_SCANNING;
|
$self->{'step'} = STEP_SCANNING;
|
||||||
$self->call('update_progress', $progress);
|
$self->call('update_progress', $progress);
|
||||||
$self->scan_subnet();
|
$self->scan_subnet();
|
||||||
|
@ -1713,7 +1715,7 @@ sub scan($) {
|
||||||
$self->call('delete_connections');
|
$self->call('delete_connections');
|
||||||
|
|
||||||
# Connectivity from address forwarding tables.
|
# Connectivity from address forwarding tables.
|
||||||
$self->call('message', "[1/4] Finding address forwarding table connectivity...", 3);
|
$self->call('message', "[2/4] Finding address forwarding table connectivity...", 3);
|
||||||
$self->{'step'} = STEP_AFT;
|
$self->{'step'} = STEP_AFT;
|
||||||
($progress, $step) = (50, 20.0 / scalar(@hosts)); # From 50% to 70%.
|
($progress, $step) = (50, 20.0 / scalar(@hosts)); # From 50% to 70%.
|
||||||
for (my $i = 0; defined($hosts[$i]); $i++) {
|
for (my $i = 0; defined($hosts[$i]); $i++) {
|
||||||
|
@ -1831,7 +1833,7 @@ sub snmp_get_command {
|
||||||
my ($self, $device, $oid, $community, $vlan) = @_;
|
my ($self, $device, $oid, $community, $vlan) = @_;
|
||||||
$vlan = defined($vlan) ? "\@" . $vlan : '';
|
$vlan = defined($vlan) ? "\@" . $vlan : '';
|
||||||
|
|
||||||
my $command = "snmpwalk -M/dev/null -r$self->{'snmp_checks'} -t$self->{'snmp_timeout'} -v$self->{'snmp_version'} -On -Oe ";
|
my $command = "snmpwalk -M$DEVNULL -r$self->{'snmp_checks'} -t$self->{'snmp_timeout'} -v$self->{'snmp_version'} -On -Oe ";
|
||||||
if ($self->{'snmp_version'} eq "3") {
|
if ($self->{'snmp_version'} eq "3") {
|
||||||
if ($self->{'community'}) { # Context
|
if ($self->{'community'}) { # Context
|
||||||
$command .= " -N $self->{'community'} ";
|
$command .= " -N $self->{'community'} ";
|
||||||
|
@ -1847,7 +1849,7 @@ sub snmp_get_command {
|
||||||
$command .= " -c$community$vlan ";
|
$command .= " -c$community$vlan ";
|
||||||
}
|
}
|
||||||
|
|
||||||
return "$command $device $oid 2>/dev/null";
|
return "$command $device $oid 2>$DEVNULL";
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -994,7 +994,8 @@ sub load_average {
|
||||||
$load_average = ((split(/\s+/, `/sbin/sysctl -n vm.loadavg`))[1]);
|
$load_average = ((split(/\s+/, `/sbin/sysctl -n vm.loadavg`))[1]);
|
||||||
} elsif ($OSNAME eq "MSWin32") {
|
} elsif ($OSNAME eq "MSWin32") {
|
||||||
# Windows hasn't got load average.
|
# Windows hasn't got load average.
|
||||||
$load_average = undef;
|
$load_average = `powershell "(Get-WmiObject win32_processor | Measure-Object -property LoadPercentage -Average).average"`;
|
||||||
|
chop($load_average);
|
||||||
}
|
}
|
||||||
# by default LINUX calls
|
# by default LINUX calls
|
||||||
else {
|
else {
|
||||||
|
|
Loading…
Reference in New Issue