Merge remote-tracking branch 'origin/develop' into ent-5708-review-discovery-h-d

This commit is contained in:
fbsanchez 2020-04-30 16:26:47 +02:00
commit 7ad06596ff
65 changed files with 1635 additions and 667 deletions

View File

@ -1,5 +1,5 @@
package: pandorafms-agent-unix package: pandorafms-agent-unix
Version: 7.0NG.745-200427 Version: 7.0NG.745-200430
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.745-200427" pandora_version="7.0NG.745-200430"
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

@ -55,7 +55,7 @@ my $Sem = undef;
my $ThreadSem = undef; my $ThreadSem = undef;
use constant AGENT_VERSION => '7.0NG.745'; use constant AGENT_VERSION => '7.0NG.745';
use constant AGENT_BUILD => '200427'; use constant AGENT_BUILD => '200430';
# 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.745 %define version 7.0NG.745
%define release 200427 %define release 200430
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.745 %define version 7.0NG.745
%define release 200427 %define release 200430
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.745" PI_VERSION="7.0NG.745"
PI_BUILD="200427" PI_BUILD="200430"
OS_NAME=`uname -s` OS_NAME=`uname -s`
FORCE=0 FORCE=0

View File

@ -186,7 +186,7 @@ UpgradeApplicationID
{} {}
Version Version
{200427} {200430}
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.745(Build 200427)") #define PANDORA_VERSION ("7.0NG.745(Build 200430)")
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.745(Build 200427))" VALUE "ProductVersion", "(7.0NG.745(Build 200430))"
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.745-200427 Version: 7.0NG.745-200430
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.745-200427" pandora_version="7.0NG.745-200430"
package_pear=0 package_pear=0
package_pandora=1 package_pandora=1

View File

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

View File

