Merge remote-tracking branch 'origin/develop' into ent-8912-Problemas-en-recuperación-alertas-de-evento---Necesaria-refactorizacion

This commit is contained in:
Ramon Novoa 2022-06-22 11:45:27 +02:00
commit 59ea9a716e
56 changed files with 55606 additions and 54897 deletions

View File

@ -1,5 +1,5 @@
package: pandorafms-agent-unix package: pandorafms-agent-unix
Version: 7.0NG.762-220620 Version: 7.0NG.762-220622
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-220622"
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 => '220622';
# 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 220622
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 220622
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="220622"
OS_NAME=`uname -s` OS_NAME=`uname -s`
FORCE=0 FORCE=0

View File

@ -186,7 +186,7 @@ UpgradeApplicationID
{} {}
Version Version
{220620} {220622}
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 220622")
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 220622))"
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-220622
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-220622"
package_pear=0 package_pear=0
package_pandora=1 package_pandora=1

View File

@ -35,7 +35,10 @@ ALTER TABLE `treset_pass` MODIFY COLUMN `id_user` VARCHAR(255) NOT NULL DEFAULT
ALTER TABLE `tuser_task_scheduled` MODIFY COLUMN `id_usuario` VARCHAR(255) NOT NULL DEFAULT '0'; ALTER TABLE `tuser_task_scheduled` MODIFY COLUMN `id_usuario` VARCHAR(255) NOT NULL DEFAULT '0';
ALTER TABLE `tbackup` MODIFY COLUMN `id_user` VARCHAR(255) DEFAULT ''; 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 NOT NULL DEFAULT 0;
ALTER TABLE `tservice` ADD COLUMN `asynchronous` TINYINT NOT NULL DEFAULT 0;
ALTER TABLE `tservice` ADD COLUMN `rca` TEXT;
ALTER TABLE `tdashboard` MODIFY `name` TEXT NOT NULL DEFAULT ''; ALTER TABLE `tdashboard` MODIFY `name` TEXT NOT NULL DEFAULT '';
ALTER TABLE `tevent_alert` ADD COLUMN `field1_recovery` TEXT AFTER `recovery_notify`; ALTER TABLE `tevent_alert` ADD COLUMN `field1_recovery` TEXT AFTER `recovery_notify`;
@ -47,6 +50,8 @@ ALTER TABLE `tevent_alert` ADD COLUMN `field8_recovery` TEXT AFTER `field7_recov
ALTER TABLE `tevent_alert` ADD COLUMN `field9_recovery` TEXT AFTER `field8_recovery`; ALTER TABLE `tevent_alert` ADD COLUMN `field9_recovery` TEXT AFTER `field8_recovery`;
ALTER TABLE `tevent_alert` ADD COLUMN `field10_recovery` TEXT AFTER `field9_recovery`; ALTER TABLE `tevent_alert` ADD COLUMN `field10_recovery` TEXT AFTER `field9_recovery`;
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",
@ -58,3 +63,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

@ -337,7 +337,7 @@ if (($create != '') || ($view != '')) {
$data = []; $data = [];
$data[0] = __('Name'); $data[0] = __('Name');
$data[1] = '<input type="text" name="form_name" size=100 value="'.$form_name.'">'; $data[1] = '<input type="text" class="text_input" name="form_name" size=100 value="'.$form_name.'">';
$table->colspan['plugin_name'][1] = 3; $table->colspan['plugin_name'][1] = 3;
$table->data['plugin_name'] = $data; $table->data['plugin_name'] = $data;
@ -399,7 +399,7 @@ if (($create != '') || ($view != '')) {
$data = []; $data = [];
$data[0] = __('Plugin command').ui_print_help_tip(__('Specify interpreter and plugin path. The server needs permissions to run it.'), true); $data[0] = __('Plugin command').ui_print_help_tip(__('Specify interpreter and plugin path. The server needs permissions to run it.'), true);
$data[1] = '<input type="text" name="form_execute" id="form_execute" class="command_component command_advanced_conf" size=100 value="'.$form_execute.'" '.$disabled.'>'; $data[1] = '<input type="text" name="form_execute" id="form_execute" class="command_component command_advanced_conf text_input" size=100 value="'.$form_execute.'" '.$disabled.'>';
if ($locked) { if ($locked) {
$data[1] .= html_print_image('images/lock_mc.png', true, ['class' => 'command_advanced_conf lock', 'class' => 'invert_filter']); $data[1] .= html_print_image('images/lock_mc.png', true, ['class' => 'command_advanced_conf lock', 'class' => 'invert_filter']);
} }
@ -411,7 +411,7 @@ if (($create != '') || ($view != '')) {
$data = []; $data = [];
$data[0] = __('Plug-in parameters'); $data[0] = __('Plug-in parameters');
$data[1] = '<input type="text" name="form_parameters" id="form_parameters" class="command_component command_advanced_conf" size=100 value="'.$parameters.'" '.$disabled.'>'; $data[1] = '<input type="text" name="form_parameters" id="form_parameters" class="command_component command_advanced_conf text_input" size=100 value="'.$parameters.'" '.$disabled.'>';
if ($locked) { if ($locked) {
$data[1] .= html_print_image('images/lock_mc.png', true, ['class' => 'command_advanced_conf lock', 'class' => 'invert_filter']); $data[1] .= html_print_image('images/lock_mc.png', true, ['class' => 'command_advanced_conf lock', 'class' => 'invert_filter']);
} }
@ -484,13 +484,13 @@ if (($create != '') || ($view != '')) {
$datam = []; $datam = [];
$datam[0] = __('Description')."<span class='normal_weight'> ($macro_name)</span>"; $datam[0] = __('Description')."<span class='normal_weight'> ($macro_name)</span>";
$datam[0] .= html_print_input_hidden($macro_name_name, $macro_name, true); $datam[0] .= html_print_input_hidden($macro_name_name, $macro_name, true);
$datam[1] = html_print_input_text_extended($macro_desc_name, $macro_desc_value, 'text-'.$macro_desc_name, '', 30, 255, $locked, '', "class='command_macro'", true); $datam[1] = html_print_input_text_extended($macro_desc_name, $macro_desc_value, 'text-'.$macro_desc_name, '', 30, 255, $locked, '', "class='command_macro text_input'", true);
if ($locked) { if ($locked) {
$datam[1] .= html_print_image('images/lock_mc.png', true, ['class' => 'command_macro lock', 'class' => 'invert_filter']); $datam[1] .= html_print_image('images/lock_mc.png', true, ['class' => 'command_macro lock', 'class' => 'invert_filter']);
} }
$datam[2] = __('Default value')."<span class='normal_weight'> ($macro_name)</span>"; $datam[2] = __('Default value')."<span class='normal_weight'> ($macro_name)</span>";
$datam[3] = html_print_input_text_extended($macro_value_name, $macro_value_value, 'text-'.$macro_value_name, '', 30, 255, $locked, '', "class='command_component command_macro'", true); $datam[3] = html_print_input_text_extended($macro_value_name, $macro_value_value, 'text-'.$macro_value_name, '', 30, 255, $locked, '', "class='command_component command_macro text_input'", true);
if ($locked) { if ($locked) {
$datam[3] .= html_print_image('images/lock_mc.png', true, ['class' => 'command_macro lock', 'class' => 'invert_filter']); $datam[3] .= html_print_image('images/lock_mc.png', true, ['class' => 'command_macro lock', 'class' => 'invert_filter']);
} }

View File

@ -114,11 +114,11 @@ if ((isset($_GET['form_add'])) or (isset($_GET['form_edit']))) {
echo "'>"; echo "'>";
echo '<tr> echo '<tr>
<td class="datos">'.__('Link name').'</td> <td class="datos">'.__('Link name').'</td>
<td class="datos"><input type="text" name="name" size="35" value="'.$nombre.'"></td>'; <td class="datos"><input type="text" class="text_input" name="name" size="50" value="'.$nombre.'"></td>';
echo '</tr><tr> echo '</tr><tr>
<td class="datos2">'.__('Link').'</td> <td class="datos2">'.__('Link').'</td>
<td class="datos2"> <td class="datos2">
<input type="text" name="link" size="50" value="'.$link.'"></td>'; <input type="text" class="text_input" name="link" size="50" value="'.$link.'"></td>';
echo '</tr>'; echo '</tr>';
echo '</table>'; echo '</table>';
echo "<table width='100%'>"; echo "<table width='100%'>";

View File

@ -181,7 +181,7 @@ if ((isset($_GET['form_add'])) || (isset($_GET['form_edit']))) {
$data = []; $data = [];
$data[0] = __('Subject').'<br>'; $data[0] = __('Subject').'<br>';
$data[0] .= '<input type="text" name="subject" size="35" value="'.$subject.'" >'; $data[0] .= '<input type="text" class="text_input" name="subject" size="35" value="'.$subject.'" >';
$data[1] = __('Group').'<br>'; $data[1] = __('Group').'<br>';
$data[1] .= '<div class="w250px">'; $data[1] .= '<div class="w250px">';

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 = 'PC220622';
$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

@ -14,7 +14,7 @@
* |___| |___._|__|__|_____||_____|__| |___._| |___| |__|_|__|_______| * |___| |___._|__|__|_____||_____|__| |___._| |___| |__|_|__|_______|
* *
* ============================================================================ * ============================================================================
* 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
@ -2688,10 +2688,10 @@ function events_print_event_table(
// Get class name, for the link color, etc. // Get class name, for the link color, etc.
$data[$i] = "<a href='index.php?sec=estado&sec2=operation/agentes/ver_agente&id_agente=".$event['id_agente']."'>".agents_get_alias($event['id_agente']).'</A>'; $data[$i] = "<a href='index.php?sec=estado&sec2=operation/agentes/ver_agente&id_agente=".$event['id_agente']."'>".agents_get_alias($event['id_agente']).'</A>';
// For System or SNMP generated alerts. // For System or SNMP generated alerts.
} else if ($event['event_type'] == 'system') { } else if ($event['event_type'] === 'system') {
$data[$i] = __('System'); $data[$i] = __('System');
} else { } else {
$data[$i] = __('Alert').'SNMP'; $data[$i] = '';
} }
$i++; $i++;

View File

@ -2690,7 +2690,9 @@ function html_print_input_password(
} }
if ($class) { if ($class) {
$attr['class'] = $class; $attr['class'] = $class.' '.'password_input';
} else {
$attr['class'] = 'password_input';
} }
if ($disabled === false) { if ($disabled === false) {
@ -2761,7 +2763,9 @@ function html_print_input_text(
} }
if ($class != '') { if ($class != '') {
$attr['class'] = $class; $attr['class'] = $class.' '.'text_input';
} else {
$attr['class'] = 'text_input';
} }
if ($onChange != '') { if ($onChange != '') {
@ -4554,7 +4558,7 @@ function html_print_autocomplete_modules(
100, 100,
false, false,
'', '',
['style' => 'background: url('.$module_icon.') no-repeat right; '.$text_color.''] ['style' => 'border: none; padding: 2px 5px; margin-bottom: 4px; border-bottom: 1px solid #ccc; border-radius: 0; background: url('.$module_icon.') no-repeat right; '.$text_color.'']
); );
html_print_input_hidden($name.'_hidden', $id_agent_module); html_print_input_hidden($name.'_hidden', $id_agent_module);

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

@ -5882,7 +5882,7 @@ function ui_print_agent_autocomplete_input($parameters)
} }
$attrs = []; $attrs = [];
$attrs['style'] = 'padding-right: 20px; background: url('.$icon_image.') no-repeat right; '.$text_color.''; $attrs['style'] = 'padding-right: 20px; padding: 2px 5px; margin-bottom: 4px; border: none; border-bottom: 1px solid #ccc; border-radius: 0; background: url('.$icon_image.') no-repeat right; '.$text_color.'';
if (!$disabled_javascript_on_blur_function) { if (!$disabled_javascript_on_blur_function) {
$attrs['onblur'] = $javascript_on_blur_function_name.'()'; $attrs['onblur'] = $javascript_on_blur_function_name.'()';

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;" +

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

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

@ -9054,3 +9054,21 @@ div#err_msg_centralised {
padding-top: 15px; padding-top: 15px;
} }
} }
.text_input {
background-color: transparent !important;
border: none;
border-radius: 0;
border-bottom: 1px solid #ccc;
margin-bottom: 4px;
padding: 2px 5px;
}
.password_input {
background-color: transparent !important;
border: none !important;
border-radius: 0 !important;
border-bottom: 1px solid #ccc !important;
margin-bottom: 4px !important;
padding: 2px 5px !important;
}

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 = '220622';
$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

@ -2311,7 +2311,7 @@ function process_datatables_item(item) {
item.evento = evn; item.evento = evn;
/* Group name */ /* Group name */
if (item.id_grupo == "0") { if (typeof item.id_grupo === 'undefined' || item.id_grupo == "0") {
item.id_grupo = "<?php echo __('All'); ?>"; item.id_grupo = "<?php echo __('All'); ?>";
} else { } else {
item.id_grupo = item.group_name; item.id_grupo = item.group_name;
@ -2331,7 +2331,7 @@ function process_datatables_item(item) {
} }
})(item.custom_data); })(item.custom_data);
if (item_custom_data_obj !== false) { if (item_custom_data_obj !== false && item_custom_data_obj !== null) {
for (const [attr_name, val] of Object.entries(item_custom_data_obj)) { for (const [attr_name, val] of Object.entries(item_custom_data_obj)) {
custom_data_str += attr_name + ' = ' + val + '<br>'; custom_data_str += attr_name + ' = ' + val + '<br>';
} }

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 220622
# 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 220622
# 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 220622
%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`),
@ -2818,6 +2819,8 @@ CREATE TABLE IF NOT EXISTS `tservice` (
`evaluate_sla` INT NOT NULL DEFAULT 0, `evaluate_sla` INT NOT NULL DEFAULT 0,
`is_favourite` TINYINT NOT NULL DEFAULT 0, `is_favourite` TINYINT NOT NULL DEFAULT 0,
`enable_sunburst` TINYINT NOT NULL DEFAULT 0, `enable_sunburst` TINYINT NOT NULL DEFAULT 0,
`asynchronous` TINYINT NOT NULL DEFAULT 0,
`rca` TEXT,
PRIMARY KEY (`id`) PRIMARY KEY (`id`)
) ENGINE=InnoDB ) ENGINE=InnoDB
COMMENT = 'Table to define services to monitor' COMMENT = 'Table to define services to monitor'
@ -3476,6 +3479,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-220622
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-220622"
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 = "220622";
our $VERSION = $pandora_version." ".$pandora_build; our $VERSION = $pandora_version." ".$pandora_build;
# Setup hash # Setup hash

