Merge remote-tracking branch 'origin/develop' into ent-8540-contel-nuevo-informe-custom-render

This commit is contained in:
Daniel Barbero Martin 2022-04-05 08:20:21 +02:00
commit c049f18bf1
37 changed files with 625 additions and 554 deletions

View File

@ -1,5 +1,5 @@
package: pandorafms-agent-unix
Version: 7.0NG.760-220404
Version: 7.0NG.760-220405
Architecture: all
Priority: optional
Section: admin

View File

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

View File

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

View File

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

View File

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

View File

@ -10,7 +10,7 @@
# **********************************************************************
PI_VERSION="7.0NG.760"
PI_BUILD="220404"
PI_BUILD="220405"
OS_NAME=`uname -s`
FORCE=0

View File

@ -186,7 +186,7 @@ UpgradeApplicationID
{}
Version
{220404}
{220405}
ViewReadme
{Yes}

View File

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

View File

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

View File

@ -1,5 +1,5 @@
package: pandorafms-console
Version: 7.0NG.760-220404
Version: 7.0NG.760-220405
Architecture: all
Priority: optional
Section: admin

View File

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

View File

@ -3,6 +3,9 @@ START TRANSACTION;
ALTER TABLE `tipam_vlan` ADD COLUMN `custom_id` bigint(20) unsigned DEFAULT NULL;
ALTER TABLE `tuser_task_scheduled`ADD COLUMN `enabled` TINYINT UNSIGNED NOT NULL DEFAULT 1;
ALTER TABLE `tevent_filter` ADD COLUMN `custom_data` VARCHAR(500) DEFAULT '';
ALTER TABLE `tevent_filter` ADD COLUMN `custom_data_filter_type` TINYINT UNSIGNED DEFAULT 0;
ALTER TABLE tagente MODIFY alias varchar(600) NOT NULL DEFAULT '';
ALTER TABLE tagente MODIFY nombre varchar(600) NOT NULL DEFAULT '';

View File

@ -1543,6 +1543,8 @@ ALTER TABLE `tevent_filter` MODIFY COLUMN `severity` text NOT NULL;
ALTER TABLE tevent_filter ADD COLUMN `server_id` int(10) NOT NULL default 0;
ALTER TABLE `tevent_filter` ADD COLUMN `time_from` TIME NULL;
ALTER TABLE `tevent_filter` ADD COLUMN `time_to` TIME NULL;
ALTER TABLE `tevent_filter` ADD COLUMN `custom_data` VARCHAR(500) DEFAULT '';
ALTER TABLE `tevent_filter` ADD COLUMN `custom_data_filter_type` TINYINT UNSIGNED DEFAULT 0;
-- ---------------------------------------------------------------------
-- Table `tusuario`

View File

@ -116,6 +116,7 @@ $fields_available['data'] = __('Data');
$fields_available['module_status'] = __('Module Status');
$fields_available['mini_severity'] = __('Severity mini');
$fields_available['module_custom_id'] = __('Module custom ID');
$fields_available['custom_data'] = __('Custom data');
// Remove fields already selected.

View File