@ -8993,22 +8993,22 @@ function reporting_get_stats_indicators($data, $width=280, $height=20, $html=tru
if ($html) { if ($html) {
$tdata[0] = '<fieldset class="databox tactical_set"> $tdata[0] = '<fieldset class="databox tactical_set">
<legend>'.__('Server health').ui_print_help_tip(sprintf(__('%d Downed servers'), $servers['down']), true).'</legend>'.progress_bar($servers['health'], $width, $height, '', 0).'</fieldset>'; <legend>'.__('Server health').ui_print_help_tip(sprintf(__('%d Downed servers'), (int) $servers['down']), true).'</legend>'.progress_bar($servers['health'], $width, $height, '', 0).'</fieldset>';
$table_ind->rowclass[] = ''; $table_ind->rowclass[] = '';
$table_ind->data[] = $tdata; $table_ind->data[] = $tdata;
$tdata[0] = '<fieldset class="databox tactical_set"> $tdata[0] = '<fieldset class="databox tactical_set">
<legend>'.__('Monitor health').ui_print_help_tip(sprintf(__('%d Not Normal monitors'), $data['monitor_not_normal']), true).'</legend>'.progress_bar($data['monitor_health'], $width, $height, $data['monitor_health'].'% '.__('of monitors up'), 0).'</fieldset>'; <legend>'.__('Monitor health').ui_print_help_tip(sprintf(__('%d Not Normal monitors'), (int) $data['monitor_not_normal']), true).'</legend>'.progress_bar($data['monitor_health'], $width, $height, $data['monitor_health'].'% '.__('of monitors up'), 0).'</fieldset>';
$table_ind->rowclass[] = ''; $table_ind->rowclass[] = '';
$table_ind->data[] = $tdata; $table_ind->data[] = $tdata;
$tdata[0] = '<fieldset class="databox tactical_set"> $tdata[0] = '<fieldset class="databox tactical_set">
<legend>'.__('Module sanity').ui_print_help_tip(sprintf(__('%d Not inited monitors'), $data['monitor_not_init']), true).'</legend>'.progress_bar($data['module_sanity'], $width, $height, $data['module_sanity'].'% '.__('of total modules inited'), 0).'</fieldset>'; <legend>'.__('Module sanity').ui_print_help_tip(sprintf(__('%d Not inited monitors'), (int) $data['monitor_not_init']), true).'</legend>'.progress_bar($data['module_sanity'], $width, $height, $data['module_sanity'].'% '.__('of total modules inited'), 0).'</fieldset>';
$table_ind->rowclass[] = ''; $table_ind->rowclass[] = '';
$table_ind->data[] = $tdata; $table_ind->data[] = $tdata;
$tdata[0] = '<fieldset class="databox tactical_set"> $tdata[0] = '<fieldset class="databox tactical_set">
<legend>'.__('Alert level').ui_print_help_tip(sprintf(__('%d Fired alerts'), $data['monitor_alerts_fired']), true).'</legend>'.progress_bar($data['alert_level'], $width, $height, $data['alert_level'].'% '.__('of defined alerts not fired'), 0).'</fieldset>'; <legend>'.__('Alert level').ui_print_help_tip(sprintf(__('%d Fired alerts'), (int) $data['monitor_alerts_fired']), true).'</legend>'.progress_bar($data['alert_level'], $width, $height, $data['alert_level'].'% '.__('of defined alerts not fired'), 0).'</fieldset>';
$table_ind->rowclass[] = ''; $table_ind->rowclass[] = '';
$table_ind->data[] = $tdata; $table_ind->data[] = $tdata;

View File

@ -244,8 +244,19 @@ function initialiceLayout(data) {
} }
$("#delete-widget-" + id).click(function(event) { $("#delete-widget-" + id).click(function(event) {
var nodo = event.target.offsetParent; // eslint-disable-next-line no-undef
deleteCell(id, nodo.parentNode); confirmDialog({
title: "Are you sure?",
message:
"<h4 style='text-align: center;padding-top: 20px;'>All changes made to this widget will be lost</h4>",
cancel: "Cancel",
ok: "Ok",
onAccept: function() {
// Continue execution.
var nodo = event.target.offsetParent;
deleteCell(id, nodo.parentNode);
}
});
}); });
$("#configure-widget-" + id).click(function() { $("#configure-widget-" + id).click(function() {

View File

@ -1042,6 +1042,17 @@ class Manager
$cellData['id_widget'] = $this->widgetId; $cellData['id_widget'] = $this->widgetId;
} }
} }
$instance = $this->instanceWidget();
$cellData['options'] = $instance->decoders(
$instance->getOptionsWidget()
);
if (isset($cellData['options']['title']) === false) {
$cellData['options']['title'] = $instance->getDescription();
}
$cellData['options'] = json_encode($cellData['options']);
} }
View::render( View::render(

View File

@ -59,7 +59,7 @@ class Widget
$cellClass = new Cell($this->cellId, $this->dashboardId); $cellClass = new Cell($this->cellId, $this->dashboardId);
$this->dataCell = $cellClass->get(); $this->dataCell = $cellClass->get();
$this->values = $this->getOptionsWidget(); $this->values = $this->decoders($this->getOptionsWidget());
} }
return $this; return $this;
@ -535,6 +535,34 @@ class Widget
} }
/**
* Decoders hack for retrocompability.
*
* @param array $decoder Values.
*
* @return array Returns the values with the correct key.
*/
public function decoders(array $decoder):array
{
$values = [];
if (isset($decoder['title']) === true) {
$values['title'] = $decoder['title'];
}
if (isset($decoder['background-color']) === true) {
$values['background'] = $decoder['background-color'];
}
if (isset($decoder['background']) === true) {
$values['background'] = $decoder['background'];
}
return $values;
}
/** /**
* Size Cell. * Size Cell.
* *

View File

@ -169,489 +169,11 @@ class AgentModuleWidget extends Widget
// This forces at least a first configuration. // This forces at least a first configuration.
$this->configurationRequired = false; $this->configurationRequired = false;
if (empty($this->values['moduleId']) === true) {
$this->configurationRequired = true;
}
$this->overflow_scrollbars = false; $this->overflow_scrollbars = false;
} }
/*
// DO NOT CHANGE THIS VALUE.
$id_group = isset($this->options['search_group_'.$id]) ? $this->options['search_group_'.$id] : 0;
$agent_conf_key = 'id_agent_'.$id;
$id_agent = $this->options[$agent_conf_key];
$module_conf_key = 'id_module_'.$id;
$id_module = $this->options[$module_conf_key];
$recursion_checked = $this->options['recursion'];
$this->add_configuration(
'search_group_'.$id,
__('Group'),
OPTION_TREE_GROUP_SELECT
);
$list_agents = agents_get_group_agents(
$id_group,
false,
'lower',
false,
$recursion_checked
);
if (!isset($this->options['selection_agent_module_'.$id])
|| $this->options['selection_agent_module_'.$id] == ''
|| $this->options['selection_agent_module_'.$id] == null
) {
$selection_agent_module = 'common';
} else {
$selection_agent_module = $this->options['selection_agent_module_'.$id];
}
$limit_common = '';
$sql = false;
if (!empty($id_agent)) {
if ($selection_agent_module == 'common') {
$limit_common = sprintf(
' AND (SELECT count(nombre)
FROM tagente_modulo t2
WHERE t2.delete_pending = 0
AND t1.nombre = t2.nombre
AND t2.id_agente IN (%s)) = (%d)',
implode(',', (array) $id_agent),
count($id_agent)
);
}
$sql = sprintf(
'SELECT DISTINCT nombre
FROM tagente_modulo t1
WHERE id_agente IN (%s)
AND delete_pending = 0 %s ORDER BY nombre',
implode(', ', (array) $id_agent),
$limit_common
);
}
if (empty($id_module)) {
$this->options[$module_conf_key] = index_array(
db_get_all_rows_sql($sql),
'nombre',
'nombre'
);
}
$this->add_configuration(
'recursion',
__('Recursion'),
OPTION_BOOLEAN
);
$this->add_configuration(
$agent_conf_key,
__('Agent'),
OPTION_SELECT_MULTISELECTION,
['values' => $list_agents]
);
$this->add_configuration(
'selection_agent_module_'.$id,
__('Show common modules'),
OPTION_SINGLE_SELECT,
[
'values' => [
'common' => __('Show common modules'),
'all' => __('Show all modules'),
],
]
);
$this->add_configuration(
$module_conf_key,
__('Module'),
OPTION_SELECT_MULTISELECTION,
[
'values' => index_array(
db_get_all_rows_sql($sql),
'nombre',
'nombre'
),
]
);
$this->add_configuration(
'',
'',
OPTION_CUSTOM_INPUT,
[
'widget' => $this,
'entire_row' => true,
'update' => false,
]
);
*/
function print_configuration_custom($return=true)
{
$id = $this->getId();
ob_start();
?>
<script>
$(document).ready(function() {
recalculate_modules_select_agent_module(
$("#selection_agent_module_<?php echo $id; ?>").val()
);
function recalculate_modules_select_agent_module (selection_mode) {
var idAgents = Array();
jQuery.each ($('#id_agent_<?php echo $id; ?> option:selected'), function (i, val) {
idAgents.push($(val).val());
});
jQuery.post ('ajax.php',
{"page": "operation/agentes/ver_agente",
"get_modules_group_value_name_json": 1,
"selection": selection_mode == 'all' ? 1 : 0,
"id_agents[]": idAgents
},
function (data, status) {
$('#id_module_<?php echo $id; ?>').empty ();
if (data) {
jQuery.each (data, function (id, value) {
$('#id_module_<?php echo $id; ?>')
.append ($('<option></option>')
.html(value)
.prop("value", value)
.prop("selected", 'selected'));
});
}
},
"json"
);
}
$('#search_group_<?php echo $id; ?>').on('change',function() {
jQuery.post ("ajax.php",
{
"page" : "operation/agentes/ver_agente",
"get_agents_group_json" : 1,
"id_group" : this.value,
"recursion" : ($('#checkbox-recursion-<?php echo $id; ?>').is(':checked')) ? 1 : 0
},
function (data, status) {
$('#id_agent_<?php echo $id; ?>').html('');
jQuery.each (data, function(id, value) {
// Remove keys_prefix from the index.
option = $("<option></option>")
.prop("value", id)
.prop("selected", 'selected')
.html(value);
$('#id_agent_<?php echo $id; ?>').append (option);
});
recalculate_modules_select_agent_module(
$("#selection_agent_module_<?php echo $id; ?>").val()
);
},
"json"
);
});
$('#checkbox-recursion-<?php echo $id; ?>').on('change', function() {
($('#hidden-recursion_sent').val() === '1') ? $('#hidden-recursion_sent').val('0') : $('#hidden-recursion_sent').val('1');
jQuery.post ("ajax.php",
{
"page" : "operation/agentes/ver_agente",
"get_agents_group_json" : 1,
"id_group" : $('#search_group_<?php echo $id; ?>').val(),
"recursion" : ($('#checkbox-recursion-<?php echo $id; ?>').is(':checked')) ? 1 : 0
},
function (data, status) {
$('#id_agent_<?php echo $id; ?>').html('');
jQuery.each (data, function(id, value) {
// Remove keys_prefix from the index.
option = $("<option></option>")
.prop("value", id)
.prop("selected", 'selected')
.html(value);
$('#id_agent_<?php echo $id; ?>').append (option);
});
recalculate_modules_select_agent_module(
$("#selection_agent_module_<?php echo $id; ?>").val()
);
},
"json"
);
});
$("#id_agent_<?php echo $id; ?>").on('change',function () {
recalculate_modules_select_agent_module(
$("#selection_agent_module_<?php echo $id; ?>").val()
);
});
$("#selection_agent_module_<?php echo $id; ?>").on('change',function(evt) {
recalculate_modules_select_agent_module(
$("#selection_agent_module_<?php echo $id; ?>").val()
);
});
});
</script>
<?php
return ob_get_clean();
}
public function generate_data_agent_module($agents, $all_modules)
{
$return = [];
$cont = 0;
$name = '';
foreach ($all_modules as $key => $module) {
if ($module == $name) {
$modules_by_name[($cont - 1)]['id'][] = $key;
} else {
$name = $module;
$modules_by_name[$cont]['name'] = $name;
$modules_by_name[$cont]['id'][] = $key;
$cont ++;
}
}
foreach ($agents as $agent) {
if (!users_access_to_agent($agent['id_agente'])) {
continue;
}
$row = [];
$row['agent_status'] = agents_get_status($agent['id_agente'], true);
$row['agent_name'] = $agent['nombre'];
$row['agent_alias'] = $agent['alias'];
$agent_modules = agents_get_modules($agent['id_agente']);
$row['modules'] = [];
foreach ($modules_by_name as $module) {
$row['modules'][$module['name']] = null;
foreach ($module['id'] as $module_id) {
if (array_key_exists($module_id, $agent_modules)) {
$row['modules'][$module['name']] = modules_get_agentmodule_status($module_id);
break;
}
}
}
$return[] = $row;
}
return $return;
}
public function generate_view_agent_module($visual_data)
{
$table_data = '<div>';
$table_data .= '<table class="widget_agent_module" cellpadding="1" cellspacing="0" border="0" style="background-color: #EEE;">';
if (!empty($visual_data)) {
$table_data .= '<th>'.__('Agents').' / '.__('Modules').'</th>';
$array_names = [];
foreach ($visual_data as $data) {
foreach ($data['modules'] as $module_name => $module) {
if ($module === null || in_array($module_name, $array_names)) {
continue;
} else {
$array_names[] = $module_name;
}
}
}
natcasesort($array_names);
foreach ($array_names as $module_name) {
$file_name = ui_print_truncate_text(
$module_name,
'module_small',
false,
true,
false,
'...'
);
$table_data .= '<th style="padding: 10px;">'.$file_name.'</th>';
}
foreach ($visual_data as $row) {
$table_data .= "<tr style='height: 35px;'>";
switch ($row['agent_status']) {
case AGENT_STATUS_ALERT_FIRED:
$rowcolor = COL_ALERTFIRED;
$textcolor = '#000';
break;
case AGENT_STATUS_CRITICAL:
$rowcolor = COL_CRITICAL;
$textcolor = '#FFF';
break;
case AGENT_STATUS_WARNING:
$rowcolor = COL_WARNING;
$textcolor = '#000';
break;
case AGENT_STATUS_NORMAL:
$rowcolor = COL_NORMAL;
$textcolor = '#FFF';
break;
case AGENT_STATUS_UNKNOWN:
case AGENT_STATUS_ALL:
default:
$rowcolor = COL_UNKNOWN;
$textcolor = '#FFF';
break;
}
$file_name = ui_print_truncate_text(
$row['agent_alias'],
'agent_small',
false,
true,
false,
'...'
);
$table_data .= "<td style='background-color: ".$rowcolor.";'>".$file_name.'</td>';
foreach ($row['modules'] as $module_name => $module) {
if ($module === null) {
if (in_array($module_name, $array_names)) {
$table_data .= "<td style='background-color: #DDD;'></td>";
} else {
continue;
}
} else {
$table_data .= "<td style='text-align: center; background-color: #DDD;'>";
switch ($module) {
case AGENT_STATUS_NORMAL:
$table_data .= ui_print_status_image(
'module_ok.png',
__(
'%s in %s : NORMAL',
$module_name,
$row['agent_alias']
),
true,
[
'width' => '20px',
'height' => '20px',
]
);
break;
case AGENT_STATUS_CRITICAL:
$table_data .= ui_print_status_image(
'module_critical.png',
__(
'%s in %s : CRITICAL',
$module_name,
$row['agent_alias']
),
true,
[
'width' => '20px',
'height' => '20px',
]
);
break;
case AGENT_STATUS_WARNING:
$table_data .= ui_print_status_image(
'module_warning.png',
__(
'%s in %s : WARNING',
$module_name,
$row['agent_alias']
),
true,
[
'width' => '20px',
'height' => '20px',
]
);
break;
case AGENT_STATUS_UNKNOWN:
$table_data .= ui_print_status_image(
'module_unknown.png',
__(
'%s in %s : UNKNOWN',
$module_name,
$row['agent_alias']
),
true,
[
'width' => '20px',
'height' => '20px',
]
);
break;
case 4:
$table_data .= ui_print_status_image(
'module_no_data.png',
__(
'%s in %s : Not initialize',
$module_name,
$row['agent_alias']
),
true,
[
'width' => '20px',
'height' => '20px',
]
);
break;
case AGENT_STATUS_ALERT_FIRED:
default:
$table_data .= ui_print_status_image(
'module_alertsfired.png',
__(
'%s in %s : ALERTS FIRED',
$module_name,
$row['agent_alias']
),
true,
[
'width' => '20px',
'height' => '20px',
]
);
break;
}
$table_data .= '</td>';
}
}
$table_data .= '</tr>';
}
} else {
$table_data .= '<tr><td>'.__('Please configure this widget before usage').'</td></tr>';
}
$table_data .= '</table>';
$table_data .= '</div>';
return $table_data;
}
/** /**
* Generates inputs for form (specific). * Generates inputs for form (specific).
* *
@ -666,38 +188,12 @@ class AgentModuleWidget extends Widget
// Retrieve global - common inputs. // Retrieve global - common inputs.
$inputs = parent::getFormInputs(); $inputs = parent::getFormInputs();
// Autocomplete agents.
$inputs[] = [ $inputs[] = [
'label' => __('Agent'), 'label' => \ui_print_error_message(
'arguments' => [ __('This widget has been removed'),
'type' => 'autocomplete_agent', '',
'name' => 'agentAlias', true
'id_agent_hidden' => $values['agentId'], ),
'name_agent_hidden' => 'agentId',
'server_id_hidden' => $values['metaconsoleId'],
'name_server_hidden' => 'metaconsoleId',
'return' => true,
'module_input' => true,
'module_name' => 'moduleId',
'module_none' => false,
'size' => 0,
],
];
// Autocomplete module.
$inputs[] = [
'label' => __('Module'),
'arguments' => [
'type' => 'autocomplete_module',
'fields' => $fields,
'name' => 'moduleId',
'selected' => $values['moduleId'],
'return' => true,
'sort' => false,
'agent_id' => $values['agentId'],
'metaconsole_id' => $values['metaconsoleId'],
'style' => 'width: inherit;',
],
]; ];
return $inputs; return $inputs;
@ -714,12 +210,6 @@ class AgentModuleWidget extends Widget
// Retrieve global - common inputs. // Retrieve global - common inputs.
$values = parent::getPost(); $values = parent::getPost();
$values['agentId'] = \get_parameter('agentId', 0);
$values['metaconsoleId'] = \get_parameter('metaconsoleId', 0);
$values['moduleId'] = \get_parameter('moduleId', 0);
$values['period'] = \get_parameter('period', 0);
$values['showLegend'] = \get_parameter_switch('showLegend');
return $values; return $values;
} }
@ -733,45 +223,14 @@ class AgentModuleWidget extends Widget
{ {
global $config; global $config;
// TODO:XXX WIP. $output .= '<div class="container-center">';
return 'WIP in this widget'; $output .= \ui_print_error_message(
/* __('This widget has been removed'),
$this->body = ''; '',
$id_agent = $this->options['id_agent_'.$this->getId()]; true
if (! check_acl($config['id_user'], 0, 'AR')) { );
$this->body = __('You don\'t have access'); $output .= '</div>';
return; return $output;
}
$id_module = $this->options['id_module_'.$this->getId()];
if ($id_agent) {
$sql = 'SELECT id_agente,nombre,alias
FROM tagente
WHERE id_agente IN ('.implode(',', $id_agent).')
ORDER BY id_agente';
$agents = db_get_all_rows_sql($sql);
if ($agents === false) {
$agents = [];
}
$sql = 'SELECT id_agente_modulo,nombre
FROM tagente_modulo
WHERE id_agente IN ('.implode(',', $id_agent).")
AND nombre IN ('".implode("','", $id_module)."')
AND delete_pending = 0 ORDER BY nombre";
$modules = index_array(db_get_all_rows_sql($sql), 'id_agente_modulo', 'nombre');
if ($modules === false) {
$modules = [];
}
} else {
$agents = [];
$modules = [];
}
$visual_data = $this->generate_data_agent_module($agents, $modules);
$this->body .= $this->generate_view_agent_module($visual_data);
*/
} }