View File

@ -3005,10 +3005,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
@ -3029,6 +3029,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 = "220622";
our $VERSION = $pandora_version." ".$pandora_build; our $VERSION = $pandora_version." ".$pandora_build;
our %EXPORT_TAGS = ( 'all' => [ qw() ] ); our %EXPORT_TAGS = ( 'all' => [ qw() ] );

View File

@ -40,6 +40,7 @@ use PandoraFMS::ProducerConsumerServer;
# Inherits from PandoraFMS::ProducerConsumerServer # Inherits from PandoraFMS::ProducerConsumerServer
our @ISA = qw(PandoraFMS::ProducerConsumerServer); our @ISA = qw(PandoraFMS::ProducerConsumerServer);
our @EXPORT = qw(start_snmptrapd);
# Global variables # Global variables
my @TaskQueue :shared; my @TaskQueue :shared;
@ -442,26 +443,29 @@ sub start_snmptrapd ($) {
# Manual start of snmptrapd # Manual start of snmptrapd
if ($config->{'snmp_trapd'} eq 'manual') { if ($config->{'snmp_trapd'} eq 'manual') {
logger ($config, "No SNMP trap daemon configured. Start snmptrapd manually.", 1); my $noSNMPTrap = "No SNMP trap daemon configured. Start snmptrapd manually.";
print_message ($config, " [*] No SNMP trap daemon configured. Start snmptrapd manually.", 1); logger ($config, $noSNMPTrap, 1);
print_message ($config, " [*] $noSNMPTrap", 1);
if (! -f $config->{'snmp_logfile'}) { if (! -f $config->{'snmp_logfile'}) {
logger ($config, "SNMP log file " . $config->{'snmp_logfile'} . " not found.", 1); my $noLogFile = "SNMP log file " . $config->{'snmp_logfile'} . " not found.";
print_message ($config, " [E] SNMP log file " . $config->{'snmp_logfile'} . " not found.", 1); logger ($config, $noLogFile, 1);
print_message ($config, " [E] $noLogFile", 1);
return 1; return 1;
} }
return 0; return 0;
} }
if ( -e $pid_file && open (PIDFILE, $pid_file)) { if ( -e $pid_file && open (PIDFILE, $pid_file)) {
my $pid = <PIDFILE> + 0; my $pid = <PIDFILE> + 0;
close PIDFILE; close PIDFILE;
# Check if snmptrapd is running # Check if snmptrapd is running
if ($snmptrapd_running = kill (0, $pid)) { if ($snmptrapd_running = kill (0, $pid)) {
logger ($config, "snmptrapd (pid $pid) is already running, attempting to kill it...", 1); my $alreadyRunning = "snmptrapd (pid $pid) is already running, attempting to kill it...";
print_message ($config, "snmptrapd (pid $pid) is already running, attempting to kill it...", 1); logger ($config, $alreadyRunning, 1);
print_message ($config, " [*] $alreadyRunning ", 1);
kill (9, $pid); kill (9, $pid);
} }
} }
@ -471,17 +475,20 @@ sub start_snmptrapd ($) {
# Select agent-addr field of the PDU or PDU source address for V1 traps # Select agent-addr field of the PDU or PDU source address for V1 traps
my $address_format = ($config->{'snmp_pdu_address'} eq '0' ? '%a' : '%b'); my $address_format = ($config->{'snmp_pdu_address'} eq '0' ? '%a' : '%b');
my $snmptrapd_args = ' -t -On -n' . $snmp_ignore_authfailure . ' -Lf ' . $config->{'snmp_logfile'} . ' -p ' . $pid_file; my $snmptrapd_args = ' -t -On -n' . $snmp_ignore_authfailure . ' -Lf ' . $config->{'snmp_logfile'} . ' -p ' . $pid_file;
$snmptrapd_args .= ' --format1=SNMPv1[**]%4y-%02.2m-%l[**]%02.2h:%02.2j:%02.2k[**]' . $address_format . '[**]%N[**]%w[**]%W[**]%q[**]%v\\\n'; $snmptrapd_args .= ' --format1=SNMPv1[**]%4y-%02.2m-%l[**]%02.2h:%02.2j:%02.2k[**]' . $address_format . '[**]%N[**]%w[**]%W[**]%q[**]%v\\\n';
$snmptrapd_args .= ' --format2=SNMPv2[**]%4y-%02.2m-%l[**]%02.2h:%02.2j:%02.2k[**]%b[**]%v\\\n'; $snmptrapd_args .= ' --format2=SNMPv2[**]%4y-%02.2m-%l[**]%02.2h:%02.2j:%02.2k[**]%b[**]%v\\\n';
if (system ($config->{'snmp_trapd'} . $snmptrapd_args . " >$DEVNULL 2>&1") != 0) { if (system ($config->{'snmp_trapd'} . $snmptrapd_args . " >$DEVNULL 2>&1") != 0) {
logger ($config, " [E] Could not start snmptrapd.", 1); my $showError = "Could not start snmptrapd.";
print_message ($config, " [E] Could not start snmptrapd.", 1); logger ($config, $showError, 1);
print_message ($config, " [E] $showError ", 1);
return 1; return 1;
} }
print_message ($config, " [*] snmptrapd started and running.", 1);
return 0; return 0;
} }

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 220622
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 220622
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="220622"
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 220622";
# Pandora server configuration # Pandora server configuration
my %conf; my %conf;