@ -89,6 +89,8 @@ if ($id) {
$tag_without_base64 = base64_encode($tag_without_json_clean);
$filter_only_alert = $filter['filter_only_alert'];
$custom_data = $filter['custom_data'];
$custom_data_filter_type = $filter['custom_data_filter_type'];
if ($id_agent_module != 0) {
$text_module = modules_get_agentmodule_name($id_agent_module);
@ -165,30 +167,34 @@ if ($update || $create) {
$tag_without_json = io_safe_input(base64_decode($tag_without_base64));
$filter_only_alert = get_parameter('filter_only_alert', '');
$custom_data = get_parameter('custom_data', '');
$custom_data_filter_type = get_parameter('custom_data_filter_type', '');
$values = [
'id_name' => $id_name,
'id_group_filter' => $id_group_filter,
'id_group' => $id_group,
'event_type' => $event_type,
'severity' => $severity,
'status' => $status,
'search' => $search,
'text_agent' => $text_agent,
'id_agent_module' => $id_agent_module,
'id_agent' => $id_agent,
'pagination' => $pagination,
'event_view_hr' => $event_view_hr,
'id_user_ack' => $id_user_ack,
'group_rep' => $group_rep,
'tag_with' => $tag_with_json,
'tag_without' => $tag_without_json,
'date_from' => $date_from,
'date_to' => $date_to,
'source' => $source,
'id_extra' => $id_extra,
'user_comment' => $user_comment,
'filter_only_alert' => $filter_only_alert,
'id_name' => $id_name,
'id_group_filter' => $id_group_filter,
'id_group' => $id_group,
'event_type' => $event_type,
'severity' => $severity,
'status' => $status,
'search' => $search,
'text_agent' => $text_agent,
'id_agent_module' => $id_agent_module,
'id_agent' => $id_agent,
'pagination' => $pagination,
'event_view_hr' => $event_view_hr,
'id_user_ack' => $id_user_ack,
'group_rep' => $group_rep,
'tag_with' => $tag_with_json,
'tag_without' => $tag_without_json,
'date_from' => $date_from,
'date_to' => $date_to,
'source' => $source,
'id_extra' => $id_extra,
'user_comment' => $user_comment,
'filter_only_alert' => $filter_only_alert,
'custom_data' => $custom_data,
'custom_data_filter_type' => $custom_data_filter_type,
];
$severity = explode(',', $severity);
@ -627,9 +633,26 @@ $table->data[23][1] = html_print_input_text('id_extra', $id_extra, '', 11, 255,
$table->data[24][0] = '<b>'.__('Comment').'</b>';
$table->data[24][1] = html_print_input_text('user_comment', $user_comment, '', 35, 255, true);
$table->data[25][0] = '<b>'.__('Custom data filter type').'</b>';
$table->data[25][1] = html_print_select(
[
'0' => __('Filter custom data by name field'),
'1' => __('Filter custom data by value field'),
],
'custom_data_filter_type',
$custom_data_filter_type,
'',
false,
'',
true
);
$table->data[26][0] = '<b>'.__('Custom data').'</b>';
$table->data[26][1] = html_print_input_text('custom_data', $custom_data, '', 35, 255, true);
if (is_metaconsole()) {
$table->data[25][0] = '<b>'.__('Id souce event').'</b>';
$table->data[25][1] = html_print_input_text(
$table->data[27][0] = '<b>'.__('Id souce event').'</b>';
$table->data[27][1] = html_print_input_text(
'id_source_event',
$id_source_event,
'',

File diff suppressed because it is too large Load Diff

View File

@ -309,6 +309,8 @@ if ($save_event_filter) {
$values['id_extra'] = get_parameter('id_extra');
$values['user_comment'] = get_parameter('user_comment');
$values['id_source_event'] = get_parameter('id_source_event');
$values['custom_data'] = get_parameter('custom_data');
$values['custom_data_filter_type'] = get_parameter('custom_data_filter_type');
if (is_metaconsole()) {
$values['server_id'] = get_parameter('server_id');
@ -363,6 +365,8 @@ if ($update_event_filter) {
$values['id_extra'] = get_parameter('id_extra');
$values['user_comment'] = get_parameter('user_comment');
$values['id_source_event'] = get_parameter('id_source_event');
$values['custom_data'] = get_parameter('custom_data');
$values['custom_data_filter_type'] = get_parameter('custom_data_filter_type');
if (is_metaconsole() === true) {
$values['server_id'] = get_parameter('server_id');
@ -834,7 +838,9 @@ function save_new_filter() {
"id_extra": $("#text-id_extra").val(),
"user_comment": $("#text-user_comment").val(),
"id_source_event": $("#text-id_source_event").val(),
"server_id": $("#server_id").val()
"server_id": $("#server_id").val(),
"custom_data": $("#text-custom_data").val(),
"custom_data_filter_type": $("#custom_data_filter_type").val()
},
function (data) {
$("#info_box").hide();
@ -907,7 +913,9 @@ function save_update_filter() {
"id_extra": $("#text-id_extra").val(),
"user_comment": $("#text-user_comment").val(),
"id_source_event": $("#text-id_source_event").val(),
"server_id": $("#server_id").val()
"server_id": $("#server_id").val(),
"custom_data": $("#text-custom_data").val(),
"custom_data_filter_type": $("#custom_data_filter_type").val()
},
function (data) {

View File

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

View File

@ -210,6 +210,7 @@ function events_get_all_fields()
$columns['data'] = __('Data');
$columns['module_status'] = __('Module status');
$columns['module_custom_id'] = __('Module custom id');
$columns['custom_data'] = __('Custom data');
return $columns;
}
@ -310,6 +311,9 @@ function events_get_column_name($field, $table_alias=false)
case 'direccion':
return __('Agent IP');
case 'custom_data':
return __('Custom data');
default:
return __($field);
}
@ -1122,6 +1126,23 @@ function events_get_all(
);
}
// Custom data.
if (empty($filter['custom_data']) === false) {
if ($filter['custom_data_filter_type'] === '1') {
$sql_filters[] = sprintf(
' AND JSON_VALID(custom_data) = 1
AND (JSON_EXTRACT(custom_data, "$.*") LIKE lower("%%%s%%") COLLATE utf8mb4_0900_ai_ci) ',
io_safe_output($filter['custom_data'])
);
} else {
$sql_filters[] = sprintf(
' AND JSON_VALID(custom_data) = 1
AND (JSON_SEARCH(JSON_KEYS(custom_data), "all", lower("%%%s%%") COLLATE utf8mb4_0900_ai_ci) IS NOT NULL) ',
io_safe_output($filter['custom_data'])
);
}
}
// Validated or in process by.
if (empty($filter['id_user_ack']) === false) {
$sql_filters[] = sprintf(

View File

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

View File

@ -134,7 +134,7 @@ if ($group_rep == 2) {
echo '<div class="nf">'.__('No events').'</div>';
}
} else {
// fields that the user has selected to show
// Fields that the user has selected to show.
if ($meta) {
$show_fields = events_meta_get_custom_fields_user();
} else {
@ -345,6 +345,13 @@ if ($group_rep == 2) {
$i++;
}
if ($fields === 'custom_data') {
$table->head[$i] = __('Custom data');
$table->align[$i] = 'left';
$i++;
}
}
if (in_array('estado', $show_fields)) {

View File

@ -226,6 +226,16 @@ $server_id = get_parameter(
$filter['id_server_meta']
);
$custom_data_filter_type = get_parameter(
'filter[custom_data_filter_type]',
$filter['custom_data_filter_type']
);
$custom_data = get_parameter(
'filter[custom_data]',
$filter['custom_data']
);
if (is_metaconsole() === true) {
// Connect to node database.
$id_node = $server_id;
@ -530,6 +540,8 @@ if ($loaded_filter !== false && $from_event_graph != 1 && !isset($fb64)) {
$user_comment = $filter['user_comment'];
$id_source_event = ($filter['id_source_event'] ?? '');
$server_id = $filter['server_id'];
$custom_data = $filter['custom_data'];
$custom_data_filter_type = $filter['custom_data_filter_type'];
}
}
@ -1451,6 +1463,54 @@ $adv_inputs[] = html_print_div(
true
);
// Custom data filter type.
$custom_data_filter_type_input = html_print_select(
[
'0' => __('Filter custom data by field name'),
'1' => __('Filter custom data by field value'),
],
'custom_data_filter_type',
$custom_data_filter_type,
'',
false,
-1,
true
);
$adv_inputs[] = html_print_div(
[
'class' => 'filter_input',
'content' => sprintf(
'<label>%s</label>%s',
__('Custom data filter'),
$custom_data_filter_type_input
),
],
true
);
// Custom data.
$custom_data_input = html_print_input_text(
'custom_data',
$custom_data,
'',
5,
255,
true
);
$adv_inputs[] = html_print_div(
[
'class' => 'filter_input',
'content' => sprintf(
'<label>%s</label>%s',
__('Custom data search'),
$custom_data_input
),
],
true
);
// Tags.
if (is_metaconsole() === true) {
$data = '<fieldset><legend class="pdd_0px">'.__('Events with following tags').'</legend>'.html_print_table($tabletags_with, true).'</fieldset>';
@ -2259,6 +2319,27 @@ function process_datatables_item(item) {
/* Module name */
item.id_agentmodule = item.module_name;
if (item.custom_data !== '') {
var custom_data_str = '';
var item_custom_data_obj = (function(json_str) {
try {
return JSON.parse(json_str);
} catch (err) {
return false;
}
})(item.custom_data);
if (item_custom_data_obj !== false) {
for (const [attr_name, val] of Object.entries(item_custom_data_obj)) {
custom_data_str += attr_name + ' = ' + val + '<br>';
}
item.custom_data = custom_data_str;
} else {
item.custom_data = '';
}
}
}
/* Datatables auxiliary functions ends */

View File

@ -127,6 +127,8 @@ if (is_ajax()) {
$values['source'] = get_parameter('source');
$values['id_extra'] = get_parameter('id_extra');
$values['user_comment'] = get_parameter('user_comment');
$values['custom_data'] = get_parameter('custom_data');
$values['custom_data_filter_type'] = get_parameter('custom_data_filter_type');
if (is_metaconsole()) {
$values['id_source_event'] = get_parameter('id_source_event');
@ -182,6 +184,8 @@ if (is_ajax()) {
$values['source'] = get_parameter('source');
$values['id_extra'] = get_parameter('id_extra');
$values['user_comment'] = get_parameter('user_comment');
$values['custom_data'] = get_parameter('custom_data');
$values['custom_data_filter_type'] = get_parameter('custom_data_filter_type');
if (is_metaconsole()) {
$values['id_source_event'] = get_parameter('id_source_event');
@ -1567,8 +1571,9 @@ $(document).ready( function() {
"id_extra": $("#text-id_extra").val(),
"user_comment": $("#text-user_comment").val(),
"id_source_event": $("#text-id_source_event").val(),
"server_id" : $("#server_id").val()
"server_id" : $("#server_id").val(),
"custom_data" : $("#text-custom_data").val(),
"custom_data_filter_type" : $("#custom_data_filter_type").val()
},
function (data) {
$(".info_box").hide();
@ -1670,7 +1675,9 @@ $(document).ready( function() {
"id_extra": $("#text-id_extra").val(),
"user_comment": $("#text-user_comment").val(),
"id_source_event": $("#text-id_source_event").val(),
"server_id" : $("#server_id").val()
"server_id" : $("#server_id").val(),
"custom_data" : $("#text-custom_data").val()
"custom_data_filter_type" : $("#custom_data_filter_type").val()
},
function (data) {
$(".info_box").hide();

View File

@ -226,7 +226,7 @@ try {
if ($custom_data_array !== null) {
array_walk(
$custom_data_array,
function (&$value, $field) {
function (&$value, $field) use ($separator) {
if (is_array($value) === true) {
$value = '['.implode($separator, $value).']';
}

View File

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

View File

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

View File

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

View File

@ -1251,6 +1251,8 @@ CREATE TABLE IF NOT EXISTS `tevent_filter` (
`server_id` INT NOT NULL DEFAULT 0,
`time_from` TIME NULL,
`time_to` TIME NULL,
`custom_data` VARCHAR(500) DEFAULT '',
`custom_data_filter_type` TINYINT UNSIGNED DEFAULT 0,
PRIMARY KEY (`id_filter`)
) ENGINE=InnoDB DEFAULT CHARSET=UTF8MB4;

View File

@ -1,5 +1,5 @@
package: pandorafms-server
Version: 7.0NG.760-220404
Version: 7.0NG.760-220405
Architecture: all
Priority: optional
Section: admin

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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