refactor events meta pandora_enterprise#9086

This commit is contained in:
Daniel Barbero Martin 2022-06-21 11:20:26 +02:00
commit c42852a18f
41 changed files with 436 additions and 340 deletions

View File

@ -1,5 +1,5 @@
package: pandorafms-agent-unix package: pandorafms-agent-unix
Version: 7.0NG.762-220620 Version: 7.0NG.762-220621
Architecture: all Architecture: all
Priority: optional Priority: optional
Section: admin Section: admin

View File

@ -14,7 +14,7 @@
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details. # GNU General Public License for more details.
pandora_version="7.0NG.762-220620" pandora_version="7.0NG.762-220621"
echo "Test if you has the tools for to make the packages." echo "Test if you has the tools for to make the packages."
whereis dpkg-deb | cut -d":" -f2 | grep dpkg-deb > /dev/null whereis dpkg-deb | cut -d":" -f2 | grep dpkg-deb > /dev/null

View File

@ -1015,7 +1015,7 @@ my $Sem = undef;
my $ThreadSem = undef; my $ThreadSem = undef;
use constant AGENT_VERSION => '7.0NG.762'; use constant AGENT_VERSION => '7.0NG.762';
use constant AGENT_BUILD => '220620'; use constant AGENT_BUILD => '220621';
# Agent log default file size maximum and instances # Agent log default file size maximum and instances
use constant DEFAULT_MAX_LOG_SIZE => 600000; use constant DEFAULT_MAX_LOG_SIZE => 600000;

View File

@ -3,7 +3,7 @@
# #
%define name pandorafms_agent_unix %define name pandorafms_agent_unix
%define version 7.0NG.762 %define version 7.0NG.762
%define release 220620 %define release 220621
Summary: Pandora FMS Linux agent, PERL version Summary: Pandora FMS Linux agent, PERL version
Name: %{name} Name: %{name}

View File

@ -3,7 +3,7 @@
# #
%define name pandorafms_agent_unix %define name pandorafms_agent_unix
%define version 7.0NG.762 %define version 7.0NG.762
%define release 220620 %define release 220621
Summary: Pandora FMS Linux agent, PERL version Summary: Pandora FMS Linux agent, PERL version
Name: %{name} Name: %{name}

View File

@ -10,7 +10,7 @@
# ********************************************************************** # **********************************************************************
PI_VERSION="7.0NG.762" PI_VERSION="7.0NG.762"
PI_BUILD="220620" PI_BUILD="220621"
OS_NAME=`uname -s` OS_NAME=`uname -s`
FORCE=0 FORCE=0

View File

@ -186,7 +186,7 @@ UpgradeApplicationID
{} {}
Version Version
{220620} {220621}
ViewReadme ViewReadme
{Yes} {Yes}

View File

@ -30,7 +30,7 @@ using namespace Pandora;
using namespace Pandora_Strutils; using namespace Pandora_Strutils;
#define PATH_SIZE _MAX_PATH+1 #define PATH_SIZE _MAX_PATH+1
#define PANDORA_VERSION ("7.0NG.762 Build 220620") #define PANDORA_VERSION ("7.0NG.762 Build 220621")
string pandora_path; string pandora_path;
string pandora_dir; string pandora_dir;

View File

@ -11,7 +11,7 @@ BEGIN
VALUE "LegalCopyright", "Artica ST" VALUE "LegalCopyright", "Artica ST"
VALUE "OriginalFilename", "PandoraAgent.exe" VALUE "OriginalFilename", "PandoraAgent.exe"
VALUE "ProductName", "Pandora FMS Windows Agent" VALUE "ProductName", "Pandora FMS Windows Agent"
VALUE "ProductVersion", "(7.0NG.762(Build 220620))" VALUE "ProductVersion", "(7.0NG.762(Build 220621))"
VALUE "FileVersion", "1.0.0.0" VALUE "FileVersion", "1.0.0.0"
END END
END END

View File

@ -1,5 +1,5 @@
package: pandorafms-console package: pandorafms-console
Version: 7.0NG.762-220620 Version: 7.0NG.762-220621
Architecture: all Architecture: all
Priority: optional Priority: optional
Section: admin Section: admin

View File

@ -14,7 +14,7 @@
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details. # GNU General Public License for more details.
pandora_version="7.0NG.762-220620" pandora_version="7.0NG.762-220621"
package_pear=0 package_pear=0
package_pandora=1 package_pandora=1

View File