View File

@ -49,11 +49,15 @@
} }
/var/log/pandora/pandora_snmptrap.log { /var/log/pandora/pandora_snmptrap.log {
su pandora apache
weekly weekly
missingok missingok
size 500000 size 500000
rotate 1 rotate 1
maxage 30 maxage 30
notifempty notifempty
postrotate
pandora_manage /etc/pandora/pandora_server.conf --start_snmptrapd > /dev/null 2>/dev/null || true
endscript
copytruncate copytruncate
} }

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 220622";
# save program name for logging # save program name for logging
my $progname = basename($0); my $progname = basename($0);
@ -231,6 +231,7 @@ sub help_screen{
print "\nTOOLS:\n\n" unless $param ne ''; print "\nTOOLS:\n\n" unless $param ne '';
help_screen_line('--exec_from_file', '<file_path> <option_to_execute> <option_params>', "Execute any CLI option \n\t with macros from CSV file"); help_screen_line('--exec_from_file', '<file_path> <option_to_execute> <option_params>', "Execute any CLI option \n\t with macros from CSV file");
help_screen_line('--create_snmp_trap', '<name> <oid> <description> <severity>', "Create a new trap definition. \n\tSeverity 0 (Maintenance), 1(Info) , 2 (Normal), 3 (Warning), 4 (Critical), 5 (Minor) and 6 (Major)"); help_screen_line('--create_snmp_trap', '<name> <oid> <description> <severity>', "Create a new trap definition. \n\tSeverity 0 (Maintenance), 1(Info) , 2 (Normal), 3 (Warning), 4 (Critical), 5 (Minor) and 6 (Major)");
help_screen_line('--start_snmptrapd', '[no parameters needed]', "Start the snmptrap process or restart if it is running");
print "\nSETUP:\n\n" unless $param ne ''; print "\nSETUP:\n\n" unless $param ne '';
help_screen_line('--set_event_storm_protection', '<value>', "Enable (1) or disable (0) event \n\t storm protection"); help_screen_line('--set_event_storm_protection', '<value>', "Enable (1) or disable (0) event \n\t storm protection");
@ -279,7 +280,7 @@ sub api_call($$$;$$$$) {
my $ua = new LWP::UserAgent; my $ua = new LWP::UserAgent;
my $url = $pa_config->{"console_api_url"}; my $url = $pa_config->{"console_api_url"};
my $response = $ua->post($url, $params); my $response = $ua->post($url, $params);
if ($response->is_success) { if ($response->is_success) {
$content = $response->decoded_content(); $content = $response->decoded_content();
} }
@ -1188,6 +1189,16 @@ sub cli_enable_group() {
pandora_enable_group ($conf, $dbh, $id_group); pandora_enable_group ($conf, $dbh, $id_group);
} }
##############################################################################
# Start snmptrap process.
# Related option: --start_snmptrapd
##############################################################################
sub cli_start_snmptrapd() {
use PandoraFMS::SNMPServer;
print_log "[INFO] Starting snmptrap process. \n";
PandoraFMS::SNMPServer::start_snmptrapd(\%conf);
}
############################################################################## ##############################################################################
# Create an agent. # Create an agent.
# Related option: --created_agent # Related option: --created_agent
@ -7546,6 +7557,10 @@ sub pandora_manage_main ($$$) {
param_check($ltotal, 1); param_check($ltotal, 1);
cli_enable_group(); cli_enable_group();
} }
elsif ($param eq '--start_snmptrapd') {
#param_check($ltotal, 0);
cli_start_snmptrapd();
}
elsif ($param eq '--create_agent') { elsif ($param eq '--create_agent') {
param_check($ltotal, 8, 4); param_check($ltotal, 8, 4);
cli_create_agent(); cli_create_agent();