View File

@ -146,7 +146,7 @@ class AlertsFiredWidget extends Widget
$this->gridWidth = $gridWidth; $this->gridWidth = $gridWidth;
// Options. // Options.
$this->values = $this->getOptionsWidget(); $this->values = $this->decoders($this->getOptionsWidget());
// Positions. // Positions.
$this->position = $this->getPositionWidget(); $this->position = $this->getPositionWidget();
@ -176,6 +176,31 @@ class AlertsFiredWidget extends Widget
} }
/**
* 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['group']) === true) {
$values['groupId'] = $decoder['group'];
}
if (isset($decoder['groupId']) === true) {
$values['groupId'] = $decoder['groupId'];
}
return $values;
}
/** /**
* Generates inputs for form (specific). * Generates inputs for form (specific).
* *
@ -234,7 +259,7 @@ class AlertsFiredWidget extends Widget
$output = ''; $output = '';
if ($this->values['groupId'] === 0) { if ((int) $this->values['groupId'] === 0) {
$groups = users_get_groups(false, 'AR', false); $groups = users_get_groups(false, 'AR', false);
} else { } else {
$groups = [$this->values['groupId'] => '']; $groups = [$this->values['groupId'] => ''];
@ -254,7 +279,7 @@ class AlertsFiredWidget extends Widget
$flag = false; $flag = false;
foreach ($groups as $id_group => $name) { foreach ($groups as $id_group => $name) {
$alerts_group = get_group_alerts($id_group); $alerts_group = get_group_alerts([$id_group]);
if (isset($alerts_group['simple']) === true) { if (isset($alerts_group['simple']) === true) {
$alerts_group = $alerts_group['simple']; $alerts_group = $alerts_group['simple'];
} }

View File

@ -142,7 +142,7 @@ class ClockWidget extends Widget
$this->gridWidth = $gridWidth; $this->gridWidth = $gridWidth;
// Options. // Options.
$this->values = $this->getOptionsWidget(); $this->values = $this->decoders($this->getOptionsWidget());
// Positions. // Positions.
$this->position = $this->getPositionWidget(); $this->position = $this->getPositionWidget();
@ -172,6 +172,31 @@ class ClockWidget extends Widget
} }
/**
* 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['clock_type']) === true) {
$values['clockType'] = $decoder['clock_type'];
}
if (isset($decoder['clockType']) === true) {
$values['clockType'] = $decoder['clockType'];
}
return $values;
}
/** /**
* Generates inputs for form (specific). * Generates inputs for form (specific).
* *

View File

@ -104,6 +104,13 @@ class CustomGraphWidget extends Widget
*/ */
protected $gridWidth; protected $gridWidth;
/**
* Cell ID.
*
* @var integer
*/
protected $cellId;
/** /**
* Construct. * Construct.
@ -141,8 +148,11 @@ class CustomGraphWidget extends Widget
// Grid Width. // Grid Width.
$this->gridWidth = $gridWidth; $this->gridWidth = $gridWidth;
// Cell Id.
$this->cellId = $cellId;
// Options. // Options.
$this->values = $this->getOptionsWidget(); $this->values = $this->decoders($this->getOptionsWidget());
// Positions. // Positions.
$this->position = $this->getPositionWidget(); $this->position = $this->getPositionWidget();
@ -173,6 +183,43 @@ class CustomGraphWidget extends Widget
} }
/**
* 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['id_graph']) === true) {
$values['id_graph'] = $decoder['id_graph'];
}
if (isset($decoder['stacked']) === true) {
$values['type'] = $decoder['stacked'];
}
if (isset($decoder['type']) === true) {
$values['type'] = $decoder['type'];
}
if (isset($decoder['period']) === true) {
$values['period'] = $decoder['period'];
}
if (isset($decoder['showLegend']) === true) {
$values['showLegend'] = $decoder['showLegend'];
}
return $values;
}
/** /**
* Generates inputs for form (specific). * Generates inputs for form (specific).
* *

View File

@ -147,7 +147,7 @@ class EventsListWidget extends Widget
$this->gridWidth = $gridWidth; $this->gridWidth = $gridWidth;
// Options. // Options.
$this->values = $this->getOptionsWidget(); $this->values = $this->decoders($this->getOptionsWidget());
// Positions. // Positions.
$this->position = $this->getPositionWidget(); $this->position = $this->getPositionWidget();
@ -177,6 +177,71 @@ class EventsListWidget extends Widget
} }
/**
* 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['type']) === true) {
$values['eventType'] = $decoder['type'];
}
if (isset($decoder['eventType']) === true) {
$values['eventType'] = $decoder['eventType'];
}
if (isset($decoder['event_view_hr']) === true) {
$values['maxHours'] = $decoder['event_view_hr'];
}
if (isset($decoder['maxHours']) === true) {
$values['maxHours'] = $decoder['maxHours'];
}
if (isset($decoder['limit']) === true) {
$values['limit'] = $decoder['limit'];
}
if (isset($decoder['status']) === true) {
$values['eventStatus'] = $decoder['status'];
}
if (isset($decoder['eventStatus']) === true) {
$values['eventStatus'] = $decoder['eventStatus'];
}
if (isset($decoder['severity']) === true) {
$values['severity'] = $decoder['severity'];
}
if (isset($decoder['id_groups']) === true) {
if (is_array($decoder['id_groups']) === true) {
$decoder['id_groups'][0] = implode(',', $decoder['id_groups']);
}
$values['groupId'] = $decoder['id_groups'];
}
if (isset($decoder['groupId']) === true) {
$values['groupId'] = $decoder['groupId'];
}
if (isset($decoder['tagsId']) === true) {
$values['tagsId'] = $decoder['tagsId'];
}
return $values;
}
/** /**
* Generates inputs for form (specific). * Generates inputs for form (specific).
* *
@ -416,13 +481,15 @@ class EventsListWidget extends Widget
$filter['limit'] = $this->values['limit']; $filter['limit'] = $this->values['limit'];
$filter['order'] = '`utimestamp` DESC'; $filter['order'] = '`utimestamp` DESC';
if ((int) $this->values['severity'] === 20) { if (isset($this->values['severity']) === true) {
$filter['criticity'] = [ if ((int) $this->values['severity'] === 20) {
EVENT_CRIT_WARNING, $filter['criticity'] = [
EVENT_CRIT_CRITICAL, EVENT_CRIT_WARNING,
]; EVENT_CRIT_CRITICAL,
} else if ((int) $this->values['severity'] !== -1) { ];
$filter['criticity'] = $this->values['severity']; } else if ((int) $this->values['severity'] !== -1) {
$filter['criticity'] = $this->values['severity'];
}
} }
if (empty($this->values['tagsId']) === false) { if (empty($this->values['tagsId']) === false) {

View File

@ -142,7 +142,7 @@ class WelcomeWidget extends Widget
$this->gridWidth = $gridWidth; $this->gridWidth = $gridWidth;
// Options. // Options.
$this->values = $this->getOptionsWidget(); $this->values = $this->decoders($this->getOptionsWidget());
// Positions. // Positions.
$this->position = $this->getPositionWidget(); $this->position = $this->getPositionWidget();
@ -168,6 +168,23 @@ class WelcomeWidget extends Widget
} }
/**
* 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);
return $values;
}
/** /**
* Generates inputs for form (specific). * Generates inputs for form (specific).
* *

View File

@ -106,6 +106,13 @@ class GraphModuleHistogramWidget extends Widget
*/ */
protected $gridWidth; protected $gridWidth;
/**
* Cell ID.
*
* @var integer
*/
protected $cellId;
/** /**
* Construct. * Construct.
@ -148,8 +155,11 @@ class GraphModuleHistogramWidget extends Widget
// Grid Width. // Grid Width.
$this->gridWidth = $gridWidth; $this->gridWidth = $gridWidth;
// Cell Id.
$this->cellId = $cellId;
// Options. // Options.
$this->values = $this->getOptionsWidget(); $this->values = $this->decoders($this->getOptionsWidget());
// Positions. // Positions.
$this->position = $this->getPositionWidget(); $this->position = $this->getPositionWidget();
@ -179,6 +189,63 @@ class GraphModuleHistogramWidget extends Widget
} }
/**
* 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['label_'.$this->cellId]) === true) {
$values['label'] = $decoder['label_'.$this->cellId];
}
if (isset($decoder['label']) === true) {
$values['label'] = $decoder['label'];
}
if (isset($decoder['id_agent_'.$this->cellId]) === true) {
$values['agentId'] = $decoder['id_agent_'.$this->cellId];
}
if (isset($decoder['agentId']) === true) {
$values['agentId'] = $decoder['agentId'];
}
if (isset($decoder['metaconsoleId']) === true) {
$values['metaconsoleId'] = $decoder['metaconsoleId'];
}
if (isset($decoder['id_module_'.$this->cellId]) === true) {
$values['moduleId'] = $decoder['id_module_'.$this->cellId];
}
if (isset($decoder['moduleId']) === true) {
$values['moduleId'] = $decoder['moduleId'];
}
if (isset($decoder['size_label_'.$this->cellId]) === true) {
$values['sizeLabel'] = $decoder['size_label_'.$this->cellId];
}
if (isset($decoder['sizeLabel']) === true) {
$values['sizeLabel'] = $decoder['sizeLabel'];
}
if (isset($decoder['period']) === true) {
$values['period'] = $decoder['period'];
}
return $values;
}
/** /**
* Generates inputs for form (specific). * Generates inputs for form (specific).
* *

View File

@ -142,7 +142,7 @@ class GroupsStatusWidget extends Widget
$this->gridWidth = $gridWidth; $this->gridWidth = $gridWidth;
// Options. // Options.
$this->values = $this->getOptionsWidget(); $this->values = $this->decoders($this->getOptionsWidget());
// Positions. // Positions.
$this->position = $this->getPositionWidget(); $this->position = $this->getPositionWidget();
@ -172,6 +172,31 @@ class GroupsStatusWidget extends Widget
} }
/**
* 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['groups']) === true) {
$values['groupId'] = $decoder['groups'];
}
if (isset($decoder['groupId']) === true) {
$values['groupId'] = $decoder['groupId'];
}
return $values;
}
/** /**
* Generates inputs for form (specific). * Generates inputs for form (specific).
* *

View File

@ -158,7 +158,7 @@ class MapsMadeByUser extends Widget
$this->cellId = $cellId; $this->cellId = $cellId;
// Options. // Options.
$this->values = $this->getOptionsWidget(); $this->values = $this->decoders($this->getOptionsWidget());
// Positions. // Positions.
$this->position = $this->getPositionWidget(); $this->position = $this->getPositionWidget();
@ -188,6 +188,31 @@ class MapsMadeByUser extends Widget
} }
/**
* 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['id_layout']) === true) {
$values['vcId'] = $decoder['id_layout'];
}
if (isset($decoder['vcId']) === true) {
$values['vcId'] = $decoder['vcId'];
}
return $values;
}
/** /**
* Generates inputs for form (specific). * Generates inputs for form (specific).
* *

View File

@ -142,7 +142,7 @@ class MapsStatusWidget extends Widget
$this->gridWidth = $gridWidth; $this->gridWidth = $gridWidth;
// Options. // Options.
$this->values = $this->getOptionsWidget(); $this->values = $this->decoders($this->getOptionsWidget());
// Positions. // Positions.
$this->position = $this->getPositionWidget(); $this->position = $this->getPositionWidget();
@ -172,6 +172,31 @@ class MapsStatusWidget extends Widget
} }
/**
* 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['maps']) === true) {
if (is_array($decoder['maps']) === true) {
$decoder['maps'][0] = implode(',', $decoder['maps']);
}
$values['maps'] = $decoder['maps'];
}
return $values;
}
/** /**
* Generates inputs for form (specific). * Generates inputs for form (specific).
* *

View File

@ -114,6 +114,13 @@ class ModuleIconWidget extends Widget
*/ */
protected $dashboardId; protected $dashboardId;
/**
* Cell ID.
*
* @var integer
*/
protected $cellId;
/** /**
* Construct. * Construct.
@ -151,8 +158,11 @@ class ModuleIconWidget extends Widget
// Grid Width. // Grid Width.
$this->gridWidth = $gridWidth; $this->gridWidth = $gridWidth;
// Cell Id.
$this->cellId = $cellId;
// Options. // Options.
$this->values = $this->getOptionsWidget(); $this->values = $this->decoders($this->getOptionsWidget());
// Positions. // Positions.
$this->position = $this->getPositionWidget(); $this->position = $this->getPositionWidget();
@ -183,6 +193,83 @@ class ModuleIconWidget extends Widget
} }
/**
* 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['label_'.$this->cellId]) === true) {
$values['label'] = $decoder['label_'.$this->cellId];
}
if (isset($decoder['label']) === true) {
$values['label'] = $decoder['label'];
}
if (isset($decoder['id_agent_'.$this->cellId]) === true) {
$values['agentId'] = $decoder['id_agent_'.$this->cellId];
}
if (isset($decoder['agentId']) === true) {
$values['agentId'] = $decoder['agentId'];
}
if (isset($decoder['metaconsoleId']) === true) {
$values['metaconsoleId'] = $decoder['metaconsoleId'];
}
if (isset($decoder['id_module_'.$this->cellId]) === true) {
$values['moduleId'] = $decoder['id_module_'.$this->cellId];
}
if (isset($decoder['moduleId']) === true) {
$values['moduleId'] = $decoder['moduleId'];
}
if (isset($decoder['size_value_'.$this->cellId]) === true) {
$values['sizeValue'] = $decoder['size_value_'.$this->cellId];
}
if (isset($decoder['sizeValue']) === true) {
$values['sizeValue'] = $decoder['sizeValue'];
}
if (isset($decoder['size_label_'.$this->cellId]) === true) {
$values['sizeLabel'] = $decoder['size_label_'.$this->cellId];
}
if (isset($decoder['sizeLabel']) === true) {
$values['sizeLabel'] = $decoder['sizeLabel'];
}
if (isset($decoder['size_icon_'.$this->cellId]) === true) {
$values['sizeIcon'] = $decoder['size_icon_'.$this->cellId];
}
if (isset($decoder['sizeIcon']) === true) {
$values['sizeIcon'] = $decoder['sizeIcon'];
}
if (isset($decoder['icon_module_'.$this->cellId]) === true) {
$values['imageSrc'] = $decoder['icon_module_'.$this->cellId];
}
if (isset($decoder['imageSrc']) === true) {
$values['imageSrc'] = $decoder['imageSrc'];
}
return $values;
}
/** /**
* Generates inputs for form (specific). * Generates inputs for form (specific).
* *

View File

@ -106,6 +106,13 @@ class ModuleStatusWidget extends Widget
*/ */
protected $gridWidth; protected $gridWidth;
/**
* Cell ID.
*
* @var integer
*/
protected $cellId;
/** /**
* Construct. * Construct.
@ -146,8 +153,11 @@ class ModuleStatusWidget extends Widget
// Grid Width. // Grid Width.
$this->gridWidth = $gridWidth; $this->gridWidth = $gridWidth;
// Cell Id.
$this->cellId = $cellId;
// Options. // Options.
$this->values = $this->getOptionsWidget(); $this->values = $this->decoders($this->getOptionsWidget());
// Positions. // Positions.
$this->position = $this->getPositionWidget(); $this->position = $this->getPositionWidget();
@ -177,6 +187,83 @@ class ModuleStatusWidget extends Widget
} }
/**
* 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['label_'.$this->cellId]) === true) {
$values['label'] = $decoder['label_'.$this->cellId];
}
if (isset($decoder['label']) === true) {
$values['label'] = $decoder['label'];
}
if (isset($decoder['id_agent_'.$this->cellId]) === true) {
$values['agentId'] = $decoder['id_agent_'.$this->cellId];
}
if (isset($decoder['agentId']) === true) {
$values['agentId'] = $decoder['agentId'];
}
if (isset($decoder['metaconsoleId']) === true) {
$values['metaconsoleId'] = $decoder['metaconsoleId'];
}
if (isset($decoder['id_module_'.$this->cellId]) === true) {
$values['moduleId'] = $decoder['id_module_'.$this->cellId];
}
if (isset($decoder['moduleId']) === true) {
$values['moduleId'] = $decoder['moduleId'];
}
if (isset($decoder['size_value_'.$this->cellId]) === true) {
$values['sizeValue'] = $decoder['size_value_'.$this->cellId];
}
if (isset($decoder['sizeValue']) === true) {
$values['sizeValue'] = $decoder['sizeValue'];
}
if (isset($decoder['size_label_'.$this->cellId]) === true) {
$values['sizeLabel'] = $decoder['size_label_'.$this->cellId];
}
if (isset($decoder['sizeLabel']) === true) {
$values['sizeLabel'] = $decoder['sizeLabel'];
}
if (isset($decoder['size_icon_'.$this->cellId]) === true) {
$values['sizeIcon'] = $decoder['size_icon_'.$this->cellId];
}
if (isset($decoder['sizeIcon']) === true) {
$values['sizeIcon'] = $decoder['sizeIcon'];
}
if (isset($decoder['icon_module_'.$this->cellId]) === true) {
$values['imageSrc'] = $decoder['icon_module_'.$this->cellId];
}
if (isset($decoder['imageSrc']) === true) {
$values['imageSrc'] = $decoder['imageSrc'];
}
return $values;
}
/** /**
* Generates inputs for form (specific). * Generates inputs for form (specific).
* *

View File

@ -107,6 +107,13 @@ class ModuleTableValueWidget extends Widget
*/ */
protected $gridWidth; protected $gridWidth;
/**
* Cell ID.
*
* @var integer
*/
protected $cellId;
/** /**
* Construct. * Construct.
@ -148,8 +155,11 @@ class ModuleTableValueWidget extends Widget
// Grid Width. // Grid Width.
$this->gridWidth = $gridWidth; $this->gridWidth = $gridWidth;
// Cell Id.
$this->cellId = $cellId;
// Options. // Options.
$this->values = $this->getOptionsWidget(); $this->values = $this->decoders($this->getOptionsWidget());
// Positions. // Positions.
$this->position = $this->getPositionWidget(); $this->position = $this->getPositionWidget();
@ -179,6 +189,59 @@ class ModuleTableValueWidget extends Widget
} }
/**
* 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['id_agent_'.$this->cellId]) === true) {
$values['agentId'] = $decoder['id_agent_'.$this->cellId];
}
if (isset($decoder['agentId']) === true) {
$values['agentId'] = $decoder['agentId'];
}
if (isset($decoder['metaconsoleId']) === true) {
$values['metaconsoleId'] = $decoder['metaconsoleId'];
}
if (isset($decoder['id_module_'.$this->cellId]) === true) {
$values['moduleId'] = $decoder['id_module_'.$this->cellId];
}
if (isset($decoder['moduleId']) === true) {
$values['moduleId'] = $decoder['moduleId'];
}
if (isset($decoder['size_text_'.$this->cellId]) === true) {
$values['sizeLabel'] = $decoder['size_text_'.$this->cellId];
}
if (isset($decoder['sizeLabel']) === true) {
$values['sizeLabel'] = $decoder['sizeLabel'];
}
if (isset($decoder['separator_data_'.$this->cellId]) === true) {
$values['separator'] = $decoder['separator_data_'.$this->cellId];
}
if (isset($decoder['separator']) === true) {
$values['separator'] = $decoder['separator'];
}
return $values;
}
/** /**
* Generates inputs for form (specific). * Generates inputs for form (specific).
* *

View File

@ -109,6 +109,13 @@ class ModuleValueWidget extends Widget
*/ */
protected $gridWidth; protected $gridWidth;
/**
* Cell ID.
*
* @var integer
*/
protected $cellId;
/** /**
* Construct. * Construct.
@ -146,8 +153,11 @@ class ModuleValueWidget extends Widget
// Grid Width. // Grid Width.
$this->gridWidth = $gridWidth; $this->gridWidth = $gridWidth;
// Cell Id.
$this->cellId = $cellId;
// Options. // Options.
$this->values = $this->getOptionsWidget(); $this->values = $this->decoders($this->getOptionsWidget());
// Positions. // Positions.
$this->position = $this->getPositionWidget(); $this->position = $this->getPositionWidget();
@ -177,6 +187,67 @@ class ModuleValueWidget extends Widget
} }
/**
* 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['label_'.$this->cellId]) === true) {
$values['label'] = $decoder['label_'.$this->cellId];
}
if (isset($decoder['label']) === true) {
$values['label'] = $decoder['label'];
}
if (isset($decoder['id_agent_'.$this->cellId]) === true) {
$values['agentId'] = $decoder['id_agent_'.$this->cellId];
}
if (isset($decoder['agentId']) === true) {
$values['agentId'] = $decoder['agentId'];
}
if (isset($decoder['metaconsoleId']) === true) {
$values['metaconsoleId'] = $decoder['metaconsoleId'];
}
if (isset($decoder['id_module_'.$this->cellId]) === true) {
$values['moduleId'] = $decoder['id_module_'.$this->cellId];
}
if (isset($decoder['moduleId']) === true) {
$values['moduleId'] = $decoder['moduleId'];
}
if (isset($decoder['size_value_'.$this->cellId]) === true) {
$values['sizeValue'] = $decoder['size_value_'.$this->cellId];
}
if (isset($decoder['sizeValue']) === true) {
$values['sizeValue'] = $decoder['sizeValue'];
}
if (isset($decoder['size_label_'.$this->cellId]) === true) {
$values['sizeLabel'] = $decoder['size_label_'.$this->cellId];
}
if (isset($decoder['sizeLabel']) === true) {
$values['sizeLabel'] = $decoder['sizeLabel'];
}
return $values;
}
/** /**
* Generates inputs for form (specific). * Generates inputs for form (specific).
* *

View File

@ -142,7 +142,7 @@ class MonitorHealthWidget extends Widget
$this->gridWidth = $gridWidth; $this->gridWidth = $gridWidth;
// Options. // Options.
$this->values = $this->getOptionsWidget(); $this->values = $this->decoders($this->getOptionsWidget());
// Positions. // Positions.
$this->position = $this->getPositionWidget(); $this->position = $this->getPositionWidget();
@ -164,14 +164,28 @@ class MonitorHealthWidget extends Widget
// This forces at least a first configuration. // This forces at least a first configuration.
$this->configurationRequired = false; $this->configurationRequired = false;
if (isset($this->values['title']) === false) {
$this->configurationRequired = true;
}
$this->overflow_scrollbars = false; $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);
return $values;
}
/** /**
* Generates inputs for form (specific). * Generates inputs for form (specific).
* *
@ -234,8 +248,11 @@ class MonitorHealthWidget extends Widget
$data['mW'] = (int) $all_data['_monitors_warning_']; $data['mW'] = (int) $all_data['_monitors_warning_'];
$data['mC'] = (int) $all_data['_monitors_critical_']; $data['mC'] = (int) $all_data['_monitors_critical_'];
$data['mNN'] = (int) $all_data['_monitor_not_normal_']; $data['mNN'] = (int) $all_data['_monitor_not_normal_'];
$data['monitor_not_normal'] = (int) $all_data['_monitor_not_normal_'];
$data['monitor_not_init'] = (int) $all_data['_monitors_not_init_'];
$data['monitor_alerts'] = (int) $all_data['_monitors_alerts_']; $data['monitor_alerts'] = (int) $all_data['_monitors_alerts_'];
$data['mAFired'] = (int) $all_data['_monitors_alerts_fired_']; $data['mAFired'] = (int) $all_data['_monitors_alerts_fired_'];
$data['monitor_alerts_fired'] = (int) $all_data['_monitors_alerts_fired_'];
$data['total_agents'] = (int) $all_data['_total_agents_']; $data['total_agents'] = (int) $all_data['_total_agents_'];

View File

@ -154,7 +154,7 @@ class NetworkMapWidget extends Widget
$this->gridWidth = $gridWidth; $this->gridWidth = $gridWidth;
// Options. // Options.
$this->values = $this->getOptionsWidget(); $this->values = $this->decoders($this->getOptionsWidget());
// Positions. // Positions.
$this->position = $this->getPositionWidget(); $this->position = $this->getPositionWidget();
@ -184,6 +184,55 @@ class NetworkMapWidget extends Widget
} }
/**
* 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['networkmaps']) === true) {
$values['networkmapId'] = $decoder['networkmaps'];
}
if (isset($decoder['networkmapId']) === true) {
$values['networkmapId'] = $decoder['networkmapId'];
}
if (isset($decoder['map_translate_x']) === true) {
$values['xOffset'] = $decoder['map_translate_x'];
}
if (isset($decoder['xOffset']) === true) {
$values['xOffset'] = $decoder['xOffset'];
}
if (isset($decoder['map_translate_y']) === true) {
$values['yOffset'] = $decoder['map_translate_y'];
}
if (isset($decoder['yOffset']) === true) {
$values['yOffset'] = $decoder['yOffset'];
}
if (isset($decoder['zoom_level_dash']) === true) {
$values['zoomLevel'] = $decoder['zoom_level_dash'];
}
if (isset($decoder['zoomLevel']) === true) {
$values['zoomLevel'] = $decoder['zoomLevel'];
}
return $values;
}
/** /**
* Generates inputs for form (specific). * Generates inputs for form (specific).
* *

View File

@ -142,7 +142,7 @@ class PostWidget extends Widget
$this->gridWidth = $gridWidth; $this->gridWidth = $gridWidth;
// Options. // Options.
$this->values = $this->getOptionsWidget(); $this->values = $this->decoders($this->getOptionsWidget());
// Positions. // Positions.
$this->position = $this->getPositionWidget(); $this->position = $this->getPositionWidget();
@ -172,6 +172,31 @@ class PostWidget extends Widget
} }
/**
* 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['textit']) === true) {
$values['text'] = $decoder['textit'];
}
if (isset($decoder['text']) === true) {
$values['text'] = $decoder['text'];
}
return $values;
}
/** /**
* Generates inputs for form (specific). * Generates inputs for form (specific).
* *

View File

@ -148,7 +148,7 @@ class ReportsWidget extends Widget
$this->gridWidth = $gridWidth; $this->gridWidth = $gridWidth;
// Options. // Options.
$this->values = $this->getOptionsWidget(); $this->values = $this->decoders($this->getOptionsWidget());
// Positions. // Positions.
$this->position = $this->getPositionWidget(); $this->position = $this->getPositionWidget();
@ -178,6 +178,31 @@ class ReportsWidget extends Widget
} }
/**
* 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['id_report']) === true) {
$values['reportId'] = $decoder['id_report'];
}
if (isset($decoder['reportId']) === true) {
$values['reportId'] = $decoder['reportId'];
}
return $values;
}
/** /**
* Generates inputs for form (specific). * Generates inputs for form (specific).
* *

View File

@ -146,7 +146,7 @@ class ServiceMapWidget extends Widget
$this->gridWidth = $gridWidth; $this->gridWidth = $gridWidth;
// Options. // Options.
$this->values = $this->getOptionsWidget(); $this->values = $this->decoders($this->getOptionsWidget());
// Positions. // Positions.
$this->position = $this->getPositionWidget(); $this->position = $this->getPositionWidget();
@ -176,6 +176,39 @@ class ServiceMapWidget extends Widget
} }
/**
* 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['service_id']) === true) {
$values['serviceId'] = $decoder['service_id'];
}
if (isset($decoder['serviceId']) === true) {
$values['serviceId'] = $decoder['serviceId'];
}
if (isset($decoder['show_legend']) === true) {
$values['showLegend'] = (int) $decoder['show_legend'];
}
if (isset($decoder['showLegend']) === true) {
$values['showLegend'] = $decoder['showLegend'];
}
return $values;
}
/** /**
* Generates inputs for form (specific). * Generates inputs for form (specific).
* *

View File

@ -106,6 +106,13 @@ class SingleGraphWidget extends Widget
*/ */
protected $gridWidth; protected $gridWidth;
/**
* Cell ID.
*
* @var integer
*/
protected $cellId;
/** /**
* Construct. * Construct.
@ -143,8 +150,11 @@ class SingleGraphWidget extends Widget
// Grid Width. // Grid Width.
$this->gridWidth = $gridWidth; $this->gridWidth = $gridWidth;
// Cell Id.
$this->cellId = $cellId;
// Options. // Options.
$this->values = $this->getOptionsWidget(); $this->values = $this->decoders($this->getOptionsWidget());
// Positions. // Positions.
$this->position = $this->getPositionWidget(); $this->position = $this->getPositionWidget();
@ -174,6 +184,55 @@ class SingleGraphWidget extends Widget
} }
/**
* 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['id_agent_'.$this->cellId]) === true) {
$values['agentId'] = $decoder['id_agent_'.$this->cellId];
}
if (isset($decoder['agentId']) === true) {
$values['agentId'] = $decoder['agentId'];
}
if (isset($decoder['metaconsoleId']) === true) {
$values['metaconsoleId'] = $decoder['metaconsoleId'];
}
if (isset($decoder['id_module_'.$this->cellId]) === true) {
$values['moduleId'] = $decoder['id_module_'.$this->cellId];
}
if (isset($decoder['moduleId']) === true) {
$values['moduleId'] = $decoder['moduleId'];
}
if (isset($decoder['period']) === true) {
$values['period'] = $decoder['period'];
}
if (isset($decoder['show_full_legend']) === true) {
$values['showLegend'] = $decoder['show_full_legend'];
}
if (isset($decoder['showLegend']) === true) {
$values['showLegend'] = $decoder['showLegend'];
}
return $values;
}
/** /**
* Generates inputs for form (specific). * Generates inputs for form (specific).
* *

View File

@ -110,6 +110,13 @@ class SLAPercentWidget extends Widget
*/ */
protected $gridWidth; protected $gridWidth;
/**
* Cell ID.
*
* @var integer
*/
protected $cellId;
/** /**
* Construct. * Construct.
@ -147,8 +154,11 @@ class SLAPercentWidget extends Widget
// Grid Width. // Grid Width.
$this->gridWidth = $gridWidth; $this->gridWidth = $gridWidth;
// Cell Id.
$this->cellId = $cellId;
// Options. // Options.
$this->values = $this->getOptionsWidget(); $this->values = $this->decoders($this->getOptionsWidget());
// Positions. // Positions.
$this->position = $this->getPositionWidget(); $this->position = $this->getPositionWidget();
@ -178,6 +188,71 @@ class SLAPercentWidget extends Widget
} }
/**
* 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['label_'.$this->cellId]) === true) {
$values['label'] = $decoder['label_'.$this->cellId];
}
if (isset($decoder['label']) === true) {
$values['label'] = $decoder['label'];
}
if (isset($decoder['id_agent_'.$this->cellId]) === true) {
$values['agentId'] = $decoder['id_agent_'.$this->cellId];
}
if (isset($decoder['agentId']) === true) {
$values['agentId'] = $decoder['agentId'];
}
if (isset($decoder['metaconsoleId']) === true) {
$values['metaconsoleId'] = $decoder['metaconsoleId'];
}
if (isset($decoder['id_module_'.$this->cellId]) === true) {
$values['moduleId'] = $decoder['id_module_'.$this->cellId];
}
if (isset($decoder['moduleId']) === true) {
$values['moduleId'] = $decoder['moduleId'];
}
if (isset($decoder['size_value_'.$this->cellId]) === true) {
$values['sizeValue'] = $decoder['size_value_'.$this->cellId];
}
if (isset($decoder['sizeValue']) === true) {
$values['sizeValue'] = $decoder['sizeValue'];
}
if (isset($decoder['size_label_'.$this->cellId]) === true) {
$values['sizeLabel'] = $decoder['size_label_'.$this->cellId];
}
if (isset($decoder['sizeLabel']) === true) {
$values['sizeLabel'] = $decoder['sizeLabel'];
}
if (isset($decoder['period']) === true) {
$values['period'] = $decoder['period'];
}
return $values;
}
/** /**
* Generates inputs for form (specific). * Generates inputs for form (specific).
* *
@ -387,7 +462,7 @@ class SLAPercentWidget extends Widget
if (empty($label) === false) { if (empty($label) === false) {
// Div Label. // Div Label.
$output .= '<div style="flex: 1 1; font-size:'.$sizeLabel.'px;">'.$label.'</div>'; $output .= '<div style="flex: 1 1; font-size:'.$sizeLabel.'px; text-align: left;">'.$label.'</div>';
} }
$output .= '</div>'; $output .= '</div>';

View File

@ -142,7 +142,7 @@ class SystemGroupStatusWidget extends Widget
$this->gridWidth = $gridWidth; $this->gridWidth = $gridWidth;
// Options. // Options.
$this->values = $this->getOptionsWidget(); $this->values = $this->decoders($this->getOptionsWidget());
// Positions. // Positions.
$this->position = $this->getPositionWidget(); $this->position = $this->getPositionWidget();
@ -164,14 +164,80 @@ class SystemGroupStatusWidget extends Widget
// This forces at least a first configuration. // This forces at least a first configuration.
$this->configurationRequired = false; $this->configurationRequired = false;
if (empty($this->values['groupId']) === true) {
$this->configurationRequired = true;
}
$this->overflow_scrollbars = false; $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['status']) === true) {
if (is_array($decoder['status']) === true) {
$compatibilityStatus = [];
foreach ($decoder['status'] as $key => $value) {
switch ((int) $value) {
case 2:
$compatibilityStatus[] = AGENT_STATUS_WARNING;
break;
case 3:
$compatibilityStatus[] = AGENT_STATUS_CRITICAL;
break;
case 4:
$compatibilityStatus[] = 4;
break;
default:
case 1:
$compatibilityStatus[] = AGENT_STATUS_NORMAL;
break;
}
}
$decoder['status'][0] = implode(',', $compatibilityStatus);
}
$values['status'] = $decoder['status'];
} else {
$values['status'][0] = implode(
',',
[
AGENT_STATUS_NORMAL,
AGENT_STATUS_WARNING,
AGENT_STATUS_CRITICAL,
4,
]
);
}
if (isset($decoder['id_groups']) === true) {
if (is_array($decoder['id_groups']) === true) {
$decoder['id_groups'][0] = implode(',', $decoder['id_groups']);
}
$values['groupId'] = $decoder['id_groups'];
}
if (isset($decoder['groupId']) === true) {
$values['groupId'] = $decoder['groupId'];
}
return $values;
}
/** /**
* Generates inputs for form (specific). * Generates inputs for form (specific).
* *
@ -186,6 +252,19 @@ class SystemGroupStatusWidget extends Widget
// Retrieve global - common inputs. // Retrieve global - common inputs.
$inputs = parent::getFormInputs(); $inputs = parent::getFormInputs();
// Default values.
if (isset($values['status']) === false) {
$values['status'][0] = implode(
',',
[
AGENT_STATUS_NORMAL,
AGENT_STATUS_WARNING,
AGENT_STATUS_CRITICAL,
4,
]
);
}
// Restrict access to group. // Restrict access to group.
$inputs[] = [ $inputs[] = [
'label' => __('Groups'), 'label' => __('Groups'),
@ -439,7 +518,7 @@ class SystemGroupStatusWidget extends Widget
} }
} }
$height = (count($table->data) * 30); $height = (count($table->data) * 32);
$style = 'min-width:200px; min-height:'.$height.'px;'; $style = 'min-width:200px; min-height:'.$height.'px;';
$output = '<div class="container-center" style="'.$style.'">'; $output = '<div class="container-center" style="'.$style.'">';
if ($flag_groups === true) { if ($flag_groups === true) {

View File

@ -160,7 +160,7 @@ class TacticalWidget extends Widget
$this->pmAccess = \users_can_manage_group_all('PM'); $this->pmAccess = \users_can_manage_group_all('PM');
// Options. // Options.
$this->values = $this->getOptionsWidget(); $this->values = $this->decoders($this->getOptionsWidget());
// Positions. // Positions.
$this->position = $this->getPositionWidget(); $this->position = $this->getPositionWidget();
@ -193,6 +193,43 @@ class TacticalWidget extends Widget
} }
/**
* 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['statusmonitors']) === true) {
$values['statusMonitor'] = $decoder['statusmonitors'];
}
if (isset($decoder['statusMonitor']) === true) {
$values['statusMonitor'] = $decoder['statusMonitor'];
}
if (isset($decoder['serverperf']) === true) {
$values['serverPerformance'] = $decoder['serverperf'];
}
if (isset($decoder['serverPerformance']) === true) {
$values['serverPerformance'] = $decoder['serverPerformance'];
}
if (isset($decoder['summary']) === true) {
$values['summary'] = $decoder['summary'];
}
return $values;
}
/** /**
* Generates inputs for form (specific). * Generates inputs for form (specific).
* *
@ -366,7 +403,7 @@ class TacticalWidget extends Widget
); );
} }
if ($this->values['statusMonitor'] === 1) { if ((int) $this->values['statusMonitor'] === 1) {
$table = new \stdClass(); $table = new \stdClass();
$table->width = '100%'; $table->width = '100%';
@ -396,7 +433,7 @@ class TacticalWidget extends Widget
$output .= \html_print_table($table, true); $output .= \html_print_table($table, true);
} }
if ($this->values['serverPerformance'] === 1 if ((int) $this->values['serverPerformance'] === 1
&& $this->pmAccess === true && $this->pmAccess === true
) { ) {
$table = new \stdClass(); $table = new \stdClass();
@ -414,7 +451,7 @@ class TacticalWidget extends Widget
$output .= \html_print_table($table, true); $output .= \html_print_table($table, true);
} }
if ($this->values['summary'] === 1) { if ((int) $this->values['summary'] === 1) {
$table = new \stdClass(); $table = new \stdClass();
$table->width = '100%'; $table->width = '100%';
$table->class = ''; $table->class = '';

View File

@ -375,7 +375,7 @@ class TopNWidget extends Widget
} }
// This function check ACL. // This function check ACL.
$agents = agents_get_group_agents(0, ['aliasRegex' => $agentRegex]); $agents = @agents_get_group_agents(0, ['aliasRegex' => $agentRegex]);
$agentsId = \array_keys($agents); $agentsId = \array_keys($agents);
$agentsIdString = \implode(',', $agentsId); $agentsIdString = \implode(',', $agentsId);
@ -414,7 +414,7 @@ class TopNWidget extends Widget
$quantity $quantity
); );
$modules = \db_get_all_rows_sql( $modules = @db_get_all_rows_sql(
$sql, $sql,
$search_in_history_db $search_in_history_db
); );
@ -422,7 +422,7 @@ class TopNWidget extends Widget
if (empty($modules) === true) { if (empty($modules) === true) {
$output .= '<div class="container-center">'; $output .= '<div class="container-center">';
$output .= \ui_print_info_message( $output .= \ui_print_info_message(
__('There are no Agent/Modules defined'), __('There are no agents/modules found matching filter set'),
'', '',
true true
); );

View File

@ -147,7 +147,7 @@ class TopNEventByGroupWidget extends Widget
$this->gridWidth = $gridWidth; $this->gridWidth = $gridWidth;
// Options. // Options.
$this->values = $this->getOptionsWidget(); $this->values = $this->decoders($this->getOptionsWidget());
// Positions. // Positions.
$this->position = $this->getPositionWidget(); $this->position = $this->getPositionWidget();
@ -177,6 +177,59 @@ class TopNEventByGroupWidget extends Widget
} }
/**
* 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['amount']) === true) {
$values['amountShow'] = $decoder['amount'];
}
if (isset($decoder['amountShow']) === true) {
$values['amountShow'] = $decoder['amountShow'];
}
if (isset($decoder['event_view_hr']) === true) {
$values['maxHours'] = $decoder['event_view_hr'];
}
if (isset($decoder['maxHours']) === true) {
$values['maxHours'] = $decoder['maxHours'];
}
if (isset($decoder['id_groups']) === true) {
if (is_array($decoder['id_groups']) === true) {
$implode = implode(',', $decoder['id_groups']);
$values['groupId'] = [];
$values['groupId'][0] = $implode;
}
}
if (isset($decoder['groupId']) === true) {
$values['groupId'] = $decoder['groupId'];
}
if (isset($decoder['legend_position']) === true) {
$values['legendPosition'] = $decoder['legend_position'];
}
if (isset($decoder['legendPosition']) === true) {
$values['legendPosition'] = $decoder['legendPosition'];
}
return $values;
}
/** /**
* Generates inputs for form (specific). * Generates inputs for form (specific).
* *
@ -320,8 +373,8 @@ class TopNEventByGroupWidget extends Widget
GROUP BY id_agente GROUP BY id_agente
ORDER BY count DESC ORDER BY count DESC
LIMIT %d', LIMIT %d',
implode(',', $this->values['groupId']),
$timestamp, $timestamp,
implode(',', $this->values['groupId']),
$this->values['amountShow'] $this->values['amountShow']
); );
} else { } else {

View File

@ -147,7 +147,7 @@ class TopNEventByModuleWidget extends Widget
$this->gridWidth = $gridWidth; $this->gridWidth = $gridWidth;
// Options. // Options.
$this->values = $this->getOptionsWidget(); $this->values = $this->decoders($this->getOptionsWidget());
// Positions. // Positions.
$this->position = $this->getPositionWidget(); $this->position = $this->getPositionWidget();
@ -177,6 +177,59 @@ class TopNEventByModuleWidget extends Widget
} }
/**
* 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['amount']) === true) {
$values['amountShow'] = $decoder['amount'];
}
if (isset($decoder['amountShow']) === true) {
$values['amountShow'] = $decoder['amountShow'];
}
if (isset($decoder['event_view_hr']) === true) {
$values['maxHours'] = $decoder['event_view_hr'];
}
if (isset($decoder['maxHours']) === true) {
$values['maxHours'] = $decoder['maxHours'];
}
if (isset($decoder['id_groups']) === true) {
if (is_array($decoder['id_groups']) === true) {
$decoder['id_groups'][0] = implode(',', $decoder['id_groups']);
}
$values['groupId'] = $decoder['id_groups'];
}
if (isset($decoder['groupId']) === true) {
$values['groupId'] = $decoder['groupId'];
}
if (isset($decoder['legend_position']) === true) {
$values['legendPosition'] = $decoder['legend_position'];
}
if (isset($decoder['legendPosition']) === true) {
$values['legendPosition'] = $decoder['legendPosition'];
}
return $values;
}
/** /**
* Generates inputs for form (specific). * Generates inputs for form (specific).
* *
@ -311,20 +364,26 @@ class TopNEventByModuleWidget extends Widget
if ($all_group === false) { if ($all_group === false) {
$sql = sprintf( $sql = sprintf(
'SELECT id_agentmodule, COUNT(*) AS count 'SELECT id_agente,
id_agentmodule,
event_type,
COUNT(*) AS count
FROM tevento FROM tevento
WHERE utimestamp >= %d WHERE utimestamp >= %d
AND id_grupo IN (%s) AND id_grupo IN (%s)
GROUP BY id_agentmodule, event_type GROUP BY id_agentmodule, event_type
ORDER BY count DESC ORDER BY count DESC
LIMIT %d', LIMIT %d',
implode(',', $this->values['groupId']),
$timestamp, $timestamp,
implode(',', $this->values['groupId']),
$this->values['amountShow'] $this->values['amountShow']
); );
} else { } else {
$sql = sprintf( $sql = sprintf(
'SELECT id_agentmodule, COUNT(*) AS count 'SELECT id_agente,
id_agentmodule,
event_type,
COUNT(*) AS count
FROM tevento FROM tevento
WHERE utimestamp >= %d WHERE utimestamp >= %d
GROUP BY id_agentmodule, event_type GROUP BY id_agentmodule, event_type
@ -353,8 +412,9 @@ class TopNEventByModuleWidget extends Widget
$name = __('System'); $name = __('System');
} else { } else {
$name_agent = io_safe_output( $name_agent = io_safe_output(
agents_get_alias($row['id_agentmodule']) agents_get_alias($row['id_agente'])
); );
$name_module = io_safe_output( $name_module = io_safe_output(
modules_get_agentmodule_name($row['id_agentmodule']) modules_get_agentmodule_name($row['id_agentmodule'])
); );

View File

@ -155,7 +155,7 @@ class TreeViewWidget extends Widget
$this->cellId = $cellId; $this->cellId = $cellId;
// Options. // Options.
$this->values = $this->getOptionsWidget(); $this->values = $this->decoders($this->getOptionsWidget());
// Positions. // Positions.
$this->position = $this->getPositionWidget(); $this->position = $this->getPositionWidget();
@ -177,14 +177,136 @@ class TreeViewWidget extends Widget
// This forces at least a first configuration. // This forces at least a first configuration.
$this->configurationRequired = false; $this->configurationRequired = false;
if (isset($this->values['groupId']) === false) {
$this->configurationRequired = true;
}
$this->overflow_scrollbars = false; $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['tab']) === true) {
$values['typeTree'] = $decoder['tab'];
}
if (isset($decoder['typeTree']) === true) {
$values['typeTree'] = $decoder['typeTree'];
}
if (isset($decoder['search_group']) === true) {
$values['groupId'] = $decoder['search_group'];
}
if (isset($decoder['groupId']) === true) {
$values['groupId'] = $decoder['groupId'];
}
if (isset($decoder['open_all_nodes']) === true) {
$values['openAllGroups'] = $decoder['open_all_nodes'];
}
if (isset($decoder['openAllGroups']) === true) {
$values['openAllGroups'] = $decoder['openAllGroups'];
}
if (isset($decoder['status_agent']) === true) {
switch ((int) $decoder['status_agent']) {
case 0:
$values['agentStatus'] = AGENT_STATUS_NORMAL;
break;
case 1:
$values['agentStatus'] = AGENT_STATUS_CRITICAL;
break;
case 2:
$values['agentStatus'] = AGENT_STATUS_WARNING;
break;
case 3:
$values['agentStatus'] = AGENT_STATUS_UNKNOWN;
break;
case 5:
$values['agentStatus'] = AGENT_STATUS_NOT_INIT;
break;
default:
case -1:
$values['agentStatus'] = AGENT_STATUS_ALL;
break;
}
}
if (isset($decoder['agentStatus']) === true) {
$values['agentStatus'] = $decoder['agentStatus'];
}
if (isset($decoder['search_agent']) === true) {
$values['filterAgent'] = $decoder['search_agent'];
}
if (isset($decoder['filterAgent']) === true) {
$values['filterAgent'] = $decoder['filterAgent'];
}
if (isset($decoder['status_module']) === true) {
switch ((int) $decoder['status_module']) {
case 0:
$values['moduleStatus'] = AGENT_MODULE_STATUS_NORMAL;
break;
case 1:
$values['moduleStatus'] = AGENT_MODULE_STATUS_CRITICAL_BAD;
break;
case 2:
$values['moduleStatus'] = AGENT_MODULE_STATUS_WARNING;
break;
case 3:
$values['moduleStatus'] = AGENT_MODULE_STATUS_UNKNOWN;
break;
case 5:
$values['moduleStatus'] = AGENT_MODULE_STATUS_NOT_INIT;
break;
default:
case -1:
$values['moduleStatus'] = -1;
break;
}
$values['moduleStatus'] = $decoder['status_module'];
}
if (isset($decoder['moduleStatus']) === true) {
$values['moduleStatus'] = $decoder['moduleStatus'];
}
if (isset($decoder['search_module']) === true) {
$values['filterModule'] = $decoder['search_module'];
}
if (isset($decoder['filterModule']) === true) {
$values['filterModule'] = $decoder['filterModule'];
}
return $values;
}
/** /**
* Generates inputs for form (specific). * Generates inputs for form (specific).
* *

View File

@ -142,7 +142,7 @@ class UrlWidget extends Widget
$this->gridWidth = $gridWidth; $this->gridWidth = $gridWidth;
// Options. // Options.
$this->values = $this->getOptionsWidget(); $this->values = $this->decoders($this->getOptionsWidget());
// Positions. // Positions.
$this->position = $this->getPositionWidget(); $this->position = $this->getPositionWidget();
@ -172,6 +172,31 @@ class UrlWidget extends Widget
} }
/**
* 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['url']) === true) {
$values['urlText'] = $decoder['url'];
}
if (isset($decoder['urlText']) === true) {
$values['urlText'] = $decoder['urlText'];
}
return $values;
}
/** /**
* Generates inputs for form (specific). * Generates inputs for form (specific).
* *

View File

@ -106,6 +106,13 @@ class WuxWidget extends Widget
*/ */
protected $gridWidth; protected $gridWidth;
/**
* Cell ID.
*
* @var integer
*/
protected $cellId;
/** /**
* Construct. * Construct.
@ -142,8 +149,11 @@ class WuxWidget extends Widget
// Grid Width. // Grid Width.
$this->gridWidth = $gridWidth; $this->gridWidth = $gridWidth;
// Cell Id.
$this->cellId = $cellId;
// Options. // Options.
$this->values = $this->getOptionsWidget(); $this->values = $this->decoders($this->getOptionsWidget());
// Positions. // Positions.
$this->position = $this->getPositionWidget(); $this->position = $this->getPositionWidget();
@ -173,6 +183,43 @@ class WuxWidget extends Widget
} }
/**
* 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['id_agent_'.$this->cellId]) === true) {
$values['agentId'] = $decoder['id_agent_'.$this->cellId];
}
if (isset($decoder['agentId']) === true) {
$values['agentId'] = $decoder['agentId'];
}
if (isset($decoder['metaconsoleId']) === true) {
$values['metaconsoleId'] = $decoder['metaconsoleId'];
}
if (isset($decoder['wux_transaction_'.$this->cellId]) === true) {
$values['transactionId'] = $decoder['wux_transaction_'.$this->cellId];
}
if (isset($decoder['transactionId']) === true) {
$values['transactionId'] = $decoder['transactionId'];
}
return $values;
}
/** /**
* Generates inputs for form (specific). * Generates inputs for form (specific).
* *

View File

@ -154,7 +154,7 @@ class WuxStatsWidget extends Widget
$this->cellId = $cellId; $this->cellId = $cellId;
// Options. // Options.
$this->values = $this->getOptionsWidget(); $this->values = $this->decoders($this->getOptionsWidget());
// Positions. // Positions.
$this->position = $this->getPositionWidget(); $this->position = $this->getPositionWidget();
@ -184,6 +184,51 @@ class WuxStatsWidget extends Widget
} }
/**
* 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['id_agent_'.$this->cellId]) === true) {
$values['agentId'] = $decoder['id_agent_'.$this->cellId];
}
if (isset($decoder['agentId']) === true) {
$values['agentId'] = $decoder['agentId'];
}
if (isset($decoder['metaconsoleId']) === true) {
$values['metaconsoleId'] = $decoder['metaconsoleId'];
}
if (isset($decoder['wux_transaction_'.$this->cellId]) === true) {
$values['transactionId'] = $decoder['wux_transaction_'.$this->cellId];
}
if (isset($decoder['transactionId']) === true) {
$values['transactionId'] = $decoder['transactionId'];
}
if (isset($decoder['view_all_stats']) === true) {
$values['allStats'] = $decoder['view_all_stats'];
}
if (isset($decoder['allStats']) === true) {
$values['allStats'] = $decoder['allStats'];
}
return $values;
}
/** /**
* Generates inputs for form (specific). * Generates inputs for form (specific).
* *

View File

@ -487,3 +487,7 @@ div#main_pure {
.info_box tbody tr td.icon { .info_box tbody tr td.icon {
padding-right: 10px !important; padding-right: 10px !important;
} }
.content-widget .databox.filters > tbody > tr > td {
padding-right: 30px;
}

View File

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

View File

@ -111,6 +111,16 @@ echo "<div style='width:100%'>".html_print_button(
var first_time = true; var first_time = true;
$(document).ready(function() { $(document).ready(function() {
confirmDialog({
title: "Attention",
message:
"<h4 style='text-align: center;'>This feature will be removed from the console in the next version of Pandora FMS.<br><br> If you want to keep the history, make a backup.</h4>",
cancel: "Cancel",
ok: "Ok",
onAccept: function() {
// Nothing to do.
}
});
$("input[name=\"message_box\"]").keydown(function(e) { $("input[name=\"message_box\"]").keydown(function(e) {
//Enter key. //Enter key.
if (e.keyCode == 13) { if (e.keyCode == 13) {

View File

@ -3,7 +3,7 @@
# #
%define name pandorafms_console %define name pandorafms_console
%define version 7.0NG.745 %define version 7.0NG.745
%define release 200427 %define release 200430
# 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.745 %define version 7.0NG.745
%define release 200427 %define release 200430
# 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.745 %define version 7.0NG.745
%define release 200427 %define release 200430
%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

@ -34,6 +34,7 @@ if ($redraw === false) {
$output .= '<div class="header-widget">'; $output .= '<div class="header-widget">';
$output .= '<div>'; $output .= '<div>';
if ((int) $cellData['id_widget'] !== 0) { if ((int) $cellData['id_widget'] !== 0) {
$options = json_decode($cellData['options'], true); $options = json_decode($cellData['options'], true);
$output .= $options['title']; $output .= $options['title'];

View File

@ -1,5 +1,5 @@
package: pandorafms-server package: pandorafms-server
Version: 7.0NG.745-200427 Version: 7.0NG.745-200430
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.745-200427" pandora_version="7.0NG.745-200430"
package_cpan=0 package_cpan=0
package_pandora=1 package_pandora=1

View File

@ -45,7 +45,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.745"; my $pandora_version = "7.0NG.745";
my $pandora_build = "200427"; my $pandora_build = "200430";
our $VERSION = $pandora_version." ".$pandora_build; our $VERSION = $pandora_version." ".$pandora_build;
# Setup hash # Setup hash

View File

@ -26,7 +26,7 @@ use Thread::Semaphore;
use IO::Socket::INET; use IO::Socket::INET;
use POSIX qw(strftime ceil); use POSIX qw(strftime ceil);
use JSON qw(decode_json encode_json); use JSON;
use Encode qw(encode_utf8); use Encode qw(encode_utf8);
use MIME::Base64; use MIME::Base64;
@ -339,14 +339,14 @@ sub exec_recon_script ($$$) {
my $macros = safe_output($task->{'macros'}); my $macros = safe_output($task->{'macros'});
# \r and \n should be escaped for decode_json(). # \r and \n should be escaped for p_decode_json().
$macros =~ s/\n/\\n/g; $macros =~ s/\n/\\n/g;
$macros =~ s/\r/\\r/g; $macros =~ s/\r/\\r/g;
my $decoded_macros; my $decoded_macros;
if ($macros) { if ($macros) {
eval { eval {
$decoded_macros = decode_json(encode_utf8($macros)); $decoded_macros = p_decode_json($pa_config, $macros);
}; };
} }
@ -1029,7 +1029,7 @@ sub PandoraFMS::Recon::Base::report_scanned_agents($;$) {
my $data; my $data;
eval { eval {
local $SIG{__DIE__}; local $SIG{__DIE__};
$data = decode_json(decode_base64($row->{'data'})); $data = p_decode_json($self->{'pa_config'}, decode_base64($row->{'data'}));
}; };
if ($@) { if ($@) {
$self->call('message', "ERROR JSON: $@", 3); $self->call('message', "ERROR JSON: $@", 3);
@ -1297,7 +1297,7 @@ sub PandoraFMS::Recon::Base::report_scanned_agents($;$) {
eval { eval {
local $SIG{__DIE__}; local $SIG{__DIE__};
$encoded = encode_base64( $encoded = encode_base64(
encode_json($data) p_encode_json($self->{'pa_config'}, $data)
); );
}; };
@ -1400,7 +1400,7 @@ sub PandoraFMS::Recon::Base::report_scanned_agents($;$) {
eval { eval {
local $SIG{__DIE__}; local $SIG{__DIE__};
$encoded = encode_base64( $encoded = encode_base64(
encode_json($self->{'agents_found'}->{$addr}) p_encode_json($self->{'pa_config'}, $self->{'agents_found'}->{$addr})
); );
}; };
@ -1740,17 +1740,25 @@ sub PandoraFMS::Recon::Base::update_progress ($$) {
my ($self, $progress) = @_; my ($self, $progress) = @_;
my $stats = {}; my $stats = {};
if (defined($self->{'summary'}) && $self->{'summary'} ne '') { eval {
$stats->{'summary'} = $self->{'summary'}; local $SIG{__DIE__};
if (defined($self->{'summary'}) && $self->{'summary'} ne '') {
$stats->{'summary'} = $self->{'summary'};
}
$stats->{'step'} = $self->{'step'};
$stats->{'c_network_name'} = $self->{'c_network_name'};
$stats->{'c_network_percent'} = $self->{'c_network_percent'};
# Store progress, last contact and overall status.
db_do ($self->{'dbh'}, 'UPDATE trecon_task SET utimestamp = ?, status = ?, summary = ? WHERE id_rt = ?',
time (), $progress, p_encode_json($self->{'pa_config'}, $stats), $self->{'task_id'});
};
if ($@) {
$self->call('message', "Problems updating progress $@", 5);
db_do ($self->{'dbh'}, 'UPDATE trecon_task SET utimestamp = ?, status = ?, summary = ? WHERE id_rt = ?',
time (), $progress, "{}", $self->{'task_id'});
} }
$stats->{'step'} = $self->{'step'};
$stats->{'c_network_name'} = $self->{'c_network_name'};
$stats->{'c_network_percent'} = $self->{'c_network_percent'};
# Store progress, last contact and overall status.
db_do ($self->{'dbh'}, 'UPDATE trecon_task SET utimestamp = ?, status = ?, summary = ? WHERE id_rt = ?',
time (), $progress, encode_json($stats), $self->{'task_id'});
} }
1; 1;

View File

@ -33,7 +33,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.745"; my $pandora_version = "7.0NG.745";
my $pandora_build = "200427"; my $pandora_build = "200430";
our $VERSION = $pandora_version." ".$pandora_build; our $VERSION = $pandora_version." ".$pandora_build;
our %EXPORT_TAGS = ( 'all' => [ qw() ] ); our %EXPORT_TAGS = ( 'all' => [ qw() ] );

View File

@ -2120,16 +2120,16 @@ sub snmp_get_value($$$) {
my ($self, $device, $oid) = @_; my ($self, $device, $oid) = @_;
my $effective_oid = $oid; my $effective_oid = $oid;
if (is_enabled($self->{'translate_snmp'})) { if (is_enabled($self->{'translate_snmp'}) && $oid !~ /^[\.\d]+$/) {
$effective_oid = `snmptranslate $oid -On 2>$DEVNULL`; $effective_oid = `snmptranslate $oid -On 2>$DEVNULL`;
chomp($effective_oid); $effective_oid =~ s/[\r\n]//g;
} }
my @output = $self->snmp_get($device, $effective_oid); my @output = $self->snmp_get($device, $effective_oid);
foreach my $line (@output) { foreach my $line (@output) {
chomp($line); $line =~ s/[\r\n]//g;
return $1 if ($line =~ /^$effective_oid\s+=\s+\S+:\s+(.*)$/); return $1 if ($line =~ /^$effective_oid\s+=\s+\S+:\s+(.*)/);
} }
return undef; return undef;

View File

@ -31,6 +31,9 @@ use LWP::UserAgent;
use threads; use threads;
use threads::shared; use threads::shared;
use JSON;
use Encode qw/decode_utf8 encode_utf8/;
use lib '/usr/lib/perl5'; use lib '/usr/lib/perl5';
use PandoraFMS::Sendmail; use PandoraFMS::Sendmail;
@ -152,6 +155,8 @@ our @EXPORT = qw(
dateTimeToTimestamp dateTimeToTimestamp
get_user_agent get_user_agent
ui_get_full_url ui_get_full_url
p_encode_json
p_decode_json
); );
# ID of the different servers # ID of the different servers
@ -1458,7 +1463,7 @@ sub pandora_block_ping($@) {
if (-x $pa_config->{'fping'}) { if (-x $pa_config->{'fping'}) {
# fping timeout in milliseconds # fping timeout in milliseconds
$cmd = $pa_config->{'fping'} . " -a -q -t " . (1000 * $pa_config->{'networktimeout'}) . " " . (join (' ', @hosts)); $cmd = '"'.$pa_config->{'fping'} . '" -a -q -t ' . (1000 * $pa_config->{'networktimeout'}) . " " . (join (' ', @hosts));
@output = `$cmd 2>$DEVNULL`; @output = `$cmd 2>$DEVNULL`;
} else { } else {
# Ping scan # Ping scan
@ -2353,6 +2358,55 @@ sub ui_get_full_url {
} }
################################################################################
# Encodes a json.
################################################################################
sub p_encode_json {
my ($pa_config, $data) = @_;
# Initialize JSON manager.
my $json = JSON->new->allow_nonref;
my $encoded_data;
eval {
local $SIG{__DIE__};
if ($JSON::VERSION > 2.90) {
$encoded_data = $json->encode($data);
} else {
$encoded_data = encode_utf8($json->encode($data));
}
};
if ($@){
if (defined($data)) {
logger($pa_config, 'Failed to encode data: '.$@, 5);
}
}
return $encoded_data;
}
################################################################################
# Dencodes a json.
################################################################################
sub p_decode_json {
my ($pa_config, $data) = @_;
# Initialize JSON manager.
my $json = JSON->new->allow_nonref;
my $decoded_data;
if ($JSON::VERSION > 2.90) {
$decoded_data = $json->decode($data);
} else {
if (!is_empty($decoded_data)) {
$decoded_data = decode_json($data);
}
}
return $decoded_data;
}
1; 1;
__END__ __END__

View File

@ -3,7 +3,7 @@
# #
%define name pandorafms_server %define name pandorafms_server
%define version 7.0NG.745 %define version 7.0NG.745
%define release 200427 %define release 200430
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.745 %define version 7.0NG.745
%define release 200427 %define release 200430
Summary: Pandora FMS Server Summary: Pandora FMS Server
Name: %{name} Name: %{name}

View File

@ -9,7 +9,7 @@
# ********************************************************************** # **********************************************************************
PI_VERSION="7.0NG.745" PI_VERSION="7.0NG.745"
PI_BUILD="200427" PI_BUILD="200430"
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.745 PS200427"; my $version = "7.0NG.745 PS200430";
# Pandora server configuration # Pandora server configuration
my %conf; my %conf;

View File

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