@ -38,6 +38,8 @@ ALTER TABLE `tbackup` MODIFY COLUMN `id_user` VARCHAR(255) DEFAULT '';
ALTER TABLE `tservice` ADD COLUMN `enable_sunburst` tinyint(1) NOT NULL default 0; ALTER TABLE `tservice` ADD COLUMN `enable_sunburst` tinyint(1) NOT NULL default 0;
ALTER TABLE `tdashboard` MODIFY `name` TEXT NOT NULL DEFAULT ''; ALTER TABLE `tdashboard` MODIFY `name` TEXT NOT NULL DEFAULT '';
ALTER TABLE `tagente` ADD COLUMN `satellite_server` INT NOT NULL default 0;
ALTER TABLE `tmetaconsole_agent` ADD COLUMN `satellite_server` INT NOT NULL default 0;
SET @st_oum763 = (SELECT IF( SET @st_oum763 = (SELECT IF(
(SELECT COUNT(*) FROM INFORMATION_SCHEMA.COLUMNS WHERE table_name = 'tautoconfig' AND table_schema = DATABASE() AND column_name = 'disabled') > 0, (SELECT COUNT(*) FROM INFORMATION_SCHEMA.COLUMNS WHERE table_name = 'tautoconfig' AND table_schema = DATABASE() AND column_name = 'disabled') > 0,
"SELECT 1", "SELECT 1",
@ -49,3 +51,4 @@ EXECUTE pr_oum763;
DEALLOCATE PREPARE pr_oum763; DEALLOCATE PREPARE pr_oum763;
COMMIT; COMMIT;

View File

@ -245,8 +245,11 @@ if (!$new_agent && $alias != '') {
} }
// Remote configuration available. // Remote configuration available.
$remote_agent = false;
if (isset($filename)) { if (isset($filename)) {
if (file_exists($filename['md5'])) { if (file_exists($filename['md5'])) {
$remote_agent = true;
$agent_name = agents_get_name($id_agente); $agent_name = agents_get_name($id_agente);
$agent_name = io_safe_output($agent_name); $agent_name = io_safe_output($agent_name);
$agent_md5 = md5($agent_name, false); $agent_md5 = md5($agent_name, false);
@ -427,6 +430,42 @@ $table_server .= html_print_select(
true true
).'<div class="label_select_child_icons"></div></div></div>'; ).'<div class="label_select_child_icons"></div></div></div>';
$table_satellite = '';
if ($remote_agent === true) {
// Satellite server selector.
$satellite_servers = db_get_all_rows_filter(
'tserver',
['server_type' => SERVER_TYPE_ENTERPRISE_SATELLITE],
[
'id_server',
'name',
]
);
$satellite_names = [];
if (empty($satellite_servers) === false) {
foreach ($satellite_servers as $s_server) {
$satellite_names[$s_server['id_server']] = $s_server['name'];
}
$table_satellite = '<div class="label_select"><p class="input_label">'.__('Satellite').'</p>';
$table_satellite .= '<div class="label_select_parent">';
$table_satellite .= html_print_input(
[
'type' => 'select',
'fields' => $satellite_names,
'name' => 'satellite_server',
'selected' => $satellite_server,
'nothing' => __('None'),
'nothinf_value' => 0,
'return' => true,
]
).'<div class="label_select_child_icons"></div></div></div>';
}
}
// Description. // Description.
$table_description = '<div class="label_select"><p class="input_label">'.__('Description').'</p>'; $table_description = '<div class="label_select"><p class="input_label">'.__('Description').'</p>';
$table_description .= html_print_textarea( $table_description .= html_print_textarea(
@ -443,7 +482,7 @@ $table_description .= html_print_textarea(
echo '<div class="first_row"> echo '<div class="first_row">
<div class="box-shadow agent_options '.$agent_options_update.' white_box"> <div class="box-shadow agent_options '.$agent_options_update.' white_box">
<div class="agent_options_column_left">'.$table_agent_name.$table_alias.$table_ip.$table_primary_group.'</div> <div class="agent_options_column_left">'.$table_agent_name.$table_alias.$table_ip.$table_primary_group.'</div>
<div class="agent_options_column_right">'.$table_interval.$table_os.$table_server.$table_description.'</div> <div class="agent_options_column_right">'.$table_interval.$table_os.$table_server.$table_satellite.$table_description.'</div>
</div>'; </div>';
if (!$new_agent && $alias != '') { if (!$new_agent && $alias != '') {
echo $table_qr_code; echo $table_qr_code;

View File

@ -155,6 +155,7 @@ $alert_d7 = 1;
$alert_recovery = 0; $alert_recovery = 0;
$alert_priority = 0; $alert_priority = 0;
$server_name = ''; $server_name = '';
$satellite_server = 0;
$grupo = 0; $grupo = 0;
$id_os = 9; $id_os = 9;
// Windows. // Windows.
@ -985,6 +986,7 @@ if ($update_agent) {
$old_values = db_get_row('tagente', 'id_agente', $id_agente); $old_values = db_get_row('tagente', 'id_agente', $id_agente);
$fields = db_get_all_fields_in_table('tagent_custom_fields'); $fields = db_get_all_fields_in_table('tagent_custom_fields');
$secondary_groups = (string) get_parameter('secondary_hidden', ''); $secondary_groups = (string) get_parameter('secondary_hidden', '');
$satellite_server = (int) get_parameter('satellite_server', 0);
if ($fields === false) { if ($fields === false) {
$fields = []; $fields = [];
@ -1092,6 +1094,7 @@ if ($update_agent) {
'quiet' => $quiet, 'quiet' => $quiet,
'cps' => $cps, 'cps' => $cps,
'safe_mode_module' => $safe_mode_module, 'safe_mode_module' => $safe_mode_module,
'satellite_server' => $satellite_server,
]; ];
if ($config['metaconsole_agent_cache'] == 1) { if ($config['metaconsole_agent_cache'] == 1) {
@ -1230,6 +1233,7 @@ if ($id_agente) {
$cps = $agent['cps']; $cps = $agent['cps'];
$safe_mode_module = $agent['safe_mode_module']; $safe_mode_module = $agent['safe_mode_module'];
$safe_mode = ($safe_mode_module) ? 1 : 0; $safe_mode = ($safe_mode_module) ? 1 : 0;
$satellite_server = (int) $agent['satellite_server'];
} }
$update_module = (bool) get_parameter('update_module'); $update_module = (bool) get_parameter('update_module');

View File

@ -203,20 +203,22 @@ if (is_ajax() !== true) {
var clientMode = '<?php echo $mode; ?>'; var clientMode = '<?php echo $mode; ?>';
</script> </script>
<?php <?php
$server_version = (string) db_get_value_sql( if (function_exists('db_get_value_sql') === true) {
'SELECT `version` FROM `tserver` ORDER BY `master` DESC' $server_version = (string) db_get_value_sql(
); 'SELECT `version` FROM `tserver` ORDER BY `master` DESC'
if ($server_version !== false );
&& preg_match('/NG\.(\d\.*\d*?) /', $server_version, $matches) > 0 if ($server_version !== false
) { && preg_match('/NG\.(\d\.*\d*?) /', $server_version, $matches) > 0
if ((float) $matches[1] !== (float) $current_package) { ) {
ui_print_warning_message( if ((float) $matches[1] !== floor((float) $current_package)) {
__( ui_print_warning_message(
'Master server version %s does not match console version %s.', __(
(float) $matches[1], 'Master server version %s does not match console version %s.',
(float) $current_package (float) $matches[1],
) (float) $current_package
); )
);
}
} }
} }

View File

@ -1528,7 +1528,7 @@ class ConsoleSupervisor
$this->cleanNotifications('NOTIF.PHP.UPLOAD_MAX_FILESIZE'); $this->cleanNotifications('NOTIF.PHP.UPLOAD_MAX_FILESIZE');
} }
if ($PHPmemory_limit < $PHPmemory_limit_min && $PHPmemory_limit !== '-1') { if ($PHPmemory_limit < $PHPmemory_limit_min && (int) $PHPmemory_limit !== -1) {
$url = 'http://php.net/manual/en/ini.core.php#ini.memory-limit'; $url = 'http://php.net/manual/en/ini.core.php#ini.memory-limit';
if ($config['language'] == 'es') { if ($config['language'] == 'es') {
$url = 'http://php.net/manual/es/ini.core.php#ini.memory-limit'; $url = 'http://php.net/manual/es/ini.core.php#ini.memory-limit';
@ -2145,8 +2145,8 @@ class ConsoleSupervisor
[ [
'type' => 'NOTIF.UPDATEMANAGER.REGISTRATION', 'type' => 'NOTIF.UPDATEMANAGER.REGISTRATION',
'title' => __('This instance is not registered in the Update manager section'), 'title' => __('This instance is not registered in the Update manager section'),
'message' => __('Click <a class="bolder underline" href="javascript: force_run_register();"> here</a> to start the registration process'), 'message' => __('Click here to start the registration process'),
'url' => 'javascript: force_run_register();', 'url' => '__url__/index.php?sec=messages&sec2=godmode/update_manager/update_manager&tab=online',
] ]
); );
} else { } else {
@ -2166,7 +2166,7 @@ class ConsoleSupervisor
// Check default password for "admin". // Check default password for "admin".
$admin_with_default_pass = db_get_value_sql( $admin_with_default_pass = db_get_value_sql(
'SELECT count(*) FROM tusuario 'SELECT count(*) FROM tusuario
WHERE WHERE
id_user="admin" id_user="admin"
AND password="1da7ee7d45b96d0e1f45ee4ee23da560" AND password="1da7ee7d45b96d0e1f45ee4ee23da560"
AND is_admin=1 AND is_admin=1
@ -2441,11 +2441,11 @@ class ConsoleSupervisor
config_update_value('last_um_check', $future, true); config_update_value('last_um_check', $future, true);
$messages = update_manager_get_messages(); $messages = update_manager_get_messages();
if (is_array($messages) === true) { if (is_array($messages) === true) {
$source_id = get_notification_source_id( $source_id = get_notification_source_id(
'Official&#x20;communication' 'Official&#x20;communication'
); );
foreach ($messages as $message) { foreach ($messages as $message) {
if (isset($message['url']) === false) { if (isset($message['url']) === false) {
$message['url'] = '#'; $message['url'] = '#';
@ -2476,8 +2476,8 @@ class ConsoleSupervisor
// List all servers except satellite server. // List all servers except satellite server.
$server_version_list = db_get_all_rows_sql( $server_version_list = db_get_all_rows_sql(
sprintf( sprintf(
'SELECT `name`, `version` 'SELECT `name`, `version`
FROM tserver FROM tserver
WHERE server_type != %d WHERE server_type != %d
GROUP BY `version`', GROUP BY `version`',
SERVER_TYPE_ENTERPRISE_SATELLITE SERVER_TYPE_ENTERPRISE_SATELLITE
@ -2490,7 +2490,7 @@ class ConsoleSupervisor
foreach ($server_version_list as $server) { foreach ($server_version_list as $server) {
if (strpos( if (strpos(
$server['version'], $server['version'],
$config['current_package'] (string) floor($config['current_package'])
) === false ) === false
) { ) {
$missed++; $missed++;
@ -2511,6 +2511,8 @@ class ConsoleSupervisor
'url' => '__url__/index.php?sec=messages&sec2=godmode/update_manager/update_manager&tab=online', 'url' => '__url__/index.php?sec=messages&sec2=godmode/update_manager/update_manager&tab=online',
] ]
); );
break;
} }
} }
} }

View File

@ -20,7 +20,7 @@
/** /**
* Pandora build version and version * Pandora build version and version
*/ */
$build_version = 'PC220620'; $build_version = 'PC220621';
$pandora_version = 'v7.0NG.762'; $pandora_version = 'v7.0NG.762';
// Do not overwrite default timezone set if defined. // Do not overwrite default timezone set if defined.

View File

@ -53,8 +53,10 @@ enterprise_include_once('include/functions_clusters.php');
enterprise_include_once('include/functions_alerts.php'); enterprise_include_once('include/functions_alerts.php');
// Clases. // Clases.
use PandoraFMS\Agent;
use PandoraFMS\Module; use PandoraFMS\Module;
use PandoraFMS\Enterprise\Cluster; use PandoraFMS\Enterprise\Cluster;
use PandoraFMS\Enterprise\Metaconsole\Node;
use PandoraFMS\SpecialDay; use PandoraFMS\SpecialDay;
@ -1842,18 +1844,18 @@ function api_set_update_agent_field($id_agent, $use_agent_alias, $params)
/** /**
* Create a new agent, and print the id for new agent. * Create a new agent, and print the id for new agent.
* *
* @param $thrash1 Don't use. * @param $id_node Id_node target (if metaconsole)
* @param $thrash2 Don't use. * @param $thrash2 Don't use.
* @param array $other it's array, $other as param is <agent_name>;<ip>;<id_parent>;<id_group>; * @param array $other it's array, $other as param is <agent_name>;<ip>;<id_parent>;<id_group>;
* <cascade_protection>;<interval_sec>;<id_os>;<id_server>;<custom_id>;<learning_mode>;<disabled>;<description> in this order * <cascade_protection>;<interval_sec>;<id_os>;<id_server>;<custom_id>;<learning_mode>;<disabled>;<description> in this order
* and separator char (after text ; ) and separator (pass in param othermode as othermode=url_encode_separator_<separator>) * and separator char (after text ; ) and separator (pass in param othermode as othermode=url_encode_separator_<separator>)
* example: * example:
* *
* api.php?op=set&op2=new_agent&other=pepito|1.1.1.1|0|4|0|30|8|10||0|0|nose%20nose&other_mode=url_encode_separator_| * api.php?op=set&op2=new_agent&other=pepito|1.1.1.1|0|4|0|30|8|10||0|0|nose%20nose&other_mode=url_encode_separator_|
* *
* @param $thrash3 Don't use. * @param $thrash3 Don't use.
*/ */
function api_set_new_agent($thrash1, $thrash2, $other, $thrash3) function api_set_new_agent($id_node, $thrash2, $other, $trhash3)
{ {
global $config; global $config;
@ -1862,158 +1864,117 @@ function api_set_new_agent($thrash1, $thrash2, $other, $thrash3)
return; return;
} }
if (defined('METACONSOLE')) {
return;
}
if ((int) $other['data'][3] == 0) { if ((int) $other['data'][3] == 0) {
returnError('For security reasons, the agent was not created. Use a group other than 0.'); returnError('For security reasons, the agent was not created. Use a group other than 0.');
return; return;
} }
$alias = io_safe_input( try {
trim( $agent = new Agent();
preg_replace(
'/[\/\\\|%#&$]/', if (is_metaconsole() === true) {
'', if ($id_node <= 0) {
preg_replace( throw new Exception('No node id specified');
'/x20;/', }
' ',
$other['data'][0] $node = new Node($id_node);
$id_agente = $node->callApi(
'new_agent',
'set',
null,
null,
$other['data'],
null
);
} else {
$alias = io_safe_input(
trim(
preg_replace(
'/[\/\\\|%#&$]/',
'',
preg_replace(
'/x20;/',
' ',
$other['data'][0]
)
)
) )
)
)
);
$direccion_agente = io_safe_input($other['data'][1]);
$nombre_agente = hash('sha256', $direccion_agente.'|'.$direccion_agente.'|'.time().'|'.sprintf('%04d', rand(0, 10000)));
$id_parent = (int) $other['data'][2];
$grupo = (int) $other['data'][3];
$cascade_protection = (int) $other['data'][4];
$cascade_protection_module = (int) $other['data'][5];
$intervalo = (string) $other['data'][6];
$id_os = (int) $other['data'][7];
$server_name = (string) $other['data'][8];
$custom_id = (string) $other['data'][9];
$modo = (int) $other['data'][10];
$disabled = (int) $other['data'][11];
$comentarios = (string) $other['data'][12];
$alias_as_name = (int) $other['data'][13];
$update_module_count = (int) $config['metaconsole_agent_cache'] == 1;
if ($cascade_protection == 1) {
if (($id_parent != 0) && (db_get_value_sql(
'SELECT id_agente_modulo
FROM tagente_modulo
WHERE id_agente = '.$id_parent.' AND id_agente_modulo = '.$cascade_protection_module
) === false)
) {
returnError('Cascade protection is not applied because it is not a parent module.');
return;
}
} else {
$cascadeProtectionModule = 0;
}
$server_name = db_get_value_sql('SELECT name FROM tserver WHERE BINARY name LIKE "'.$server_name.'"');
// Check if agent exists (BUG WC-50518-2).
if ($alias == '' && $alias_as_name === 0) {
returnError('No agent alias specified');
} else if (agents_get_agent_id($nombre_agente)) {
returnError('The agent name already exists in DB.');
} else if (db_get_value_sql('SELECT id_grupo FROM tgrupo WHERE id_grupo = '.$grupo) === false) {
returnError('The group does not exist.');
} else if (group_allow_more_agents($grupo, true, 'create') === false) {
returnError('Agent cannot be created due to the maximum agent limit for this group');
} else if (db_get_value_sql('SELECT id_os FROM tconfig_os WHERE id_os = '.$id_os) === false) {
returnError('The OS does not exist.');
} else if ($server_name === false) {
returnError('The '.get_product_name().' Server does not exist.');
} else {
if ($alias_as_name === 1) {
$exists_alias = db_get_row_sql('SELECT nombre FROM tagente WHERE nombre = "'.$alias.'"');
$nombre_agente = $alias;
}
$exists_ip = false;
if ($config['unique_ip'] && $direccion_agente != '') {
$exists_ip = db_get_row_sql('SELECT direccion FROM tagente WHERE direccion = "'.$direccion_agente.'"');
}
if (!$exists_alias && !$exists_ip) {
$id_agente = db_process_sql_insert(
'tagente',
[
'nombre' => $nombre_agente,
'alias' => $alias,
'alias_as_name' => $alias_as_name,
'direccion' => $direccion_agente,
'id_grupo' => $grupo,
'intervalo' => $intervalo,
'comentarios' => $comentarios,
'modo' => $modo,
'id_os' => $id_os,
'disabled' => $disabled,
'cascade_protection' => $cascade_protection,
'cascade_protection_module' => $cascade_protection_module,
'server_name' => $server_name,
'id_parent' => $id_parent,
'custom_id' => $custom_id,
'os_version' => '',
'agent_version' => '',
'timezone_offset' => 0,
'icon_path' => '',
'url_address' => '',
'update_module_count' => $update_module_count,
]
); );
enterprise_hook('update_agent', [$id_agente]);
} else {
$id_agente = false;
}
if ($id_agente !== false) { $direccion_agente = io_safe_input($other['data'][1]);
// Create address for this agent in taddress. $id_parent = (int) $other['data'][2];
if ($direccion_agente != '') { $grupo = (int) $other['data'][3];
agents_add_address($id_agente, $direccion_agente); $cascade_protection = (int) $other['data'][4];
$cascade_protection_module = (int) $other['data'][5];
$intervalo = (string) $other['data'][6];
$id_os = (int) $other['data'][7];
$server_name = (string) $other['data'][8];
$custom_id = (string) $other['data'][9];
$modo = (int) $other['data'][10];
$disabled = (int) $other['data'][11];
$comentarios = (string) html_entity_decode($other['data'][12]);
$alias_as_name = (int) $other['data'][13];
$update_module_count = (int) $config['metaconsole_agent_cache'] == 1;
$agent->nombre($alias);
$agent->alias($alias);
$agent->alias_as_name($alias_as_name);
$agent->direccion($direccion_agente);
$agent->id_grupo($grupo);
$agent->intervalo($intervalo);
$agent->comentarios($comentarios);
$agent->modo($modo);
$agent->id_os($id_os);
$agent->disabled($disabled);
$agent->cascade_protection($cascade_protection);
$agent->cascade_protection_module($cascade_protection_module);
$agent->server_name($server_name);
$agent->id_parent($id_parent);
$agent->custom_id($custom_id);
$agent->timezone_offset(0);
$agent->update_module_count($update_module_count);
if ($cascade_protection == 1) {
if ($id_parent != 0) {
try {
$parent = new Agent($id_parent);
} catch (\Exception $e) {
returnError('Cascade protection is not applied because it is not a parent module.');
}
}
} }
$info = '{"Name":"'.$nombre_agente.'", $server_name = db_get_value_sql('SELECT name FROM tserver WHERE BINARY name LIKE "'.$server_name.'"');
"IP":"'.$direccion_agente.'",
"Group":"'.$grupo.'",
"Interval":"'.$intervalo.'",
"Comments":"'.$comentarios.'",
"Mode":"'.$modo.'",
"ID_parent:":"'.$id_parent.'",
"Server":"'.$server_name.'",
"ID os":"'.$id_os.'",
"Disabled":"'.$disabled.'",
"Custom ID":"'.$custom_id.'",
"Cascade protection":"'.$cascade_protection.'",
"Cascade protection module":"'.$cascade_protection_module.'"}';
$unsafe_alias = io_safe_output($alias); // Check if agent exists (BUG WC-50518-2).
db_pandora_audit( if ($alias == '' && $alias_as_name === 0) {
AUDIT_LOG_AGENT_MANAGEMENT, returnError('No agent alias specified');
'Created agent '.$unsafe_alias, } else if (agents_get_agent_id($nombre_agente)) {
false, returnError('The agent name already exists in DB.');
true, } else if (db_get_value_sql('SELECT id_grupo FROM tgrupo WHERE id_grupo = '.$grupo) === false) {
$info returnError('The group does not exist.');
); } else if (group_allow_more_agents($grupo, true, 'create') === false) {
} else { returnError('Agent cannot be created due to the maximum agent limit for this group');
$id_agente = 0; } else if (db_get_value_sql('SELECT id_os FROM tconfig_os WHERE id_os = '.$id_os) === false) {
returnError('The OS does not exist.');
if ($exists_alias) { } else if ($server_name === false) {
$agent_creation_error = 'Could not be created because name already exists'; returnError('The '.get_product_name().' Server does not exist.');
} else if ($exists_ip) {
$agent_creation_error = 'Could not be created because IP already exists';
} else { } else {
$agent_creation_error = 'Could not be created for unknown reason'; if ($alias_as_name === 1) {
} $exists_alias = db_get_row_sql('SELECT nombre FROM tagente WHERE nombre = "'.$alias.'"');
$nombre_agente = $alias;
}
returnError($agent_creation_error); $exists_ip = false;
return;
if ($config['unique_ip'] && $direccion_agente != '') {
$exists_ip = db_get_row_sql('SELECT direccion FROM tagente WHERE direccion = "'.$direccion_agente.'"');
}
$agent->save((bool) $alias_as_name);
$id_agente = $agent->id_agente();
$agent->updateFromCache();
}
} }
returnData( returnData(
@ -2023,6 +1984,9 @@ function api_set_new_agent($thrash1, $thrash2, $other, $thrash3)
'data' => $id_agente, 'data' => $id_agente,
] ]
); );
} catch (\Exception $e) {
returnError($e->getMessage());
return;
} }
} }

View File

@ -84,10 +84,7 @@ function get_notification_targets(int $id_message)
if (is_array($ret)) { if (is_array($ret)) {
foreach ($ret as $row) { foreach ($ret as $row) {
array_push( array_push($targets['users'], get_user_fullname($row['id_user']));
$targets['users'],
get_user_fullname($row['id_user'])
);
} }
} }
@ -227,8 +224,10 @@ function check_notification_readable(int $id_message)
* *
* @return array [users] and [groups] with the targets. * @return array [users] and [groups] with the targets.
*/ */
function get_notification_source_targets(int $id_source, ?string $subtype=null) function get_notification_source_targets(
{ int $id_source,
?string $subtype=null
) {
$ret = []; $ret = [];
$filter = ''; $filter = '';
@ -484,7 +483,8 @@ function notifications_add_group_to_source($source_id, $groups)
continue; continue;
} }
$res = $res && db_process_sql_insert( $res = $res &&
db_process_sql_insert(
'tnotification_source_group', 'tnotification_source_group',
[ [
'id_group' => $group, 'id_group' => $group,
@ -525,7 +525,8 @@ function notifications_add_users_to_source($source_id, $users)
continue; continue;
} }
$res = $res && db_process_sql_insert( $res = $res &&
db_process_sql_insert(
'tnotification_source_user', 'tnotification_source_user',
[ [
'id_user' => $user, 'id_user' => $user,
@ -551,7 +552,13 @@ function notifications_add_users_to_source($source_id, $users)
function notifications_get_group_source_not_configured($source_id) function notifications_get_group_source_not_configured($source_id)
{ {
$groups_selected = notifications_get_group_sources_for_select($source_id); $groups_selected = notifications_get_group_sources_for_select($source_id);
$all_groups = users_get_groups_for_select(false, 'AR', false, true, $groups_selected); $all_groups = users_get_groups_for_select(
false,
'AR',
false,
true,
$groups_selected
);
return array_diff($all_groups, $groups_selected); return array_diff($all_groups, $groups_selected);
} }
@ -566,12 +573,10 @@ function notifications_get_group_source_not_configured($source_id)
*/ */
function notifications_get_user_source_not_configured($source_id) function notifications_get_user_source_not_configured($source_id)
{ {
$users_selected = array_keys(notifications_get_user_sources_for_select($source_id)); $users_selected = array_keys(
$users = get_users( notifications_get_user_sources_for_select($source_id)
'id_user',
['!id_user' => $users_selected],
['id_user']
); );
$users = get_users('id_user', ['!id_user' => $users_selected], ['id_user']);
return index_array($users, 'id_user', 'id_user'); return index_array($users, 'id_user', 'id_user');
} }
@ -587,8 +592,8 @@ function notifications_get_user_source_not_configured($source_id)
function notifications_build_user_enable_return($status, $enabled) function notifications_build_user_enable_return($status, $enabled)
{ {
return [ return [
'status' => ((bool) $status === true) ? 1 : 0, 'status' => (bool) $status === true ? 1 : 0,
'enabled' => ((bool) $enabled === true) ? 1 : 0, 'enabled' => (bool) $enabled === true ? 1 : 0,
]; ];
} }
@ -625,16 +630,11 @@ function notifications_get_user_label_status($source, $user, $label)
$common_groups = array_intersect( $common_groups = array_intersect(
array_keys(users_get_groups($user)), array_keys(users_get_groups($user)),
array_keys( array_keys(notifications_get_group_sources_for_select($source['id']))
notifications_get_group_sources_for_select($source['id'])
)
); );
// No group found, return no permissions. // No group found, return no permissions.
$value = empty($common_groups) ? false : $source[$label]; $value = empty($common_groups) ? false : $source[$label];
return notifications_build_user_enable_return( return notifications_build_user_enable_return($value, false);
$value,
false
);
} }
@ -681,13 +681,7 @@ function notifications_get_counters()
{ {
$num_notifications = 0; $num_notifications = 0;
$last_id = 0; $last_id = 0;
$last_message = messages_get_overview( $last_message = messages_get_overview('timestamp', 'DESC', false, false, 1);
'timestamp',
'DESC',
false,
false,
1
);
if (!empty($last_message)) { if (!empty($last_message)) {
$num_notifications = messages_get_count(); $num_notifications = messages_get_count();
$last_id = $last_message[0]['id_mensaje']; $last_id = $last_message[0]['id_mensaje'];
@ -718,7 +712,9 @@ function notifications_get_counters()
function notifications_print_ball($num_notifications, $last_id) function notifications_print_ball($num_notifications, $last_id)
{ {
$no_notifications = (int) $num_notifications === 0; $no_notifications = (int) $num_notifications === 0;
$class_status = ($no_notifications) ? 'notification-ball-no-messages' : 'notification-ball-new-messages'; $class_status = $no_notifications
? 'notification-ball-no-messages'
: 'notification-ball-new-messages';
return sprintf( return sprintf(
'<div '<div
%s %s
@ -728,7 +724,7 @@ function notifications_print_ball($num_notifications, $last_id)
> >
%s %s
</div>', </div>',
($no_notifications) ? '' : 'onclick="addNotifications(event)"', $no_notifications ? '' : 'onclick="addNotifications(event)"',
$class_status, $class_status,
$last_id, $last_id,
$num_notifications $num_notifications
@ -799,7 +795,7 @@ function notifications_print_global_source_configuration($source)
'type' => 'switch', 'type' => 'switch',
'id' => 'nt-'.$source['id'].'.'.$type.'-subtype', 'id' => 'nt-'.$source['id'].'.'.$type.'-subtype',
'class' => 'elem-clickable', 'class' => 'elem-clickable',
'value' => (isset($blacklist[$type]) === false), 'value' => isset($blacklist[$type]) === false,
'return' => true, 'return' => true,
] ]
); );
@ -833,14 +829,11 @@ function notifications_print_global_source_configuration($source)
* *
* @return string HTML with the generated selector * @return string HTML with the generated selector
*/ */
function notifications_print_source_select_box( function notifications_print_source_select_box($info_selec, $id, $source_id)
$info_selec, {
$id, $title = $id === 'users' ? __('Notified users') : __('Notified groups');
$source_id $add_title = $id === 'users' ? __('Add users') : __('Add groups');
) { $delete_title = $id === 'users' ? __('Delete users') : __('Delete groups');
$title = ($id === 'users') ? __('Notified users') : __('Notified groups');
$add_title = ($id === 'users') ? __('Add users') : __('Add groups');
$delete_title = ($id === 'users') ? __('Delete users') : __('Delete groups');
// Generate the HTML. // Generate the HTML.
return sprintf( return sprintf(
@ -873,11 +866,7 @@ function notifications_print_source_select_box(
true, true,
[ [
'title' => $add_title, 'title' => $add_title,
'onclick' => sprintf( 'onclick' => sprintf("add_source_dialog('%s', '%s')", $id, $source_id),
"add_source_dialog('%s', '%s')",
$id,
$source_id
),
] ]
), ),
html_print_image( html_print_image(
@ -1062,7 +1051,6 @@ function notifications_print_dropdown()
function notifications_print_dropdown_element($message_info) function notifications_print_dropdown_element($message_info)
{ {
$action = ''; $action = '';
switch ($message_info['description']) { switch ($message_info['description']) {
case 'Official&#x20;communication': case 'Official&#x20;communication':
$action = 'show_modal(this.id);'; $action = 'show_modal(this.id);';

View File

@ -29,6 +29,12 @@ function chordDiagram(recipient, elements, matrix, width) {
var width = 700; var width = 700;
var margin = 150; var margin = 150;
var padding = 0.02; var padding = 0.02;
var consoleStyle = document.getElementById("hidden-selected_style_theme")
.value;
var textColor =
consoleStyle === "pandora_black" ? "rgb(240, 240, 240)" : "rgb(0, 0, 0)";
var tooltipColor =
consoleStyle === "pandora_black" ? "rgb(0, 0, 0)" : "rgb(240, 240, 240)";
function chart(selection) { function chart(selection) {
selection.each(function(data) { selection.each(function(data) {
@ -103,7 +109,6 @@ function chordDiagram(recipient, elements, matrix, width) {
const chords = chord.chords(); const chords = chord.chords();
let aux = 0; let aux = 0;
$.each(chords, function(key, value) { $.each(chords, function(key, value) {
console.log(aux);
if (aux < 5) { if (aux < 5) {
if ( if (
(value.source.index == i && value.target.subindex == i) || (value.source.index == i && value.target.subindex == i) ||
@ -159,6 +164,7 @@ function chordDiagram(recipient, elements, matrix, width) {
.attr("text-anchor", function(d) { .attr("text-anchor", function(d) {
return d.angle > Math.PI ? "end" : null; return d.angle > Math.PI ? "end" : null;
}) })
.attr("style", "fill: " + textColor)
.attr("transform", function(d) { .attr("transform", function(d) {
return ( return (
"rotate(" + "rotate(" +
@ -266,7 +272,12 @@ function chordDiagram(recipient, elements, matrix, width) {
$("#tooltip").attr( $("#tooltip").attr(
"style", "style",
"background: #fff;" + "background: " +
tooltipColor +
";" +
"color: " +
textColor +
";" +
"position: absolute;" + "position: absolute;" +
"display: inline-block;" + "display: inline-block;" +
"width: auto;" + "width: auto;" +
@ -393,6 +404,16 @@ function treeMap(recipient, data, width, height) {
var isIE = true; var isIE = true;
var chartWidth = width; var chartWidth = width;
var chartHeight = height; var chartHeight = height;
var consoleStyle = document.getElementById("hidden-selected_style_theme")
.value;
$("#tooltip").css(
"color",
consoleStyle === "pandora_black" ? "rgb(240, 240, 240)" : "rgb(0, 0, 0)"
);
$("#tooltip").css(
"background-color",
consoleStyle === "pandora_black" ? "rgb(0, 0, 0)" : "rgb(240, 240, 240)"
);
if (width === "auto") { if (width === "auto") {
chartWidth = $(recipient).innerWidth(); chartWidth = $(recipient).innerWidth();
} }
@ -761,6 +782,7 @@ function treeMap(recipient, data, width, height) {
$("#tooltip").attr( $("#tooltip").attr(
"style", "style",
"background: #fff;" + "background: #fff;" +
"color: #111;" +
"position: absolute;" + "position: absolute;" +
"display: block;" + "display: block;" +
"width: 200px;" + "width: 200px;" +
@ -1023,6 +1045,7 @@ function sunburst(recipient, data, width, height, tooltip = true) {
$("#tooltip").attr( $("#tooltip").attr(
"style", "style",
"background: #fff;" + "background: #fff;" +
"color: #111;" +
"position: absolute;" + "position: absolute;" +
"display: block;" + "display: block;" +
"width: 200px;" + "width: 200px;" +

View File

@ -248,7 +248,7 @@ class Agent extends Entity
/** /**
* Calculates cascade protection service value for this service. * Calculates cascade protection _nameice value for this service.
* *
* @param integer|null $id_node Meta searching node will use this field. * @param integer|null $id_node Meta searching node will use this field.
* *
@ -621,4 +621,25 @@ class Agent extends Entity
} }
/**
* Update agent in metaconsole
*
* @return void
*/
public function updateFromCache()
{
$res = (bool) \enterprise_hook(
'agent_update_from_cache',
[
$this->id_agente(),
$this->toArray(),
$this->server_name(),
]
);
return $res;
}
} }

View File

@ -258,8 +258,8 @@ class TopNWidget extends Widget
// Order. // Order.
$fields = [ $fields = [
1 => __('Descending'), 1 => __('Ascending'),
2 => __('Ascending'), 2 => __('Descending'),
3 => __('By agent name'), 3 => __('By agent name'),
]; ];
@ -466,7 +466,7 @@ class TopNWidget extends Widget
]; ];
foreach ($modules as $module) { foreach ($modules as $module) {
$module['aliasAgent'] = ui_print_truncate_text($module['aliasAgent'], 20); $module['aliasAgent'] = ui_print_truncate_text($module['aliasAgent'], 20, false, true, false);
$item_name = $module['aliasAgent'].' - '.$module['nameModule']; $item_name = $module['aliasAgent'].' - '.$module['nameModule'];
$data_hbar[$item_name]['g'] = $module[$display]; $data_hbar[$item_name]['g'] = $module[$display];
// Calculation of max-min values for show in graph. // Calculation of max-min values for show in graph.

View File

@ -1,4 +1,5 @@
<?php <?php
/** /**
* Index. * Index.
* *
@ -53,8 +54,8 @@ $develop_bypass = 0;
if ($develop_bypass != 1) { if ($develop_bypass != 1) {
// If no config file, automatically try to install. // If no config file, automatically try to install.
if (! file_exists('include/config.php')) { if (!file_exists('include/config.php')) {
if (! file_exists('install.php')) { if (!file_exists('install.php')) {
$url = explode('/', $_SERVER['REQUEST_URI']); $url = explode('/', $_SERVER['REQUEST_URI']);
$flag_url = 0; $flag_url = 0;
foreach ($url as $key => $value) { foreach ($url as $key => $value) {
@ -128,8 +129,8 @@ if ($develop_bypass != 1) {
} }
} }
if ((! file_exists('include/config.php')) if ((!file_exists('include/config.php'))
|| (! is_readable('include/config.php')) || (!is_readable('include/config.php'))
) { ) {
$login_screen = 'error_noconfig'; $login_screen = 'error_noconfig';
include 'general/error_screen.php'; include 'general/error_screen.php';
@ -224,9 +225,9 @@ ob_start('ui_process_page_head');
enterprise_include_once('index.php'); enterprise_include_once('index.php');
echo '<script type="text/javascript">'; echo '<script type="text/javascript">';
echo 'var dispositivo = navigator.userAgent.toLowerCase();'; echo 'var dispositivo = navigator.userAgent.toLowerCase();';
echo 'if( dispositivo.search(/iphone|ipod|ipad|android/) > -1 ){'; echo 'if( dispositivo.search(/iphone|ipod|ipad|android/) > -1 ){';
echo 'document.location = "'.ui_get_full_url('/mobile').'"; }'; echo 'document.location = "'.ui_get_full_url('/mobile').'"; }';
echo '</script>'; echo '</script>';
// This tag is included in the buffer passed to ui_process_page_head so // This tag is included in the buffer passed to ui_process_page_head so
@ -275,7 +276,7 @@ if (strlen($search) > 0) {
// Login process. // Login process.
enterprise_include_once('include/auth/saml.php'); enterprise_include_once('include/auth/saml.php');
if (! isset($config['id_user'])) { if (!isset($config['id_user'])) {
// Clear error messages. // Clear error messages.
unset($_COOKIE['errormsg']); unset($_COOKIE['errormsg']);
setcookie('errormsg', null, -1); setcookie('errormsg', null, -1);
@ -731,9 +732,9 @@ if (! isset($config['id_user'])) {
} }
// Boolean parameters. // Boolean parameters.
$correct_pass_change = (boolean) get_parameter('correct_pass_change', false); $correct_pass_change = (bool) get_parameter('correct_pass_change', false);
$reset = (boolean) get_parameter('reset', false); $reset = (bool) get_parameter('reset', false);
$first = (boolean) get_parameter('first', false); $first = (bool) get_parameter('first', false);
// Strings. // Strings.
$reset_hash = get_parameter('reset_hash'); $reset_hash = get_parameter('reset_hash');
$pass1 = get_parameter_post('pass1'); $pass1 = get_parameter_post('pass1');
@ -955,7 +956,7 @@ if (! isset($config['id_user'])) {
exit('</html>'); exit('</html>');
} else { } else {
if (((bool) $user_in_db['is_admin'] === false) if (((bool) $user_in_db['is_admin'] === false)
&& ( (bool) $user_in_db['not_login'] === true && ((bool) $user_in_db['not_login'] === true
|| (is_metaconsole() === false || (is_metaconsole() === false
&& has_metaconsole() === true && has_metaconsole() === true
&& is_management_allowed() === false && is_management_allowed() === false
@ -1170,7 +1171,7 @@ if (has_metaconsole() === true
$err .= '</div>'; $err .= '</div>';
?> ?>
<script type="text/javascript"> <script type="text/javascript">
$(document).ready(function () { $(document).ready(function() {
infoMessage({ infoMessage({
title: '<?php echo __('Warning'); ?>', title: '<?php echo __('Warning'); ?>',
text: '<?php echo $err; ?>', text: '<?php echo $err; ?>',
@ -1208,7 +1209,7 @@ if ($searchPage) {
$main_sec = $sec; $main_sec = $sec;
} }
} else if ($sec == 'gextensions') { } else if ($sec == 'gextensions') {
$main_sec = get_parameter('extension_in_menu'); $main_sec = get_parameter('extension_in_menu');
if (empty($main_sec) === true) { if (empty($main_sec) === true) {
$main_sec = $sec; $main_sec = $sec;
} }
@ -1379,12 +1380,12 @@ if ($config['pure'] == 0) {
// Main pure. // Main pure.
} }
html_print_div( echo html_print_div(
['id' => 'wiz_container'], ['id' => 'wiz_container'],
true true
); );
html_print_div( echo html_print_div(
['id' => 'um_msg_receiver'], ['id' => 'um_msg_receiver'],
true true
); );
@ -1426,26 +1427,27 @@ require 'include/php_to_js_values.php';
?> ?>
<script type="text/javascript" language="javascript"> <script type="text/javascript" language="javascript">
// When there are less than 5 rows, all rows must be white // When there are less than 5 rows, all rows must be white
var theme = "<?php echo $config['style']; ?>"; var theme = "<?php echo $config['style']; ?>";
if(theme === 'pandora'){ if (theme === 'pandora') {
if($('table.info_table tr').length < 5){ if ($('table.info_table tr').length < 5) {
$('table.info_table tbody > tr').css('background-color', '#fff'); $('table.info_table tbody > tr').css('background-color', '#fff');
} }
} }
// When the user scrolls down 400px from the top of the document, show the // When the user scrolls down 400px from the top of the document, show the
// button. // button.
window.onscroll = function() {scrollFunction()}; window.onscroll = function() {
scrollFunction()
};
function scrollFunction() { function scrollFunction() {
if (document.body.scrollTop > 400 || document.documentElement.scrollTop > 400) { if (document.body.scrollTop > 400 || document.documentElement.scrollTop > 400) {
if(document.getElementById("top_btn")){ if (document.getElementById("top_btn")) {
document.getElementById("top_btn").style.display = "block"; document.getElementById("top_btn").style.display = "block";
} }
} else { } else {
if(document.getElementById("top_btn")){ if (document.getElementById("top_btn")) {
document.getElementById("top_btn").style.display = "none"; document.getElementById("top_btn").style.display = "none";
} }
} }
@ -1455,48 +1457,49 @@ require 'include/php_to_js_values.php';
function topFunction() { function topFunction() {
/* /*
* Safari. * Safari.
* document.body.scrollTop = 0; * document.body.scrollTop = 0;
* For Chrome, Firefox, IE and Opera. * For Chrome, Firefox, IE and Opera.
* document.documentElement.scrollTop = 0; * document.documentElement.scrollTop = 0;
*/ */
$("HTML, BODY").animate({ scrollTop: 0 }, 500); $("HTML, BODY").animate({
scrollTop: 0
}, 500);
} }
// Initial load of page. // Initial load of page.
$(document).ready(adjustFooter); $(document).ready(adjustFooter);
// Every resize of window. // Every resize of window.
$(window).resize(adjustFooter); $(window).resize(adjustFooter);
// Every show/hide call may need footer re-layout. // Every show/hide call may need footer re-layout.
(function() { (function() {
var oShow = jQuery.fn.show; var oShow = jQuery.fn.show;
var oHide = jQuery.fn.hide; var oHide = jQuery.fn.hide;
jQuery.fn.show = function () { jQuery.fn.show = function() {
var rv = oShow.apply(this, arguments); var rv = oShow.apply(this, arguments);
adjustFooter(); adjustFooter();
return rv; return rv;
}; };
jQuery.fn.hide = function () { jQuery.fn.hide = function() {
var rv = oHide.apply(this, arguments); var rv = oHide.apply(this, arguments);
adjustFooter(); adjustFooter();
return rv; return rv;
}; };
})(); })();
function first_time_identification () { function first_time_identification() {
jQuery.post ("ajax.php", jQuery.post("ajax.php", {
{
"page": "general/register", "page": "general/register",
"load_wizards": 'initial' "load_wizards": 'initial'
}, },
function (data) { function(data) {
$('#wiz_container').empty () $('#wiz_container').empty()
.html (data); .html(data);
run_configuration_wizard (); run_configuration_wizard();
}, },
"html" "html"
); );
@ -1512,42 +1515,42 @@ require 'include/php_to_js_values.php';
); );
return; return;
} }
jQuery.post ("ajax.php", jQuery.post("ajax.php", {
{
"page": "godmode/setup/setup_notifications", "page": "godmode/setup/setup_notifications",
"get_notification": 1, "get_notification": 1,
"id": match[2] "id": match[2]
}, },
function (data) { function(data) {
notifications_hide(); notifications_hide();
try { try {
var json = JSON.parse(data); var json = JSON.parse(data);
$('#um_msg_receiver') $('#um_msg_receiver')
.empty () .empty()
.html (json.mensaje); .html(json.mensaje);
$('#um_msg_receiver').prop('title', json.subject); $('#um_msg_receiver').prop('title', json.subject);
// Launch modal. // Launch modal.
$("#um_msg_receiver").dialog({ $("#um_msg_receiver").dialog({
resizable: true, resizable: true,
draggable: true, draggable: true,
modal: true, modal: true,
width: 800, width: 800,
buttons: [ height: 600,
{ buttons: [{
text: "OK", text: "OK",
click: function() { click: function() {
$( this ).dialog( "close" ); $(this).dialog("close");
}
} }
], }],
overlay: { overlay: {
opacity: 0.5, opacity: 0.5,
background: "black" background: "black"
}, },
closeOnEscape: false, closeOnEscape: false,
open: function(event, ui) { $(".ui-dialog-titlebar-close").hide(); } open: function(event, ui) {
$(".ui-dialog-titlebar-close").hide();
}
}); });
$(".ui-widget-overlay").css("background", "#000"); $(".ui-widget-overlay").css("background", "#000");
@ -1563,30 +1566,30 @@ require 'include/php_to_js_values.php';
); );
} }
//Dynamically assign footer position and width. //Dynamically assign footer position and width.
function adjustFooter() { function adjustFooter() {
/* /*
if (document.readyState !== 'complete' || $('#container').position() == undefined) { if (document.readyState !== 'complete' || $('#container').position() == undefined) {
return; return;
}
// minimum top value (upper limit) for div#foot
var ulim = $('#container').position().top + $('#container').outerHeight(true);
// window height. $(window).height() returns wrong value on Opera and Google Chrome.
var wh = document.documentElement.clientHeight;
// save div#foot's height for latter use
var h = $('#foot').height();
// new top value for div#foot
var t = (ulim + $('#foot').outerHeight() > wh) ? ulim : wh - $('#foot').outerHeight();
/*
if ($('#foot').position().top != t) {
$('#foot').css({ position: "absolute", top: t, left: $('#foot').offset().left});
$('#foot').height(h);
}
if ($('#foot').width() != $(window).width()) {
$('#foot').width($(window).width());
}
*/
} }
// minimum top value (upper limit) for div#foot
var ulim = $('#container').position().top + $('#container').outerHeight(true);
// window height. $(window).height() returns wrong value on Opera and Google Chrome.
var wh = document.documentElement.clientHeight;
// save div#foot's height for latter use
var h = $('#foot').height();
// new top value for div#foot
var t = (ulim + $('#foot').outerHeight() > wh) ? ulim : wh - $('#foot').outerHeight();
/*
if ($('#foot').position().top != t) {
$('#foot').css({ position: "absolute", top: t, left: $('#foot').offset().left});
$('#foot').height(h);
}
if ($('#foot').width() != $(window).width()) {
$('#foot').width($(window).width());
}
*/
}
</script> </script>
<?php <?php
if (__PAN_XHPROF__ === 1) { if (__PAN_XHPROF__ === 1) {

View File

@ -129,7 +129,7 @@
<div style='height: 10px'> <div style='height: 10px'>
<?php <?php
$version = '7.0NG.762'; $version = '7.0NG.762';
$build = '220620'; $build = '220621';
$banner = "v$version Build $build"; $banner = "v$version Build $build";
error_reporting(0); error_reporting(0);

View File

@ -265,6 +265,27 @@ if ($has_remote_conf) {
['class' => 'invert_filter'] ['class' => 'invert_filter']
); );
$remote_cfg .= __('Remote configuration enabled').'</p>'; $remote_cfg .= __('Remote configuration enabled').'</p>';
$satellite_server = (int) db_get_value_filter(
'satellite_server',
'tagente',
['id_agente' => $id_agente]
);
if (empty($satellite_server) === false) {
$satellite_name = db_get_value_filter(
'name',
'tserver',
['id_server' => $satellite_server]
);
$remote_cfg .= '<p>'.html_print_image(
'images/satellite.png',
true,
['class' => 'invert_filter']
);
$remote_cfg .= $satellite_name.'</p>';
}
} else { } else {
$remote_cfg = ''; $remote_cfg = '';
} }

View File

@ -2,20 +2,28 @@
/** /**
* Netflow live view * Netflow live view
* *
* @package Pandora FMS open. * @category Netflow
* @subpackage UI file. * @package Pandora FMS
* @subpackage Community
* @version 1.0.0
* @license See below
* *
* Pandora FMS - http://pandorafms.com * ______ ___ _______ _______ ________
* ================================================== * | __ \.-----.--.--.--| |.-----.----.-----. | ___| | | __|
* Copyright (c) 2005-2021 Artica Soluciones Tecnologicas * | __/| _ | | _ || _ | _| _ | | ___| |__ |
* |___| |___._|__|__|_____||_____|__| |___._| |___| |__|_|__|_______|
*
* ============================================================================
* Copyright (c) 2005-2022 Artica Soluciones Tecnologicas
* Please see http://pandorafms.org for full contribution list * Please see http://pandorafms.org for full contribution list
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; version 2 * as published by the Free Software Foundation for version 2.
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* ============================================================================
*/ */
global $config; global $config;
@ -40,7 +48,7 @@ if (! check_acl($config['id_user'], 0, 'AR') && ! check_acl($config['id_user'],
$pure = get_parameter('pure', 0); $pure = get_parameter('pure', 0);
// Ajax callbacks. // Ajax callbacks.
if (is_ajax()) { if (is_ajax() === true) {
$get_filter_type = get_parameter('get_filter_type', 0); $get_filter_type = get_parameter('get_filter_type', 0);
$get_filter_values = get_parameter('get_filter_values', 0); $get_filter_values = get_parameter('get_filter_values', 0);
@ -117,7 +125,7 @@ $draw = get_parameter('draw_button', '');
$save = get_parameter('save_button', ''); $save = get_parameter('save_button', '');
$update = get_parameter('update_button', ''); $update = get_parameter('update_button', '');
if (!is_metaconsole()) { if (is_metaconsole() === false) {
// Header. // Header.
ui_print_page_header( ui_print_page_header(
__('Netflow live view'), __('Netflow live view'),
@ -505,7 +513,7 @@ if (is_metaconsole()) {
echo '</form>'; echo '</form>';
if ($draw != '') { if (empty($draw) === false) {
// Draw. // Draw.
echo '<br/>'; echo '<br/>';
@ -513,6 +521,11 @@ if (is_metaconsole()) {
if ($netflow_disable_custom_lvfilters && $filter_selected == 0) { if ($netflow_disable_custom_lvfilters && $filter_selected == 0) {
ui_print_error_message(__('No filter selected')); ui_print_error_message(__('No filter selected'));
} else { } else {
// Hidden input for handle properly the text colors.
html_print_input_hidden(
'selected_style_theme',
$config['style']
);
// Draw the netflow chart. // Draw the netflow chart.
echo netflow_draw_item( echo netflow_draw_item(
$start_date, $start_date,

View File

@ -3,7 +3,7 @@
# #
%define name pandorafms_console %define name pandorafms_console
%define version 7.0NG.762 %define version 7.0NG.762
%define release 220620 %define release 220621
# User and Group under which Apache is running # User and Group under which Apache is running
%define httpd_name httpd %define httpd_name httpd

View File

@ -3,7 +3,7 @@
# #
%define name pandorafms_console %define name pandorafms_console
%define version 7.0NG.762 %define version 7.0NG.762
%define release 220620 %define release 220621
# User and Group under which Apache is running # User and Group under which Apache is running
%define httpd_name httpd %define httpd_name httpd

View File

@ -3,7 +3,7 @@
# #
%define name pandorafms_console %define name pandorafms_console
%define version 7.0NG.762 %define version 7.0NG.762
%define release 220620 %define release 220621
%define httpd_name httpd %define httpd_name httpd
# User and Group under which Apache is running # User and Group under which Apache is running
%define httpd_name apache2 %define httpd_name apache2

View File

@ -88,6 +88,7 @@ CREATE TABLE IF NOT EXISTS `tagente` (
`alias_as_name` TINYINT NOT NULL DEFAULT 0, `alias_as_name` TINYINT NOT NULL DEFAULT 0,
`safe_mode_module` INT UNSIGNED NOT NULL DEFAULT 0, `safe_mode_module` INT UNSIGNED NOT NULL DEFAULT 0,
`cps` INT NOT NULL DEFAULT 0, `cps` INT NOT NULL DEFAULT 0,
`satellite_server` INT NOT NULL DEFAULT 0,
PRIMARY KEY (`id_agente`), PRIMARY KEY (`id_agente`),
KEY `nombre` (`nombre`(255)), KEY `nombre` (`nombre`(255)),
KEY `direccion` (`direccion`), KEY `direccion` (`direccion`),
@ -3367,6 +3368,7 @@ CREATE TABLE IF NOT EXISTS `tmetaconsole_agent` (
`alias_as_name` TINYINT NOT NULL DEFAULT 0, `alias_as_name` TINYINT NOT NULL DEFAULT 0,
`safe_mode_module` INT UNSIGNED NOT NULL DEFAULT 0, `safe_mode_module` INT UNSIGNED NOT NULL DEFAULT 0,
`cps` INT NOT NULL DEFAULT 0, `cps` INT NOT NULL DEFAULT 0,
`satellite_server` INT NOT NULL DEFAULT 0,
PRIMARY KEY (`id_agente`), PRIMARY KEY (`id_agente`),
KEY `nombre` (`nombre`(255)), KEY `nombre` (`nombre`(255)),
KEY `direccion` (`direccion`), KEY `direccion` (`direccion`),

View File

@ -1,5 +1,5 @@
package: pandorafms-server package: pandorafms-server
Version: 7.0NG.762-220620 Version: 7.0NG.762-220621
Architecture: all Architecture: all
Priority: optional Priority: optional
Section: admin Section: admin

View File

@ -14,7 +14,7 @@
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details. # GNU General Public License for more details.
pandora_version="7.0NG.762-220620" pandora_version="7.0NG.762-220621"
package_cpan=0 package_cpan=0
package_pandora=1 package_pandora=1

View File

@ -46,7 +46,7 @@ our @EXPORT = qw(
# version: Defines actual version of Pandora Server for this module only # version: Defines actual version of Pandora Server for this module only
my $pandora_version = "7.0NG.762"; my $pandora_version = "7.0NG.762";
my $pandora_build = "220620"; my $pandora_build = "220621";
our $VERSION = $pandora_version." ".$pandora_build; our $VERSION = $pandora_version." ".$pandora_build;
# Setup hash # Setup hash

View File

@ -3001,10 +3001,10 @@ defined also the parent is updated.
=cut =cut
########################################################################## ##########################################################################
sub pandora_update_agent ($$$$$$$;$$) { sub pandora_update_agent ($$$$$$$;$$$) {
my ($pa_config, $agent_timestamp, $agent_id, $os_version, my ($pa_config, $agent_timestamp, $agent_id, $os_version,
$agent_version, $agent_interval, $dbh, $timezone_offset, $agent_version, $agent_interval, $dbh, $timezone_offset,
$parent_agent_id) = @_; $parent_agent_id, $satellite_server_id) = @_;
# No access update for data without interval. # No access update for data without interval.
# Single modules from network server, for example. This could be very Heavy for Pandora FMS # Single modules from network server, for example. This could be very Heavy for Pandora FMS
@ -3025,6 +3025,7 @@ sub pandora_update_agent ($$$$$$$;$$) {
'os_version' => $os_version, 'os_version' => $os_version,
'timezone_offset' => $timezone_offset, 'timezone_offset' => $timezone_offset,
'id_parent' => $parent_agent_id, 'id_parent' => $parent_agent_id,
'satellite_server' => $satellite_server_id
}); });
db_do ($dbh, "UPDATE tagente SET $set WHERE id_agente = ?", @{$values}, $agent_id); db_do ($dbh, "UPDATE tagente SET $set WHERE id_agente = ?", @{$values}, $agent_id);

View File

@ -452,6 +452,16 @@ sub process_xml_data ($$$$$) {
logger($pa_config, "Error retrieving information for agent ID $agent_id",10); logger($pa_config, "Error retrieving information for agent ID $agent_id",10);
return; return;
} }
# Get the ID of the Satellite Server if available.
my $satellite_server_id = 0;
if (defined($data->{'satellite_server'})) {
$satellite_server_id = get_server_id($dbh, $data->{'satellite_server'}, SATELLITESERVER);
if ($satellite_server_id < 0) {
logger($pa_config, "Satellite Server '" . $data->{'satellite_server'} . "' does not exist.", 10);
$satellite_server_id = 0;
}
}
# Check if agent is disabled and return if it's disabled. Disabled agents doesnt process data # Check if agent is disabled and return if it's disabled. Disabled agents doesnt process data
# in order to avoid not only events, also possible invalid data coming from agents. # in order to avoid not only events, also possible invalid data coming from agents.
@ -536,7 +546,7 @@ sub process_xml_data ($$$$$) {
} }
# Update agent information # Update agent information
pandora_update_agent($pa_config, $timestamp, $agent_id, $os_version, $agent_version, $interval, $dbh, $timezone_offset, $parent_id); pandora_update_agent($pa_config, $timestamp, $agent_id, $os_version, $agent_version, $interval, $dbh, $timezone_offset, $parent_id, $satellite_server_id);
# Update GIS data # Update GIS data
if ($pa_config->{'activate_gis'} != 0 && $agent->{'update_gis_data'} == 1) { if ($pa_config->{'activate_gis'} != 0 && $agent->{'update_gis_data'} == 1) {

View File

@ -34,7 +34,7 @@ our @ISA = qw(Exporter);
# version: Defines actual version of Pandora Server for this module only # version: Defines actual version of Pandora Server for this module only
my $pandora_version = "7.0NG.762"; my $pandora_version = "7.0NG.762";
my $pandora_build = "220620"; my $pandora_build = "220621";
our $VERSION = $pandora_version." ".$pandora_build; our $VERSION = $pandora_version." ".$pandora_build;
our %EXPORT_TAGS = ( 'all' => [ qw() ] ); our %EXPORT_TAGS = ( 'all' => [ qw() ] );

View File

@ -3,7 +3,7 @@
# #
%define name pandorafms_server %define name pandorafms_server
%define version 7.0NG.762 %define version 7.0NG.762
%define release 220620 %define release 220621
Summary: Pandora FMS Server Summary: Pandora FMS Server
Name: %{name} Name: %{name}

View File

@ -3,7 +3,7 @@
# #
%define name pandorafms_server %define name pandorafms_server
%define version 7.0NG.762 %define version 7.0NG.762
%define release 220620 %define release 220621
Summary: Pandora FMS Server Summary: Pandora FMS Server
Name: %{name} Name: %{name}

View File

@ -9,7 +9,7 @@
# ********************************************************************** # **********************************************************************
PI_VERSION="7.0NG.762" PI_VERSION="7.0NG.762"
PI_BUILD="220620" PI_BUILD="220621"
MODE=$1 MODE=$1
if [ $# -gt 1 ]; then if [ $# -gt 1 ]; then

View File

@ -35,7 +35,7 @@ use PandoraFMS::Config;
use PandoraFMS::DB; use PandoraFMS::DB;
# version: define current version # version: define current version
my $version = "7.0NG.762 Build 220620"; my $version = "7.0NG.762 Build 220621";
# Pandora server configuration # Pandora server configuration
my %conf; my %conf;

View File

@ -36,7 +36,7 @@ use Encode::Locale;
Encode::Locale::decode_argv; Encode::Locale::decode_argv;
# version: define current version # version: define current version
my $version = "7.0NG.762 Build 220620"; my $version = "7.0NG.762 Build 220621";
# save program name for logging # save program name for logging
my $progname = basename($0); my $progname = basename($0);