diff --git a/pandora_console/extras/mr/37.sql b/pandora_console/extras/mr/37.sql
index 840f6994c7..31a4b2c96a 100644
--- a/pandora_console/extras/mr/37.sql
+++ b/pandora_console/extras/mr/37.sql
@@ -1,8 +1,10 @@
START TRANSACTION;
ALTER TABLE trecon_task MODIFY COLUMN `id_network_profile` TEXT;
-ALTER TABLE `trecon_task` CHANGE COLUMN `create_incident` `direct_report` TINYINT(1) UNSIGNED DEFAULT 0;
-UPDATE `trecon_task` SET `direct_report` = 1;
+ALTER TABLE `trecon_task` CHANGE COLUMN `create_incident` `review_mode` TINYINT(1) UNSIGNED DEFAULT 0;
+UPDATE `trecon_task` SET `review_mode` = 1;
+ALTER TABLE trecon_task add column `auto_monitor` TINYINT(1) UNSIGNED DEFAULT 1 AFTER `auth_strings`;
+UPDATE `trecon_task` SET `auto_monitor` = 0;
CREATE TABLE `tdiscovery_tmp_agents` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
@@ -18,6 +20,7 @@ CREATE TABLE `tdiscovery_tmp_agents` (
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
CREATE TABLE `tdiscovery_tmp_connections` (
+ `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`id_rt` int(10) unsigned NOT NULL,
`id1` int(10) unsigned NOT NULL AUTO_INCREMENT,
`id2` int(10) unsigned NOT NULL,
diff --git a/pandora_console/extras/pandoradb_migrate_6.0_to_7.0.mysql.sql b/pandora_console/extras/pandoradb_migrate_6.0_to_7.0.mysql.sql
index a0b563e04c..3552c7d1ee 100644
--- a/pandora_console/extras/pandoradb_migrate_6.0_to_7.0.mysql.sql
+++ b/pandora_console/extras/pandoradb_migrate_6.0_to_7.0.mysql.sql
@@ -1671,10 +1671,10 @@ ALTER TABLE `trecon_task` ADD COLUMN `type` int(11) NOT NULL DEFAULT '0',
MODIFY COLUMN `autoconfiguration_enabled` tinyint(1) unsigned NULL DEFAULT '0',
MODIFY COLUMN `summary` text NULL,
MODIFY COLUMN `id_network_profile` text,
- CHANGE COLUMN `create_incident` `direct_report` TINYINT(1) UNSIGNED DEFAULT 0;
+ CHANGE COLUMN `create_incident` `review_mode` TINYINT(1) UNSIGNED DEFAULT 0;
-- Old recon always report.
-UPDATE `trecon_task` SET `direct_report` = 1;
+UPDATE `trecon_task` SET `review_mode` = 1;
-- ----------------------------------------------------------------------
-- Table `tdiscovery_tmp`
@@ -1693,18 +1693,13 @@ CREATE TABLE `tdiscovery_tmp_agents` (
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
CREATE TABLE `tdiscovery_tmp_connections` (
+ `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`id_rt` int(10) unsigned NOT NULL,
- `id1` int(10) unsigned NOT NULL AUTO_INCREMENT,
- `id2` int(10) unsigned NOT NULL,
- `if1` text,
- `if2` text,
- PRIMARY KEY (`id1`,`id2`),
- CONSTRAINT `tdtc_trt` FOREIGN KEY (`id_rt`)
- REFERENCES `trecon_task` (`id_rt`) ON DELETE CASCADE ON UPDATE CASCADE,
- CONSTRAINT `tdtc_tdta1` FOREIGN KEY (`id1`)
- REFERENCES `tdiscovery_tmp_agents` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
- CONSTRAINT `tdtc_tdta2` FOREIGN KEY (`id2`)
- REFERENCES `tdiscovery_tmp_agents` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
+ `dev_1` text,
+ `dev_2` text,
+ `if_1` text,
+ `if_2` text,
+ PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-- ---------------------------------------------------------------------
@@ -2172,6 +2167,8 @@ ALTER TABLE `trecon_task` ADD COLUMN `snmp_auth_method` varchar(25) NOT NULL def
ALTER TABLE `trecon_task` ADD COLUMN `snmp_privacy_method` varchar(25) NOT NULL default '';
ALTER TABLE `trecon_task` ADD COLUMN `snmp_privacy_pass` varchar(255) NOT NULL default '';
ALTER TABLE `trecon_task` ADD COLUMN `snmp_security_level` varchar(25) NOT NULL default '';
+ALTER TABLE trecon_task add column `auto_monitor` TINYINT(1) UNSIGNED DEFAULT 1 AFTER `auth_strings`;
+UPDATE `trecon_task` SET `auto_monitor` = 0;
-- ---------------------------------------------------------------------
-- Table `tagent_custom_fields_filter`
diff --git a/pandora_console/godmode/wizards/DiscoveryTaskList.class.php b/pandora_console/godmode/wizards/DiscoveryTaskList.class.php
index 94e3d5f3aa..59f53a2f48 100644
--- a/pandora_console/godmode/wizards/DiscoveryTaskList.class.php
+++ b/pandora_console/godmode/wizards/DiscoveryTaskList.class.php
@@ -272,24 +272,24 @@ class DiscoveryTaskList extends HTML
if (isset($_GET['force'])) {
$id = (int) get_parameter_get('force', 0);
// Schedule execution.
- $direct_report = db_get_value(
- 'direct_report',
+ $review_mode = db_get_value(
+ 'review_mode',
'trecon_task',
'id_rt',
$id
);
- if ($direct_report != DISCOVERY_STANDARD) {
+ if ($review_mode != DISCOVERY_STANDARD) {
// Force re-scan for supervised tasks.
- $direct_report = DISCOVERY_SEARCH;
+ $review_mode = DISCOVERY_REVIEW;
}
db_process_sql_update(
'trecon_task',
[
- 'utimestamp' => 0,
- 'status' => 1,
- 'direct_report' => $direct_report,
+ 'utimestamp' => 0,
+ 'status' => 1,
+ 'review_mode' => $review_mode,
],
['id_rt' => $id]
);
@@ -523,7 +523,7 @@ class DiscoveryTaskList extends HTML
$data[4] = '-';
}
- if ($task['direct_report'] == 1) {
+ if ($task['review_mode'] == DISCOVERY_STANDARD) {
if ($task['status'] <= 0
&& empty($task['summary']) === false
) {
@@ -547,7 +547,11 @@ class DiscoveryTaskList extends HTML
) {
$data[5] = __('Not started');
} else {
- $data[5] = __('Searching');
+ if ($task['review_mode'] == DISCOVERY_RESULTS) {
+ $data[5] = __('Processing');
+ } else {
+ $data[5] = __('Searching');
+ }
}
}
@@ -622,14 +626,7 @@ class DiscoveryTaskList extends HTML
true,
['title' => __('Discovery NetScan')]
).' ';
- $str = network_profiles_get_name(
- $task['id_network_profile']
- );
- if (!empty($str)) {
- $data[6] .= $str;
- } else {
- $data[6] .= __('Discovery.NetScan');
- }
+ $data[6] .= __('Discovery.NetScan');
} else {
// APP or external script recon task.
$data[6] = html_print_image(
@@ -918,13 +915,16 @@ class DiscoveryTaskList extends HTML
);
$result .= '';
-
if ($task['status'] > 0) {
switch ($task['stats']['step']) {
case STEP_SCANNING:
$str = __('Scanning network');
break;
+ case STEP_CAPABILITIES:
+ $str = __('Checking');
+ break;
+
case STEP_AFT:
$str = __('Finding AFT connectivity');
break;
@@ -958,14 +958,14 @@ class DiscoveryTaskList extends HTML
break;
default:
- $str = '';
+ $str = __('Processing...');
break;
}
$result .= '';
$result .= '
';
$result .= ''.$str.' ';
- if (!empty($str)) {
+ if (empty($str) === false) {
$result .= $task['stats']['c_network_name'];
}
@@ -986,6 +986,16 @@ class DiscoveryTaskList extends HTML
$result .= '
';
}
+ if ($task['review_mode'] == DISCOVERY_REVIEW) {
+ if ($task['status'] <= 0
+ && empty($task['summary']) === false
+ ) {
+ $result .= '';
+ $result .= '»'.__('Review');
+ $result .= ' ';
+ }
+ }
+
$result .= '';
return $result;
@@ -1039,15 +1049,17 @@ class DiscoveryTaskList extends HTML
$table->data[$i][1] .= $task['stats']['summary']['not_alive'];
$table->data[$i++][1] .= '';
- $table->data[$i][0] = ''.__('Responding SNMP').' ';
- $table->data[$i][1] = '';
- $table->data[$i][1] .= $task['stats']['summary']['SNMP'];
- $table->data[$i++][1] .= ' ';
+ if ($task['type'] == DISCOVERY_HOSTDEVICES) {
+ $table->data[$i][0] = ''.__('Responding SNMP').' ';
+ $table->data[$i][1] = '';
+ $table->data[$i][1] .= $task['stats']['summary']['SNMP'];
+ $table->data[$i++][1] .= ' ';
- $table->data[$i][0] = ''.__('Responding WMI').' ';
- $table->data[$i][1] = '';
- $table->data[$i][1] .= $task['stats']['summary']['WMI'];
- $table->data[$i++][1] .= ' ';
+ $table->data[$i][0] = ''.__('Responding WMI').' ';
+ $table->data[$i][1] = '';
+ $table->data[$i][1] .= $task['stats']['summary']['WMI'];
+ $table->data[$i++][1] .= ' ';
+ }
$output = ''.__('Summary').'
';
$output .= html_print_table($table, true).'';
@@ -1156,6 +1168,10 @@ class DiscoveryTaskList extends HTML
continue;
}
+ if (is_array($data['agent']) === false) {
+ continue;
+ }
+
$id = $data['agent']['nombre'];
// Partial.
@@ -1201,7 +1217,7 @@ class DiscoveryTaskList extends HTML
'checked' => $item['checked'],
];
- $agentmodule_id = $agentmodule_id = modules_get_agentmodule_id(
+ $agentmodule_id = modules_get_agentmodule_id(
io_safe_input($item['name']),
$agent_id
);
@@ -1342,9 +1358,9 @@ class DiscoveryTaskList extends HTML
db_process_sql_update(
'trecon_task',
[
- 'utimestamp' => 0,
- 'status' => 1,
- 'direct_report' => DISCOVERY_RESULTS,
+ 'utimestamp' => 0,
+ 'status' => 1,
+ 'review_mode' => DISCOVERY_RESULTS,
],
['id_rt' => $id_task]
);
diff --git a/pandora_console/godmode/wizards/HostDevices.class.php b/pandora_console/godmode/wizards/HostDevices.class.php
index 265e48d821..727010cb8d 100755
--- a/pandora_console/godmode/wizards/HostDevices.class.php
+++ b/pandora_console/godmode/wizards/HostDevices.class.php
@@ -138,6 +138,8 @@ class HostDevices extends Wizard
// Load styles.
parent::run();
+ ui_require_css_file('hostdevices');
+
$mode = get_parameter('mode', null);
if ($mode === null) {
@@ -421,6 +423,8 @@ class HostDevices extends Wizard
}
$id_network_profile = get_parameter('id_network_profile', []);
+ $review_results = get_parameter_switch('review_results');
+ $auto_monitor = get_parameter_switch('auto_monitor');
$autoconf_enabled = get_parameter_switch(
'autoconfiguration_enabled'
);
@@ -457,6 +461,15 @@ class HostDevices extends Wizard
);
}
+ if ($review_results) {
+ if ($this->task['review_mode'] != DISCOVERY_RESULTS) {
+ $this->task['review_mode'] = DISCOVERY_REVIEW;
+ }
+ } else {
+ $this->task['review_mode'] = DISCOVERY_STANDARD;
+ }
+
+ $this->task['auto_monitor'] = $auto_monitor;
$this->task['snmp_enabled'] = $snmp_enabled;
$this->task['os_detect'] = $os_detect;
$this->task['parent_detection'] = $parent_detection;
@@ -893,6 +906,22 @@ class HostDevices extends Wizard
).'',
];
+ $form['inputs'][] = [
+ 'label' => __('Auto discover known hardware').ui_print_help_tip(
+ __(
+ 'Targets will be monitorized based on its Private Enterprise Number . Requires SNMP.'
+ ),
+ true
+ ),
+ 'arguments' => [
+ 'name' => 'auto_monitor',
+ 'type' => 'switch',
+ 'return' => true,
+ 'value' => (isset($this->task['auto_monitor'])) ? $this->task['auto_monitor'] : 1,
+ 'onclick' => 'toggleTemplatesSelection();',
+ ],
+ ];
+
$form['inputs'][] = [
'label' => __('Module templates').ui_print_help_tip(
__(
@@ -917,6 +946,21 @@ class HostDevices extends Wizard
],
];
+ $form['inputs'][] = [
+ 'label' => __('Review results').ui_print_help_tip(
+ __(
+ 'Targets must be validated by user before create agents.'
+ ),
+ true
+ ),
+ 'arguments' => [
+ 'name' => 'review_results',
+ 'type' => 'switch',
+ 'return' => true,
+ 'value' => ($this->task['review_mode'] == DISCOVERY_STANDARD) ? 0 : 1,
+ ],
+ ];
+
if (enterprise_installed() === true) {
// Input: Enable auto configuration.
$form['inputs'][] = [
@@ -948,6 +992,32 @@ class HostDevices extends Wizard
}
}
+ $form['js'] .= '
+
+ function toggleTemplatesSelection() {
+ if (document.getElementsByName("auto_monitor")[0].checked) {
+ document.getElementById("templates_selection").style["display"] = "none";
+ var snmp = document.getElementsByName("snmp_enabled");
+ if (snmp[0] != undefined) {
+ if(snmp[0].checked != 1) {
+ snmp[0].click();
+ }
+ } else {
+ // Not found.
+ document.getElementById("templates_selection").style["display"] = "block";
+ document.getElementsByName("auto_monitor")[0].checked = false;
+ }
+ } else {
+ document.getElementById("templates_selection").style["display"] = "block";
+ }
+ }
+
+ $(document).ready(function () {
+ toggleTemplatesSelection();
+ });
+
+';
+
// Submit button.
$form['inputs'][] = [
'arguments' => [
diff --git a/pandora_console/include/config_process.php b/pandora_console/include/config_process.php
index b854d66b75..93c06455fd 100644
--- a/pandora_console/include/config_process.php
+++ b/pandora_console/include/config_process.php
@@ -209,7 +209,7 @@ if (!isset($config['inventory_changes_blacklist'])) {
if (!isset($config['url_update_manager'])) {
config_update_value(
'url_update_manager',
- 'https://licensing.artica.es/pandoraupdate7/server.php'
+ 'https://taldarim.artica.lan/pandoraupdate7/server.php'
);
}
diff --git a/pandora_console/include/constants.php b/pandora_console/include/constants.php
index 7395f90cb5..e6c4108615 100644
--- a/pandora_console/include/constants.php
+++ b/pandora_console/include/constants.php
@@ -524,6 +524,7 @@ define('ARROW_TYPE', 1);
// Discovery task steps.
define('STEP_SCANNING', 1);
+define('STEP_CAPABILITIES', 7);
define('STEP_AFT', 2);
define('STEP_TRACEROUTE', 3);
define('STEP_GATEWAY', 4);
@@ -600,7 +601,7 @@ define('DISCOVERY_APP_SAP', 10);
// Force task build tmp results.
-define('DISCOVERY_SEARCH', 0);
+define('DISCOVERY_REVIEW', 0);
define('DISCOVERY_STANDARD', 1);
define('DISCOVERY_RESULTS', 2);
diff --git a/pandora_console/include/functions_config.php b/pandora_console/include/functions_config.php
index 96f266fc1e..08931feaf8 100644
--- a/pandora_console/include/functions_config.php
+++ b/pandora_console/include/functions_config.php
@@ -3087,10 +3087,10 @@ function get_um_url()
$url = $config['url_update_manager'];
$url = substr($url, 0, (strlen($url) - strpos(strrev($url), '/')));
} else {
- $url = 'https://licensing.artica.es/pandoraupdate7/';
+ $url = 'https://taldarim.artica.lan/pandoraupdate7/';
config_update_value(
'url_update_manager',
- 'https://licensing.artica.es/pandoraupdate7/server.php'
+ 'https://taldarim.artica.lan/pandoraupdate7/server.php'
);
}
diff --git a/pandora_console/include/styles/hostdevices.css b/pandora_console/include/styles/hostdevices.css
index 461327705e..ebd13988d5 100644
--- a/pandora_console/include/styles/hostdevices.css
+++ b/pandora_console/include/styles/hostdevices.css
@@ -1,3 +1,7 @@
/*
* TODO: This may be at hostdevices.css
*/
+
+#id_network_profile {
+ width: 300px;
+}
diff --git a/pandora_console/include/styles/task_list.css b/pandora_console/include/styles/task_list.css
index cdf147e5c4..1b29103cfd 100644
--- a/pandora_console/include/styles/task_list.css
+++ b/pandora_console/include/styles/task_list.css
@@ -63,6 +63,12 @@ div.subtitle div.manage button {
text-align: left;
}
+div.subtitle .link.review {
+ margin: 15px 0 -30px;
+ display: block;
+ font-weight: bold;
+}
+
#msg ul li {
margin-left: 3em;
}
diff --git a/pandora_console/install.php b/pandora_console/install.php
deleted file mode 100644
index db1ed51f29..0000000000
--- a/pandora_console/install.php
+++ /dev/null
@@ -1,1127 +0,0 @@
-
-
-
-
- Pandora FMS - Installation Wizard
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-';
- echo " $label ";
- echo ' ';
- if (!extension_loaded($ext)) {
- echo " ";
- return 1;
- } else {
- echo " ";
- return 0;
- }
-
- echo ' ';
-}
-
-function check_include($ext, $label)
-{
- echo '';
- echo " $label ";
- echo ' ';
- if (!include $ext) {
- echo " ";
- return 1;
- } else {
- echo " ";
- return 0;
- }
-
- echo ' ';
-}
-
-
-function check_exists($file, $label)
-{
- echo '';
- echo " $label ";
- echo ' ';
- if (!file_exists($file)) {
- echo " ";
- return 1;
- } else {
- echo " ";
- return 0;
- }
-
- echo ' ';
-}
-
-
-function check_generic($ok, $label)
-{
- echo "";
- if ($ok == 0) {
- echo " ";
- echo ' ';
- echo " $label ";
- echo ' ';
- echo ' ';
- return 1;
- } else {
- echo " ";
- echo '';
- echo " $label ";
- echo ' ';
- echo '';
- return 0;
- }
-}
-
-
-function check_writable($fullpath, $label)
-{
- echo "";
- if (file_exists($fullpath)) {
- if (is_writable($fullpath)) {
- echo " ";
- echo ' ';
- echo " $label ";
- echo ' ';
- echo ' ';
- return 0;
- } else {
- echo " ";
- echo '';
- echo " $label ";
- echo ' ';
- echo '';
- return 1;
- }
- } else {
- echo " ";
- echo '';
- echo " $label ";
- echo ' ';
- echo '';
- return 1;
- }
-}
-
-
-function check_variable($var, $value, $label, $mode)
-{
- echo '';
- echo " $label ";
- echo ' ';
- if ($mode == 1) {
- if ($var >= $value) {
- echo " ";
- return 0;
- } else {
- echo " ";
- return 1;
- }
- } else if ($var == $value) {
- echo " ";
- return 0;
- } else {
- echo " ";
- return 1;
- }
-
- echo ' ';
-}
-
-
-function parse_mysql_dump($url)
-{
- if (file_exists($url)) {
- $file_content = file($url);
- $query = '';
- foreach ($file_content as $sql_line) {
- if (trim($sql_line) != '' && strpos($sql_line, '-- ') === false) {
- $query .= $sql_line;
- if (preg_match("/;[\040]*\$/", $sql_line)) {
- if (!$result = mysql_query($query)) {
- echo mysql_error();
- // Uncomment for debug
- echo " $query ";
- return 0;
- }
-
- $query = '';
- }
- }
- }
-
- return 1;
- } else {
- return 0;
- }
-}
-
-
-function parse_mysqli_dump($connection, $url)
-{
- if (file_exists($url)) {
- $file_content = file($url);
- $query = '';
- foreach ($file_content as $sql_line) {
- if (trim($sql_line) != '' && strpos($sql_line, '-- ') === false) {
- $query .= $sql_line;
- if (preg_match("/;[\040]*\$/", $sql_line)) {
- if (!$result = mysqli_query($connection, $query)) {
- echo mysqli_error();
- // Uncomment for debug
- echo " $query ";
- return 0;
- }
-
- $query = '';
- }
- }
- }
-
- return 1;
- } else {
- return 0;
- }
-}
-
-
-function random_name($size)
-{
- $temp = '';
- for ($a = 0; $a < $size; $a++) {
- $temp = $temp.chr(rand(122, 97));
- }
-
- return $temp;
-}
-
-
-function print_logo_status($step, $step_total)
-{
- global $banner;
-
- $header = "
-
-
-
-
$banner
-
-
";
- $header .= "
-
- Install step $step of $step_total
-
";
-
- return $header;
-}
-
-
-//
-// This function adjusts path settings in pandora db for FreeBSD.
-//
-// All packages and configuration files except operating system's base files
-// are installed under /usr/local in FreeBSD. So, path settings in pandora db
-// for some programs should be changed from the Linux default.
-//
-function adjust_paths_for_freebsd($engine, $connection=false)
-{
- $adjust_sql = [
- "update trecon_script set script = REPLACE(script,'/usr/share','/usr/local/share');",
- "update tconfig set value = REPLACE(value,'/usr/bin','/usr/local/bin') where token='netflow_daemon' OR token='netflow_nfdump' OR token='netflow_nfexpire';",
- "update talert_commands set command = REPLACE(command,'/usr/bin','/usr/local/bin');",
- "update talert_commands set command = REPLACE(command,'/usr/share', '/usr/local/share');",
- "update tplugin set execute = REPLACE(execute,'/usr/share','/usr/local/share');",
- "update tevent_response set target = REPLACE(target,'/usr/share','/usr/local/share');",
- "insert into tconfig (token, value) VALUES ('graphviz_bin_dir', '/usr/local/bin');",
- ];
-
- for ($i = 0; $i < count($adjust_sql); $i++) {
- switch ($engine) {
- case 'mysql':
- $result = mysql_query($adjust_sql[$i]);
- break;
-
- case 'mysqli':
- $result = mysqli_query($connection, $adjust_sql[$i]);
- break;
-
- case 'oracle':
- // Delete the last semicolon from current query
- $query = substr($adjust_sql[$i], 0, (strlen($adjust_sql[$i]) - 1));
- $sql = oci_parse($connection, $query);
- $result = oci_execute($sql);
- break;
-
- case 'pgsql':
- pg_send_query($connection, $adjust_sql[$i]);
- $result = pg_get_result($connection);
- break;
- }
-
- if (!$result) {
- return 0;
- }
- }
-
- return 1;
-}
-
-
-function install_step1()
-{
- global $banner;
-
- echo "
-
-
- ".print_logo_status(1, 6)."
-
-
Welcome to Pandora FMS installation Wizard
-
This wizard helps you to quick install Pandora FMS console and main database in your system.
-
In four steps, this installer will check all dependencies and will create your configuration, ready to use.
-
For more information, please refer to documentation.
- Pandora FMS Development Team
- ";
- if (file_exists('include/config.php')) {
- echo "
Warning: You already have a config.php file.
- Configuration and database would be overwritten if you continued.
";
- }
-
- echo '
';
- echo '
';
- $writable = check_writable('include', 'Checking if ./include is writable');
- if (file_exists('include/config.php')) {
- $writable += check_writable('include/config.php', 'Checking if include/config.php is writable');
- }
-
- echo '
';
-
- echo "
Warning: This installer will overwrite and destroy
- your existing Pandora FMS configuration and Database . Before continue,
- please be sure that you have no valuable Pandora FMS data in your Database .
-
";
-
- echo "
Upgrade :
- If you want to upgrade from Pandora FMS 4.x to 5.0 version, please use the migration tool inside /extras directory in this setup.
-
";
-
- echo '
';
-
- if ($writable == 0) {
- echo "
";
- echo "
Next ";
- echo '
';
- } else {
- echo "
ERROR: You need to setup permissions to be able to write in ./include directory
";
- }
-
- echo '
';
-
- echo "
";
- echo "
-
-
-
";
-}
-
-
-function install_step1_licence()
-{
- echo "
-
-
- ".print_logo_status(2, 6)."
-
-
GPL2 Licence terms agreement
-
Pandora FMS is an OpenSource software project licensed under the GPL2 licence. Pandora FMS includes, as well, another software also licensed under LGPL and BSD licenses. Before continue, you must accept the licence terms. .
-
For more information, please refer to our website at http://pandorafms.org and contact us if you have any kind of question about the usage of Pandora FMS
-
If you dont accept the licence terms, please, close your browser and delete Pandora FMS files.
- ";
-
- if (!file_exists('COPYING')) {
- echo "
Licence file 'COPYING' is not present in your distribution. This means you have some 'partial' Pandora FMS distribution. We cannot continue without accepting the licence file. ";
- echo '
';
- } else {
- echo "
';
-
- echo "
-
-
-
";
-}
-
-
-function install_step2()
-{
- echo "
-
-
- ".print_logo_status(3, 6)."
-
";
- echo '
Checking software dependencies ';
- echo '
';
- $res = 0;
- $res += check_variable(phpversion(), '7.0', 'PHP version >= 7.0', 1);
- $res += check_extension('gd', 'PHP GD extension');
- $res += check_extension('ldap', 'PHP LDAP extension');
- $res += check_extension('snmp', 'PHP SNMP extension');
- $res += check_extension('session', 'PHP session extension');
- $res += check_extension('gettext', 'PHP gettext extension');
- $res += check_extension('mbstring', 'PHP Multibyte String');
- $res += check_extension('zip', 'PHP Zip');
- $res += check_extension('zlib', 'PHP Zlib extension');
- $res += check_extension('json', 'PHP json extension');
- $res += check_extension('curl', 'CURL (Client URL Library)');
- $res += check_extension('filter', 'PHP filter extension');
- $res += check_extension('calendar', 'PHP calendar extension');
- if (PHP_OS == 'FreeBSD') {
- $res += check_exists('/usr/local/bin/twopi', 'Graphviz Binary');
- } else if (PHP_OS == 'NetBSD') {
- $res += check_exists('/usr/pkg/bin/twopi', 'Graphviz Binary');
- } else if (substr(PHP_OS, 0, 3) == 'WIN') {
- $res += check_exists("..\\..\\..\\Graphviz\\bin\\twopi.exe", 'Graphviz Binary');
- } else {
- $res += check_exists('/usr/bin/twopi', 'Graphviz Binary');
- }
-
- echo '';
- echo "DB Engines ";
- echo ' ';
- echo ' ';
- check_extension('mysqli', 'PHP MySQL(mysqli) extension');
- echo '
';
-
- if ($res > 0) {
- echo "
-
You have some incomplete
- dependencies. Please correct them or this installer
- will not be able to finish your installation.
-
-
- Remember, if you install any PHP module to comply
- with these dependences, you need to restart
- your HTTP/Apache server after it to use the new
- modules.
-
-
";
- } else {
- echo "
';
- }
-
- echo '
';
- echo "
";
- echo "
-
-
-
-
- ";
-}
-
-
-function install_step3()
-{
- $options = '';
- if (extension_loaded('mysql')) {
- $options .= "MySQL ";
- }
-
- if (extension_loaded('mysqli')) {
- $options .= "MySQL(mysqli) ";
- }
-
- $error = false;
- if (empty($options)) {
- $error = true;
- }
-
- echo "
-
-
- ".print_logo_status(4, 6)."
-
-
Environment and database setup
-
- This wizard will create your Pandora FMS database,
- and populate it with all the data needed to run for the first time.
-
-
- You need a privileged user to create database schema, this is usually root user.
- Information about root user will not be used or stored anymore.
-
-
- You can also deploy the scheme into an existing Database.
- In this case you need a privileged Database user and password of that instance.
-
-
- Now, please, complete all details to configure your database and environment setup.
-
-
- Warning: This installer will overwrite and destroy your existing
- Pandora FMS configuration and Database . Before continue,
- please be sure that you have no valuable Pandora FMS data in your Database.
-
-
";
-
- if (extension_loaded('oci8')) {
- echo "
For Oracle installation an existing Database with a privileged user is needed.
";
- }
-
- if (!$error) {
- echo "
";
- }
-
- echo "
- ";
-
- if (!$error) {
- echo "';
- ?>
-
- ';
-
- echo ' ';
-
- echo "
";
- echo "
-
-
";
-}
-
-
-function install_step4()
-{
- $pandora_config = 'include/config.php';
-
- if ((! isset($_POST['user'])) || (! isset($_POST['dbname'])) || (! isset($_POST['host']))
- || (! isset($_POST['pass'])) || (!isset($_POST['engine'])) || (! isset($_POST['db_action']))
- ) {
- $dbpassword = '';
- $dbuser = '';
- $dbhost = '';
- $dbname = '';
- $engine = '';
- $dbaction = '';
- $dbgrant = '';
- } else {
- $engine = $_POST['engine'];
- $dbpassword = $_POST['pass'];
- $dbuser = $_POST['user'];
- $dbhost = $_POST['host'];
- $dbaction = $_POST['db_action'];
- if (isset($_POST['dbgrant']) && $_POST['dbgrant'] != '') {
- $dbgrant = $_POST['dbgrant'];
- } else {
- $dbgrant = $_SERVER['SERVER_ADDR'];
- }
-
- if (isset($_POST['drop'])) {
- $dbdrop = $_POST['drop'];
- } else {
- $dbdrop = 0;
- }
-
- $dbname = $_POST['dbname'];
- if (isset($_POST['url'])) {
- $url = $_POST['url'];
- } else {
- $url = 'http://localhost';
- }
-
- if (isset($_POST['path'])) {
- $path = $_POST['path'];
- $path = str_replace('\\', '/', $path);
- // Windows compatibility
- } else {
- $path = '/var/www';
- }
- }
-
- $everything_ok = 0;
- $step1 = 0;
- $step2 = 0;
- $step3 = 0;
- $step4 = 0;
- $step5 = 0;
- $step6 = 0;
- $step7 = 0;
-
- echo "
-
-
- ".print_logo_status(5, 6)."
-
-
Creating database and default configuration file
-
";
- switch ($engine) {
- case 'mysql':
- if (! mysql_connect($dbhost, $dbuser, $dbpassword)) {
- check_generic(0, 'Connection with Database');
- } else {
- check_generic(1, 'Connection with Database');
-
- // Drop database if needed and don't want to install over an existing DB
- if ($dbdrop == 1) {
- mysql_query("DROP DATABASE IF EXISTS `$dbname`");
- }
-
- // Create schema
- if ($dbaction == 'db_new' || $dbdrop == 1) {
- $step1 = mysql_query("CREATE DATABASE `$dbname`");
- check_generic($step1, "Creating database '$dbname'");
- } else {
- $step1 = 1;
- }
-
- if ($step1 == 1) {
- $step2 = mysql_select_db($dbname);
- check_generic($step2, "Opening database '$dbname'");
-
- $step3 = parse_mysql_dump('pandoradb.sql');
- check_generic($step3, 'Creating schema');
-
- $step4 = parse_mysql_dump('pandoradb_data.sql');
- check_generic($step4, 'Populating database');
- if (PHP_OS == 'FreeBSD') {
- $step_freebsd = adjust_paths_for_freebsd($engine);
- check_generic($step_freebsd, 'Adjusting paths in database for FreeBSD');
- }
-
- $random_password = random_name(8);
- $host = $dbhost;
- // set default granted origin to the origin of the queries
- if (($dbhost != 'localhost') && ($dbhost != '127.0.0.1')) {
- $host = $dbgrant;
- // if the granted origin is different from local machine, set the valid origin
- }
-
- $step5 = mysql_query(
- "GRANT ALL PRIVILEGES ON `$dbname`.* to pandora@$host
- IDENTIFIED BY '".$random_password."'"
- );
- mysql_query('FLUSH PRIVILEGES');
- check_generic($step5, "Established privileges for user pandora. A new random password has been generated: $random_password Please write it down, you will need to setup your Pandora FMS server, editing the /etc/pandora/pandora_server.conf file
");
-
- $step6 = is_writable('include');
- check_generic($step6, "Write permissions to save config file in './include'");
-
- $cfgin = fopen('include/config.inc.php', 'r');
- $cfgout = fopen($pandora_config, 'w');
- $config_contents = fread($cfgin, filesize('include/config.inc.php'));
- $dbtype = 'mysql';
- $config_new = '';
- $step7 = fputs($cfgout, $config_new);
- $step7 = ($step7 + fputs($cfgout, $config_contents));
- if ($step7 > 0) {
- $step7 = 1;
- }
-
- fclose($cfgin);
- fclose($cfgout);
- chmod($pandora_config, 0600);
- check_generic($step7, "Created new config file at '".$pandora_config."'");
- }
- }
-
- if (($step7 + $step6 + $step5 + $step4 + $step3 + $step2 + $step1) == 7) {
- $everything_ok = 1;
- }
- break;
-
- case 'mysqli':
- $connection = mysqli_connect($dbhost, $dbuser, $dbpassword);
- if (mysqli_connect_error() > 0) {
- check_generic(0, 'Connection with Database');
- } else {
- check_generic(1, 'Connection with Database');
-
- // Drop database if needed and don't want to install over an existing DB
- if ($dbdrop == 1) {
- mysqli_query($connection, "DROP DATABASE IF EXISTS `$dbname`");
- }
-
- // Create schema
- if ($dbaction == 'db_new' || $dbdrop == 1) {
- $step1 = mysqli_query($connection, "CREATE DATABASE `$dbname`");
- check_generic($step1, "Creating database '$dbname'");
- } else {
- $step1 = 1;
- }
-
- if ($step1 == 1) {
- $step2 = mysqli_select_db($connection, $dbname);
- check_generic($step2, "Opening database '$dbname'");
-
- $step3 = parse_mysqli_dump($connection, 'pandoradb.sql');
- check_generic($step3, 'Creating schema');
-
- $step4 = parse_mysqli_dump($connection, 'pandoradb_data.sql');
- check_generic($step4, 'Populating database');
- if (PHP_OS == 'FreeBSD') {
- $step_freebsd = adjust_paths_for_freebsd($engine, $connection);
- check_generic($step_freebsd, 'Adjusting paths in database for FreeBSD');
- }
-
- $random_password = random_name(8);
- $host = $dbhost;
- // set default granted origin to the origin of the queries
- if (($dbhost != 'localhost') && ($dbhost != '127.0.0.1')) {
- $host = $dbgrant;
- // if the granted origin is different from local machine, set the valid origin
- }
-
- $step5 = mysqli_query(
- $connection,
- "GRANT ALL PRIVILEGES ON `$dbname`.* to pandora@$host
- IDENTIFIED BY '".$random_password."'"
- );
- mysqli_query($connection, 'FLUSH PRIVILEGES');
- check_generic($step5, "Established privileges for user pandora. A new random password has been generated: $random_password Please write it down, you will need to setup your Pandora FMS server, editing the /etc/pandora/pandora_server.conf file
");
-
- $step6 = is_writable('include');
- check_generic($step6, "Write permissions to save config file in './include'");
-
- $cfgin = fopen('include/config.inc.php', 'r');
- $cfgout = fopen($pandora_config, 'w');
- $config_contents = fread($cfgin, filesize('include/config.inc.php'));
- $dbtype = 'mysql';
- $config_new = '';
- $step7 = fputs($cfgout, $config_new);
- $step7 = ($step7 + fputs($cfgout, $config_contents));
- if ($step7 > 0) {
- $step7 = 1;
- }
-
- fclose($cfgin);
- fclose($cfgout);
- chmod($pandora_config, 0600);
- check_generic($step7, "Created new config file at '".$pandora_config."'");
- }
- }
-
- if (($step7 + $step6 + $step5 + $step4 + $step3 + $step2 + $step1) == 7) {
- $everything_ok = 1;
- }
- break;
- }
-
- echo '
';
-
- if ($everything_ok == 1) {
- echo "
';
- } else {
- $info = "
There were some problems.
- Installation was not completed.
-
Please correct failures before trying again.
- All database ";
- if ($engine == 'oracle') {
- $info .= 'objects ';
- } else {
- $info .= 'schemes ';
- }
-
- $info .= 'created in this step have been dropped.
-
';
- echo $info;
-
- switch ($engine) {
- case 'mysql':
- if (mysql_error() != '') {
- echo "
ERROR: ".mysql_error().'.
';
- }
-
- if ($step1 == 1) {
- mysql_query("DROP DATABASE $dbname");
- }
- break;
-
- case 'mysqli':
- if (mysqli_error($connection) != '') {
- echo "
ERROR: ".mysqli_error($connection).'.
';
- }
-
- if ($step1 == 1) {
- mysqli_query($connection, "DROP DATABASE $dbname");
- }
- break;
- }
-
- echo '
';
- }
-
- echo '
';
- echo "
";
- echo "
-
-
-
";
-}
-
-
-function install_step5()
-{
- echo "
-
-
- ".print_logo_status(6, 6)."
-
-
Installation complete
-
For security, you now must manually delete this installer
- ('install.php ') file before trying to access to your Pandora FMS console.
-
You should also install Pandora FMS Servers before trying to monitor anything;
- please read documentation on how to install it.
-
Default user is 'admin' with password 'pandora' ,
- please change it both as soon as possible.
-
Don't forget to check http://pandorafms.com
- for updates.
-
Select if you want to rename 'install.php '.
-
- Yes, rename the file
-
-
-
Click here to access to your Pandora FMS console .
-
-
";
-
- echo "
-
-
";
-}
diff --git a/pandora_console/pandoradb.sql b/pandora_console/pandoradb.sql
index d40787c74a..2d446e007d 100644
--- a/pandora_console/pandoradb.sql
+++ b/pandora_console/pandoradb.sql
@@ -771,7 +771,7 @@ CREATE TABLE IF NOT EXISTS `trecon_task` (
`description` varchar(250) NOT NULL default '',
`subnet` text NOT NULL,
`id_network_profile` text,
- `direct_report` tinyint(1) unsigned NOT NULL default 0,
+ `review_mode` tinyint(1) unsigned NOT NULL default 0,
`id_group` int(10) unsigned NOT NULL default 1,
`utimestamp` bigint(20) unsigned NOT NULL default 0,
`status` tinyint(4) NOT NULL default 0,
@@ -803,6 +803,7 @@ CREATE TABLE IF NOT EXISTS `trecon_task` (
`snmp_security_level` varchar(25) NOT NULL default '',
`wmi_enabled` tinyint(1) unsigned DEFAULT 0,
`auth_strings` text,
+ `auto_monitor` TINYINT(1) UNSIGNED DEFAULT 1,
`autoconfiguration_enabled` tinyint(1) unsigned default 0,
`summary` text,
`type` int NOT NULL default 0,
@@ -827,18 +828,13 @@ CREATE TABLE `tdiscovery_tmp_agents` (
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
CREATE TABLE `tdiscovery_tmp_connections` (
- `id_rt` int(10) unsigned NOT NULL,
- `id1` int(10) unsigned NOT NULL AUTO_INCREMENT,
- `id2` int(10) unsigned NOT NULL,
- `if1` text,
- `if2` text,
- PRIMARY KEY (`id1`,`id2`),
- CONSTRAINT `tdtc_trt` FOREIGN KEY (`id_rt`)
- REFERENCES `trecon_task` (`id_rt`) ON DELETE CASCADE ON UPDATE CASCADE,
- CONSTRAINT `tdtc_tdta1` FOREIGN KEY (`id1`)
- REFERENCES `tdiscovery_tmp_agents` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
- CONSTRAINT `tdtc_tdta2` FOREIGN KEY (`id2`)
- REFERENCES `tdiscovery_tmp_agents` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
+ `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
+ `id_rt` int(10) unsigned NOT NULL,
+ `dev_1` text,
+ `dev_2` text,
+ `if_1` text,
+ `if_2` text,
+ PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-- ----------------------------------------------------------------------
@@ -945,6 +941,16 @@ CREATE TABLE IF NOT EXISTS `tnetwork_profile` (
PRIMARY KEY (`id_np`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
+-- ----------------------------------------------------------------------
+-- Table `tpen`
+-- ----------------------------------------------------------------------
+CREATE TABLE `tpen` (
+ `id_np` int(10) unsigned NOT NULL,
+ `pen` int(10) unsigned NOT NULL,
+ PRIMARY KEY (`id_np`,`pen`),
+ CONSTRAINT `fk_np_id` FOREIGN KEY (`id_np`) REFERENCES `tnetwork_profile` (`id_np`) ON DELETE CASCADE ON UPDATE CASCADE
+) ENGINE=InnoDB DEFAULT CHARSET=utf8;
+
-- ----------------------------------------------------------------------
-- Table `tnetwork_profile_component`
-- ----------------------------------------------------------------------
diff --git a/pandora_server/lib/PandoraFMS/Core.pm b/pandora_server/lib/PandoraFMS/Core.pm
index 99ddf48796..ca2eae5157 100644
--- a/pandora_server/lib/PandoraFMS/Core.pm
+++ b/pandora_server/lib/PandoraFMS/Core.pm
@@ -3076,7 +3076,7 @@ sub pandora_create_module_from_network_component ($$$$) {
##########################################################################
sub pandora_create_module_from_hash ($$$) {
my ($pa_config, $parameters, $dbh) = @_;
-
+
logger($pa_config,
"Creating module '$parameters->{'nombre'}' for agent ID $parameters->{'id_agente'}.", 10);
@@ -3107,8 +3107,12 @@ sub pandora_create_module_from_hash ($$$) {
}
# Encrypt SNMP v3 passwords.
- if ($parameters->{'id_tipo_modulo'} >= 15 && $parameters->{'id_tipo_modulo'} <= 18 &&
- $parameters->{'tcp_send'} eq '3') {
+ if (defined($parameters->{'tcp_send'})
+ && $parameters->{'tcp_send'} eq '3'
+ && defined($parameters->{'id_tipo_modulo'})
+ && $parameters->{'id_tipo_modulo'} >= 15
+ && $parameters->{'id_tipo_modulo'} <= 18
+ ) {
$parameters->{'custom_string_2'} = pandora_input_password($pa_config, $parameters->{'custom_string_2'});
}
@@ -3116,7 +3120,11 @@ sub pandora_create_module_from_hash ($$$) {
'tagente_modulo', $parameters);
my $status = 4;
- if (defined ($parameters->{'id_tipo_modulo'}) && ($parameters->{'id_tipo_modulo'} == 21 || $parameters->{'id_tipo_modulo'} == 22 || $parameters->{'id_tipo_modulo'} == 23)) {
+ if (defined ($parameters->{'id_tipo_modulo'})
+ && ($parameters->{'id_tipo_modulo'} == 21
+ || $parameters->{'id_tipo_modulo'} == 22
+ || $parameters->{'id_tipo_modulo'} == 23)
+ ) {
$status = 0;
}
diff --git a/pandora_server/lib/PandoraFMS/DB.pm b/pandora_server/lib/PandoraFMS/DB.pm
index b190c763da..d712a45ea6 100644
--- a/pandora_server/lib/PandoraFMS/DB.pm
+++ b/pandora_server/lib/PandoraFMS/DB.pm
@@ -81,6 +81,8 @@ our @EXPORT = qw(
get_module_id
get_module_name
get_nc_profile_name
+ get_pen_templates
+ get_nc_profile_advanced
get_os_id
get_os_name
get_plugin_id
@@ -657,6 +659,39 @@ sub get_nc_profile_name ($$) {
return get_db_value ($dbh, "SELECT * FROM tnetwork_profile WHERE id_np = ?", $nc_id);
}
+##########################################################################
+## Return all network component's profile ids matching given PEN.
+##########################################################################
+sub get_pen_templates($$) {
+ my ($dbh, $pen) = @_;
+
+ my @results = get_db_rows(
+ $dbh,
+ 'SELECT t.`id_np`
+ FROM `tnetwork_profile` t
+ INNER JOIN `tpen` p ON p.`id_np` = t.`id_np`
+ WHERE p.`pen` = ?',
+ $pen
+ );
+
+ return @results;
+}
+
+##########################################################################
+## Return a network component's profile data and pen list, given its ID.
+##########################################################################
+sub get_nc_profile_advanced($$) {
+ my ($dbh, $id_nc) = @_;
+ return get_db_single_row(
+ $dbh,
+ 'SELECT t.*,GROUP_CONCAT(p.pen) AS "pen"
+ FROM `tnetwork_profile` t LEFT JOIN `tpen` p ON t.id_np = p.id_np
+ WHERE t.`id_np` = ?
+ GROUP BY t.`id_np`',
+ $id_nc
+ );
+}
+
##########################################################################
## Return user profile ID given the user id, group id and profile id.
##########################################################################
diff --git a/pandora_server/lib/PandoraFMS/DiscoveryServer.pm b/pandora_server/lib/PandoraFMS/DiscoveryServer.pm
index c16d93f42f..68db6f0467 100644
--- a/pandora_server/lib/PandoraFMS/DiscoveryServer.pm
+++ b/pandora_server/lib/PandoraFMS/DiscoveryServer.pm
@@ -74,7 +74,7 @@ use constant {
DISCOVERY_CLOUD_AZURE_COMPUTE => 8,
DISCOVERY_DEPLOY_AGENTS => 9,
DISCOVERY_APP_SAP => 10,
- DISCOVERY_SEARCH => 0,
+ DISCOVERY_REVIEW => 0,
DISCOVERY_STANDARD => 1,
DISCOVERY_RESULTS => 2,
};
@@ -469,7 +469,7 @@ sub PandoraFMS::Recon::Base::test_module($$) {
if ($test->{'id_tipo_modulo'} >= 15 && $test->{'id_tipo_modulo'} <= 18) {
# SNMP
$value = $self->call(
- 'snmp_get',
+ 'snmp_get_value',
$test->{'ip_target'},
$test->{'snmp_oid'}
);
@@ -565,32 +565,194 @@ sub PandoraFMS::Recon::Base::test_module($$) {
}
+################################################################################
+# Create interface modules for the given agent (if needed).
+################################################################################
+sub PandoraFMS::Recon::Base::create_interface_modules($$) {
+ my ($self, $device) = @_;
+
+ # Add interfaces to the agent if it responds to SNMP.
+ return unless ($self->is_snmp_discovered($device));
+ my $community = $self->get_community($device);
+
+ my @output = $self->snmp_get_value_array($device, $PandoraFMS::Recon::Base::IFINDEX);
+ foreach my $if_index (@output) {
+ next unless ($if_index =~ /^[0-9]+$/);
+
+ # Check the status of the interface.
+ my $if_status = $self->snmp_get_value($device, "$PandoraFMS::Recon::Base::IFOPERSTATUS.$if_index");
+ next unless $if_status == 1;
+
+ # Fill the module description with the IP and MAC addresses.
+ my $mac = $self->get_if_mac($device, $if_index);
+ my $ip = $self->get_if_ip($device, $if_index);
+ my $if_desc = ($mac ne '' ? "MAC $mac " : '') . ($ip ne '' ? "IP $ip" : '');
+
+ # Get the name of the network interface.
+ my $if_name = $self->snmp_get_value($device, "$PandoraFMS::Recon::Base::IFNAME.$if_index");
+ $if_name = "if$if_index" unless defined ($if_name);
+ $if_name =~ s/"//g;
+ $if_name = clean_blank($if_name);
+
+ # Interface status module.
+ $self->call(
+ 'add_module',
+ $device,
+ {
+ 'id_tipo_modulo' => 18,
+ 'id_modulo' => 2,
+ 'name' => $if_name."_ifOperStatus",
+ 'descripcion' => safe_input(
+ $if_desc
+ ),
+ 'ip_target' => $device,
+ 'tcp_send' => $self->{'task_data'}{'snmp_version'},
+ 'custom_string_1' => $self->{'task_data'}{'snmp_privacy_method'},
+ 'custom_string_2' => $self->{'task_data'}{'snmp_privacy_pass'},
+ 'custom_string_3' => $self->{'task_data'}{'snmp_security_level'},
+ 'plugin_parameter' => $self->{'task_data'}{'snmp_auth_method'},
+ 'plugin_user' => $self->{'task_data'}{'snmp_auth_user'},
+ 'plugin_pass' => $self->{'task_data'}{'snmp_auth_pass'},
+ 'snmp_community' => $community,
+ 'snmp_oid' => "$PandoraFMS::Recon::Base::IFOPERSTATUS.$if_index"
+ }
+ );
+
+ # Incoming traffic module.
+ my $if_hc_in_octets = $self->snmp_get_value($device, "$PandoraFMS::Recon::Base::IFHCINOCTECTS.$if_index");
+ if (defined($if_hc_in_octets)) {
+ # Use HC counters.
+ # ifHCInOctets
+ $self->call(
+ 'add_module',
+ $device,
+ {
+ 'id_tipo_modulo' => 16,
+ 'id_modulo' => 2,
+ 'name' => $if_name."_ifHCInOctets",
+ 'descripcion' => safe_input(
+ 'The total number of octets received on the interface, including framing characters. This object is a 64-bit version of ifInOctets.'
+ ),
+ 'ip_target' => $device,
+ 'tcp_send' => $self->{'task_data'}{'snmp_version'},
+ 'custom_string_1' => $self->{'task_data'}{'snmp_privacy_method'},
+ 'custom_string_2' => $self->{'task_data'}{'snmp_privacy_pass'},
+ 'custom_string_3' => $self->{'task_data'}{'snmp_security_level'},
+ 'plugin_parameter' => $self->{'task_data'}{'snmp_auth_method'},
+ 'plugin_user' => $self->{'task_data'}{'snmp_auth_user'},
+ 'plugin_pass' => $self->{'task_data'}{'snmp_auth_pass'},
+ 'snmp_community' => $community,
+ 'snmp_oid' => "$PandoraFMS::Recon::Base::IFHCINOCTECTS.$if_index"
+ }
+ );
+ } else {
+ # Use 32b counters.
+ # ifInOctets
+ $self->call(
+ 'add_module',
+ $device,
+ {
+ 'id_tipo_modulo' => 16,
+ 'id_modulo' => 2,
+ 'name' => $if_name."_ifInOctets",
+ 'descripcion' => safe_input(
+ 'The total number of octets received on the interface, including framing characters.'
+ ),
+ 'ip_target' => $device,
+ 'tcp_send' => $self->{'task_data'}{'snmp_version'},
+ 'custom_string_1' => $self->{'task_data'}{'snmp_privacy_method'},
+ 'custom_string_2' => $self->{'task_data'}{'snmp_privacy_pass'},
+ 'custom_string_3' => $self->{'task_data'}{'snmp_security_level'},
+ 'plugin_parameter' => $self->{'task_data'}{'snmp_auth_method'},
+ 'plugin_user' => $self->{'task_data'}{'snmp_auth_user'},
+ 'plugin_pass' => $self->{'task_data'}{'snmp_auth_pass'},
+ 'snmp_community' => $community,
+ 'snmp_oid' => "$PandoraFMS::Recon::Base::IFINOCTECTS.$if_index"
+ }
+ );
+ }
+
+ # Outgoing traffic module.
+ my $if_hc_out_octets = $self->snmp_get_value($device, "$PandoraFMS::Recon::Base::IFHCOUTOCTECTS.$if_index");
+ if (defined($if_hc_out_octets)) {
+ # Use HC counters.
+ # ifHCOutOctets
+ $self->call(
+ 'add_module',
+ $device,
+ {
+ 'id_tipo_modulo' => 16,
+ 'id_modulo' => 2,
+ 'name' => $if_name."_ifHCOutOctets",
+ 'descripcion' => safe_input(
+ 'The total number of octets received on the interface, including framing characters. This object is a 64-bit version of ifOutOctets.'
+ ),
+ 'ip_target' => $device,
+ 'tcp_send' => $self->{'task_data'}{'snmp_version'},
+ 'custom_string_1' => $self->{'task_data'}{'snmp_privacy_method'},
+ 'custom_string_2' => $self->{'task_data'}{'snmp_privacy_pass'},
+ 'custom_string_3' => $self->{'task_data'}{'snmp_security_level'},
+ 'plugin_parameter' => $self->{'task_data'}{'snmp_auth_method'},
+ 'plugin_user' => $self->{'task_data'}{'snmp_auth_user'},
+ 'plugin_pass' => $self->{'task_data'}{'snmp_auth_pass'},
+ 'snmp_community' => $community,
+ 'snmp_oid' => "$PandoraFMS::Recon::Base::IFHCOUTOCTECTS.$if_index"
+ }
+ );
+ } else {
+ # Use 32b counters.
+ # ifOutOctets
+ $self->call(
+ 'add_module',
+ $device,
+ {
+ 'id_tipo_modulo' => 16,
+ 'id_modulo' => 2,
+ 'name' => $if_name."_ifOutOctets",
+ 'descripcion' => safe_input(
+ 'The total number of octets received on the interface, including framing characters.'
+ ),
+ 'ip_target' => $device,
+ 'tcp_send' => $self->{'task_data'}{'snmp_version'},
+ 'custom_string_1' => $self->{'task_data'}{'snmp_privacy_method'},
+ 'custom_string_2' => $self->{'task_data'}{'snmp_privacy_pass'},
+ 'custom_string_3' => $self->{'task_data'}{'snmp_security_level'},
+ 'plugin_parameter' => $self->{'task_data'}{'snmp_auth_method'},
+ 'plugin_user' => $self->{'task_data'}{'snmp_auth_user'},
+ 'plugin_pass' => $self->{'task_data'}{'snmp_auth_pass'},
+ 'snmp_community' => $community,
+ 'snmp_oid' => "$PandoraFMS::Recon::Base::IFOUTOCTECTS.$if_index"
+ }
+ );
+ }
+ }
+
+}
+
################################################################################
# Create network profile modules for the given agent.
################################################################################
sub PandoraFMS::Recon::Base::create_network_profile_modules($$) {
my ($self, $device) = @_;
- #
- # Plugin
- # SNMP
- # WMI
- # ICMP
- #
+ my @template_ids = ();
- return if is_empty($self->{'id_network_profile'});
+ if (is_enabled($self->{'task_data'}{'auto_monitor'})) {
+ # Apply PEN monitoring template (HW).
+ push @template_ids, get_pen_templates($self->{'dbh'}, $self->get_pen($device));
+ } else {
+ # Return if no specific templates are selected.
+ return if is_empty($self->{'id_network_profile'});
+ }
- my @templates = split /,/, $self->{'id_network_profile'};
+ push @template_ids, split /,/, $self->{'id_network_profile'}
+ unless is_empty($self->{'id_network_profile'});
my $data = $self->{'agents_found'}{$device};
- foreach my $t_id (@templates) {
+ foreach my $t_id (@template_ids) {
# 1. Retrieve template info.
- my $template = get_db_single_row(
- $self->{'dbh'},
- 'SELECT * FROM `tnetwork_profile` WHERE `id_np` = ?',
- $t_id
- );
+ my $template = get_nc_profile_advanced($self->{'dbh'}, $t_id);
# 2. Verify Private Enterprise Number matches (PEN)
if (defined($template->{'pen'})) {
@@ -599,7 +761,7 @@ sub PandoraFMS::Recon::Base::create_network_profile_modules($$) {
next unless (is_in_array(\@penes, $data->{'pen'}));
}
- # 2. retrieve module list from target template.
+ # 3. Retrieve module list from target template.
my @np_components = get_db_rows(
$self->{'dbh'},
'SELECT * FROM tnetwork_profile_component WHERE id_np = ?',
@@ -607,7 +769,7 @@ sub PandoraFMS::Recon::Base::create_network_profile_modules($$) {
);
foreach my $np_component (@np_components) {
- # 2. Test each possible module.
+ # 4. Register each module (candidate). 'add_module' will test them.
my $component = get_db_single_row(
$self->{'dbh'},
'SELECT * FROM tnetwork_component WHERE id_nc = ?',
@@ -643,8 +805,8 @@ sub PandoraFMS::Recon::Base::report_scanned_agents($) {
my $force_creation = 0;
- if (defined($self->{'task_data'}{'direct_report'})
- && $self->{'task_data'}{'direct_report'} == DISCOVERY_STANDARD
+ if (defined($self->{'task_data'}{'review_mode'})
+ && $self->{'task_data'}{'review_mode'} == DISCOVERY_STANDARD
) {
$force_creation = 1;
}
@@ -652,8 +814,8 @@ sub PandoraFMS::Recon::Base::report_scanned_agents($) {
#
# Creation
#
- if(defined($self->{'task_data'}{'direct_report'})
- && $self->{'task_data'}{'direct_report'} == DISCOVERY_RESULTS
+ if(defined($self->{'task_data'}{'review_mode'})
+ && $self->{'task_data'}{'review_mode'} == DISCOVERY_RESULTS
) {
# Load cache.
my @rows = get_db_rows(
@@ -754,6 +916,7 @@ sub PandoraFMS::Recon::Base::report_scanned_agents($) {
$data->{'agent'}{'agent_id'} = $agent_id;
}
+ $data->{'agent'}{'modo'} = $agent_learning;
$self->call('message', "Agent id: ".$data->{'agent'}{'agent_id'}, 5);
# Create selected modules.
@@ -817,18 +980,24 @@ sub PandoraFMS::Recon::Base::report_scanned_agents($) {
$module->{'__module_component'} = 1;
} else {
# Create module - Direct.
+ my $name = $module->{'name'};
+ delete $module->{'name'};
$agentmodule_id = pandora_create_module_from_hash(
$self->{'pa_config'},
{
+ %{$module},
'id_tipo_modulo' => $id_tipo_modulo,
'id_modulo' => $module->{'id_modulo'},
- 'nombre' => safe_input($module->{'name'}),
+ 'nombre' => safe_input($name),
'descripcion' => safe_input($description),
'id_agente' => $agent_id,
'ip_target' => $data->{'agent'}{'direccion'}
},
$self->{'dbh'}
);
+
+ $module->{'name'} = $name;
+
}
# Restore.
@@ -854,6 +1023,8 @@ sub PandoraFMS::Recon::Base::report_scanned_agents($) {
);
};
+ push @agents, $data->{'agent'};
+
# Update.
db_do(
$self->{'dbh'},
@@ -868,6 +1039,49 @@ sub PandoraFMS::Recon::Base::report_scanned_agents($) {
}
+ # Update parent relationships.
+ foreach my $agent (@agents) {
+ # Avoid processing if does not exist.
+ next unless (defined($agent->{'agent_id'}));
+
+ # Avoid processing undefined parents.
+ next unless defined($agent->{'parent'});
+
+ # Get parent id.
+ my $parent = get_agent_from_addr($self->{'dbh'}, $agent->{'parent'});
+ if (!defined($parent)) {
+ $parent = get_agent_from_name($self->{'dbh'}, $agent->{'parent'});
+ }
+ next unless defined($parent);
+
+ # Is the agent in learning mode?
+ next unless ($agent->{'modo'} == 1);
+
+ # Connect the host to its parent.
+ db_do($self->{'dbh'},
+ 'UPDATE tagente SET id_parent=? WHERE id_agente=?',
+ $parent->{'id_agente'}, $agent->{'agent_id'}
+ );
+ }
+
+ # Connect agents.
+ my @connections = get_db_rows(
+ $self->{'dbh'},
+ 'SELECT * FROM tdiscovery_tmp_connections WHERE id_rt = ?',
+ $self->{'task_data'}{'id_rt'}
+ );
+
+ foreach my $cn (@connections) {
+ $self->call('connect_agents',
+ $cn->{'dev_1'},
+ $cn->{'if_1'},
+ $cn->{'dev_2'},
+ $cn->{'if_2'},
+ # Force creation if direct.
+ $force_creation
+ );
+ }
+
# Data creation finished.
return;
}
@@ -876,6 +1090,7 @@ sub PandoraFMS::Recon::Base::report_scanned_agents($) {
#
# Cleanup previous results.
#
+ $self->call('message', "Cleanup previous results", 6);
db_do(
$self->{'dbh'},
'DELETE FROM tdiscovery_tmp_agents '
@@ -887,6 +1102,7 @@ sub PandoraFMS::Recon::Base::report_scanned_agents($) {
# Store and review.
#
+ $self->call('message', "Storing results", 6);
my @hosts = keys %{$self->{'agents_found'}};
$self->{'step'} = STEP_PROCESSING;
my ($progress, $step) = (90, 10.0 / scalar(@hosts)); # From 90% to 100%.
@@ -935,6 +1151,8 @@ sub PandoraFMS::Recon::Base::report_scanned_agents($) {
$encoded
);
}
+
+ $self->call('message', "Completed", 5);
}
################################################################################
@@ -948,22 +1166,54 @@ sub PandoraFMS::Recon::Base::apply_monitoring($) {
$self->{'step'} = STEP_MONITORING;
# From 80% to 90%.
my ($progress, $step) = (80, 10.0 / scalar(@hosts));
+ my ($partial, $sub_step) = (0, 100 / scalar(@hosts));
foreach my $label (keys %{$self->{'agents_found'}}) {
+ $self->{'c_network_percent'} = $partial;
+ $self->{'c_network_name'} = $label;
$self->call('update_progress', $progress);
$progress += $step;
+ $partial += $sub_step;
$self->call('message', "Checking modules for $label", 5);
+
+ # Monitorization selected.
$self->call('create_network_profile_modules', $label);
+ # Monitorization - interfaces
+ $self->call('create_interface_modules', $label);
+
}
+ $self->{'c_network_percent'} = 100;
+ $self->call('update_progress', $progress);
}
################################################################################
# Connect the given devices in the Pandora FMS database.
################################################################################
-sub PandoraFMS::Recon::Base::connect_agents($$$$$) {
- my ($self, $dev_1, $if_1, $dev_2, $if_2) = @_;
+sub PandoraFMS::Recon::Base::connect_agents($$$$$;$) {
+ my ($self, $dev_1, $if_1, $dev_2, $if_2, $force) = @_;
+
+ if($self->{'task_data'}{'review_mode'} == DISCOVERY_REVIEW
+ || is_enabled($force)
+ ) {
+ # Store in tdiscovery_tmp_connections;
+
+ db_process_insert(
+ $self->{'dbh'},
+ 'id',
+ 'tdiscovery_tmp_connections',
+ {
+ 'id_rt' => $self->{'task_data'}{'id_rt'},
+ 'dev_1' => $dev_1,
+ 'if_1' => $if_1,
+ 'dev_2' => $dev_2,
+ 'if_2' => $if_2,
+ }
+ );
+
+ return;
+ }
# Get the agent for the first device.
my $agent_1 = get_agent_from_addr($self->{'dbh'}, $dev_1);
@@ -1209,7 +1459,7 @@ sub PandoraFMS::Recon::Base::create_agent($$) {
next unless ($if_index =~ /^[0-9]+$/);
# Check the status of the interface.
- if ($self->{'all_ifaces'} == 0) {
+ if (!is_enabled($self->{'all_ifaces'})) {
my $if_status = $self->snmp_get_value($device, "$PandoraFMS::Recon::Base::IFOPERSTATUS.$if_index");
next unless $if_status == 1;
}
@@ -1447,25 +1697,11 @@ sub PandoraFMS::Recon::Base::set_parent($$$) {
return unless ($self->{'parent_detection'} == 1);
- # Get the agent for the host.
- my $agent = get_agent_from_addr($self->{'dbh'}, $host);
- if (!defined($agent)) {
- $agent = get_agent_from_name($self->{'dbh'}, $host);
- }
- return unless defined($agent);
+ # Do not edit 'not scaned' agents.
+ return if is_empty($self->{'agents_found'}{$host}{'agent'});
- # Check if the parent agent exists.
- my $agent_parent = get_agent_from_addr($self->{'dbh'}, $parent);
- if (!defined($agent_parent)) {
- $agent_parent = get_agent_from_name($self->{'dbh'}, $parent);
- }
- return unless (defined ($agent_parent));
+ $self->{'agents_found'}{$host}{'parent'} = $parent;
- # Is the agent in learning mode?
- return unless ($agent_parent->{'modo'} == 1);
-
- # Connect the host to its parent.
- db_do($self->{'dbh'}, 'UPDATE tagente SET id_parent=? WHERE id_agente=?', $agent_parent->{'id_agente'}, $agent->{'id_agente'});
}
################################################################################
diff --git a/pandora_server/lib/PandoraFMS/NetworkServer.pm b/pandora_server/lib/PandoraFMS/NetworkServer.pm
index 755a05bf8c..0bca799815 100644
--- a/pandora_server/lib/PandoraFMS/NetworkServer.pm
+++ b/pandora_server/lib/PandoraFMS/NetworkServer.pm
@@ -384,6 +384,7 @@ sub pandora_query_snmp ($$$$) {
my $output; # Command output
# If not defined, always snmp v1 (standard)
+ $snmp_version = '1' unless defined($snmp_version);
if ($snmp_version ne '1' && $snmp_version ne '2'
&& $snmp_version ne '2c' && $snmp_version ne '3') {
$snmp_version = '1';
@@ -591,7 +592,7 @@ sub exec_network_module ($$$$) {
my %data = ("data" => $module_data);
pandora_process_module ($pa_config, \%data, '', $module, '', $timestamp, $utimestamp, $server_id, $dbh);
- if ($agent_os_version eq ''){
+ if (!defined($agent_os_version) || $agent_os_version eq ''){
$agent_os_version = $pa_config->{'servername'}.'_Net';
}
diff --git a/pandora_server/lib/PandoraFMS/Recon/Base.pm b/pandora_server/lib/PandoraFMS/Recon/Base.pm
index 450db59933..8d2db93fb2 100644
--- a/pandora_server/lib/PandoraFMS/Recon/Base.pm
+++ b/pandora_server/lib/PandoraFMS/Recon/Base.pm
@@ -19,6 +19,7 @@ use PandoraFMS::Recon::Util;
# Constants.
use constant {
STEP_SCANNING => 1,
+ STEP_CAPABILITIES => 7,
STEP_AFT => 2,
STEP_TRACEROUTE => 3,
STEP_GATEWAY => 4,
@@ -38,7 +39,7 @@ use constant {
DISCOVERY_CLOUD_AZURE_COMPUTE => 8,
DISCOVERY_DEPLOY_AGENTS => 9,
DISCOVERY_APP_SAP => 10,
- DISCOVERY_SEARCH => 0,
+ DISCOVERY_REVIEW => 0,
DISCOVERY_STANDARD => 1,
DISCOVERY_RESULTS => 2,
};
@@ -351,7 +352,7 @@ sub aft_connectivity($$) {
# Get the name of the host interface if available.
my $host_if_name = $self->get_iface($aft_mac);
- $host_if_name = defined($host_if_name) ? $host_if_name : 'ping';
+ $host_if_name = defined($host_if_name) ? $host_if_name : 'Host Alive';
# Get the interface associated to the port were we found the MAC address.
my $switch_if_name = $self->get_if_from_aft($switch, $aft_mac);
@@ -459,6 +460,9 @@ sub snmp_discovery($$) {
}
}
+ # Create an agent for the device and add it to the list of known hosts.
+ push(@{$self->{'hosts'}}, $device);
+
# Create an agent for the device and add it to the list of known hosts.
$self->add_agent($device);
@@ -651,6 +655,17 @@ sub get_connections($) {
return $self->{'connections'};
}
+################################################################################
+# Return the PEN associated to target host.
+################################################################################
+sub get_pen($$) {
+ my ($self, $host) = @_;
+
+ return undef unless ref($self->{'pen'}) eq 'HASH';
+
+ return $self->{'pen'}->{$host};
+}
+
################################################################################
# Return the parent relationship hash.
################################################################################
@@ -1341,7 +1356,8 @@ sub add_module($$$) {
&& $data->{'name'} ne '';
# Test module. Is it success?
- return unless $self->call('test_module', $agent, $data);
+ my $rs = $self->call('test_module', $agent, $data);
+ return unless is_enabled($rs);
$self->{'agents_found'}->{$agent}->{'modules'}{$data->{'name'}} = $data;
@@ -1418,7 +1434,6 @@ sub scan_subnet($) {
my @block = pandora_block_ping(
{
'fping' => $self->{'fping'},
- # XXX CAMBIAR POR 0.5
'networktimeout' => 0.5 # use fping defaults
},
@hosts[$block_index .. $to - 1]
@@ -1452,9 +1467,12 @@ sub scan_subnet($) {
$total_hosts = scalar keys %hosts_alive;
$step = 25.0 / scalar(@subnets) / $total_hosts;
$subnet_step = 50.0 / $total_hosts;
+
+ $self->{'step'} = STEP_CAPABILITIES;
foreach my $addr (keys %hosts_alive) {
# Increase self summary.alive hosts.
$self->call('message', "Scanning host: $addr", 5);
+ $self->{'c_network_name'} = $addr;
# Update progress.
$progress += $step;
@@ -1820,10 +1838,11 @@ sub scan($) {
}
}
- if(defined($self->{'task_data'}{'direct_report'})
- && $self->{'task_data'}{'direct_report'} == DISCOVERY_RESULTS
+ if(defined($self->{'task_data'}{'review_mode'})
+ && $self->{'task_data'}{'review_mode'} == DISCOVERY_RESULTS
) {
# Use Cached results.
+ $self->{'step'} = STEP_PROCESSING;
$self->call('report_scanned_agents');
# Done!
@@ -1834,6 +1853,7 @@ sub scan($) {
# Find devices.
$self->call('message', "[1/6] Scanning the network...", 3);
+ $self->{'c_network_name'} = '';
$self->{'step'} = STEP_SCANNING;
$self->call('update_progress', $progress);
@@ -1850,6 +1870,7 @@ sub scan($) {
# Connectivity from address forwarding tables.
$self->call('message', "[2/6] Finding address forwarding table connectivity...", 3);
+ $self->{'c_network_name'} = '';
$self->{'step'} = STEP_AFT;
($progress, $step) = (50, 10.0 / scalar(@hosts)); # From 50% to 60%.
for (my $i = 0; defined($hosts[$i]); $i++) {
@@ -1860,6 +1881,7 @@ sub scan($) {
# Connect hosts that are still unconnected using traceroute.
$self->call('message', "[3/6] Finding traceroute connectivity.", 3);
+ $self->{'c_network_name'} = '';
$self->{'step'} = STEP_TRACEROUTE;
($progress, $step) = (60, 10.0 / scalar(@hosts)); # From 60% to 70%.
foreach my $host (@hosts) {
@@ -1871,6 +1893,7 @@ sub scan($) {
# Connect hosts that are still unconnected using known gateways.
$self->call('message', "[4/6] Finding host to gateway connectivity.", 3);
+ $self->{'c_network_name'} = '';
$self->{'step'} = STEP_GATEWAY;
($progress, $step) = (70, 10.0 / scalar(@hosts)); # From 70% to 80%.
$self->get_routes(); # Update the route cache.
@@ -1941,7 +1964,7 @@ sub snmp_pen($$) {
$self->{'pen'} = {} if ref($self->{'pen'}) ne 'HASH';
- $self->{'pen'}{$addr} = $self->snmp_get($addr, $PEN_OID);
+ $self->{'pen'}{$addr} = $self->snmp_get_value($addr, $PEN_OID);
if(defined($self->{'pen'}{$addr})) {
($self->{'pen'}{$addr}) = $self->{'pen'}{$addr} =~ /\.\d+\.\d+\.\d+\.\d+\.\d+\.\d+\.(\d+?)\./