';
+ echo html_print_submit_button(
+ __('Save current filter'),
'save_filter',
false,
'class="sub upd float-right" onclick="save_new_filter();"',
@@ -1986,6 +2019,7 @@ if (check_login()) {
$('#save_filter_row1').show();
$('#save_filter_row2').show();
$('#update_filter_row1').hide();
+ $('#update_delete_row').hide();
// Filter save mode selector
$("[name='filter_mode']").click(function() {
if ($(this).val() == 'new') {
@@ -1993,12 +2027,14 @@ if (check_login()) {
$('#save_filter_row2').show();
$('#submit-save_filter').show();
$('#update_filter_row1').hide();
+ $('#update_delete_row').hide();
}
else {
$('#save_filter_row1').hide();
$('#save_filter_row2').hide();
$('#update_filter_row1').show();
$('#submit-save_filter').hide();
+ $('#update_delete_row').show();
}
});
$("#save-filter-select").dialog({
@@ -2189,6 +2225,69 @@ if (check_login()) {
$('#filter_loaded_span').html($('#filter_loaded_text').html() + ': ' + name_filter_update);
return false;
}
+
+ function save_delete_filter() {
+ var id_filter_update = $("#overwrite_filter").val();
+
+ jQuery.post ("",
+ {
+ "page" : "include/ajax/module",
+ "delete_monitor_filter" : 1,
+ "id" : $("#overwrite_filter").val(),
+ },
+ function (data) {
+ $(".info_box").hide();
+ if (data == 'ok') {
+ $(".info_box").filter(function(i, item) {
+ if ($(item).data('type_info_box') == "success_update_filter") {
+ return true;
+ }
+ else
+ return false;
+ }).show();
+ }
+ else {
+ $(".info_box").filter(function(i, item) {
+ if ($(item).data('type_info_box') == "error_create_filter") {
+ return true;
+ }
+ else
+ return false;
+ }).show();
+ }
+ });
+
+ // First remove all options of filters select.
+ $('#filter_id').find('option').remove().end();
+
+ // Add 'none' option.
+ $('#filter_id').append ($('
').html ( ).attr ("value", 0));
+
+ // Reload filters select.
+ jQuery.post ("",
+ {
+ "page" : "include/ajax/module",
+ "get_monitor_filters" : 1
+ },
+ function (data) {
+ jQuery.each (data, function (i, val) {
+ s = js_html_entity_decode(val);
+ if (i == id_filter_update) {
+ $('#filter_id').append ($('
').html (s).attr ("value", i));
+ }
+ else {
+ $('#filter_id').append ($('
').html (s).attr ("value", i));
+ }
+ });
+ },
+ "json"
+ );
+
+ // Close dialog
+ $('.ui-dialog-titlebar-close').trigger('click');
+
+ return false;
+ }
$(document).ready(function() {
show_save_filter();
diff --git a/pandora_console/include/class/AuditLog.class.php b/pandora_console/include/class/AuditLog.class.php
index 235652711c..4986cc399a 100644
--- a/pandora_console/include/class/AuditLog.class.php
+++ b/pandora_console/include/class/AuditLog.class.php
@@ -96,7 +96,10 @@ class AuditLog extends HTML
// Datatables list.
try {
$columns = [
- 'id_usuario',
+ [
+ 'text' => 'id_usuario',
+ 'class' => 'w50px',
+ ],
'accion',
'fecha',
'ip_origen',
@@ -116,11 +119,11 @@ class AuditLog extends HTML
$columns,
[
'text' => 'security',
- 'class' => 'w80px action_buttons show_security_info',
+ 'class' => 'w50px action_buttons show_security_info',
],
[
'text' => 'action',
- 'class' => 'w80px action_buttons show_extended_info',
+ 'class' => 'w50px action_buttons show_extended_info',
]
);
@@ -199,16 +202,28 @@ class AuditLog extends HTML
[
'label' => __('Free search').ui_print_help_tip(__('Search filter by User, Action, Date, Source IP or Comments fields content'), true),
'type' => 'text',
- 'class' => 'w200px',
+ 'class' => 'w150px',
'id' => 'filter_text',
'name' => 'filter_text',
],
[
- 'label' => __('Max. hours old'),
- 'type' => 'text',
- 'class' => 'w100px',
- 'id' => 'filter_period',
- 'name' => 'filter_period',
+ 'label' => __('Max. hours old'),
+ 'type' => 'select',
+ 'class' => 'w20px',
+ 'select2_enable' => true,
+ 'sort' => false,
+ 'selected' => 168,
+ 'fields' => [
+ 24 => __('1 day'),
+ 168 => __('7 days'),
+ 360 => __('15 days'),
+ 744 => __('1 month'),
+ 2160 => __('3 months'),
+ 4320 => __('6 months'),
+ 8760 => __('1 Year'),
+ ],
+ 'id' => 'filter_period',
+ 'name' => 'filter_period',
],
[
'label' => __('IP'),
@@ -223,7 +238,7 @@ class AuditLog extends HTML
'nothing' => __('All'),
'nothing_value' => '-1',
'sql' => 'SELECT DISTINCT(accion), accion AS text FROM tsesion',
- 'class' => 'mw250px',
+ 'class' => 'mw200px',
'id' => 'filter_type',
'name' => 'filter_type',
],
@@ -235,7 +250,7 @@ class AuditLog extends HTML
'sql' => 'SELECT id_user, id_user AS text FROM tusuario UNION SELECT "SYSTEM"
AS id_user, "SYSTEM" AS text UNION SELECT "N/A"
AS id_user, "N/A" AS text',
- 'class' => 'mw250px',
+ 'class' => 'mw200px',
'id' => 'filter_user',
'name' => 'filter_user',
],
@@ -346,9 +361,12 @@ class AuditLog extends HTML
).ui_print_timestamp($tmp->utimestamp, true);
if (enterprise_installed() === true) {
- $tmp->security = enterprise_hook('cell1EntepriseAudit', [$tmp->id_sesion]);
- $tmp->action = enterprise_hook('cell2EntepriseAudit', []);
- $tmp->extendedInfo = enterprise_hook('rowEnterpriseAudit', [$tmp->id_sesion]);
+ $extendedInfo = enterprise_hook('rowEnterpriseAudit', [$tmp->id_sesion]);
+ if (empty($extendedInfo) === false) {
+ $tmp->security = enterprise_hook('cell1EntepriseAudit', [$tmp->id_sesion]);
+ $tmp->action = enterprise_hook('cell2EntepriseAudit', []);
+ $tmp->extendedInfo = $extendedInfo;
+ }
}
$carry[] = $tmp;
diff --git a/pandora_console/include/class/ConsoleSupervisor.php b/pandora_console/include/class/ConsoleSupervisor.php
index bfa8e2fd68..4e14a73048 100644
--- a/pandora_console/include/class/ConsoleSupervisor.php
+++ b/pandora_console/include/class/ConsoleSupervisor.php
@@ -248,6 +248,11 @@ class ConsoleSupervisor
$this->checkAuditLogOldLocation();
+ /*
+ * Check if performance variables are corrects
+ */
+ $this->checkPerformanceVariables();
+
/*
* Checks if sync queue is longer than limits.
* NOTIF.SYNCQUEUE.LENGTH
@@ -258,14 +263,21 @@ class ConsoleSupervisor
$this->checkSyncQueueStatus();
}
- /*
- * Checkc agent missing libraries.
- * NOTIF.AGENT.LIBRARY
- */
+ /*
+ * Check number of agents is equals and more than 200.
+ * NOTIF.ACCESSSTASTICS.PERFORMANCE
+ */
+
+ $this->checkAccessStatisticsPerformance();
+
+ /*
+ * Checkc agent missing libraries.
+ * NOTIF.AGENT.LIBRARY
+ */
+
if ((bool) enterprise_installed() === true) {
$this->checkLibaryError();
}
-
}
@@ -517,6 +529,11 @@ class ConsoleSupervisor
$this->checkAuditLogOldLocation();
+ /*
+ * Check if performance variables are corrects
+ */
+ $this->checkPerformanceVariables();
+
/*
* Checks if sync queue is longer than limits.
* NOTIF.SYNCQUEUE.LENGTH
@@ -527,13 +544,107 @@ class ConsoleSupervisor
$this->checkSyncQueueStatus();
}
+ /*
+ * Check number of agents is equals and more than 200.
+ * NOTIF.ACCESSSTASTICS.PERFORMANCE
+ */
+
+ $this->checkAccessStatisticsPerformance();
+
/*
* Checkc agent missing libraries.
* NOTIF.AGENT.LIBRARY
*/
+
if ((bool) enterprise_installed() === true) {
$this->checkLibaryError();
}
+
+ }
+
+
+ /**
+ * Check if performance variables are corrects
+ *
+ * @return void
+ */
+ public function checkPerformanceVariables()
+ {
+ global $config;
+
+ $names = [
+ 'event_purge' => 'Max. days before events are deleted',
+ 'trap_purge' => 'Max. days before traps are deleted',
+ 'audit_purge' => 'Max. days before audited events are deleted',
+ 'string_purge' => 'Max. days before string data is deleted',
+ 'gis_purge' => 'Max. days before GIS data is deleted',
+ 'days_purge' => 'Max. days before purge',
+ 'days_compact' => 'Max. days before data is compacted',
+ 'days_delete_unknown' => 'Max. days before unknown modules are deleted',
+ 'days_delete_not_initialized' => 'Max. days before delete not initialized modules',
+ 'days_autodisable_deletion' => 'Max. days before autodisabled agents are deleted',
+ 'delete_old_network_matrix' => 'Max. days before delete old network matrix data',
+ 'report_limit' => 'Item limit for real-time reports',
+ 'event_view_hr' => 'Default hours for event view',
+ 'big_operation_step_datos_purge' => 'Big Operation Step to purge old data',
+ 'small_operation_step_datos_purge' => 'Small Operation Step to purge old data',
+ 'row_limit_csv' => 'Row limit in csv log',
+ 'limit_parameters_massive' => 'Limit for bulk operations',
+ 'block_size' => 'Block size for pagination',
+ 'short_module_graph_data' => 'Data precision',
+ 'graph_precision' => 'Data precision in graphs',
+ ];
+
+ $variables = (array) json_decode(io_safe_output($config['performance_variables_control']));
+
+ foreach ($variables as $variable => $values) {
+ if (empty($config[$variable]) === true || $config[$variable] === '') {
+ continue;
+ }
+
+ $message = '';
+ $limit_value = '';
+ if ($config[$variable] > $values->max) {
+ $message = 'Check the setting of %s, a value greater than %s is not recommended';
+ $limit_value = $values->max;
+ }
+
+ if ($config[$variable] < $values->min) {
+ $message = 'Check the setting of %s, a value less than %s is not recommended';
+ $limit_value = $values->min;
+ }
+
+ if ($limit_value !== '' && $message !== '') {
+ if (is_metaconsole() === true) {
+ $this->notify(
+ [
+ 'type' => 'NOTIF.VARIABLES.PERFORMANCE.'.$variable,
+ 'title' => __('Incorrect config value'),
+ 'message' => __(
+ $message,
+ $names[$variable],
+ $limit_value
+ ),
+ 'url' => '__url__index.php?sec=advanced&sec2=advanced/metasetup',
+ ]
+ );
+ } else {
+ $this->notify(
+ [
+ 'type' => 'NOTIF.VARIABLES.PERFORMANCE.'.$variable,
+ 'title' => __('Incorrect config value'),
+ 'message' => __(
+ $message,
+ $names[$variable],
+ $limit_value
+ ),
+ 'url' => '__url__/index.php?sec=general&sec2=godmode/setup/setup',
+ ]
+ );
+ }
+ }
+ }
+
}
@@ -548,6 +659,34 @@ class ConsoleSupervisor
}
+ /**
+ * Check number of agents and disable agentaccess token if number
+ * is equals and more than 200.
+ *
+ * @return void
+ */
+ public function checkAccessStatisticsPerformance()
+ {
+ $total_agents = db_get_value('count(*)', 'tagente');
+
+ if ($total_agents >= 200) {
+ db_process_sql_update('tconfig', ['value' => 0], ['token' => 'agentaccess']);
+ $this->notify(
+ [
+ 'type' => 'NOTIF.ACCESSSTASTICS.PERFORMANCE',
+ 'title' => __('Access statistics performance'),
+ 'message' => __(
+ 'Usage of agent access statistics IS NOT RECOMMENDED on systems with more than 200 agents due performance penalty'
+ ),
+ 'url' => '__url__/index.php?sec=general&sec2=godmode/setup/setup§ion=perf',
+ ]
+ );
+ } else {
+ $this->cleanNotifications('NOTIF.ACCESSSTASTICS.PERFORMANCE');
+ }
+ }
+
+
/**
* Update targets for given notification using object targets.
*
diff --git a/pandora_console/include/class/Diagnostics.class.php b/pandora_console/include/class/Diagnostics.class.php
index 99e28e3983..02bec5060d 100644
--- a/pandora_console/include/class/Diagnostics.class.php
+++ b/pandora_console/include/class/Diagnostics.class.php
@@ -646,7 +646,7 @@ class Diagnostics extends Wizard
$currentTime = time();
$pandoraDbLastRun = __('Pandora DB has never been executed');
- if ($dateDbMantenaince !== false) {
+ if ($dateDbMantenaince !== false && empty($dateDbMantenaince) === false) {
$difference = ($currentTime - $dateDbMantenaince);
$pandoraDbLastRun = human_time_description_raw(
$difference,
diff --git a/pandora_console/include/class/EventSound.class.php b/pandora_console/include/class/EventSound.class.php
new file mode 100644
index 0000000000..b943e9cce1
--- /dev/null
+++ b/pandora_console/include/class/EventSound.class.php
@@ -0,0 +1,495 @@
+ajaxController = $ajaxController;
+ }
+
+
+ /**
+ * Run view
+ *
+ * @return void
+ */
+ public function run()
+ {
+ global $config;
+ $tab = get_parameter('tab', '');
+ $action = get_parameter('action', '');
+ $message_ok = 0;
+ $error_msg = __('Name already exist');
+ $ok_msg = __('Successfully created');
+
+ if ($action == 'create') {
+ $name = get_parameter('name', '');
+ $sound = get_parameter('file', '');
+
+ $exist = db_get_all_rows_sql(sprintf('SELECT * FROM tevent_sound WHERE name = "%s"', $name));
+
+ if ($exist === false) {
+ $uploadMaxFilesize = config_return_in_bytes(ini_get('upload_max_filesize'));
+
+ $upload_status = get_file_upload_status('file');
+ $upload_result = translate_file_upload_status($upload_status);
+ if ($uploadMaxFilesize < $sound['size']) {
+ $error_msg = __('File is too large to upload. Check the configuration in php.ini.');
+ } else {
+ $pathname = $config['homedir'].'/include/sounds/';
+ $nameSound = str_replace(' ', '_', $_FILES['file']['name']);
+ $target_file = $pathname.basename($nameSound);
+
+ if (file_exists($target_file)) {
+ $error_msg = __('Sound already are exists.');
+ } else {
+ if (move_uploaded_file($_FILES['file']['tmp_name'], $target_file)) {
+ $insert = db_process_sql_insert(
+ 'tevent_sound',
+ [
+ 'name' => $name,
+ 'sound' => $nameSound,
+ ]
+ );
+ $ok_msg = __('Successfully created');
+ } else {
+ $error_msg = __('Fail uploading the sound');
+ }
+ }
+ }
+
+ if ($insert > 0) {
+ $tab = '';
+ $message_ok = 1;
+ }
+ } else {
+ $error_msg = __('Sound already are exists');
+ }
+ } else if ($action == 'change_action') {
+ $id = get_parameter('id', '');
+ $new_action = (int) get_parameter('set_action', '1');
+
+ $exist = db_get_all_rows_sql(sprintf('SELECT * FROM tevent_sound WHERE id = "%s"', $id));
+
+ if ($exist !== false) {
+ $result = db_process_sql_update(
+ 'tevent_sound',
+ ['active' => $new_action],
+ ['id' => $id]
+ );
+ if (false === (bool) $result) {
+ $error_msg = __('Error on update status');
+ } else {
+ $message_ok = 1;
+ }
+ } else {
+ $error_msg = __('Sound not exist');
+ }
+ }
+
+ if ($action) {
+ ui_print_result_message(
+ $message_ok,
+ $ok_msg,
+ $error_msg,
+ '',
+ false
+ );
+ }
+
+ $base_url = 'index.php?sec=eventos&sec2=godmode/events/configuration_sounds';
+ $setup_url = $base_url.'&tab=add';
+ $tabs = [
+ 'list' => [
+ 'text' => '
'.html_print_image(
+ 'images/eye_show.png',
+ true,
+ [
+ 'title' => __('Sounds'),
+ 'class' => 'invert_filter',
+ ]
+ ).'',
+ 'active' => (bool) ($tab != 'add'),
+ ],
+ 'options' => [
+ 'text' => '
'.html_print_image(
+ 'images/pen.png',
+ true,
+ [
+ 'title' => __('Create'),
+ 'class' => 'invert_filter',
+ ]
+ ).'',
+ 'active' => (bool) ($tab == 'add'),
+ ],
+ ];
+
+ if ($tab === 'add') {
+ $helpHeader = '';
+ $titleHeader = __('Add new sound');
+ } else {
+ $helpHeader = 'servers_ha_clusters_tab';
+ $titleHeader = __('Accoustic console sound list');
+ }
+
+ // Header.
+ ui_print_standard_header(
+ $titleHeader,
+ 'images/gm_servers.png',
+ false,
+ $helpHeader,
+ false,
+ $tabs,
+ [
+ [
+ 'link' => '',
+ 'label' => __('Admin tools'),
+ ],
+ [
+ 'link' => '',
+ 'label' => __('Accoustic console setup'),
+ ],
+ ]
+ );
+
+ // Javascript.
+ ui_require_jquery_file('pandora');
+ // CSS.
+ ui_require_css_file('wizard');
+ ui_require_css_file('discovery');
+
+ if ($tab === 'add') {
+ echo '
';
+
+ // Load own javascript file.
+ echo $this->loadJS();
+ } else {
+ // Datatables list.
+ try {
+ $columns = [
+ 'name',
+ 'sound',
+ [
+ 'text' => 'options',
+ 'class' => 'action_buttons mw120px',
+ ],
+ ];
+
+ $column_names = [
+ __('Name'),
+ __('Sound'),
+ __('Options'),
+ ];
+
+ $this->tableId = 'event_sounds';
+
+ if (is_metaconsole() === true) {
+ // Only in case of Metaconsole, format the frame.
+ open_meta_frame();
+ }
+
+ // Load datatables user interface.
+ ui_print_datatable(
+ [
+ 'id' => $this->tableId,
+ 'class' => 'info_table',
+ 'style' => 'width: 100%',
+ 'columns' => $columns,
+ 'column_names' => $column_names,
+ 'ajax_url' => $this->ajaxController,
+ 'ajax_data' => ['method' => 'draw'],
+ 'no_sortable_columns' => [-1],
+ 'order' => [
+ 'field' => 'id',
+ 'direction' => 'asc',
+ ],
+ 'search_button_class' => 'sub filter',
+ 'form' => [
+ 'inputs' => [
+ [
+ 'label' => __('Free search').ui_print_help_tip(__('Search filter by Name or Sound fields content'), true),
+ 'type' => 'text',
+ 'class' => 'w200px',
+ 'id' => 'filter_text',
+ 'name' => 'filter_text',
+ ],
+ [
+ 'label' => __('Active'),
+ 'type' => 'select',
+ 'fields' => [
+ '' => __('All'),
+ '0' => __('No'),
+ '1' => __('Yes'),
+ ],
+ 'class' => 'w100px',
+ 'id' => 'active',
+ 'name' => 'active',
+ ],
+ ],
+ ],
+ ]
+ );
+ } catch (Exception $e) {
+ echo $e->getMessage();
+ }
+
+ if (is_metaconsole() === true) {
+ // Close the frame.
+ close_meta_frame();
+ }
+
+ // Load own javascript file.
+ echo $this->loadJS();
+ }
+ }
+
+
+ /**
+ * Get the data for draw the table.
+ *
+ * @return void.
+ */
+ public function draw()
+ {
+ global $config;
+ // Initialice filter.
+ $filter = '1=1';
+ // Init data.
+ $data = [];
+ // Count of total records.
+ $count = 0;
+ // Catch post parameters.
+ $start = get_parameter('start', 0);
+ $length = get_parameter('length', $config['block_size']);
+ // There is a limit of (2^32)^2 (18446744073709551615) rows in a MyISAM table, show for show all use max nrows.
+ $length = ($length != '-1') ? $length : '18446744073709551615';
+ $order = get_datatable_order();
+ $filters = get_parameter('filter', []);
+ $filterText = $filters['filter_text'];
+ $filterActive = $filters['active'];
+
+ if (empty($filterText) === false) {
+ $filter .= sprintf(
+ " AND (name LIKE '%%%s%%' OR sound LIKE '%%%s%%')",
+ $filterText,
+ $filterText
+ );
+ }
+
+ if (in_array($filterActive, [0, 1])) {
+ $filter .= sprintf(
+ ' AND active = %s',
+ $filterActive,
+ );
+ }
+
+ $count = (int) db_get_value_sql(sprintf('SELECT COUNT(*) as "total" FROM tevent_sound WHERE %s', $filter));
+
+ $sql = sprintf(
+ 'SELECT *
+ FROM tevent_sound
+ WHERE %s
+ ORDER BY %s
+ LIMIT %d, %d',
+ $filter,
+ $order,
+ $start,
+ $length
+ );
+ $data = db_get_all_rows_sql($sql);
+
+ foreach ($data as $key => $row) {
+ if ($row['active'] === '1') {
+ $img = 'images/lightbulb.png';
+ $action = __('Disable sound');
+ $new_action = 0;
+ } else {
+ $img = 'images/lightbulb_off.png';
+ $action = __('Enable sound');
+ $new_action = 1;
+ }
+
+ $options = '
';
+ $options .= html_print_image(
+ $img,
+ true,
+ [
+ 'title' => $action,
+ 'class' => 'invert_filter',
+ ]
+ );
+ $options .= '';
+
+ $data[$key]['options'] = $options;
+ }
+
+ echo json_encode(
+ [
+ 'data' => $data,
+ 'recordsTotal' => $count,
+ 'recordsFiltered' => $count,
+ ]
+ );
+ }
+
+
+ /**
+ * Checks if target method is available to be called using AJAX.
+ *
+ * @param string $method Target method.
+ *
+ * @return boolean True allowed, false not.
+ */
+ public function ajaxMethod(string $method)
+ {
+ return in_array($method, $this->AJAXMethods);
+ }
+
+
+ /**
+ * Load Javascript code.
+ *
+ * @return string.
+ */
+ public function loadJS()
+ {
+ // Nothing for this moment.
+ ob_start();
+
+ // Javascript content.
+ ?>
+
+ 'flex-row',
'inputs' => [
[
- 'label' => __('Alert'),
- 'type' => 'select',
- 'id' => 'filter_alert',
- 'name' => 'filter_alert',
- 'class' => 'w200px',
- 'fields' => $show_alerts,
- 'return' => true,
- 'selected' => $this->filter_alert,
+ 'label' => __('Alert'),
+ 'type' => 'select',
+ 'id' => 'filter_alert',
+ 'input_class' => 'filter_input_datatable',
+ 'name' => 'filter_alert',
+ 'fields' => $show_alerts,
+ 'return' => true,
+ 'selected' => $this->filter_alert,
],
[
- 'label' => __('Severity'),
- 'type' => 'select',
- 'id' => 'filter_severity',
- 'name' => 'filter_severity',
- 'class' => 'w200px',
- 'fields' => $severities,
- 'return' => true,
- 'selected' => $this->filter_severity,
+ 'label' => __('Severity'),
+ 'type' => 'select',
+ 'id' => 'filter_severity',
+ 'input_class' => 'filter_input_datatable',
+ 'name' => 'filter_severity',
+ 'fields' => $severities,
+ 'return' => true,
+ 'selected' => $this->filter_severity,
],
[
- 'label' => __('Free search'),
- 'type' => 'text',
- 'class' => 'w400px',
- 'id' => 'filter_free_search',
- 'name' => 'filter_free_search',
- 'value' => $this->filter_free_search,
+ 'label' => __('Free search'),
+ 'type' => 'text',
+ 'id' => 'filter_free_search',
+ 'input_class' => 'filter_input_datatable',
+ 'name' => 'filter_free_search',
+ 'value' => $this->filter_free_search,
],
[
- 'label' => __('Status'),
- 'type' => 'select',
- 'id' => 'filter_status',
- 'name' => 'filter_status',
- 'class' => 'w200px',
- 'fields' => $status_array,
- 'return' => true,
- 'selected' => $this->filter_status,
+ 'label' => __('Status'),
+ 'type' => 'select',
+ 'id' => 'filter_status',
+ 'input_class' => 'filter_input_datatable',
+ 'name' => 'filter_status',
+ 'fields' => $status_array,
+ 'return' => true,
+ 'selected' => $this->filter_status,
],
[
- 'label' => __('Group by Enterprise String/IP'),
- 'type' => 'select',
- 'name' => 'filter_group_by',
- 'selected' => $this->filter_group_by,
- 'disabled' => false,
- 'return' => true,
- 'id' => 'filter_group_by',
- 'fields' => [
+ 'label' => __('Group by Enterprise String/IP'),
+ 'type' => 'select',
+ 'name' => 'filter_group_by',
+ 'selected' => $this->filter_group_by,
+ 'disabled' => false,
+ 'return' => true,
+ 'id' => 'filter_group_by',
+ 'input_class' => 'filter_input_datatable',
+ 'fields' => [
0 => __('No'),
1 => __('Yes'),
],
],
[
- 'label' => __('Max. hours old'),
- 'type' => 'text',
- 'class' => 'w200px',
- 'id' => 'filter_hours_ago',
- 'name' => 'filter_hours_ago',
- 'value' => $this->filter_hours_ago,
+ 'label' => __('Max. hours old'),
+ 'type' => 'text',
+ 'id' => 'filter_hours_ago',
+ 'input_class' => 'filter_input_datatable',
+ 'name' => 'filter_hours_ago',
+ 'value' => $this->filter_hours_ago,
],
[
- 'label' => __('Trap type'),
- 'type' => 'select',
- 'id' => 'filter_trap_type',
- 'name' => 'filter_trap_type',
- 'class' => 'w200px',
- 'fields' => $trap_types,
- 'return' => true,
- 'selected' => $this->filter_trap_type,
+ 'label' => __('Trap type'),
+ 'type' => 'select',
+ 'id' => 'filter_trap_type',
+ 'input_class' => 'filter_input_datatable',
+ 'name' => 'filter_trap_type',
+ 'fields' => $trap_types,
+ 'return' => true,
+ 'selected' => $this->filter_trap_type,
],
],
],
diff --git a/pandora_console/include/config_process.php b/pandora_console/include/config_process.php
index e0058687db..70d3efe878 100644
--- a/pandora_console/include/config_process.php
+++ b/pandora_console/include/config_process.php
@@ -20,7 +20,7 @@
/**
* Pandora build version and version
*/
-$build_version = 'PC230220';
+$build_version = 'PC230303';
$pandora_version = 'v7.0NG.769';
// Do not overwrite default timezone set if defined.
diff --git a/pandora_console/include/functions.php b/pandora_console/include/functions.php
index 5b13cac83d..4c6245b8a5 100644
--- a/pandora_console/include/functions.php
+++ b/pandora_console/include/functions.php
@@ -6399,11 +6399,34 @@ function getBearerToken()
}
+/**
+ * Check whether an instance of pandora_db is running.
+ *
+ * @return boolean Result.
+ */
+function is_pandora_db_running()
+{
+ // Get current DB name: useful for metaconsole connection to node.
+ $db_name = db_get_sql('SELECT DATABASE()');
+
+ $is_free_lock = mysql_db_process_sql(
+ 'SELECT IS_FREE_LOCK("'.$db_name.'_pandora_db") AS "value"',
+ 'affected_rows',
+ '',
+ false
+ );
+
+ $is_free_lock = (bool) $is_free_lock[0]['value'];
+
+ return !$is_free_lock;
+}
+
+
/**
* Check nms license on api.
*
- * @return boolean
- */
+ * @return boolean.
+ * */
function nms_check_api()
{
global $config;
diff --git a/pandora_console/include/functions_agents.php b/pandora_console/include/functions_agents.php
index 6e37a1e991..bd33e1ddf8 100644
--- a/pandora_console/include/functions_agents.php
+++ b/pandora_console/include/functions_agents.php
@@ -519,6 +519,27 @@ function agents_get_agents(
$search_custom = '';
}
+ if (isset($filter['id_os'])) {
+ $id_os = $filter['id_os'];
+ unset($filter['id_os']);
+ } else {
+ $id_os = '';
+ }
+
+ if (isset($filter['policies'])) {
+ $policies = $filter['policies'];
+ unset($filter['policies']);
+ } else {
+ $policies = '';
+ }
+
+ if (isset($filter['other_condition'])) {
+ $other_condition = $filter['other_condition'];
+ unset($filter['other_condition']);
+ } else {
+ $other_condition = '';
+ }
+
if (isset($filter['offset'])) {
$offset = $filter['offset'];
unset($filter['offset']);
@@ -692,25 +713,38 @@ function agents_get_agents(
$where_nogroup = '1 = 1';
}
+ $policy_join = '';
+
+ if ($policies !== '') {
+ $policy_join = 'INNER JOIN tpolicy_agents
+ ON tpolicy_agents.id_agent=tagente.id_agente';
+ }
+
if ($extra) {
$where = sprintf(
- '(%s OR (%s)) AND (%s) AND (%s) %s AND %s',
+ '(%s OR (%s)) AND (%s) AND (%s) %s AND %s %s %s %s',
$sql_extra,
$where,
$where_nogroup,
$status_sql,
$search,
- $disabled
+ $disabled,
+ $id_os,
+ $policies,
+ $other_condition
);
} else {
$where = sprintf(
- '%s AND %s AND (%s) %s AND %s %s',
+ '%s AND %s AND (%s) %s AND %s %s %s %s %s',
$where,
$where_nogroup,
$status_sql,
$search,
$disabled,
- $search_custom
+ $search_custom,
+ $id_os,
+ $policies,
+ $other_condition
);
}
@@ -720,9 +754,11 @@ function agents_get_agents(
FROM `%s` tagente
LEFT JOIN tagent_secondary_group
ON tagent_secondary_group.id_agent=tagente.id_agente
+ %s
WHERE %s %s',
implode(',', $fields),
$table_name,
+ $policy_join,
$where,
$order
);
diff --git a/pandora_console/include/functions_api.php b/pandora_console/include/functions_api.php
index 688bdb782f..bd1577116c 100644
--- a/pandora_console/include/functions_api.php
+++ b/pandora_console/include/functions_api.php
@@ -11071,20 +11071,55 @@ function api_set_event_validate_filter($trash1, $trash2, $other, $trash3)
function api_set_validate_events($id_event, $trash1, $other, $return_type, $user_in_db)
{
- $text = $other['data'];
+ $node_int = 0;
+ if ($other['type'] == 'string') {
+ returnError('Parameter error.');
+ return;
+ } else if ($other['type'] == 'array') {
+ $text = $other['data'][0];
+ if (is_metaconsole() === true) {
+ if (isset($other['data'][1]) === true
+ && empty($other['data'][1]) === false
+ ) {
+ $node_int = $other['data'][1];
+ }
+ }
+ }
- // Set off the standby mode when close an event
- $event = events_get_event($id_event);
- alerts_agent_module_standby($event['id_alert_am'], 0);
+ try {
+ if (is_metaconsole() === true
+ && (int) $node_int > 0
+ ) {
+ $node = new Node($node_int);
+ $node->connect();
+ }
- $result = events_change_status($id_event, EVENT_VALIDATE);
+ // Set off the standby mode when close an event
+ $event = events_get_event($id_event);
+ alerts_agent_module_standby($event['id_alert_am'], 0);
+ $result = events_change_status($id_event, EVENT_VALIDATE);
- if ($result) {
if (!empty($text)) {
// Set the comment for the validation
events_comment($id_event, $text);
}
+ } catch (\Exception $e) {
+ if (is_metaconsole() === true
+ && $node_int > 0
+ ) {
+ $node->disconnect();
+ }
+ $result = false;
+ } finally {
+ if (is_metaconsole() === true
+ && $node_int > 0
+ ) {
+ $node->disconnect();
+ }
+ }
+
+ if ($result) {
returnData(
'string',
[
diff --git a/pandora_console/include/functions_config.php b/pandora_console/include/functions_config.php
index 1acbfa0760..7b6e133f22 100644
--- a/pandora_console/include/functions_config.php
+++ b/pandora_console/include/functions_config.php
@@ -844,6 +844,10 @@ function config_update_config()
$error_update[] = __('Item limit for realtime reports)');
}
+ if (config_update_value('events_per_query', (int) get_parameter('events_per_query'), true) === false) {
+ $error_update[] = __('Limit of events per query');
+ }
+
if (config_update_value('step_compact', (int) get_parameter('step_compact'), true) === false) {
$error_update[] = __('Compact interpolation in hours (1 Fine-20 bad)');
}
@@ -1982,6 +1986,10 @@ function config_process_config()
config_update_value('report_limit', 100);
}
+ if (!isset($config['events_per_query'])) {
+ config_update_value('events_per_query', 5000);
+ }
+
if (!isset($config['loginhash_pwd'])) {
config_update_value('loginhash_pwd', io_input_password((rand(0, 1000) * rand(0, 1000)).'pandorahash'));
}
@@ -2289,6 +2297,96 @@ function config_process_config()
config_update_value('2Fa_auth', '');
}
+ if (isset($config['performance_variables_control']) === false) {
+ config_update_value(
+ 'performance_variables_control',
+ json_encode(
+ [
+ 'event_purge' => [
+ 'max' => 45,
+ 'min' => 1,
+ ],
+ 'trap_purge' => [
+ 'max' => 45,
+ 'min' => 1,
+ ],
+ 'audit_purge' => [
+ 'max' => 365,
+ 'min' => 7,
+ ],
+ 'string_purge' => [
+ 'max' => 365,
+ 'min' => 7,
+ ],
+ 'gis_purge' => [
+ 'max' => 365,
+ 'min' => 7,
+ ],
+ 'days_purge' => [
+ 'max' => 365,
+ 'min' => 7,
+ ],
+ 'days_compact' => [
+ 'max' => 365,
+ 'min' => 0,
+ ],
+ 'days_delete_unknown' => [
+ 'max' => 90,
+ 'min' => 0,
+ ],
+ 'days_delete_not_initialized' => [
+ 'max' => 90,
+ 'min' => 0,
+ ],
+ 'days_autodisable_deletion' => [
+ 'max' => 90,
+ 'min' => 0,
+ ],
+ 'delete_old_network_matrix' => [
+ 'max' => 30,
+ 'min' => 1,
+ ],
+ 'report_limit' => [
+ 'max' => 500,
+ 'min' => 1,
+ ],
+ 'event_view_hr' => [
+ 'max' => 360,
+ 'min' => 1,
+ ],
+ 'big_operation_step_datos_purge' => [
+ 'max' => 10000,
+ 'min' => 100,
+ ],
+ 'small_operation_step_datos_purge' => [
+ 'max' => 10000,
+ 'min' => 100,
+ ],
+ 'row_limit_csv' => [
+ 'max' => 1000000,
+ 'min' => 1,
+ ],
+ 'limit_parameters_massive' => [
+ 'max' => 2000,
+ 'min' => 100,
+ ],
+ 'block_size' => [
+ 'max' => 200,
+ 'min' => 10,
+ ],
+ 'short_module_graph_data' => [
+ 'max' => 20,
+ 'min' => 1,
+ ],
+ 'graph_precision' => [
+ 'max' => 5,
+ 'min' => 1,
+ ],
+ ]
+ )
+ );
+ }
+
if (isset($config['agent_wizard_defaults']) === false) {
config_update_value(
'agent_wizard_defaults',
diff --git a/pandora_console/include/functions_events.php b/pandora_console/include/functions_events.php
index 48ef7b2c30..c41c909c27 100644
--- a/pandora_console/include/functions_events.php
+++ b/pandora_console/include/functions_events.php
@@ -2018,7 +2018,7 @@ function events_change_status(
// Update ack info if the new status is validated.
$ack_utimestamp = 0;
$ack_user = $config['id_user'];
- if ((int) $new_status === EVENT_STATUS_VALIDATED) {
+ if ((int) $new_status === EVENT_STATUS_VALIDATED || (int) $new_status === EVENT_STATUS_INPROCESS) {
$ack_utimestamp = time();
}
@@ -2412,14 +2412,17 @@ function events_create_event(
$source = get_product_name();
}
+ // Get Timestamp.
+ $timestamp = time();
+
$values = [
'id_agente' => $id_agent,
'id_usuario' => $id_user,
'id_grupo' => $id_group,
'estado' => $status,
- 'timestamp' => date('Y-m-d H:i:s'),
+ 'timestamp' => date('Y-m-d H:i:s', $timestamp),
'evento' => $event,
- 'utimestamp' => time(),
+ 'utimestamp' => $timestamp,
'event_type' => $event_type,
'id_agentmodule' => $id_agent_module,
'id_alert_am' => $id_aam,
@@ -4814,7 +4817,7 @@ function events_page_general($event)
$data = [];
$data[0] = __('Acknowledged by');
- if ($event['estado'] == 1) {
+ if ($event['estado'] == 1 || $event['estado'] == 2) {
if (empty($event['id_usuario']) === true) {
$user_ack = __('Autovalidated');
} else {
@@ -4948,7 +4951,7 @@ function events_page_general_acknowledged($event_id)
global $config;
$Acknowledged = '';
$event = db_get_row('tevento', 'id_evento', $event_id);
- if ($event !== false && $event['estado'] == 1) {
+ if ($event !== false && ($event['estado'] == 1 || $event['estado'] == 2)) {
$user_ack = db_get_value(
'fullname',
'tusuario',
@@ -5826,3 +5829,58 @@ function get_events_get_response_target(
}
}
}
+
+
+/**
+ * Gets the count of events by criticity.
+ *
+ * @param integer $utimestamp Utimestamp to search.
+ * @param integer $eventType Event type.
+ * @param array $groupId Groups.
+ * @param integer $eventStatus Event status.
+ * @param array $criticityId Criticity to search.
+ *
+ * @return array
+ */
+function get_count_event_criticity(
+ $utimestamp,
+ $eventType,
+ $groupId,
+ $eventStatus,
+ $criticityId
+) {
+ $type = ' ';
+ if ($eventType !== '0') {
+ $type = 'AND event_type = "'.$eventType.'"';
+ }
+
+ $groups = ' ';
+ if ((int) $groupId !== 0) {
+ $groups = 'AND id_grupo IN ('.$groupId.')';
+ }
+
+ $status = ' ';
+ if ((int) $eventStatus !== -1) {
+ $status = 'AND estado = '.$eventStatus;
+ }
+
+ $criticity = ' ';
+ if (empty($criticityId) === false) {
+ $criticity = 'AND criticity IN ('.$criticityId.')';
+ }
+
+ $sql_meta = sprintf(
+ 'SELECT COUNT(id_evento) AS count,
+ criticity
+ FROM tevento
+ WHERE utimestamp >= %d %s %s %s %s
+ GROUP BY criticity',
+ $utimestamp,
+ $type,
+ $groups,
+ $status,
+ $criticity
+ );
+
+ return db_get_all_rows_sql($sql_meta);
+}
diff --git a/pandora_console/include/functions_html.php b/pandora_console/include/functions_html.php
index 31c2e5214a..44a8289b0d 100644
--- a/pandora_console/include/functions_html.php
+++ b/pandora_console/include/functions_html.php
@@ -84,6 +84,27 @@ function html_debug_print($var, $file='', $oneline=false)
}
+/**
+ * Console log.
+ */
+function jslog($var)
+{
+ $more_info = '';
+ if (is_string($var)) {
+ $more_info = 'size: '.strlen($var);
+ } else if (is_bool($var)) {
+ $more_info = 'val: '.($var ? 'true' : 'false');
+ } else if (is_null($var)) {
+ $more_info = 'is null';
+ } else if (is_array($var)) {
+ $more_info = count($var);
+ }
+
+ echo ''."\n";
+ echo '';
+}
+
+
// Alias for "html_debug_print"
function html_debug($var, $file='', $oneline=false)
{
diff --git a/pandora_console/include/functions_notifications.php b/pandora_console/include/functions_notifications.php
index 705d67ab3b..657ce1ff35 100644
--- a/pandora_console/include/functions_notifications.php
+++ b/pandora_console/include/functions_notifications.php
@@ -159,6 +159,8 @@ function notifications_get_subtypes(?string $source=null)
'NOTIF.SERVER.STATUS',
'NOTIF.SERVER.QUEUE',
'NOTIF.SERVER.MASTER',
+ 'NOTIF.ACCESSSTASTICS.PERFORMANCE',
+ 'NOTIF.VARIABLES.PERFORMANCE',
],
];
diff --git a/pandora_console/include/functions_reporting.php b/pandora_console/include/functions_reporting.php
index 637ae59752..6fc5e600cd 100755
--- a/pandora_console/include/functions_reporting.php
+++ b/pandora_console/include/functions_reporting.php
@@ -68,6 +68,7 @@ define('REPORT_STATUS_IGNORED', 5);
// Clases.
use PandoraFMS\Enterprise\Metaconsole\Node;
+use PandoraFMS\Enterprise\Metaconsole\Synchronizer;
use PandoraFMS\Event;
use PandoraFMS\Module;
@@ -7421,6 +7422,14 @@ function reporting_text($report, $content)
}
+/**
+ * Build SQL report item.
+ *
+ * @param array $report Report info.
+ * @param array $content Content info.
+ *
+ * @return array
+ */
function reporting_sql($report, $content)
{
global $config;
@@ -7438,15 +7447,98 @@ function reporting_sql($report, $content)
$return['description'] = $content['description'];
$return['date'] = reporting_get_date_text();
- if ($config['metaconsole'] && !empty($content['server_name'])) {
- $id_meta = metaconsole_get_id_server(
+ if (is_metaconsole() === true
+ && empty($content['server_name']) === false
+ && $content['server_name'] !== 'all'
+ ) {
+ $id_server = metaconsole_get_id_server(
$content['server_name']
);
-
- $server = metaconsole_get_connection_by_id($id_meta);
- metaconsole_connect($server);
}
+ if (is_metaconsole() === true && $content['server_name'] === 'all') {
+ $sync = new Synchronizer();
+ $results = $sync->apply(
+ function ($node) use ($report, $content) {
+ try {
+ $node->connect();
+ $rs = reporting_sql_auxiliary($report, $content);
+ $node->disconnect();
+ } catch (Exception $e) {
+ return [
+ 'error' => __(
+ 'Failed to connect to node %s',
+ $node->server_name()
+ ),
+ ];
+ }
+
+ if ($rs === false) {
+ return ['result' => []];
+ }
+
+ return ['result' => $rs];
+ },
+ false
+ );
+
+ $data = [];
+ $return['correct'] = 1;
+ $return['error'] = '';
+
+ foreach ($results as $id_node => $items) {
+ foreach ($items['result']['data'] as $key => $item) {
+ $items['result']['data'][$key] = (['node_id' => $id_node] + $items['result']['data'][$key]);
+ }
+
+ if ((int) $items['result']['correct'] !== 1) {
+ $return['correct'] = 0;
+ }
+
+ if ($items['result']['error'] !== '') {
+ $return['error'] = $items['result']['error'];
+ }
+
+ $return['sql'] = $items['result']['sql'];
+
+ $data = array_merge($data, $items['result']['data']);
+ }
+
+ $return['data'] = $data;
+ } else {
+ try {
+ if (is_metaconsole() === true && $id_server > 0) {
+ $node = new Node($id_server);
+ $node->connect();
+ }
+
+ $query_result = reporting_sql_auxiliary($report, $content);
+ $return = array_merge($return, $query_result);
+
+ if (is_metaconsole() === true && $id_server > 0) {
+ $node->disconnect();
+ }
+ } catch (\Exception $e) {
+ if (is_metaconsole() === true && $id_server > 0) {
+ $node->disconnect();
+ }
+ }
+ }
+
+ return reporting_check_structure_content($return);
+}
+
+
+/**
+ * Auxiliary function for reporting_sql.
+ *
+ * @param array $report Report info.
+ * @param array $content Content info.
+ *
+ * @return array
+ */
+function reporting_sql_auxiliary($report, $content)
+{
if ($content['treport_custom_sql_id'] != 0) {
$sql = io_safe_output(
db_get_value_filter(
@@ -7459,7 +7551,7 @@ function reporting_sql($report, $content)
$sql = $content['external_source'];
}
- // Check if exist sql macro.
+ // Check if SQL macro exists.
$sql = reporting_sql_macro($report, $sql);
// Do a security check on SQL coming from the user.
@@ -7514,11 +7606,7 @@ function reporting_sql($report, $content)
$return['error'] = __('Illegal query: Due security restrictions, there are some tokens or words you cannot use: *, delete, drop, alter, modify, password, pass, insert or update.');
}
- if ($config['metaconsole'] && !empty($content['server_name'])) {
- metaconsole_restore_db();
- }
-
- return reporting_check_structure_content($return);
+ return $return;
}
diff --git a/pandora_console/include/functions_servers.php b/pandora_console/include/functions_servers.php
index a1dfc32197..3f9fe1a6b2 100644
--- a/pandora_console/include/functions_servers.php
+++ b/pandora_console/include/functions_servers.php
@@ -1,5 +1,4 @@
0
- AND tagente_estado.last_execution_try > 0
- AND tagente_estado.running_by = %d
- ) tae
- JOIN (
- SELECT tagente_modulo.id_agente_modulo
- FROM tagente_modulo LEFT JOIN tagente
- ON tagente_modulo.id_agente = tagente.id_agente
- WHERE tagente.disabled = 0
- AND tagente_modulo.disabled = 0
- ) tam
- ON tae.id_agente_modulo = tam.id_agente_modulo
- WHERE (UNIX_TIMESTAMP() - tae.last_execution_try) > (tae.current_interval)
- AND (UNIX_TIMESTAMP() - tae.last_execution_try) < ( tae.current_interval * 10)',
- $server['id_server']
+ $result = db_get_row_sql(
+ 'SELECT COUNT(tagente_modulo.id_agente_modulo) AS module_lag,
+ AVG(UNIX_TIMESTAMP() - utimestamp - current_interval) AS "lag"
+ FROM tagente_estado, tagente_modulo, tagente
+ WHERE utimestamp > 0
+ AND tagente.disabled = 0
+ AND tagente.id_agente = tagente_estado.id_agente
+ AND tagente_modulo.disabled = 0
+ AND tagente_modulo.id_agente_modulo = tagente_estado.id_agente_modulo
+ AND current_interval > 0
+ AND running_by = '.$server['id_server'].'
+ AND (UNIX_TIMESTAMP() - utimestamp) < ( current_interval * 10)
+ AND (UNIX_TIMESTAMP() - utimestamp) > current_interval'
);
} else {
// Local/Dataserver server LAG calculation.
// MySQL 8.0 has function lag(). So, lag must be enclosed in quotations.
- $sql = sprintf(
- 'SELECT COUNT(tam.id_agente_modulo) AS module_lag,
- AVG(UNIX_TIMESTAMP() - tae.last_execution_try - tae.current_interval) AS "lag"
- FROM (
- SELECT tagente_estado.last_execution_try, tagente_estado.current_interval, tagente_estado.id_agente_modulo
- FROM tagente_estado
- WHERE tagente_estado.current_interval > 0
- AND tagente_estado.last_execution_try > 0
- AND tagente_estado.running_by = %d
- ) tae
- JOIN (
- SELECT tagente_modulo.id_agente_modulo
- FROM tagente_modulo LEFT JOIN tagente
- ON tagente_modulo.id_agente = tagente.id_agente
- WHERE tagente.disabled = 0
- AND tagente_modulo.disabled = 0
- AND tagente_modulo.id_tipo_modulo < 5
- ) tam
- ON tae.id_agente_modulo = tam.id_agente_modulo
- WHERE (UNIX_TIMESTAMP() - tae.last_execution_try) > (tae.current_interval * 1.1)
- AND (UNIX_TIMESTAMP() - tae.last_execution_try) < ( tae.current_interval * 10)',
- $server['id_server']
+ $result = db_get_row_sql(
+ 'SELECT COUNT(tagente_modulo.id_agente_modulo) AS module_lag,
+ AVG(UNIX_TIMESTAMP() - utimestamp - current_interval) AS "lag"
+ FROM tagente_estado, tagente_modulo, tagente
+ WHERE utimestamp > 0
+ AND tagente.disabled = 0
+ AND tagente.id_agente = tagente_estado.id_agente
+ AND tagente_modulo.disabled = 0
+ AND tagente_modulo.id_tipo_modulo < 5
+ AND tagente_modulo.id_agente_modulo = tagente_estado.id_agente_modulo
+ AND current_interval > 0
+ AND (UNIX_TIMESTAMP() - utimestamp) < ( current_interval * 10)
+ AND running_by = '.$server['id_server'].'
+ AND (UNIX_TIMESTAMP() - utimestamp) > (current_interval * 1.1)'
);
}
- $result = db_get_row_sql($sql);
// Lag over current_interval * 2 is not lag,
// it's a timed out module.
if (!empty($result['lag'])) {
@@ -1154,11 +1137,11 @@ function servers_check_remote_config($server_name)
$config['remote_config']
).'/conf/'.$server_md5.'.srv.conf';
- if (!isset($filenames['conf'])) {
+ if (! isset($filenames['conf'])) {
return false;
}
- if (!isset($filenames['md5'])) {
+ if (! isset($filenames['md5'])) {
return false;
}
diff --git a/pandora_console/include/functions_treeview.php b/pandora_console/include/functions_treeview.php
index 198d4a51c8..2062ccb8c8 100755
--- a/pandora_console/include/functions_treeview.php
+++ b/pandora_console/include/functions_treeview.php
@@ -696,6 +696,8 @@ function treeview_printTable($id_agente, $server_data=[], $no_head=false)
$go_to_agent .= '
';
$go_to_agent .= html_print_submit_button(__('Go to cluster edition'), 'upd_button', false, 'class="sub config"', true);
} else {
+ $go_to_agent .= '';
+ $go_to_agent .= html_print_submit_button(__('Go to module creation'), 'upd_button', false, 'class="sub config"', true);
$go_to_agent .= '';
$go_to_agent .= html_print_submit_button(__('Go to agent edition'), 'upd_button', false, 'class="sub config"', true);
}
diff --git a/pandora_console/include/functions_ui.php b/pandora_console/include/functions_ui.php
index 6a658997f6..ce17086f02 100755
--- a/pandora_console/include/functions_ui.php
+++ b/pandora_console/include/functions_ui.php
@@ -7084,3 +7084,21 @@ function ui_get_inventory_module_add_form(
}
+function ui_print_status_div($status)
+{
+ switch ((int) $status) {
+ case 0:
+ $return = '
';
+ break;
+
+ case 1:
+ $return = '
';
+ break;
+
+ default:
+ $return = '
';
+ break;
+ }
+
+ return $return;
+}
\ No newline at end of file
diff --git a/pandora_console/include/lib/Dashboard/Widget.php b/pandora_console/include/lib/Dashboard/Widget.php
index 2753b8a55d..bb082de0c7 100644
--- a/pandora_console/include/lib/Dashboard/Widget.php
+++ b/pandora_console/include/lib/Dashboard/Widget.php
@@ -420,6 +420,7 @@ class Widget
case 'ColorModuleTabs':
case 'BlockHistogram':
case 'DataMatrix':
+ case 'EventCardboard':
$className .= '\\'.$name;
break;
diff --git a/pandora_console/include/lib/Dashboard/Widgets/EventCardboard.php b/pandora_console/include/lib/Dashboard/Widgets/EventCardboard.php
new file mode 100644
index 0000000000..87e592c8af
--- /dev/null
+++ b/pandora_console/include/lib/Dashboard/Widgets/EventCardboard.php
@@ -0,0 +1,664 @@
+width = $width;
+
+ // Height.
+ $this->height = $height;
+
+ // Grid Width.
+ $this->gridWidth = $gridWidth;
+
+ // Cell Id.
+ $this->cellId = $cellId;
+
+ // Options.
+ $this->values = $this->decoders($this->getOptionsWidget());
+
+ // Positions.
+ $this->position = $this->getPositionWidget();
+
+ // Page.
+ $this->page = basename(__FILE__);
+
+ // ClassName.
+ $class = new \ReflectionClass($this);
+ $this->className = $class->getShortName();
+
+ // Title.
+ $this->title = __('Event cardboard');
+
+ // Name.
+ if (empty($this->name) === true) {
+ $this->name = 'EventCardboard';
+ }
+
+ // This forces at least a first configuration.
+ $this->configurationRequired = false;
+ if (isset($this->values['groupId']) === false) {
+ $this->configurationRequired = true;
+ }
+
+ $this->overflow_scrollbars = false;
+ }
+
+
+ /**
+ * Decoders hack for retrocompability.
+ *
+ * @param array $decoder Values.
+ *
+ * @return array Returns the values with the correct key.
+ */
+ public function decoders(array $decoder): array
+ {
+ $values = [];
+ // Retrieve global - common inputs.
+ $values = parent::decoders($decoder);
+
+ if (isset($decoder['eventType']) === true) {
+ $values['eventType'] = $decoder['eventType'];
+ }
+
+ if (isset($decoder['maxHours']) === true) {
+ $values['maxHours'] = $decoder['maxHours'];
+ }
+
+ if (isset($decoder['eventStatus']) === true) {
+ $values['eventStatus'] = $decoder['eventStatus'];
+ }
+
+ if (isset($decoder['severity']) === true) {
+ $values['severity'] = $decoder['severity'];
+ }
+
+ if (isset($decoder['groupId']) === true) {
+ $values['groupId'] = $decoder['groupId'];
+ }
+
+ if (isset($decoder['nodes']) === true) {
+ $values['nodes'] = $decoder['nodes'];
+ }
+
+ return $values;
+ }
+
+
+ /**
+ * Generates inputs for form (specific).
+ *
+ * @return array Of inputs.
+ *
+ * @throws Exception On error.
+ */
+ public function getFormInputs(): array
+ {
+ $values = $this->values;
+
+ // Retrieve global - common inputs.
+ $inputs = parent::getFormInputs();
+
+ // Remove background field, this widget doesn't use it.
+ foreach ($inputs as $kIn => $vIn) {
+ if ($vIn['label'] === 'Background') {
+ unset($inputs[$kIn]);
+ }
+ }
+
+ $blocks = [
+ 'row1',
+ 'row2',
+ ];
+
+ $inputs['blocks'] = $blocks;
+
+ foreach ($inputs as $kInput => $vInput) {
+ $inputs['inputs']['row1'][] = $vInput;
+ }
+
+ // Event Type.
+ $fields = get_event_types();
+ $fields['not_normal'] = __('Not normal');
+
+ $inputs['inputs']['row1'][] = [
+ 'label' => __('Event type'),
+ 'arguments' => [
+ 'type' => 'select',
+ 'fields' => $fields,
+ 'class' => 'event-widget-input',
+ 'name' => 'eventType',
+ 'selected' => $values['eventType'],
+ 'return' => true,
+ 'nothing' => __('Any'),
+ 'nothing_value' => 0,
+ ],
+ ];
+
+ // Max. hours old. Default 8.
+ if (isset($values['maxHours']) === false) {
+ $values['maxHours'] = 8;
+ }
+
+ $inputs['inputs']['row1'][] = [
+ 'label' => __('Max. hours old'),
+ 'arguments' => [
+ 'name' => 'maxHours',
+ 'type' => 'number',
+ 'class' => 'event-widget-input',
+ 'value' => $values['maxHours'],
+ 'return' => true,
+ 'min' => 0,
+ ],
+ ];
+
+ // Event status.
+ $fields = [
+ -1 => __('All event'),
+ 1 => __('Only validated'),
+ 0 => __('Only pending'),
+ ];
+
+ $inputs['inputs']['row1'][] = [
+ 'label' => __('Event status'),
+ 'arguments' => [
+ 'type' => 'select',
+ 'fields' => $fields,
+ 'class' => 'event-widget-input',
+ 'name' => 'eventStatus',
+ 'selected' => $values['eventStatus'],
+ 'return' => true,
+ ],
+ ];
+
+ // Groups.
+ $return_all_group = false;
+ $selected_groups_array = explode(',', $values['groupId'][0]);
+
+ if (empty($values['groupId'][0]) === true) {
+ $selected_groups_array = [0];
+ }
+
+ if ((bool) \users_can_manage_group_all('RM') === true
+ || ($selected_groups_array[0] !== ''
+ && in_array(0, $selected_groups_array) === true)
+ ) {
+ // Return all group if user has permissions or it is a currently
+ // selected group.
+ $return_all_group = true;
+ }
+
+ $inputs['inputs']['row1'][] = [
+ 'label' => __('Groups'),
+ 'arguments' => [
+ 'type' => 'select_groups',
+ 'name' => 'groupId[]',
+ 'class' => 'event-widget-input',
+ 'returnAllGroup' => true,
+ 'privilege' => 'AR',
+ 'selected' => $selected_groups_array,
+ 'return' => true,
+ 'multiple' => true,
+ 'returnAllGroup' => $return_all_group,
+ 'required' => true,
+ ],
+ ];
+
+ // Nodes.
+ if (is_metaconsole() === true) {
+ $nodes_fields = [];
+ $servers_ids = metaconsole_get_servers();
+
+ foreach ($servers_ids as $server) {
+ $nodes_fields[$server['id']] = $server['server_name'];
+ }
+
+ $nodes_fields[0] = __('Metaconsola');
+
+ $nodes_selected = explode(',', $values['nodes']);
+
+ (isset($values['nodes']) === false) ? $nodes_selected = $servers_ids : '';
+
+ $nodes_height = count($nodes_fields);
+ if (count($nodes_fields) > 5) {
+ $nodes_height = 5;
+ }
+
+ $inputs['inputs']['row2'][] = [
+ 'label' => __('Servers'),
+ 'arguments' => [
+ 'name' => 'nodes',
+ 'type' => 'select',
+ 'fields' => $nodes_fields,
+ 'selected' => $nodes_selected,
+ 'return' => true,
+ 'multiple' => true,
+ 'class' => 'overflow-hidden',
+ 'size' => $nodes_height,
+ 'select_all' => false,
+ 'required' => true,
+ ],
+ ];
+ }
+
+ // Severity.
+ $fields = get_priorities();
+
+ $severity_selected = explode(',', $values['severity']);
+
+ if (isset($values['severity']) === false) {
+ $severity_selected = array_keys($fields);
+ }
+
+ $inputs['inputs']['row2'][] = [
+ 'label' => __('Severity'),
+ 'arguments' => [
+ 'type' => 'select',
+ 'fields' => $fields,
+ 'class' => 'event-widget-input',
+ 'name' => 'severity',
+ 'selected' => $severity_selected,
+ 'return' => true,
+ 'multiple' => true,
+ ],
+ ];
+
+ return $inputs;
+ }
+
+
+ /**
+ * Get Post for widget.
+ *
+ * @return array
+ */
+ public function getPost():array
+ {
+ // Retrieve global - common inputs.
+ $values = parent::getPost();
+
+ $values['eventType'] = \get_parameter('eventType', 0);
+ $values['maxHours'] = \get_parameter('maxHours', 8);
+ $values['eventStatus'] = \get_parameter('eventStatus', -1);
+ $values['groupId'] = \get_parameter('groupId', []);
+ $values['severity'] = \get_parameter('severity', -1);
+ $values['nodes'] = \get_parameter('nodes', 0);
+
+ return $values;
+ }
+
+
+ /**
+ * Draw widget.
+ *
+ * @return string;
+ */
+ public function load()
+ {
+ $output = '';
+
+ ui_require_css_file('events', 'include/styles/', true);
+ ui_require_javascript_file('pandora_events', 'include/javascript/', true);
+
+ $eventType = $this->values['eventType'];
+ $groupId = implode(',', $this->values['groupId']);
+ $utimestamp = strtotime('-'.$this->values['maxHours'].' hours');
+ $eventStatus = $this->values['eventStatus'];
+ $severity = $this->values['severity'];
+
+ $priorities = explode(',', $severity);
+ // Sort criticity array.
+ asort($priorities);
+
+ $count_meta = [];
+ $count_meta_tmp = [];
+ if (is_metaconsole() === true) {
+ $meta = false;
+ $nodes = $this->values['nodes'];
+
+ if (isset($nodes) === true) {
+ $servers_ids = explode(',', $nodes);
+ }
+
+ if (in_array(0, $servers_ids) === true) {
+ $meta = true;
+ unset($servers_ids[0]);
+ }
+
+ if (is_metaconsole() === true && $meta === true) {
+ $events_meta_rows = get_count_event_criticity(
+ $utimestamp,
+ $eventType,
+ $groupId,
+ $eventStatus,
+ $severity
+ );
+
+ array_push($count_meta_tmp, $events_meta_rows);
+ }
+
+ foreach ($servers_ids as $server_id) {
+ try {
+ $node = new Node((int) $server_id);
+ $node->connect();
+
+ $events_meta_rows = get_count_event_criticity(
+ $utimestamp,
+ $eventType,
+ $groupId,
+ $eventStatus,
+ $severity
+ );
+
+ array_push($count_meta_tmp, $events_meta_rows);
+ $node->disconnect();
+ } catch (\Exception $e) {
+ // Unexistent envents.
+ $node->disconnect();
+ }
+ }
+
+ foreach ($count_meta_tmp as $tmpValue) {
+ foreach ($tmpValue as $value) {
+ array_push($count_meta, $value);
+ }
+ }
+
+ $events_rows = [];
+ foreach ($priorities as $pKey) {
+ $count = 0;
+ $tmp['criticity'] = $pKey;
+ foreach ($count_meta as $kEventMeta => $vEventMeta) {
+ if ((int) $pKey === (int) $vEventMeta['criticity']) {
+ $count += (int) $vEventMeta['count'];
+ }
+ }
+
+ $tmp['count'] = $count;
+ array_push($events_rows, $tmp);
+ }
+ } else {
+ $events_rows = get_count_event_criticity(
+ $utimestamp,
+ $eventType,
+ $groupId,
+ $eventStatus,
+ $severity
+ );
+ }
+
+ $output .= '';
+
+ $width_td = (100 / count(explode(',', $severity)));
+
+ $td_count = 0;
+ foreach ($priorities as $key) {
+ $count = 0;
+ foreach ($events_rows as $event) {
+ if ((int) $key === (int) $event['criticity']) {
+ $count = $event['count'];
+ }
+ }
+
+ switch ((int) $key) {
+ case 0:
+ $text = __('Maintenance');
+ $color = get_priority_class((int) $key);
+ break;
+
+ case 1:
+ $text = __('Informational');
+ $color = get_priority_class((int) $key);
+ break;
+
+ case 2:
+ $text = __('Normal');
+ $color = get_priority_class((int) $key);
+ break;
+
+ case 3:
+ $text = __('Warning');
+ $color = get_priority_class((int) $key);
+ break;
+
+ case 4:
+ $text = __('Critical');
+ $color = get_priority_class((int) $key);
+ break;
+
+ case 5:
+ $text = __('Minor');
+ $color = get_priority_class((int) $key);
+ break;
+
+ case 6:
+ $text = __('Major');
+ $color = get_priority_class((int) $key);
+ break;
+
+ case 20:
+ $text = __('Not normal');
+ $color = get_priority_class((int) $key);
+ break;
+
+ case 21:
+ $text = __('Critical').'/'.__('Normal');
+ $color = get_priority_class((int) $key);
+ break;
+
+ case 34:
+ $text = __('Warning').'/'.__('Critical');
+ $color = get_priority_class((int) $key);
+ break;
+
+ default:
+ return false;
+ }
+
+ $border = '';
+ $td_count++;
+ if (count($priorities) > $td_count) {
+ $border = ' border-right: 1px solid white; border-collapse: collapse;';
+ }
+
+ $output .= '';
+ $output .= $count;
+ $output .= ' ';
+ $output .= $text;
+ $output .= ' | ';
+ }
+
+ $output .= '
';
+
+ return $output;
+ }
+
+
+ /**
+ * Get description.
+ *
+ * @return string.
+ */
+ public static function getDescription()
+ {
+ return __('Event cardboard');
+ }
+
+
+ /**
+ * Get Name.
+ *
+ * @return string.
+ */
+ public static function getName()
+ {
+ return 'EventCardboard';
+ }
+
+
+ /**
+ * Get size Modal Configuration.
+ *
+ * @return array
+ */
+ public function getSizeModalConfiguration(): array
+ {
+ if (is_metaconsole() === true) {
+ $size = [
+ 'width' => 950,
+ 'height' => 450,
+ ];
+ } else {
+ $size = [
+ 'width' => 900,
+ 'height' => 450,
+ ];
+ }
+
+ return $size;
+ }
+
+
+}
diff --git a/pandora_console/include/rest-api/models/VisualConsole/View.php b/pandora_console/include/rest-api/models/VisualConsole/View.php
index cd1e25fd49..e8305df830 100644
--- a/pandora_console/include/rest-api/models/VisualConsole/View.php
+++ b/pandora_console/include/rest-api/models/VisualConsole/View.php
@@ -144,6 +144,8 @@ class View extends \HTML
tinyMCE.init({
selector: "#textarea_label",
theme: "advanced",
+ convert_urls:false,
+ relative_urls:false,
content_css: "'.ui_get_full_url(false, false, false, false).'include/styles/pandora.css",
theme_advanced_font_sizes:
"4pt=.visual_font_size_4pt, " +
diff --git a/pandora_console/include/styles/meta_dashboards.css b/pandora_console/include/styles/meta_dashboards.css
index f75afafa93..f3716c0f81 100644
--- a/pandora_console/include/styles/meta_dashboards.css
+++ b/pandora_console/include/styles/meta_dashboards.css
@@ -29,3 +29,18 @@ li#select_multiple_modules_filtered {
#menu_tab li.nomn form#form-select-dashboard {
margin-top: 0px !important;
}
+
+.table-border-0 {
+ border: none !important;
+ border-spacing: 0px !important;
+}
+
+.big_data {
+ text-decoration: none;
+ font-size: 2em;
+}
+
+.med_data {
+ text-decoration: none;
+ font-size: 1.5em;
+}
diff --git a/pandora_console/include/styles/tables.css b/pandora_console/include/styles/tables.css
index 40ecaf11ba..30592ed6db 100644
--- a/pandora_console/include/styles/tables.css
+++ b/pandora_console/include/styles/tables.css
@@ -323,6 +323,27 @@ a.pandora_pagination.current:hover {
cursor: default;
}
+.filter_input_datatable {
+ width: 45% !important;
+ display: flex;
+ flex-wrap: nowrap;
+ flex-direction: row;
+ max-width: 450px;
+ min-width: 400px;
+}
+.filter_input_datatable input {
+ flex: 1;
+}
+.filter_input_datatable label {
+ width: 93px;
+ max-width: 100%;
+}
+.filter_input_datatable .select2.select2-container {
+ flex: 1;
+}
+.datatable_filter.content li.filter_input_datatable {
+ margin: 1em 0;
+}
/* Default datatable filter style */
.datatable_filter.content {
display: flex;
@@ -337,6 +358,7 @@ a.pandora_pagination.current:hover {
.datatable_filter.content li {
flex: 1 1 auto;
margin: 1em auto;
+ padding: 0px 10px;
}
.sorting_desc {
background: url(../../images/sort_down_green.png) no-repeat;
diff --git a/pandora_console/index.php b/pandora_console/index.php
index 1826dbe789..d7f124575b 100755
--- a/pandora_console/index.php
+++ b/pandora_console/index.php
@@ -1049,6 +1049,7 @@ if (isset($_GET['bye'])) {
header_remove('Set-Cookie');
setcookie(session_name(), $_COOKIE[session_name()], (time() - 4800), '/');
+ generate_csrf_code();
// Process logout.
include 'general/logoff.php';
diff --git a/pandora_console/install.php b/pandora_console/install.php
index 9a64b90539..f89f637f9e 100644
--- a/pandora_console/install.php
+++ b/pandora_console/install.php
@@ -131,7 +131,7 @@
0) {
+ $user_groups_fl = users_get_groups(
+ $config['id_user'],
+ 'AR',
+ users_can_manage_group_all('AR'),
+ true
+ );
+
+ $sql = sprintf(
+ 'SELECT id_filter, id_name
+ FROM tagent_filter
+ WHERE id_filter = %d AND id_group_filter IN (%s)',
+ $load_filter_id,
+ implode(',', array_keys($user_groups_fl))
+ );
+
+ $loaded_filter = db_get_row_sql($sql);
+}
+
+if ($loaded_filter['id_filter'] > 0) {
+ $query_filter['id_filter'] = $load_filter_id;
+ $filter = db_get_row_filter('tagent_filter', $query_filter, false);
+
+ if ($filter !== false) {
+ $group_id = (int) $filter['group_id'];
+ $recursion = $filter['recursion'];
+ $status = $filter['status'];
+ $search = $filter['search'];
+ $os = $filter['id_os'];
+ $policies = json_decode($filter['policies'], true);
+ $search_custom = $filter['search_custom'];
+ $ag_custom_fields = $filter['ag_custom_fields'];
+ }
+
+
+ if (is_array($ag_custom_fields) === false) {
+ $ag_custom_fields = json_decode(io_safe_output($ag_custom_fields), true);
+ }
+
+ if (is_array($policies) === false) {
+ $policies = json_decode(io_safe_output($policies), true);
+ }
+}
+
if (check_acl($config['id_user'], 0, 'AW')) {
// Prepare the tab system to the future.
$tab = 'setup';
@@ -247,23 +297,44 @@ if (isset($result_delete)) {
echo '