Merge remote-tracking branch 'origin/develop' into ent-8797-giss-13405-acciones-vista-de-alertas-metaconsola

This commit is contained in:
Calvo 2022-07-19 09:40:56 +02:00
commit 642c60428c
126 changed files with 4685 additions and 407 deletions

View File

@ -1,5 +1,5 @@
package: pandorafms-agent-unix package: pandorafms-agent-unix
Version: 7.0NG.763-220630 Version: 7.0NG.763-220719
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.763-220630" pandora_version="7.0NG.763-220719"
echo "Test if you has the tools for to make the packages." echo "Test if you has the tools for to make the packages."
whereis dpkg-deb | cut -d":" -f2 | grep dpkg-deb > /dev/null whereis dpkg-deb | cut -d":" -f2 | grep dpkg-deb > /dev/null

View File

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

View File

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

View File

@ -0,0 +1,41 @@
START TRANSACTION;
CREATE TABLE IF NOT EXISTS `tuser_task` (
`id` INT UNSIGNED NOT NULL AUTO_INCREMENT,
`function_name` VARCHAR(80) NOT NULL DEFAULT '',
`parameters` TEXT ,
`name` VARCHAR(60) NOT NULL DEFAULT '',
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=UTF8MB4;
CREATE TABLE IF NOT EXISTS `tuser_task_scheduled` (
`id` INT UNSIGNED NOT NULL AUTO_INCREMENT,
`id_usuario` VARCHAR(255) NOT NULL DEFAULT '0',
`id_user_task` INT UNSIGNED NOT NULL DEFAULT 0,
`args` TEXT,
`scheduled` ENUM('no','hourly','daily','weekly','monthly','yearly','custom') DEFAULT 'no',
`last_run` INT UNSIGNED DEFAULT 0,
`custom_data` INT NULL DEFAULT 0,
`flag_delete` TINYINT UNSIGNED NOT NULL DEFAULT 0,
`id_grupo` INT UNSIGNED NOT NULL DEFAULT 0,
`enabled` TINYINT UNSIGNED NOT NULL DEFAULT 1,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=UTF8MB4;
ALTER TABLE `tautoconfig` ADD COLUMN `type_execution` VARCHAR(100) NOT NULL DEFAULT 'start';
ALTER TABLE `tautoconfig` ADD COLUMN `type_periodicity` VARCHAR(100) NOT NULL DEFAULT 'weekly';
ALTER TABLE `tautoconfig` ADD COLUMN `monday` TINYINT DEFAULT 0;
ALTER TABLE `tautoconfig` ADD COLUMN `tuesday` TINYINT DEFAULT 0;
ALTER TABLE `tautoconfig` ADD COLUMN `wednesday` TINYINT DEFAULT 0;
ALTER TABLE `tautoconfig` ADD COLUMN `thursday` TINYINT DEFAULT 0;
ALTER TABLE `tautoconfig` ADD COLUMN `friday` TINYINT DEFAULT 0;
ALTER TABLE `tautoconfig` ADD COLUMN `saturday` TINYINT DEFAULT 0;
ALTER TABLE `tautoconfig` ADD COLUMN `sunday` TINYINT DEFAULT 0;
ALTER TABLE `tautoconfig` ADD COLUMN `periodically_day_from` INT UNSIGNED DEFAULT NULL;
ALTER TABLE `tautoconfig` ADD COLUMN `periodically_time_from` time NULL DEFAULT NULL;
ALTER TABLE `tautoconfig` ADD COLUMN `executed` TINYINT UNSIGNED NOT NULL DEFAULT 0;
ALTER TABLE `tusuario` DROP COLUMN `metaconsole_assigned_server`;
COMMIT;

View File

@ -42,17 +42,10 @@ if (tags_has_user_acl_tags()) {
ui_print_tags_warning(); ui_print_tags_warning();
} }
$user_strict = (bool) db_get_value(
'strict_acl',
'tusuario',
'id_user',
$config['id_user']
);
$all_data = tactical_status_modules_agents( $all_data = tactical_status_modules_agents(
$config['id_user'], $config['id_user'],
$user_strict, false,
'AR', 'AR'
$user_strict
); );
$data = []; $data = [];

View File

@ -45,7 +45,7 @@ if ($default != 0) {
'token' => 'event_fields', 'token' => 'event_fields',
'value' => $event_fields, 'value' => $event_fields,
]; ];
// update 'event_fields' in tconfig table to keep the value at update. // Update 'event_fields' in tconfig table to keep the value at update.
$result = db_process_sql_update( $result = db_process_sql_update(
'tconfig', 'tconfig',
$values, $values,
@ -147,7 +147,7 @@ $table->data[1][1] .= '<br><br><br><br><a href="javascript:">'.html_print_image(
$table->data[0][1] = ''; $table->data[0][1] = '';
$table->data[0][2] = '<b>'.__('Fields selected').'</b>'; $table->data[0][2] = '<b>'.__('Fields selected').'</b>';
$table->data[1][2] = html_print_select( $table->data[1][2] = '<div class="flex_justify">'.html_print_select(
$result_selected, $result_selected,
'fields_selected[]', 'fields_selected[]',
true, true,
@ -162,6 +162,25 @@ $table->data[1][2] = html_print_select(
'width: 300px' 'width: 300px'
); );
$table->data[1][2] .= '<div id="sort_arrows" class="flex-column">';
$table->data[1][2] .= '<a href="javascript:">'.html_print_image(
'images/darrowup.png',
true,
[
'onclick' => 'sortUpDown(\'up\');',
'title' => __('Move up selected fields'),
]
).'</a>';
$table->data[1][2] .= '<a href="javascript:">'.html_print_image(
'images/darrowdown.png',
true,
[
'onclick' => 'sortUpDown(\'down\');',
'title' => __('Move down selected fields'),
]
).'</a>';
$table->data[1][2] .= '</div></div>';
echo '<form id="custom_events" method="post" action="index.php?sec=geventos&sec2=godmode/events/events&section=fields&amp;pure='.$config['pure'].'">'; echo '<form id="custom_events" method="post" action="index.php?sec=geventos&sec2=godmode/events/events&section=fields&amp;pure='.$config['pure'].'">';
html_print_table($table); html_print_table($table);
@ -174,7 +193,7 @@ echo '</div>';
<script type="text/javascript"> <script type="text/javascript">
/* <![CDATA[ */ /* <![CDATA[ */
$(document).ready (function () { $(document).ready (function () {
$("#right").click (function () { $("#right").click (function () {
jQuery.each($("select[name='fields_available[]'] option:selected"), function (key, value) { jQuery.each($("select[name='fields_available[]'] option:selected"), function (key, value) {
field_name = $(value).html(); field_name = $(value).html();
@ -186,9 +205,9 @@ $(document).ready (function () {
} }
}); });
}); });
$("#left").click (function () { $("#left").click (function () {
var current_fields_size = ($('#fields_selected option').length); var current_fields_size = ($('#fields_selected option').length);
var selected_fields = []; var selected_fields = [];
var selected_fields_total = ''; var selected_fields_total = '';
@ -214,7 +233,7 @@ $(document).ready (function () {
move_left(); move_left();
} }
}); });
$("#submit-upd_button").click(function () { $("#submit-upd_button").click(function () {
$("#fields_selected").find("option[value='0']").remove(); $("#fields_selected").find("option[value='0']").remove();
$('#fields_selected option').map(function() { $('#fields_selected option').map(function() {
@ -223,7 +242,7 @@ $(document).ready (function () {
}); });
}); });
function move_left(){ function move_left() {
jQuery.each($("select[name='fields_selected[]'] option:selected"), function (key, value) { jQuery.each($("select[name='fields_selected[]'] option:selected"), function (key, value) {
field_name = $(value).html(); field_name = $(value).html();
if (field_name != <?php echo "'".__('None')."'"; ?>) { if (field_name != <?php echo "'".__('None')."'"; ?>) {
@ -234,4 +253,16 @@ function move_left(){
} }
}); });
} }
// Change the order (to up or down).
function sortUpDown(mode) {
$("#fields_selected option:selected").each(function() {
const field = $(this);
if (field.length) {
(mode === 'up') ? field.first().prev().before(field): field.last().next().after(field);
}
});
}
</script> </script>

View File

@ -526,7 +526,8 @@ $menu_godmode['links']['sub'] = $sub;
// Warp Manager. // Warp Manager.
if ((bool) check_acl($config['id_user'], 0, 'PM') === true && (bool) $config['enable_update_manager'] === true) { if ((bool) check_acl($config['id_user'], 0, 'PM') === true && (bool) $config['enable_update_manager'] === true) {
$menu_godmode['messages']['text'] = __('Warp Update');; $menu_godmode['messages']['text'] = __('Warp Update');
;
$menu_godmode['messages']['id'] = 'god-um_messages'; $menu_godmode['messages']['id'] = 'god-um_messages';
$menu_godmode['messages']['sec2'] = ''; $menu_godmode['messages']['sec2'] = '';

View File

@ -180,6 +180,9 @@ $uncompressed_module = true;
$macros_definition = ''; $macros_definition = '';
$render_definition = ''; $render_definition = '';
$text_agent = '';
$text_agent_module = '';
$only_data = false; $only_data = false;
// Users. // Users.
@ -678,6 +681,21 @@ switch ($action) {
$period = $item['period']; $period = $item['period'];
$order_uptodown = $item['order_uptodown']; $order_uptodown = $item['order_uptodown'];
$show_resume = $item['show_resume']; $show_resume = $item['show_resume'];
$text_agent = '';
if (isset($style['text_agent']) === true
&& empty($style['text_agent']) === false
) {
$text_agent = base64_decode($style['text_agent']);
}
$text_agent_module = '';
if (isset($style['text_agent_module']) === true
&& empty($style['text_agent_module']) === false
) {
$text_agent_module = base64_decode($style['text_agent_module']);
}
break; break;
case 'availability': case 'availability':
@ -745,6 +763,21 @@ switch ($action) {
$show_resume = $item['show_resume']; $show_resume = $item['show_resume'];
$show_graph = $item['show_graph']; $show_graph = $item['show_graph'];
$order_uptodown = $item['order_uptodown']; $order_uptodown = $item['order_uptodown'];
$text_agent = '';
if (isset($style['text_agent']) === true
&& empty($style['text_agent']) === false
) {
$text_agent = base64_decode($style['text_agent']);
}
$text_agent_module = '';
if (isset($style['text_agent_module']) === true
&& empty($style['text_agent_module']) === false
) {
$text_agent_module = base64_decode($style['text_agent_module']);
}
break; break;
case 'exception': case 'exception':
@ -755,6 +788,21 @@ switch ($action) {
$show_resume = $item['show_resume']; $show_resume = $item['show_resume'];
$show_graph = $item['show_graph']; $show_graph = $item['show_graph'];
$order_uptodown = $item['order_uptodown']; $order_uptodown = $item['order_uptodown'];
$text_agent = '';
if (isset($style['text_agent']) === true
&& empty($style['text_agent']) === false
) {
$text_agent = base64_decode($style['text_agent']);
}
$text_agent_module = '';
if (isset($style['text_agent_module']) === true
&& empty($style['text_agent_module']) === false
) {
$text_agent_module = base64_decode($style['text_agent_module']);
}
break; break;
case 'agent_module': case 'agent_module':
@ -1093,6 +1141,52 @@ $class = 'databox filters';
</td> </td>
</tr> </tr>
<tr id="row_agent_regexp" class="datos">
<td class="bolder">
<?php
echo __('Agent').ui_print_help_tip(
__('Case insensitive regular expression for agent name. For example: Network.* will match with the following agent names: network_agent1, NetworK CHECKS'),
true
);
?>
</td>
<td>
<?php
html_print_input_text(
'text_agent',
$text_agent,
'',
30,
100,
false
);
?>
</td>
</tr>
<tr id="row_module_regexp" class="datos">
<td class="bolder">
<?php
echo __('Module').ui_print_help_tip(
__('Case insensitive regular expression or string for module name. For example: if you use this field with "Module exact match" enabled then this field has to be fulfilled with the literally string of the module name, if not you can use a regular expression. Example: .*usage.* will match: cpu_usage, vram usage in matchine 1.'),
true
);
?>
</td>
<td class="mx180px">
<?php
html_print_input_text(
'text_agent_module',
$text_agent_module,
'',
30,
100,
false
);
?>
</td>
</tr>
<?php <?php
if ($meta) { if ($meta) {
?> ?>
@ -5990,6 +6084,8 @@ function chooseType() {
$("#row_render_definition").hide(); $("#row_render_definition").hide();
$("#row_time_compare_overlapped").hide(); $("#row_time_compare_overlapped").hide();
$("#row_quantity").hide(); $("#row_quantity").hide();
$("#row_agent_regexp").hide();
$("#row_module_regexp").hide();
$("#row_exception_condition_value").hide(); $("#row_exception_condition_value").hide();
$("#row_exception_condition").hide(); $("#row_exception_condition").hide();
$("#row_dyn_height").hide(); $("#row_dyn_height").hide();
@ -6480,6 +6576,8 @@ function chooseType() {
$("#row_order_uptodown").show(); $("#row_order_uptodown").show();
$("#row_show_resume").show(); $("#row_show_resume").show();
$("#row_show_in_same_row").show(); $("#row_show_in_same_row").show();
$("#row_agent_regexp").show();
$("#row_module_regexp").show();
var checked = $("input[name='last_value']").prop("checked"); var checked = $("input[name='last_value']").prop("checked");
@ -6548,6 +6646,8 @@ function chooseType() {
$("#row_description").show(); $("#row_description").show();
$("#row_period").show(); $("#row_period").show();
$("#row_max_min_avg").show(); $("#row_max_min_avg").show();
$("#row_agent_regexp").show();
$("#row_module_regexp").show();
$("#row_quantity").show(); $("#row_quantity").show();
$("#general_list").show(); $("#general_list").show();
$("#row_order_uptodown").show(); $("#row_order_uptodown").show();
@ -6565,6 +6665,8 @@ function chooseType() {
$("#row_order_uptodown").show(); $("#row_order_uptodown").show();
$("#row_show_resume").show(); $("#row_show_resume").show();
$("#row_show_graph").show(); $("#row_show_graph").show();
$("#row_agent_regexp").show();
$("#row_module_regexp").show();
var checked = $("input[name='last_value']").prop("checked"); var checked = $("input[name='last_value']").prop("checked");

View File

@ -2321,6 +2321,20 @@ switch ($action) {
// $values['external_source'] = json_encode($es); // $values['external_source'] = json_encode($es);
break; break;
case 'top_n':
case 'general':
case 'exception':
$text_agent = get_parameter('text_agent', '');
$text_agent_module = get_parameter('text_agent_module', '');
if (empty($text_agent) === false) {
$style['text_agent'] = base64_encode($text_agent);
}
if (empty($text_agent_module) === false) {
$style['text_agent_module'] = base64_encode($text_agent_module);
}
break;
default: default:
// Default. // Default.
break; break;
@ -3073,6 +3087,20 @@ switch ($action) {
$es['agent_not_assigned_to_ip'] = get_parameter('agent_not_assigned_to_ip'); $es['agent_not_assigned_to_ip'] = get_parameter('agent_not_assigned_to_ip');
break; break;
case 'top_n':
case 'general':
case 'exception':
$text_agent = get_parameter('text_agent', '');
$text_agent_module = get_parameter('text_agent_module', '');
if (empty($text_agent) === false) {
$style['text_agent'] = base64_encode($text_agent);
}
if (empty($text_agent_module) === false) {
$style['text_agent_module'] = base64_encode($text_agent_module);
}
break;
default: default:
// Default. // Default.
break; break;

View File

@ -1298,6 +1298,15 @@ $table_other->data[$row][1] = html_print_checkbox_switch(
); );
$row++; $row++;
$table_other->data[$row][0] = __('Show empty groups in group view');
$table_other->data[$row][1] = html_print_checkbox_switch(
'show_empty_groups',
1,
$config['show_empty_groups'],
true
);
$row++;
$table_other->data[$row][0] = __('Date format string'); $table_other->data[$row][0] = __('Date format string');
$table_other->data[$row][1] = '<em>'.__('Example').'</em> '.date($config['date_format']); $table_other->data[$row][1] = '<em>'.__('Example').'</em> '.date($config['date_format']);
$table_other->data[$row][1] .= html_print_input_text('date_format', $config['date_format'], '', 30, 100, true); $table_other->data[$row][1] .= html_print_input_text('date_format', $config['date_format'], '', 30, 100, true);

View File

@ -301,7 +301,6 @@ if ($new_user && $config['admin_can_add_user']) {
if (enterprise_installed() && is_metaconsole() === true) { if (enterprise_installed() && is_metaconsole() === true) {
$user_info['metaconsole_agents_manager'] = 0; $user_info['metaconsole_agents_manager'] = 0;
$user_info['metaconsole_assigned_server'] = '';
$user_info['metaconsole_access_node'] = 0; $user_info['metaconsole_access_node'] = 0;
} }
@ -375,7 +374,6 @@ if ($create_user) {
if (defined('METACONSOLE')) { if (defined('METACONSOLE')) {
$values['metaconsole_access'] = get_parameter('metaconsole_access', 'basic'); $values['metaconsole_access'] = get_parameter('metaconsole_access', 'basic');
$values['metaconsole_agents_manager'] = ($user_is_admin == 1 ? 1 : get_parameter('metaconsole_agents_manager', '0')); $values['metaconsole_agents_manager'] = ($user_is_admin == 1 ? 1 : get_parameter('metaconsole_agents_manager', '0'));
$values['metaconsole_assigned_server'] = get_parameter('metaconsole_assigned_server', '');
$values['metaconsole_access_node'] = ($user_is_admin == 1 ? 1 : get_parameter('metaconsole_access_node', '0')); $values['metaconsole_access_node'] = ($user_is_admin == 1 ? 1 : get_parameter('metaconsole_access_node', '0'));
} }
} }
@ -588,7 +586,6 @@ if ($update_user) {
if (enterprise_installed() && defined('METACONSOLE')) { if (enterprise_installed() && defined('METACONSOLE')) {
$values['metaconsole_access'] = get_parameter('metaconsole_access'); $values['metaconsole_access'] = get_parameter('metaconsole_access');
$values['metaconsole_agents_manager'] = get_parameter('metaconsole_agents_manager', '0'); $values['metaconsole_agents_manager'] = get_parameter('metaconsole_agents_manager', '0');
$values['metaconsole_assigned_server'] = get_parameter('metaconsole_assigned_server', '');
$values['metaconsole_access_node'] = get_parameter('metaconsole_access_node', '0'); $values['metaconsole_access_node'] = get_parameter('metaconsole_access_node', '0');
} }
@ -1357,15 +1354,6 @@ if ($meta) {
true true
).'</div>'; ).'</div>';
$metaconsole_assigned_server = '<div class="label_select" id="metaconsole_assigned_server_div"><p class="edit_user_labels">'.__('Assigned node').ui_print_help_tip(__('Server where the agents created of this user will be placed'), true).'</p>';
$servers = metaconsole_get_servers();
$servers_for_select = [];
foreach ($servers as $server) {
$servers_for_select[$server['id']] = $server['server_name'];
}
$metaconsole_assigned_server .= html_print_select($servers_for_select, 'metaconsole_assigned_server', $user_info['metaconsole_assigned_server'], '', '', -1, true, false, false).'</div>';
$metaconsole_access_node = '<div class="label_select_simple" id="metaconsole_access_node_div"><p class="edit_user_labels">'.__('Enable node access').ui_print_help_tip(__('With this option enabled, the user will can access to nodes console'), true).'</p>'; $metaconsole_access_node = '<div class="label_select_simple" id="metaconsole_access_node_div"><p class="edit_user_labels">'.__('Enable node access').ui_print_help_tip(__('With this option enabled, the user will can access to nodes console'), true).'</p>';
$metaconsole_access_node .= html_print_checkbox( $metaconsole_access_node .= html_print_checkbox(
'metaconsole_access_node', 'metaconsole_access_node',
@ -1416,7 +1404,7 @@ if (!is_metaconsole()) {
<map name="timezone-map" id="timezone-map">'.$area_data_timezone_polys.$area_data_timezone_rects.'</map> <map name="timezone-map" id="timezone-map">'.$area_data_timezone_polys.$area_data_timezone_rects.'</map>
</div>'; </div>';
} else { } else {
echo $search_custom_fields_view.$metaconsole_agents_manager.$metaconsole_assigned_server.$metaconsole_access_node; echo $search_custom_fields_view.$metaconsole_agents_manager.$metaconsole_access_node;
} }
echo '</div> echo '</div>
@ -1535,16 +1523,16 @@ $(document).ready (function () {
}); });
$('#checkbox-is_admin').change(function() { $('#checkbox-is_admin').change(function() {
if($('#checkbox-is_admin').is(':checked') == true) { if ($('#checkbox-is_admin').is(':checked') == true) {
$('#metaconsole_agents_manager_div').show();
$('#metaconsole_access_node_div').show();
if($('#checkbox-metaconsole_agents_manager').prop('checked')) {
$('#metaconsole_assigned_server_div').show();
}
} else {
$('#metaconsole_agents_manager_div').hide(); $('#metaconsole_agents_manager_div').hide();
$('#metaconsole_access_node_div').hide(); $('#metaconsole_access_node_div').hide();
$('#metaconsole_assigned_server_div').hide(); $('#metaconsole_assigned_server_div').hide();
} else {
$('#metaconsole_agents_manager_div').show();
$('#metaconsole_access_node_div').show();
if ($('#checkbox-metaconsole_agents_manager').prop('checked')) {
$('#metaconsole_assigned_server_div').show();
}
} }
}); });

Binary file not shown.

After

Width:  |  Height:  |  Size: 419 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 712 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 232 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 465 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 463 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 284 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.7 KiB

After

Width:  |  Height:  |  Size: 5.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.6 KiB

After

Width:  |  Height:  |  Size: 6.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 46 KiB

After

Width:  |  Height:  |  Size: 9.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.3 KiB

After

Width:  |  Height:  |  Size: 6.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.9 KiB

After

Width:  |  Height:  |  Size: 5.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.7 KiB

After

Width:  |  Height:  |  Size: 5.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.2 KiB

After

Width:  |  Height:  |  Size: 4.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.5 KiB

After

Width:  |  Height:  |  Size: 6.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.1 KiB

After

Width:  |  Height:  |  Size: 9.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.6 KiB

After

Width:  |  Height:  |  Size: 8.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.8 KiB

After

Width:  |  Height:  |  Size: 6.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.1 KiB

After

Width:  |  Height:  |  Size: 6.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.2 KiB

After

Width:  |  Height:  |  Size: 4.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.4 KiB

After

Width:  |  Height:  |  Size: 5.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.0 KiB

After

Width:  |  Height:  |  Size: 6.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.6 KiB

After

Width:  |  Height:  |  Size: 7.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.5 KiB

After

Width:  |  Height:  |  Size: 5.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.7 KiB

After

Width:  |  Height:  |  Size: 5.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.5 KiB

After

Width:  |  Height:  |  Size: 7.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.3 KiB

After

Width:  |  Height:  |  Size: 8.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.0 KiB

After

Width:  |  Height:  |  Size: 5.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.9 KiB

After

Width:  |  Height:  |  Size: 7.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.5 KiB

After

Width:  |  Height:  |  Size: 8.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.8 KiB

After

Width:  |  Height:  |  Size: 6.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.5 KiB

After

Width:  |  Height:  |  Size: 6.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.1 KiB

After

Width:  |  Height:  |  Size: 6.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.9 KiB

After

Width:  |  Height:  |  Size: 4.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.3 KiB

After

Width:  |  Height:  |  Size: 5.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.0 KiB

After

Width:  |  Height:  |  Size: 4.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.1 KiB

After

Width:  |  Height:  |  Size: 5.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.8 KiB

After

Width:  |  Height:  |  Size: 6.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.1 KiB

After

Width:  |  Height:  |  Size: 7.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.1 KiB

After

Width:  |  Height:  |  Size: 7.0 KiB

View File

@ -55,6 +55,7 @@ if (! check_acl($config['id_user'], 0, 'ER')
return; return;
} }
$drawConsoleSound = (bool) get_parameter('drawConsoleSound', false);
$process_buffers = (bool) get_parameter('process_buffers', false); $process_buffers = (bool) get_parameter('process_buffers', false);
$get_extended_event = (bool) get_parameter('get_extended_event'); $get_extended_event = (bool) get_parameter('get_extended_event');
$change_status = (bool) get_parameter('change_status'); $change_status = (bool) get_parameter('change_status');
@ -2225,6 +2226,228 @@ if ($process_buffers === true) {
return; return;
} }
if ($drawConsoleSound === true) {
echo ui_require_css_file('wizard', 'include/styles/', true);
echo ui_require_css_file('discovery', 'include/styles/', true);
echo ui_require_css_file('sound_events', 'include/styles/', true);
$output = '<div id="tabs-sound-modal">';
// Header tabs.
$output .= '<ul class="tabs-sound-modal-options">';
$output .= '<li>';
$output .= '<a href="#tabs-sound-modal-1">';
$output .= html_print_image(
'images/gear.png',
true,
[
'title' => __('Options'),
'class' => 'invert_filter',
]
);
$output .= '</a>';
$output .= '</li>';
$output .= '<li>';
$output .= '<a href="#tabs-sound-modal-2">';
$output .= html_print_image(
'images/list.png',
true,
[
'title' => __('Events list'),
'class' => 'invert_filter',
]
);
$output .= '</a>';
$output .= '</li>';
$output .= '</ul>';
// Content tabs.
$output .= '<div id="tabs-sound-modal-1">';
$output .= '<h3 class="console-configuration">';
$output .= __('Console configuration');
$output .= '</h3>';
$inputs = [];
// Load filter.
$fields = \events_get_event_filter_select();
$inputs[] = [
'label' => \__('Set condition'),
'arguments' => [
'type' => 'select',
'fields' => $fields,
'name' => 'filter_id',
'selected' => 0,
'return' => true,
'nothing' => \__('All new events'),
'nothing_value' => 0,
'class' => 'fullwidth',
],
];
$times_interval = [
10 => '10 '.__('seconds'),
15 => '15 '.__('seconds'),
30 => '30 '.__('seconds'),
60 => '60 '.__('seconds'),
];
$times_sound = [
2 => '2 '.__('seconds'),
5 => '5 '.__('seconds'),
10 => '10 '.__('seconds'),
15 => '15 '.__('seconds'),
30 => '30 '.__('seconds'),
60 => '60 '.__('seconds'),
];
$inputs[] = [
'class' => 'interval-sounds',
'direct' => 1,
'block_content' => [
[
'label' => __('Interval'),
'arguments' => [
'type' => 'select',
'fields' => $times_interval,
'name' => 'interval',
'selected' => 10,
'return' => true,
],
],
[
'label' => __('Time Sound'),
'arguments' => [
'type' => 'select',
'fields' => $times_sound,
'name' => 'time_sound',
'selected' => 10,
'return' => true,
],
],
],
];
$sounds = [
'aircraftalarm.wav' => 'Air craft alarm',
'air_shock_alarm.wav' => 'Air shock alarm',
'alien_alarm.wav' => 'Alien alarm',
'alien_beacon.wav' => 'Alien beacon',
'bell_school_ringing.wav' => 'Bell school ringing',
'Door_Alarm.wav' => 'Door alarm',
'EAS_beep.wav' => 'EAS beep',
'Firewarner.wav' => 'Fire warner',
'HardPCMAlarm.wav' => 'Hard PCM Alarm',
'negativebeep.wav' => 'Negative beep',
'Star_Trek_emergency_simulation.wav' => 'StarTrek emergency simulation',
];
$inputs[] = [
'class' => 'test-sounds',
'direct' => 1,
'block_content' => [
[
'label' => \__('Sound melody'),
'arguments' => [
'type' => 'select',
'fields' => $sounds,
'name' => 'sound_id',
'selected' => 'Star_Trek_emergency_simulation.wav',
'return' => true,
'class' => 'fullwidth',
],
],
[
'arguments' => [
'type' => 'button',
'name' => 'melody_sound',
'label' => __('Test sound'),
'attributes' => 'class="sub upd"',
'return' => true,
],
],
],
];
// Print form.
$output .= HTML::printForm(
[
'form' => [
'action' => '',
'method' => 'POST',
],
'inputs' => $inputs,
],
true,
false
);
$output .= '</div>';
$output .= '<div id="tabs-sound-modal-2">';
$output .= '<h3 class="title-discovered-alerts">';
$output .= __('Discovered alerts');
$output .= '</h3>';
$output .= '<div class="empty-discovered-alerts">';
$output .= html_print_image(
'images/no-alerts-discovered.png',
true,
[
'title' => __('No alerts discovered'),
'class' => 'invert_filter',
]
);
$output .= '<span class="text-discovered-alerts">';
$output .= __('Congrats! theres nothing to show');
$output .= '</span>';
$output .= '</div>';
$output .= '<div class="elements-discovered-alerts"><ul></ul></div>';
$output .= '</div>';
$output .= '</div>';
$output .= '<div class="actions-sound-modal">';
$output .= '<div id="progressbar_time"></div>';
$output .= '<div class="buttons-sound-modal">';
$output .= '<div class="container-button-play">';
$output .= html_print_input(
[
'label' => __('Start'),
'type' => 'button',
'name' => 'start-search',
'attributes' => 'class="sub play"',
'return' => true,
],
'div',
true
);
$output .= '</div>';
$output .= '<div class="container-button-alert">';
$output .= html_print_input(
[
'type' => 'button',
'name' => 'no-alerts',
'label' => __('No alerts'),
'attributes' => 'class="sub alerts"',
'return' => true,
],
'div',
true
);
$output .= '</div>';
$output .= html_print_input(
[
'type' => 'hidden',
'name' => 'mode_alert',
'value' => 0,
'return' => true,
],
'div',
true
);
$output .= '</div>';
$output .= '</div>';
echo $output;
return;
}
if ($get_events_fired) { if ($get_events_fired) {
global $config; global $config;
$filter_id = (int) get_parameter('filter_id', 0); $filter_id = (int) get_parameter('filter_id', 0);

View File

@ -2483,14 +2483,12 @@ class ConsoleSupervisor
SERVER_TYPE_ENTERPRISE_SATELLITE SERVER_TYPE_ENTERPRISE_SATELLITE
) )
); );
$missed = 0; $missed = 0;
if (is_array($server_version_list) === true) { if (is_array($server_version_list) === true) {
foreach ($server_version_list as $server) { foreach ($server_version_list as $server) {
if (strpos( if (strpos(
$server['version'], $server['version'],
(string) floor($config['current_package']) (string) floor((int) $config['current_package'])
) === false ) === false
) { ) {
$missed++; $missed++;

View File

@ -252,6 +252,7 @@ class TreeService extends Tree
protected function getProcessedServices() protected function getProcessedServices()
{ {
$is_favourite = $this->getServiceFavouriteFilter(); $is_favourite = $this->getServiceFavouriteFilter();
$service_search = $this->getServiceNameSearchFilter();
if (users_can_manage_group_all('AR')) { if (users_can_manage_group_all('AR')) {
$groups_acl = ''; $groups_acl = '';
@ -259,6 +260,16 @@ class TreeService extends Tree
$groups_acl = 'AND ts.id_group IN ('.implode(',', $this->userGroupsArray).')'; $groups_acl = 'AND ts.id_group IN ('.implode(',', $this->userGroupsArray).')';
} }
$exclude_children = 'ts.id NOT IN (
SELECT DISTINCT id_service_child
FROM tservice_element
WHERE id_server_meta = 0
)';
if ($service_search !== '') {
$exclude_children = '1=1';
}
$sql = sprintf( $sql = sprintf(
'SELECT 'SELECT
ts.id, ts.id,
@ -277,15 +288,14 @@ class TreeService extends Tree
FROM tservice ts FROM tservice ts
LEFT JOIN tservice_element tse LEFT JOIN tservice_element tse
ON tse.id_service = ts.id ON tse.id_service = ts.id
WHERE ts.id NOT IN ( WHERE %s
SELECT DISTINCT id_service_child %s
FROM tservice_element
WHERE id_server_meta = 0
)
%s %s
%s %s
GROUP BY ts.id', GROUP BY ts.id',
$exclude_children,
$is_favourite, $is_favourite,
$service_search,
$groups_acl $groups_acl
); );
@ -722,6 +732,23 @@ class TreeService extends Tree
} }
/**
* Retrieve SQL filter for current filter
*
* @return string SQL filter.
*/
protected function getServiceNameSearchFilter()
{
if (isset($this->filter['searchService']) === true
&& empty($this->filter['searchService']) === false
) {
return " AND (ts.name LIKE '%".$this->filter['searchService']."%' OR ts.description LIKE '%".$this->filter['searchService']."%')";
}
return '';
}
/** /**
* Overwrites partial functionality of general Tree.class. * Overwrites partial functionality of general Tree.class.
* *

View File

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

View File

@ -2263,7 +2263,14 @@ function check_login($output=true)
|| (isset($_SESSION['merge-request-user-trick']) === true || (isset($_SESSION['merge-request-user-trick']) === true
&& $_SESSION['merge-request-user-trick'] === $_SESSION['id_usuario']) && $_SESSION['merge-request-user-trick'] === $_SESSION['id_usuario'])
) { ) {
$config['id_user'] = $_SESSION['id_usuario']; if (isset($config['auth']) === true && $config['auth'] === 'ad' && is_user($_SESSION['id_usuario'])) {
// User name in active directory is case insensitive.
// Get the user name from database.
$user_info = get_user_info($_SESSION['id_usuario']);
$config['id_user'] = $user_info['id_user'];
} else {
$config['id_user'] = $_SESSION['id_usuario'];
}
return true; return true;
} }

View File

@ -4298,3 +4298,140 @@ function agents_get_offspring(int $id_agent)
return $return; return $return;
} }
function agents_get_starmap(int $id_agent, float $width=0, float $height=0)
{
ui_require_css_file('heatmap');
$all_modules = agents_get_modules($id_agent);
if (empty($all_modules)) {
return null;
}
$total_modules = count($all_modules);
// Best square.
$high = (float) max($width, $height);
$low = 0.0;
while (abs($high - $low) > 0.000001) {
$mid = (($high + $low) / 2.0);
$midval = (floor($width / $mid) * floor($height / $mid));
if ($midval >= $total_modules) {
$low = $mid;
} else {
$high = $mid;
}
}
$square_length = min(($width / floor($width / $low)), ($height / floor($height / $low)));
// Print starmap.
$html = sprintf(
'<svg id="svg_%s" style="width: %spx; height: %spx;">',
$id_agent,
$width,
$height
);
$html .= '<g>';
$row = 0;
$column = 0;
$x = 0;
$y = 0;
$cont = 1;
foreach ($all_modules as $key => $value) {
// Colour by status.
$status = modules_get_agentmodule_status($key);
switch ($status) {
case 0:
case 4:
case 300:
$status = 'normal';
break;
case 1:
case 100:
$status = 'critical';
break;
case 2:
case 200:
$status = 'warning';
break;
case 3:
$status = 'unknown';
break;
case 5:
$status = 'notinit';
break;
}
$html .= sprintf(
'<rect id="%s" x="%s" y="%s" row="%s" col="%s" width="%s" height="%s" class="%s_%s"></rect>',
'rect_'.$cont,
$x,
$y,
$row,
$column,
$square_length,
$square_length,
$status,
random_int(1, 10)
);
$y += $square_length;
$row++;
if ((int) ($y + $square_length) > (int) $height) {
$y = 0;
$x += $square_length;
$row = 0;
$column++;
}
if ((int) ($x + $square_length) > (int) $width) {
$x = 0;
$y += $square_length;
$column = 0;
$row++;
}
$cont++;
}
?>
<script type="text/javascript">
$(document).ready(function() {
const total_modules = '<?php echo $total_modules; ?>';
function getRandomInteger(min, max) {
return Math.floor(Math.random() * max) + min;
}
function oneSquare(solid, time) {
var randomPoint = getRandomInteger(1, total_modules);
let target = $(`#rect_${randomPoint}`);
let class_name = target.attr('class');
class_name = class_name.split('_')[0];
setTimeout(function() {
target.removeClass();
target.addClass(`${class_name}_${solid}`);
oneSquare(getRandomInteger(1, 10), getRandomInteger(100, 900));
}, time);
}
let cont = 0;
while (cont < Math.ceil(total_modules / 3)) {
oneSquare(getRandomInteger(1, 10), getRandomInteger(100, 900));
cont ++;
}
});
</script>
<?php
$html .= '</g>';
$html .= '</svg>';
return $html;
}

View File

@ -1245,6 +1245,10 @@ function config_update_config()
$error_update[] = __('Show the group name instead the group icon.'); $error_update[] = __('Show the group name instead the group icon.');
} }
if (config_update_value('show_empty_groups', get_parameter('show_empty_groups'), true) === false) {
$error_update[] = __('Show empty groups in group view.');
}
if (config_update_value('custom_graph_width', (int) get_parameter('custom_graph_width', 1), true) === false) { if (config_update_value('custom_graph_width', (int) get_parameter('custom_graph_width', 1), true) === false) {
$error_update[] = __('Default line thickness for the Custom Graph.'); $error_update[] = __('Default line thickness for the Custom Graph.');
} }
@ -3115,6 +3119,10 @@ function config_process_config()
config_update_value('show_group_name', 0); config_update_value('show_group_name', 0);
} }
if (!isset($config['show_empty_groups'])) {
config_update_value('show_empty_groups', 1);
}
if (!isset($config['custom_graph_width'])) { if (!isset($config['custom_graph_width'])) {
config_update_value('custom_graph_width', 1); config_update_value('custom_graph_width', 1);
} }

View File

@ -401,15 +401,8 @@ function events_delete($id_evento, $filter=null, $history=false, $force_node=fal
case '1': case '1':
// Group by events. // Group by events.
$event = events_get_event($id_evento, ['estado', 'event_type', 'id_agente', 'id_agentmodule']);
$filter['group_rep'] = 0;
$filter['status'] = $event['estado'];
$filter['event_type'] = $event['event_type'];
$filter['id_agent'] = $event['id_agente'];
$filter['id_agentmodule'] = $event['id_agentmodule'];
$sql = events_get_all( $sql = events_get_all(
['te.id_evento'], ['te.*'],
$filter, $filter,
// Offset. // Offset.
null, null,
@ -425,7 +418,18 @@ function events_delete($id_evento, $filter=null, $history=false, $force_node=fal
true true
); );
$target_ids = db_get_all_rows_sql($sql); $target_ids = db_get_all_rows_sql(
sprintf(
'SELECT tu.id_evento FROM tevento tu INNER JOIN ( %s ) tf
ON tu.estado = tf.estado
AND tu.evento = tf.evento
AND tu.id_agente = tf.id_agente
AND tu.id_agentmodule = tf.id_agentmodule
AND tf.max_id_evento = %d',
$sql,
$id_evento
)
);
// Try to avoid deadlock while updating full set. // Try to avoid deadlock while updating full set.
if ($target_ids !== false && count($target_ids) > 0) { if ($target_ids !== false && count($target_ids) > 0) {
@ -490,15 +494,8 @@ function events_update_status($id_evento, $status, $filter=null)
case '1': case '1':
// Group by events. // Group by events.
$event = events_get_event($id_evento, ['estado', 'event_type', 'id_agente', 'id_agentmodule']);
$filter['group_rep'] = 0;
$filter['status'] = $event['estado'];
$filter['event_type'] = $event['event_type'];
$filter['id_agent'] = $event['id_agente'];
$filter['id_agentmodule'] = $event['id_agentmodule'];
$sql = events_get_all( $sql = events_get_all(
['te.id_evento'], ['te.*'],
$filter, $filter,
// Offset. // Offset.
null, null,
@ -514,7 +511,18 @@ function events_update_status($id_evento, $status, $filter=null)
true true
); );
$target_ids = db_get_all_rows_sql($sql); $target_ids = db_get_all_rows_sql(
sprintf(
'SELECT tu.id_evento FROM tevento tu INNER JOIN ( %s ) tf
ON tu.estado = tf.estado
AND tu.evento = tf.evento
AND tu.id_agente = tf.id_agente
AND tu.id_agentmodule = tf.id_agentmodule
AND tf.max_id_evento = %d',
$sql,
$id_evento
)
);
// Try to avoid deadlock while updating full set. // Try to avoid deadlock while updating full set.
if ($target_ids !== false && count($target_ids) > 0) { if ($target_ids !== false && count($target_ids) > 0) {
@ -1416,16 +1424,19 @@ function events_get_all(
$group_selects = ''; $group_selects = '';
if ($group_by != '') { if ($group_by != '') {
if ($count === false) { if ($count === false) {
$group_selects = ',COUNT(id_evento) AS event_rep,
GROUP_CONCAT(DISTINCT user_comment SEPARATOR "<br>") AS comments,
MAX(utimestamp) as timestamp_last,
MIN(utimestamp) as timestamp_first,
MAX(id_evento) as max_id_evento';
$idx = array_search('te.user_comment', $fields); $idx = array_search('te.user_comment', $fields);
if ($idx !== false) { if ($idx !== false) {
unset($fields[$idx]); unset($fields[$idx]);
} }
$group_selects = sprintf(
',COUNT(id_evento) AS event_rep,
%s
MAX(utimestamp) as timestamp_last,
MIN(utimestamp) as timestamp_first,
MAX(id_evento) as max_id_evento',
($idx !== false) ? 'GROUP_CONCAT(DISTINCT user_comment SEPARATOR "<br>") AS comments,' : ''
);
} }
} else { } else {
$idx = array_search('te.user_comment', $fields); $idx = array_search('te.user_comment', $fields);

View File

@ -2558,7 +2558,8 @@ function combined_graph_summatory_average(
function graphic_agentaccess( function graphic_agentaccess(
int $id_agent, int $id_agent,
int $period=0, int $period=0,
?bool $return=false ?bool $return=false,
?bool $agent_view=false
) { ) {
global $config; global $config;
@ -2599,6 +2600,10 @@ function graphic_agentaccess(
$options = []; $options = [];
$options['grid']['hoverable'] = true; $options['grid']['hoverable'] = true;
if ($agent_view === true) {
$options['agent_view'] = true;
}
if ($return === true) { if ($return === true) {
return vbar_graph($data_array, $options, 1); return vbar_graph($data_array, $options, 1);
} else { } else {
@ -3015,7 +3020,7 @@ function graph_sla_slicebar(
true, true,
$ttl, $ttl,
false, false,
false, true,
$date $date
); );
} }
@ -3959,7 +3964,7 @@ function graph_graphic_agentevents(
EVENT_CRIT_CRITICAL => COL_CRITICAL, EVENT_CRIT_CRITICAL => COL_CRITICAL,
]; ];
// Draw slicebar graph // Draw slicebar graph.
$out = flot_slicesbar_graph( $out = flot_slicesbar_graph(
$data, $data,
$period, $period,
@ -3978,6 +3983,7 @@ function graph_graphic_agentevents(
$not_interactive, $not_interactive,
1, 1,
$widgets, $widgets,
true,
$server_id $server_id
); );

View File

@ -983,6 +983,14 @@ function html_print_select(
if ($select2_multiple_enable === true if ($select2_multiple_enable === true
&& $select2_multiple_enable_all === true && $select2_multiple_enable_all === true
) { ) {
$output .= 'if($("#'.$id.' > option").length !== $("#'.$id.' > option:selected").length) {
checked = false;
} else {
checked = true;
}
$("#checkbox-'.$id.'-check-all").prop("checked", checked);';
$output .= '$("#'.$id.'").on("change", function(e) { $output .= '$("#'.$id.'").on("change", function(e) {
var checked = false; var checked = false;
if(e.target.length !== $("#'.$id.' > option:selected").length) { if(e.target.length !== $("#'.$id.' > option:selected").length) {
@ -994,8 +1002,6 @@ function html_print_select(
$("#checkbox-'.$id.'-check-all").prop("checked", checked); $("#checkbox-'.$id.'-check-all").prop("checked", checked);
});'; });';
$output .= '$("#'.$id.'").trigger("change");';
$output .= 'var count_shift_'.$id.' = 0;'; $output .= 'var count_shift_'.$id.' = 0;';
$output .= 'var shift_array_'.$id.' = [];'; $output .= 'var shift_array_'.$id.' = [];';
$output .= 'var options_selecteds_'.$id.' = [];'; $output .= 'var options_selecteds_'.$id.' = [];';
@ -1007,13 +1013,17 @@ function html_print_select(
if(count_shift_'.$id.' == 2 ){ if(count_shift_'.$id.' == 2 ){
if(shift_array_'.$id.'[0] <= shift_array_'.$id.'[1]) { if(shift_array_'.$id.'[0] <= shift_array_'.$id.'[1]) {
for (var i = shift_array_'.$id.'[0]; i <= shift_array_'.$id.'[1]; i++) { for (var i = shift_array_'.$id.'[0]; i <= shift_array_'.$id.'[1]; i++) {
var option_value = $("#'.$id.' option").eq(i).val(); if ($("#'.$id.' option").eq(i).text().includes($(".select2-search__field").val()) == true) {
options_selecteds_'.$id.'.push(option_value); var option_value = $("#'.$id.' option").eq(i).val();
options_selecteds_'.$id.'.push(option_value);
}
} }
} else { } else {
for (var i = shift_array_'.$id.'[0]; i >= shift_array_'.$id.'[1]; i--) { for (var i = shift_array_'.$id.'[0]; i >= shift_array_'.$id.'[1]; i--) {
var option_value = $("#'.$id.' option").eq(i).val(); if ($("#'.$id.' option").eq(i).text().includes($(".select2-search__field").val()) == true) {
options_selecteds_'.$id.'.push(option_value); var option_value = $("#'.$id.' option").eq(i).val();
options_selecteds_'.$id.'.push(option_value);
}
} }
} }
@ -5449,6 +5459,108 @@ function html_print_input($data, $wrapper='div', $input_only=false)
); );
break; break;
case 'select_multiple_modules_filtered_select2':
$output .= '<li class="agents_select2">';
$output .= html_print_label(__('Agents'), '', true);
$output .= html_print_select(
$data['agent_values'],
$data['agent_name'],
$data['agent_ids'],
'agent_multiple_change(this, \''.base64_encode(json_encode($data)).'\')',
'',
0,
true,
true,
true,
'',
false,
'min-width: 150px; max-height: 100px',
false,
false,
false,
'',
false,
false,
false,
false,
true,
true,
true
);
$output .= '</li>';
// $output .= html_print_input_hidden(
// 'id_agents2-multiple-text',
// json_encode($agents_select)
// );
$selection = [
0 => __('Show common modules'),
1 => __('Show all modules'),
];
$output .= '<li>';
$output .= html_print_label(__('Type'), '', true);
$output .= html_print_select(
$selection,
$data['selectionModulesNameId'],
$data['selectionModules'],
'selection_multiple_change(\''.base64_encode(json_encode($data)).'\')',
'',
0,
true,
false,
true,
'',
false,
'min-width: 180px'
);
$output .= '</li>';
$all_modules = [];
if (empty($data['agent_ids']) === false) {
$all_modules = get_modules_agents(
0,
$data['agent_ids'],
$data['selectionModules'],
true
);
}
$output .= '<li class="modules_select2">';
$output .= html_print_label(__('Modules'), '', true);
$output .= html_print_select(
$all_modules,
$data['modules_name'],
$data['modules_ids'],
'',
'',
0,
true,
true,
true,
'',
false,
'min-width: 150px; max-width: 500px; max-height: 100px',
false,
false,
false,
'',
false,
false,
false,
false,
true,
true,
true
);
$output .= '</li>';
// $output .= html_print_input_hidden(
// 'module-multiple-text',
// json_encode($agents_select)
// );
break;
default: default:
// Ignore. // Ignore.
break; break;
@ -6026,3 +6138,36 @@ function html_print_select_agent_secondary($agent, $id_agente, $options=[])
return $output; return $output;
} }
/**
* Prints a simple 'Go Back' button.
*
* @param string $url Destination Url.
* @param array $options Options.
* `button_class`: Class for button. 'w100p' by default.
* `title`: Title of the button. 'Go Back' by default.
* `action_class`: Class of icon of button. 'cancel' by default.
* @param boolean $return If true, return a formed HTML element.
*
* @return mixed
*/
function html_print_go_back_button(string $url, array $options=[], bool $return=false)
{
$output = html_print_div(
[
'class' => ($options['button_class'] ?? 'w100p'),
'content' => html_print_button(
($options['title'] ?? __('Go back')),
'go_back',
false,
'window.location.href = \''.$url.'\'',
'class="sub '.($options['action_class'] ?? ' cancel').' right"',
true
),
],
$return
);
return $output;
}

View File

@ -2820,6 +2820,40 @@ function modules_get_color_status($status, $force_module=false)
} }
/**
* Text color status.
*
* @param string $status Type status.
*
* @return string Color.
*/
function modules_get_textcolor_status($status)
{
$result = '#ffffff';
switch ($status) {
case AGENT_MODULE_STATUS_WARNING:
case AGENT_MODULE_STATUS_CRITICAL_ALERT:
case AGENT_MODULE_STATUS_WARNING_ALERT:
case AGENT_MODULE_STATUS_NORMAL_ALERT:
$result = '#000000';
break;
case AGENT_MODULE_STATUS_CRITICAL_BAD:
case AGENT_MODULE_STATUS_NOT_NORMAL:
case AGENT_MODULE_STATUS_NO_DATA:
case AGENT_MODULE_STATUS_NOT_INIT:
case AGENT_MODULE_STATUS_NORMAL:
case AGENT_MODULE_STATUS_ALL:
case AGENT_MODULE_STATUS_UNKNOWN:
default:
$result = '#ffffff';
break;
}
return $result;
}
/** /**
* Gets a module status an modify the status and title reference variables * Gets a module status an modify the status and title reference variables
* *
@ -3630,7 +3664,7 @@ function get_modules_agents($id_module_group, $id_agents, $selection, $select_mo
} }
} }
if (!$selection) { if (!$selection && $useName === true) {
// Common modules. // Common modules.
$final_modules = []; $final_modules = [];
$nodes_consulted = count($modules); $nodes_consulted = count($modules);
@ -3732,6 +3766,10 @@ function get_same_modules($agents, array $modules=[])
return []; return [];
} }
if (is_array($modules) === false || empty($modules) === true) {
return [];
}
$name_modules = modules_get_agentmodule_name_array_data( $name_modules = modules_get_agentmodule_name_array_data(
array_values($modules) array_values($modules)
); );
@ -4224,3 +4262,50 @@ function modules_get_min_max_data($id_agent_module, $time_init=0)
return $data; return $data;
} }
/**
* Get modules match regex.
*
* @param string $regex_alias Regex alias.
* @param string $regex_name_module Regex module name.
* @param string $server_name Name server.
*
* @return array
*/
function modules_get_regex(
$regex_alias,
$regex_name_module='',
$server_name=''
) {
$agent_regexp = sprintf('AND tagente.alias REGEXP "%s"', $regex_alias);
$module_regexp = '';
if (empty($regex_name_module) === false) {
$module_regexp = sprintf(
'AND tagente_modulo.nombre REGEXP "%s"',
$regex_name_module
);
}
$sql = sprintf(
'SELECT tagente_modulo.id_agente_modulo as id_agent_module,
"%s" as server_name
FROM tagente_modulo
INNER JOIN tagente
ON tagente.id_agente = tagente_modulo.id_agente
WHERE 1=1
%s
%s',
$server_name,
$agent_regexp,
$module_regexp
);
$result = db_get_all_rows_sql($sql);
if ($result === false) {
$result = [];
}
return $result;
}

View File

@ -67,6 +67,7 @@ define('REPORT_STATUS_DOWNTIME', 4);
define('REPORT_STATUS_IGNORED', 5); define('REPORT_STATUS_IGNORED', 5);
// Clases. // Clases.
use PandoraFMS\Enterprise\Metaconsole\Node;
use PandoraFMS\Event; use PandoraFMS\Event;
use PandoraFMS\Module; use PandoraFMS\Module;
@ -1544,10 +1545,6 @@ function reporting_event_top_n(
$return['top_n'] = $content['top_n_value']; $return['top_n'] = $content['top_n_value'];
if (empty($content['subitems'])) { if (empty($content['subitems'])) {
if (is_metaconsole()) {
metaconsole_restore_db();
}
// Get all the related data. // Get all the related data.
$sql = sprintf( $sql = sprintf(
'SELECT id_agent_module, server_name 'SELECT id_agent_module, server_name
@ -1556,7 +1553,67 @@ function reporting_event_top_n(
$content['id_rc'] $content['id_rc']
); );
$tops = db_process_sql($sql); $tops = db_get_all_rows_sql($sql);
if ($tops === false) {
$tops = [];
}
// REGEXP.
$text_agent = '';
if (isset($content['style']['text_agent']) === true
&& empty($content['style']['text_agent']) === false
) {
$text_agent = base64_decode($content['style']['text_agent']);
}
$text_agent_module = '';
if (isset($content['style']['text_agent_module']) === true
&& empty($content['style']['text_agent_module']) === false
) {
$text_agent_module = base64_decode($content['style']['text_agent_module']);
}
$modules_regex = [];
if (empty($text_agent) === false) {
if (is_metaconsole() === true) {
$nodes = metaconsole_get_connections();
foreach ($nodes as $node) {
try {
$nd = new Node($node['id']);
$nd->connect();
$modules_regex_node = modules_get_regex(
$text_agent,
$text_agent_module,
$node['server_name']
);
} catch (\Exception $e) {
$nd->disconnect();
$modules_regex_node = [];
} finally {
$nd->disconnect();
}
$modules_regex = array_merge($modules_regex, $modules_regex_node);
}
} else {
$modules_regex = modules_get_regex(
$text_agent,
$text_agent_module
);
}
}
if (empty($modules_regex) === false) {
$tops = array_merge($tops, $modules_regex);
$tops = array_reduce(
$tops,
function ($carry, $item) {
$carry[$item['id_agent_module'].'|'.$item['server_name']] = $item;
return $carry;
},
[]
);
}
} else { } else {
$tops = $content['subitems']; $tops = $content['subitems'];
} }
@ -1579,6 +1636,9 @@ function reporting_event_top_n(
$height = $force_height_chart; $height = $force_height_chart;
} }
// Force width 600px.
$width = 600;
if (empty($tops)) { if (empty($tops)) {
$return['failed'] = __('There are no Agent/Modules defined'); $return['failed'] = __('There are no Agent/Modules defined');
} else { } else {
@ -1590,7 +1650,6 @@ function reporting_event_top_n(
if (($config['metaconsole'] == 1) && $server_name != '' && is_metaconsole()) { if (($config['metaconsole'] == 1) && $server_name != '' && is_metaconsole()) {
$connection = metaconsole_get_connection($server_name); $connection = metaconsole_get_connection($server_name);
if (metaconsole_load_external_db($connection) != NOERR) { if (metaconsole_load_external_db($connection) != NOERR) {
// ui_print_error_message ("Error connecting to ".$server_name);
continue; continue;
} }
} }
@ -1644,18 +1703,51 @@ function reporting_event_top_n(
switch ($order_uptodown) { switch ($order_uptodown) {
// Descending. // Descending.
case 1: case 1:
array_multisort($data_top, SORT_DESC, $agent_name, SORT_ASC, $module_name, SORT_ASC, $id_agent_module, SORT_ASC, $units, SORT_ASC); array_multisort(
$data_top,
SORT_DESC,
$agent_name,
SORT_ASC,
$module_name,
SORT_ASC,
$id_agent_module,
SORT_ASC,
$units,
SORT_ASC
);
break; break;
// Ascending. // Ascending.
case 2: case 2:
array_multisort($data_top, SORT_ASC, $agent_name, SORT_ASC, $module_name, SORT_ASC, $id_agent_module, SORT_ASC, $units, SORT_ASC); array_multisort(
$data_top,
SORT_ASC,
$agent_name,
SORT_ASC,
$module_name,
SORT_ASC,
$id_agent_module,
SORT_ASC,
$units,
SORT_ASC
);
break; break;
// By agent name or without selection. // By agent name or without selection.
case 0: case 0:
case 3: case 3:
array_multisort($agent_name, SORT_ASC, $data_top, SORT_ASC, $module_name, SORT_ASC, $id_agent_module, SORT_ASC, $units, SORT_ASC); array_multisort(
$agent_name,
SORT_ASC,
$data_top,
SORT_ASC,
$module_name,
SORT_ASC,
$id_agent_module,
SORT_ASC,
$units,
SORT_ASC
);
break; break;
default: default:
@ -1683,66 +1775,18 @@ function reporting_event_top_n(
$i = 0; $i = 0;
$data_pie_graph = []; $data_pie_graph = [];
$data_hbar = []; $data_hbar = [];
foreach ($data_top as $dt) { foreach ($data_top as $key_dt => $dt) {
$item_name = '';
$item_name = ui_print_truncate_text($agent_name[$i], $truncate_size, false, true, false, '...').' - '.ui_print_truncate_text($module_name[$i], $truncate_size, false, true, false, '...');
$item_name_key_pie = $item_name;
$exist_key = true;
while ($exist_key) {
if (isset($data_pie_graph[$item_name_key_pie])) {
$item_name_key_pie .= ' ';
} else {
$exist_key = false;
}
}
$item_name_key_hbar = $item_name;
$exist_key = true;
while ($exist_key) {
if (isset($data_hbar[$item_name_key_hbar])) {
$item_name_key_hbar = ' '.$item_name_key_hbar;
} else {
$exist_key = false;
}
}
$data_hbar[$item_name]['g'] = $dt;
$data_pie_graph[$item_name] = $dt;
if ($show_graph == 0 || $show_graph == 1) {
$data = [];
$data['agent'] = $agent_name[$i];
$data['module'] = $module_name[$i];
$data['value'] = $dt;
$divisor = get_data_multiplier($units[$i]);
$data['formated_value'] = format_for_graph($dt, 2, '.', ',', $divisor, $units[$i]);
$data_return[] = $data;
}
$i++;
if ($i >= $top_n_value) {
break;
}
}
} else if ($order_uptodown == 0 || $order_uptodown == 3) {
$i = 0;
$data_pie_graph = [];
$data_hbar = [];
foreach ($agent_name as $an) {
$item_name = '';
$item_name = ui_print_truncate_text( $item_name = ui_print_truncate_text(
$agent_name[$i], $agent_name[$key_dt],
$truncate_size, $truncate_size,
false, false,
true, true,
false, false,
'...' '...'
).' - '.ui_print_truncate_text( );
$module_name[$i], $item_name .= ' - ';
$item_name .= ui_print_truncate_text(
$module_name[$key_dt],
$truncate_size, $truncate_size,
false, false,
true, true,
@ -1770,17 +1814,94 @@ function reporting_event_top_n(
} }
} }
$data_pie_graph[$item_name] = $data_top[$i]; $data_hbar[$item_name]['g'] = $dt;
$data_hbar[$item_name]['g'] = $data_top[$i]; $data_pie_graph[$item_name] = $dt;
$divisor = get_data_multiplier($units[$i]); if ($show_graph == 0 || $show_graph == 1) {
$data = [];
$data['agent'] = $agent_name[$key_dt];
$data['module'] = $module_name[$key_dt];
$data['value'] = $dt;
$divisor = get_data_multiplier($units[$key_dt]);
$data['formated_value'] = format_for_graph(
$dt,
2,
'.',
',',
$divisor,
$units[$key_dt]
);
$data_return[] = $data;
}
$i++;
if ($i >= $top_n_value) {
break;
}
}
} else if ($order_uptodown == 0 || $order_uptodown == 3) {
$i = 0;
$data_pie_graph = [];
$data_hbar = [];
foreach ($agent_name as $key_an => $an) {
$item_name = '';
$item_name = ui_print_truncate_text(
$agent_name[$key_an],
$truncate_size,
false,
true,
false,
'...'
).' - '.ui_print_truncate_text(
$module_name[$key_an],
$truncate_size,
false,
true,
false,
'...'
);
$item_name_key_pie = $item_name;
$exist_key = true;
while ($exist_key) {
if (isset($data_pie_graph[$item_name_key_pie])) {
$item_name_key_pie .= ' ';
} else {
$exist_key = false;
}
}
$item_name_key_hbar = $item_name;
$exist_key = true;
while ($exist_key) {
if (isset($data_hbar[$item_name_key_hbar])) {
$item_name_key_hbar = ' '.$item_name_key_hbar;
} else {
$exist_key = false;
}
}
$data_pie_graph[$item_name] = $data_top[$key_an];
$data_hbar[$item_name]['g'] = $data_top[$key_an];
$divisor = get_data_multiplier($units[$key_an]);
if ($show_graph == 0 || $show_graph == 1) { if ($show_graph == 0 || $show_graph == 1) {
$data = []; $data = [];
$data['agent'] = $an; $data['agent'] = $an;
$data['module'] = $module_name[$i]; $data['module'] = $module_name[$key_an];
$data['value'] = $data_top[$i]; $data['value'] = $data_top[$key_an];
$data['formated_value'] = format_for_graph($data_top[$i], 2, '.', ',', $divisor, $units[$i]); $data['formated_value'] = format_for_graph(
$data_top[$key_an],
2,
'.',
',',
$divisor,
$units[$key_an]
);
$data_return[] = $data; $data_return[] = $data;
} }
@ -1826,7 +1947,7 @@ function reporting_event_top_n(
$ttl, $ttl,
$config['homeurl'], $config['homeurl'],
'white', 'white',
'black' '#DFDFDF'
); );
} }
@ -3150,11 +3271,72 @@ function reporting_exception(
WHERE id_report_content = %d', WHERE id_report_content = %d',
$content['id_rc'] $content['id_rc']
); );
if (is_metaconsole()) {
metaconsole_restore_db(); $exceptions = db_get_all_rows_sql($sql);
if ($exceptions === false) {
$exceptions = [];
} }
$exceptions = db_process_sql($sql); // REGEXP.
$text_agent = '';
if (isset($content['style']['text_agent']) === true
&& empty($content['style']['text_agent']) === false
) {
$text_agent = base64_decode($content['style']['text_agent']);
}
$text_agent_module = '';
if (isset($content['style']['text_agent_module']) === true
&& empty($content['style']['text_agent_module']) === false
) {
$text_agent_module = base64_decode($content['style']['text_agent_module']);
}
$modules_regex = [];
if (empty($text_agent) === false) {
if (is_metaconsole() === true) {
$nodes = metaconsole_get_connections();
foreach ($nodes as $node) {
try {
$nd = new Node($node['id']);
$nd->connect();
$modules_regex_node = modules_get_regex(
$text_agent,
$text_agent_module,
$node['server_name']
);
} catch (\Exception $e) {
$nd->disconnect();
$modules_regex_node = [];
} finally {
$nd->disconnect();
}
$modules_regex = array_merge($modules_regex, $modules_regex_node);
}
} else {
$modules_regex = modules_get_regex(
$text_agent,
$text_agent_module
);
}
}
if (empty($modules_regex) === false) {
$exceptions = array_merge($exceptions, $modules_regex);
$exceptions = array_reduce(
$exceptions,
function ($carry, $item) {
if (isset($item['operation']) === false) {
$item['operation'] = 'avg';
}
$carry[$item['id_agent_module'].'|'.$item['server_name']] = $item;
return $carry;
},
[]
);
}
} else { } else {
$exceptions = $content['subitems']; $exceptions = $content['subitems'];
} }
@ -4924,7 +5106,7 @@ function reporting_custom_render($report, $content, $type='dinamic', $pdf=0)
$data_macro['server_id'] $data_macro['server_id']
); );
if (metaconsole_connect($server) != NOERR) { if (metaconsole_connect($server) != NOERR) {
continue; continue 2;
} }
} }
@ -9423,14 +9605,75 @@ function reporting_general($report, $content)
$return['show_in_same_row'] = $content['style']['show_in_same_row']; $return['show_in_same_row'] = $content['style']['show_in_same_row'];
if (empty($content['subitems'])) { if (empty($content['subitems'])) {
if (is_metaconsole()) {
metaconsole_restore_db();
}
$generals = db_get_all_rows_filter( $generals = db_get_all_rows_filter(
'treport_content_item', 'treport_content_item',
['id_report_content' => $content['id_rc']] ['id_report_content' => $content['id_rc']]
); );
if ($generals === false) {
$generals = [];
}
// REGEXP.
$text_agent = '';
if (isset($content['style']['text_agent']) === true
&& empty($content['style']['text_agent']) === false
) {
$text_agent = base64_decode($content['style']['text_agent']);
}
$text_agent_module = '';
if (isset($content['style']['text_agent_module']) === true
&& empty($content['style']['text_agent_module']) === false
) {
$text_agent_module = base64_decode($content['style']['text_agent_module']);
}
$modules_regex = [];
if (empty($text_agent) === false) {
if (is_metaconsole() === true) {
$nodes = metaconsole_get_connections();
foreach ($nodes as $node) {
try {
$nd = new Node($node['id']);
$nd->connect();
$modules_regex_node = modules_get_regex(
$text_agent,
$text_agent_module,
$node['server_name']
);
} catch (\Exception $e) {
$nd->disconnect();
$modules_regex_node = [];
} finally {
$nd->disconnect();
}
$modules_regex = array_merge($modules_regex, $modules_regex_node);
}
} else {
$modules_regex = modules_get_regex(
$text_agent,
$text_agent_module
);
}
}
if (empty($modules_regex) === false) {
$generals = array_merge($generals, $modules_regex);
$generals = array_reduce(
$generals,
function ($carry, $item) {
if (isset($item['operation']) === false) {
$item['operation'] = 'avg';
}
$carry[$item['id_agent_module'].'|'.$item['server_name']] = $item;
return $carry;
},
[]
);
}
} else { } else {
$generals = $content['subitems']; $generals = $content['subitems'];
} }
@ -9440,16 +9683,14 @@ function reporting_general($report, $content)
} }
$i = 0; $i = 0;
$index = 0;
$is_string = []; $is_string = [];
foreach ($generals as $row) { foreach ($generals as $key_row => $row) {
// Metaconsole connection // Metaconsole connection.
$server_name = $row['server_name']; $server_name = $row['server_name'];
if (($config['metaconsole'] == 1) && $server_name != '' && is_metaconsole()) { if (($config['metaconsole'] == 1) && $server_name != '' && is_metaconsole()) {
$connection = metaconsole_get_connection($server_name); $connection = metaconsole_get_connection($server_name);
if (metaconsole_load_external_db($connection) != NOERR) { if (metaconsole_load_external_db($connection) != NOERR) {
// ui_print_error_message ("Error connecting to ".$server_name);
continue; continue;
} }
} }
@ -9458,7 +9699,7 @@ function reporting_general($report, $content)
|| modules_is_not_init($row['id_agent_module']) || modules_is_not_init($row['id_agent_module'])
) { ) {
if (is_metaconsole()) { if (is_metaconsole()) {
// Restore db connection // Restore db connection.
metaconsole_restore_db(); metaconsole_restore_db();
} }
@ -9469,7 +9710,7 @@ function reporting_general($report, $content)
$ag_name = modules_get_agentmodule_agent_alias($row['id_agent_module']); $ag_name = modules_get_agentmodule_agent_alias($row['id_agent_module']);
$name_agent = modules_get_agentmodule_agent_name($row['id_agent_module']); $name_agent = modules_get_agentmodule_agent_name($row['id_agent_module']);
$type_mod = modules_get_last_value($row['id_agent_module']); $type_mod = modules_get_last_value($row['id_agent_module']);
$is_string[$index] = modules_is_string($row['id_agent_module']); $is_string[$key_row] = modules_is_string($row['id_agent_module']);
$unit = db_get_value( $unit = db_get_value(
'unit', 'unit',
'tagente_modulo', 'tagente_modulo',
@ -9478,7 +9719,7 @@ function reporting_general($report, $content)
); );
$id_module_type = db_get_value('id_tipo_modulo', 'tagente_modulo', 'nombre', $mod_name); $id_module_type = db_get_value('id_tipo_modulo', 'tagente_modulo', 'nombre', $mod_name);
if ($content['period'] == 0) { if ($content['period'] == 0) {
$data_res[$index] = modules_get_last_value($row['id_agent_module']); $data_res[$key_row] = modules_get_last_value($row['id_agent_module']);
} else { } else {
$data_sum = reporting_get_agentmodule_data_sum( $data_sum = reporting_get_agentmodule_data_sum(
$row['id_agent_module'], $row['id_agent_module'],
@ -9502,34 +9743,34 @@ function reporting_general($report, $content)
); );
if ($content['style']['show_in_same_row'] && $content['group_by_agent'] == REPORT_GENERAL_NOT_GROUP_BY_AGENT) { if ($content['style']['show_in_same_row'] && $content['group_by_agent'] == REPORT_GENERAL_NOT_GROUP_BY_AGENT) {
$data_res[$index] = [ $data_res[$key_row] = [
$data_avg, $data_avg,
$data_max, $data_max,
$data_min, $data_min,
$data_sum, $data_sum,
]; ];
} else { } else {
if (is_numeric($type_mod) && !$is_string[$index]) { if (is_numeric($type_mod) && !$is_string[$key_row]) {
switch ($row['operation']) { switch ($row['operation']) {
case 'sum': case 'sum':
$data_res[$index] = $data_sum; $data_res[$key_row] = $data_sum;
break; break;
case 'max': case 'max':
$data_res[$index] = $data_max; $data_res[$key_row] = $data_max;
break; break;
case 'min': case 'min':
$data_res[$index] = $data_min; $data_res[$key_row] = $data_min;
break; break;
case 'avg': case 'avg':
default: default:
$data_res[$index] = $data_avg; $data_res[$key_row] = $data_avg;
break; break;
} }
} else { } else {
$data_res[$index] = $type_mod; $data_res[$key_row] = $type_mod;
} }
} }
} }
@ -9538,46 +9779,46 @@ function reporting_general($report, $content)
switch ($content['group_by_agent']) { switch ($content['group_by_agent']) {
case REPORT_GENERAL_NOT_GROUP_BY_AGENT: case REPORT_GENERAL_NOT_GROUP_BY_AGENT:
$id_agent_module[$index] = $row['id_agent_module']; $id_agent_module[$key_row] = $row['id_agent_module'];
$agent_name[$index] = $ag_name; $agent_name[$key_row] = $ag_name;
$module_name[$index] = $mod_name; $module_name[$key_row] = $mod_name;
$units[$index] = $unit; $units[$key_row] = $unit;
$id_module_types[$index] = $id_module_type; $id_module_types[$key_row] = $id_module_type;
$operations[$index] = $row['operation']; $operations[$key_row] = $row['operation'];
break; break;
case REPORT_GENERAL_GROUP_BY_AGENT: case REPORT_GENERAL_GROUP_BY_AGENT:
$id_module_types[$index] = $id_module_type; $id_module_types[$key_row] = $id_module_type;
if ($id_module_types[$index] == 2 || $id_module_types[$index] == 6 || $id_module_types[$index] == 9 || $id_module_types[$index] == 18) { if ($id_module_types[$key_row] == 2 || $id_module_types[$key_row] == 6 || $id_module_types[$key_row] == 9 || $id_module_types[$key_row] == 18) {
$data_res[$index] = round($data_res[$index], 0, PHP_ROUND_HALF_DOWN); $data_res[$key_row] = round($data_res[$key_row], 0, PHP_ROUND_HALF_DOWN);
} }
if ($id_module_types[$index] == 2 || $id_module_types[$index] == 6 || $id_module_types[$index] == 9 || $id_module_types[$index] == 18) { if ($id_module_types[$key_row] == 2 || $id_module_types[$key_row] == 6 || $id_module_types[$key_row] == 9 || $id_module_types[$key_row] == 18) {
if ($data_res[$index] == 1) { if ($data_res[$key_row] == 1) {
$data_res[$index] = 'Up'; $data_res[$key_row] = 'Up';
} else if ($data_res[$index] == 0) { } else if ($data_res[$key_row] == 0) {
$data_res[$index] = 'Down'; $data_res[$key_row] = 'Down';
} }
} }
if ($data_res[$index] === false) { if ($data_res[$key_row] === false) {
$return['data'][$name_agent][$mod_name] = null; $return['data'][$name_agent][$mod_name] = null;
} else { } else {
if (!is_numeric($data_res[$index])) { if (!is_numeric($data_res[$key_row])) {
$return['data'][$name_agent][$mod_name] = $data_res[$index]; $return['data'][$name_agent][$mod_name] = $data_res[$key_row];
} else { } else {
$return['data'][$name_agent][$mod_name] = format_for_graph($data_res[$index], 2, '.', ',', $divisor, ' '.$unit); $return['data'][$name_agent][$mod_name] = format_for_graph($data_res[$key_row], 2, '.', ',', $divisor, ' '.$unit);
} }
} }
break; break;
} }
if ($content['style']['show_in_same_row']) { if ($content['style']['show_in_same_row']) {
foreach ($data_res[$index] as $val) { foreach ($data_res[$key_row] as $val) {
// Calculate the avg, min and max // Calculate the avg, min and max
if (is_numeric($val)) { if (is_numeric($val)) {
$change_min = false; $change_min = false;
if (is_null($return['min']['value'])) { if ($return['min']['value'] === null) {
$change_min = true; $change_min = true;
} else { } else {
if ($return['min']['value'] > $val) { if ($return['min']['value'] > $val) {
@ -9593,7 +9834,7 @@ function reporting_general($report, $content)
} }
$change_max = false; $change_max = false;
if (is_null($return['max']['value'])) { if ($return['max']['value'] === null) {
$change_max = true; $change_max = true;
} else { } else {
if ($return['max']['value'] < $val) { if ($return['max']['value'] < $val) {
@ -9617,51 +9858,50 @@ function reporting_general($report, $content)
} }
} else { } else {
// Calculate the avg, min and max // Calculate the avg, min and max
if (is_numeric($data_res[$index]) && !$is_string[$index]) { if (is_numeric($data_res[$key_row]) && !$is_string[$key_row]) {
$change_min = false; $change_min = false;
if (is_null($return['min']['value'])) { if ($return['min']['value'] === null) {
$change_min = true; $change_min = true;
} else { } else {
if ($return['min']['value'] > $data_res[$index]) { if ($return['min']['value'] > $data_res[$key_row]) {
$change_min = true; $change_min = true;
} }
} }
if ($change_min) { if ($change_min) {
$return['min']['value'] = $data_res[$index]; $return['min']['value'] = $data_res[$key_row];
$return['min']['formated_value'] = format_for_graph($data_res[$index], 2, '.', ',', $divisor, ' '.$unit); $return['min']['formated_value'] = format_for_graph($data_res[$key_row], 2, '.', ',', $divisor, ' '.$unit);
$return['min']['agent'] = $ag_name; $return['min']['agent'] = $ag_name;
$return['min']['module'] = $mod_name; $return['min']['module'] = $mod_name;
} }
$change_max = false; $change_max = false;
if (is_null($return['max']['value'])) { if ($return['max']['value'] === null) {
$change_max = true; $change_max = true;
} else { } else {
if ($return['max']['value'] < $data_res[$index]) { if ($return['max']['value'] < $data_res[$key_row]) {
$change_max = true; $change_max = true;
} }
} }
if ($change_max) { if ($change_max) {
$return['max']['value'] = $data_res[$index]; $return['max']['value'] = $data_res[$key_row];
$return['max']['formated_value'] = format_for_graph($data_res[$index], 2, '.', ',', $divisor, ' '.$unit); $return['max']['formated_value'] = format_for_graph($data_res[$key_row], 2, '.', ',', $divisor, ' '.$unit);
$return['max']['agent'] = $ag_name; $return['max']['agent'] = $ag_name;
$return['max']['module'] = $mod_name; $return['max']['module'] = $mod_name;
} }
if ($i == 0) { if ($i == 0) {
$return['avg_value'] = $data_res[$index]; $return['avg_value'] = $data_res[$key_row];
} else { } else {
$return['avg_value'] = ((($return['avg_value'] * $i) / ($i + 1)) + ($data_res[$index] / ($i + 1))); $return['avg_value'] = ((($return['avg_value'] * $i) / ($i + 1)) + ($data_res[$key_row] / ($i + 1)));
} }
} }
} }
$index++;
$i++; $i++;
// Restore dbconnection // Restore dbconnection.
if (($config['metaconsole'] == 1) && $server_name != '' && is_metaconsole()) { if (($config['metaconsole'] == 1) && $server_name != '' && is_metaconsole()) {
metaconsole_restore_db(); metaconsole_restore_db();
} }
@ -9719,20 +9959,19 @@ function reporting_general($report, $content)
break; break;
} }
$i = 0; foreach ($data_res as $d_key => $d) {
foreach ($data_res as $d) {
$data = []; $data = [];
$data['agent'] = $agent_name[$i]; $data['agent'] = $agent_name[$d_key];
$data['module'] = $module_name[$i]; $data['module'] = $module_name[$d_key];
$data['id_agent_module'] = $id_agent_module[$i]; $data['id_agent_module'] = $id_agent_module[$d_key];
$data['id_agent'] = agents_get_agent_id_by_module_id($id_agent_module[$i]); $data['id_agent'] = agents_get_agent_id_by_module_id($id_agent_module[$d_key]);
$data['id_module_type'] = $id_module_types[$i]; $data['id_module_type'] = $id_module_types[$d_key];
$data['operator'] = ''; $data['operator'] = '';
if ($content['period'] != 0) { if ($content['period'] != 0) {
if ($content['style']['show_in_same_row']) { if ($content['style']['show_in_same_row']) {
$data['operator'] = 'all'; $data['operator'] = 'all';
} else { } else {
switch ($operations[$i]) { switch ($operations[$d_key]) {
case 'sum': case 'sum':
$data['operator'] = __('Summatory'); $data['operator'] = __('Summatory');
break; break;
@ -9758,28 +9997,16 @@ function reporting_general($report, $content)
if ($val === false) { if ($val === false) {
$data['value'][] = null; $data['value'][] = null;
} else { } else {
switch ($config['dbtype']) { $divisor = get_data_multiplier($units[$d_key]);
case 'mysql':
case 'postgresql':
break;
case 'oracle': if (!is_numeric($val) || $is_string[$d_key]) {
if (preg_match('/[0-9]+,[0-9]E+[+-][0-9]+/', $val)) {
$val = oracle_format_float_to_php($val);
}
break;
}
$divisor = get_data_multiplier($units[$i]);
if (!is_numeric($val) || $is_string[$i]) {
$data['value'][] = $val; $data['value'][] = $val;
// to see the chains on the table // to see the chains on the table
$data['formated_value'][] = $val; $data['formated_value'][] = $val;
} else { } else {
$data['value'][] = $val; $data['value'][] = $val;
$data['formated_value'][] = format_for_graph($val, 2, '.', ',', $divisor, ' '.$units[$i]); $data['formated_value'][] = format_for_graph($val, 2, '.', ',', $divisor, ' '.$units[$d_key]);
} }
} }
} }
@ -9787,35 +10014,21 @@ function reporting_general($report, $content)
if ($d === false) { if ($d === false) {
$data['value'] = null; $data['value'] = null;
} else { } else {
switch ($config['dbtype']) { $divisor = get_data_multiplier($units[$d_key]);
case 'mysql':
case 'postgresql':
break;
case 'oracle': if (!is_numeric($d) || $is_string[$d_key]) {
if (preg_match('/[0-9]+,[0-9]E+[+-][0-9]+/', $d)) {
$d = oracle_format_float_to_php($d);
}
break;
}
$divisor = get_data_multiplier($units[$i]);
if (!is_numeric($d) || $is_string[$i]) {
$data['value'] = $d; $data['value'] = $d;
// to see the chains on the table // to see the chains on the table
$data['formated_value'] = $d; $data['formated_value'] = $d;
} else { } else {
$data['value'] = $d; $data['value'] = $d;
$data['formated_value'] = format_for_graph($d, 2, '.', ',', $divisor, ' '.$units[$i]); $data['formated_value'] = format_for_graph($d, 2, '.', ',', $divisor, ' '.$units[$d_key]);
} }
} }
} }
$return['data'][] = $data; $return['data'][] = $data;
$i++;
} }
break; break;
} }
@ -10908,7 +11121,7 @@ function reporting_get_group_stats($id_group=0, $access='AR', $recursion=true)
* *
* @return array Group statistics * @return array Group statistics
*/ */
function reporting_get_group_stats_resume($id_group=0, $access='AR', $ignore_permissions=false) function reporting_get_group_stats_resume($id_group=0, $access='AR', $ignore_permissions=false, $recursive=false)
{ {
global $config; global $config;
@ -10952,6 +11165,8 @@ function reporting_get_group_stats_resume($id_group=0, $access='AR', $ignore_per
$id_group = array_keys( $id_group = array_keys(
users_get_groups($config['id_user'], $access, false) users_get_groups($config['id_user'], $access, false)
); );
} else if ($recursive === true) {
$id_group = groups_get_children_ids($id_group);
} }
// ----------------------------------------------------------------- // -----------------------------------------------------------------
@ -11082,7 +11297,7 @@ function reporting_get_group_stats_resume($id_group=0, $access='AR', $ignore_per
$group_stat = db_get_all_rows_sql($sql); $group_stat = db_get_all_rows_sql($sql);
$data = [ $data = [
'monitor_checks' => (int) $group_stat[0]['modules'], 'monitor_checks' => (int) $group_stat[0]['modules'],
'monitor_alerts' => (int) groups_monitor_alerts($group_array), 'monitor_alerts' => (int) groups_monitor_alerts($group_stat[0]['id_group']),
'monitor_alerts_fired' => (int) $group_stat[0]['alerts_fired'], 'monitor_alerts_fired' => (int) $group_stat[0]['alerts_fired'],
'monitor_alerts_fire_count' => (int) $group_stat[0]['alerts_fired'], 'monitor_alerts_fire_count' => (int) $group_stat[0]['alerts_fired'],
'monitor_ok' => (int) $group_stat[0]['normal'], 'monitor_ok' => (int) $group_stat[0]['normal'],
@ -11096,10 +11311,33 @@ function reporting_get_group_stats_resume($id_group=0, $access='AR', $ignore_per
'agent_warning' => (int) $group_stat[0]['agents_warnings'], 'agent_warning' => (int) $group_stat[0]['agents_warnings'],
'agent_critical' => (int) $group_stat[0]['agents_critical'], 'agent_critical' => (int) $group_stat[0]['agents_critical'],
'total_checks' => (int) $group_stat[0]['modules'], 'total_checks' => (int) $group_stat[0]['modules'],
'total_alerts' => (int) groups_monitor_alerts($group_array), 'total_alerts' => (int) groups_monitor_alerts($group_stat[0]['id_group']),
'total_agents' => (int) $group_stat[0]['agents'], 'total_agents' => (int) $group_stat[0]['agents'],
'utimestamp' => (int) $group_stat[0]['utimestamp'], 'utimestamp' => (int) $group_stat[0]['utimestamp'],
]; ];
if ($recursive === true) {
unset($group_stat[0]);
foreach ($group_stat as $value) {
$data['monitor_checks'] = ($data['monitor_checks'] + $value['modules']);
$data['monitor_alerts'] = ($data['monitor_alerts'] + groups_monitor_alerts($value['id_group']));
$data['monitor_alerts_fired'] = ($data['monitor_alerts_fired'] + $value['alerts_fired']);
$data['monitor_alerts_fire_count'] = ($data['monitor_alerts_fire_count'] + $value['alerts_fired']);
$data['monitor_ok'] = ($data['monitor_ok'] + $value['normal']);
$data['monitor_warning'] = ($data['monitor_warning'] + $value['warning']);
$data['monitor_critical'] = ($data['monitor_critical'] + $value['critical']);
$data['monitor_unknown'] = ($data['monitor_unknown'] + $value['unknown']);
$data['monitor_not_init'] = ($data['monitor_not_init'] + $value['non-init']);
$data['agent_not_init'] = ($data['agent_not_init'] + $value['agents_not_init']);
$data['agent_unknown'] = ($data['agent_unknown'] + $value['agents_unknown']);
$data['agent_ok'] = ($data['agent_ok'] + $value['agents_normal']);
$data['agent_warning'] = ($data['agent_warning'] + $value['agents_warnings']);
$data['agent_critical'] = ($data['agent_critical'] + $value['agents_critical']);
$data['total_checks'] = ($data['total_checks'] + $value['modules']);
$data['total_alerts'] = ($data['total_alerts'] + groups_monitor_alerts($value['id_group']));
$data['total_agents'] = ($data['total_agents'] + $value['agents']);
}
}
} }
} }
@ -14623,6 +14861,16 @@ function reporting_module_histogram_graph($report, $content, $pdf=0)
); );
} }
$showLabelTicks = true;
if (isset($content['showLabelTicks']) === true) {
$showLabelTicks = $content['showLabelTicks'];
}
$height_graph = 80;
if (isset($content['height_graph']) === true) {
$height_graph = $content['height_graph'];
}
$return['title'] = $title; $return['title'] = $title;
$return['landscape'] = $content['landscape']; $return['landscape'] = $content['landscape'];
$return['pagebreak'] = $content['pagebreak']; $return['pagebreak'] = $content['pagebreak'];
@ -14871,7 +15119,6 @@ function reporting_module_histogram_graph($report, $content, $pdf=0)
]; ];
$width_graph = 100; $width_graph = 100;
$height_graph = 80;
if (empty($array_result) === false) { if (empty($array_result) === false) {
$return['chart'] = flot_slicesbar_graph( $return['chart'] = flot_slicesbar_graph(
$array_result, $array_result,
@ -14882,7 +15129,7 @@ function reporting_module_histogram_graph($report, $content, $pdf=0)
$colors, $colors,
$config['fontpath'], $config['fontpath'],
$config['round_corner'], $config['round_corner'],
$homeurl, $config['homeurl'],
'', '',
'', '',
false, false,
@ -14891,7 +15138,7 @@ function reporting_module_histogram_graph($report, $content, $pdf=0)
true, true,
$ttl, $ttl,
$content['sizeForTicks'], $content['sizeForTicks'],
true, $showLabelTicks,
$report['datetime'] $report['datetime']
); );
} else { } else {

View File

@ -961,8 +961,8 @@ function reporting_html_top_n($table, $item, $pdf=0)
if ($pdf !== 0) { if ($pdf !== 0) {
$return_pdf .= $item['charts']['pie']; $return_pdf .= $item['charts']['pie'];
} else { } else {
$table->colspan['char_pie']['cell'] = 3; $table->colspan['char_pie'][0] = 2;
$table->data['char_pie']['cell'] = $item['charts']['pie']; $table->data['char_pie'][0] = $item['charts']['pie'];
} }
} }
@ -970,8 +970,8 @@ function reporting_html_top_n($table, $item, $pdf=0)
if ($pdf !== 0) { if ($pdf !== 0) {
$return_pdf .= $item['charts']['bars']; $return_pdf .= $item['charts']['bars'];
} else { } else {
$table->colspan['char_bars']['cell'] = 3; // $table->colspan['char_bars']['cell'] = 3;
$table->data['char_bars']['cell'] = $item['charts']['bars']; $table->data['char_pie'][1] = $item['charts']['bars'];
} }
} }
@ -4815,6 +4815,7 @@ function reporting_html_general($table, $item, $pdf=0)
} }
$list_modules = array_keys($list_modules); $list_modules = array_keys($list_modules);
$table1 = new stdClass();
$table1->width = '99%'; $table1->width = '99%';
$table1->data = []; $table1->data = [];
$table1->head = array_merge([__('Agent')], $list_modules); $table1->head = array_merge([__('Agent')], $list_modules);
@ -5967,7 +5968,7 @@ function reporting_get_event_histogram($events, $text_header_event=false)
true, true,
1, 1,
false, false,
false true
); );
$table->data[0][0] = $slicebar; $table->data[0][0] = $slicebar;
@ -6126,7 +6127,7 @@ function reporting_get_event_histogram_meta($width, $events)
true, true,
1, 1,
false, false,
false true
); );
$table->data[0][0] = $slicebar; $table->data[0][0] = $slicebar;

View File

@ -1440,13 +1440,17 @@ function snmp_browser_create_modules_snmp(
/** /**
* Prints html for create module from snmp massive dialog * Prints html for create module from snmp massive dialog
* *
* @param string $url_form * @param string $target Target.
* @param string $title * @param string $snmp_conf Conf.
* @param boolean $return * @param boolean $return Type return.
* @return void *
* @return string Output html.
*/ */
function snmp_browser_print_create_module_massive($target='agent', $snmp_conf, $return=false) function snmp_browser_print_create_module_massive(
{ $target='agent',
$snmp_conf='',
$return=false
) {
global $config; global $config;
// String for labels. // String for labels.
@ -1458,6 +1462,10 @@ function snmp_browser_print_create_module_massive($target='agent', $snmp_conf, $
case 'policy': case 'policy':
$target_item = 'Policies'; $target_item = 'Policies';
break; break;
default:
// Not possible.
break;
} }
$output = "<form target='_blank' id='create_module_massive' action='#' method='post'>"; $output = "<form target='_blank' id='create_module_massive' action='#' method='post'>";

View File

@ -478,7 +478,14 @@ function tactical_get_data(
$list['_monitors_alerts_fired_'] = tactical_monitor_fired_alerts(explode(',', $user_groups_ids), $user_strict, explode(',', $user_groups_ids)); $list['_monitors_alerts_fired_'] = tactical_monitor_fired_alerts(explode(',', $user_groups_ids), $user_strict, explode(',', $user_groups_ids));
$list['_monitors_alerts_'] = tactical_monitor_alerts($user_strict); $list['_monitors_alerts_'] = tactical_monitor_alerts($user_strict);
$total_agentes = agents_get_agents(false, ['count(DISTINCT id_agente) as total_agents'], 'AR', false, false, 1); $total_agentes = agents_get_agents(
['id_grupo' => explode(',', $user_groups_ids)],
['count(DISTINCT id_agente) as total_agents'],
'AR',
false,
false,
1
);
$list['_total_agents_'] = $total_agentes[0]['total_agents']; $list['_total_agents_'] = $total_agentes[0]['total_agents'];
$list['_monitor_checks_'] = ($list['_monitors_not_init_'] + $list['_monitors_unknown_'] + $list['_monitors_warning_'] + $list['_monitors_critical_'] + $list['_monitors_ok_']); $list['_monitor_checks_'] = ($list['_monitors_not_init_'] + $list['_monitors_unknown_'] + $list['_monitors_warning_'] + $list['_monitors_critical_'] + $list['_monitors_ok_']);
@ -493,16 +500,32 @@ function tactical_get_data(
} }
function tactical_status_modules_agents($id_user=false, $user_strict=false, $access='AR', $force_group_and_tag=true) function tactical_status_modules_agents($id_user=false, $user_strict=false, $access='AR', $groups=[])
{ {
global $config; global $config;
if ($id_user == false) { if ($id_user === false) {
$id_user = $config['id_user']; $id_user = $config['id_user'];
} }
if (empty($groups) === false) {
if (is_array($groups) === false) {
$groups = explode(',', (string) $groups);
// Group id as key.
$groups = array_flip($groups);
}
if (isset($groups[0]) === true) {
$groups = [];
}
}
$acltags = tags_get_user_groups_and_tags($id_user, $access, $user_strict); $acltags = tags_get_user_groups_and_tags($id_user, $access, $user_strict);
if (empty($groups) === false) {
$acltags = array_intersect_key($acltags, $groups);
}
$result_list = tactical_get_data($id_user, $user_strict, $acltags); $result_list = tactical_get_data($id_user, $user_strict, $acltags);
return $result_list; return $result_list;

View File

@ -817,7 +817,7 @@ function treeview_printTable($id_agente, $server_data=[], $no_head=false)
$events_graph .= graph_graphic_agentevents( $events_graph .= graph_graphic_agentevents(
$id_agente, $id_agente,
'340px;margin:0', '340px;margin:0',
'130px', '60px',
SECONDS_1DAY, SECONDS_1DAY,
'', '',
true, true,

View File

@ -3184,6 +3184,7 @@ function ui_progress_extend(
* 'class' => th class. * 'class' => th class.
* 'style' => th style. * 'style' => th style.
* 'text' => 'column1'. * 'text' => 'column1'.
* 'title' => 'column title'.
* ] * ]
* ], * ],
* 'columns' => [ * 'columns' => [
@ -3219,12 +3220,15 @@ function ui_progress_extend(
* 'option2' * 'option2'
* ... * ...
* ] * ]
* 'no_toggle' => Pint form withouth UI toggle.
* ] * ]
* ], * ],
* 'extra_html' => HTML content to be placed after 'filter' section. * 'extra_html' => HTML content to be placed after 'filter' section.
* 'drawCallback' => function to be called after draw. Sample in: * 'drawCallback' => function to be called after draw. Sample in:
* https://datatables.net/examples/advanced_init/row_grouping.html * https://datatables.net/examples/advanced_init/row_grouping.html
* ] * ]
* 'zeroRecords' => Message when zero records obtained from filter.(Leave blank for default).
* 'emptyTable' => Message when table data empty.(Leave blank for default).
* End. * End.
* *
* @return string HTML code with datatable. * @return string HTML code with datatable.
@ -3429,7 +3433,18 @@ function ui_print_datatable(array $parameters)
} }
// Languages. // Languages.
$processing = __('Processing'); $processing = '<div class=\'processing-datatables-inside\'>';
$processing .= '<i>'.__('Processing').'</i> ';
$processing .= str_replace(
'"',
"'",
html_print_image(
'images/spinner.gif',
true
)
);
$processing .= '</div>';
$zeroRecords = isset($parameters['zeroRecords']) === true ? $parameters['zeroRecords'] : __('No matching records found'); $zeroRecords = isset($parameters['zeroRecords']) === true ? $parameters['zeroRecords'] : __('No matching records found');
$emptyTable = isset($parameters['emptyTable']) === true ? $parameters['emptyTable'] : __('No data available in table'); $emptyTable = isset($parameters['emptyTable']) === true ? $parameters['emptyTable'] : __('No data available in table');
@ -3478,7 +3493,8 @@ function ui_print_datatable(array $parameters)
$(document).ready(function(){ $(document).ready(function(){
$.fn.dataTable.ext.errMode = "none"; $.fn.dataTable.ext.errMode = "none";
$.fn.dataTable.ext.classes.sPageButton = "'.$pagination_class.'"; $.fn.dataTable.ext.classes.sPageButton = "'.$pagination_class.'";
dt_'.$table_id.' = $("#'.$table_id.'").DataTable({
var settings_datatable = {
drawCallback: function(settings) {'; drawCallback: function(settings) {';
if (isset($parameters['drawCallback'])) { if (isset($parameters['drawCallback'])) {
$js .= $parameters['drawCallback']; $js .= $parameters['drawCallback'];
@ -3541,6 +3557,10 @@ function ui_print_datatable(array $parameters)
url: "'.ui_get_full_url('ajax.php', false, false, false).'", url: "'.ui_get_full_url('ajax.php', false, false, false).'",
type: "POST", type: "POST",
dataSrc: function (json) { dataSrc: function (json) {
if($("#'.$form_id.'_search_bt") != undefined) {
$("#'.$form_id.'_loading").remove();
}
if (json.error) { if (json.error) {
console.error(json.error); console.error(json.error);
$("#error-'.$table_id.'").html(json.error); $("#error-'.$table_id.'").html(json.error);
@ -3587,6 +3607,18 @@ function ui_print_datatable(array $parameters)
} }
}, },
data: function (data) { data: function (data) {
if($("#'.$form_id.'_search_bt") != undefined) {
var loading = \''.html_print_image(
'images/spinner.gif',
true,
[
'id' => $form_id.'_loading',
'class' => 'loading-search-datatables-button',
]
).'\';
$("#'.$form_id.'_search_bt").parent().append(loading);
}
inputs = $("#'.$form_id.' :input"); inputs = $("#'.$form_id.' :input");
values = {}; values = {};
@ -3626,7 +3658,9 @@ function ui_print_datatable(array $parameters)
$js .= ' $js .= '
], ],
order: [[ '.$order.' ]] order: [[ '.$order.' ]]
}); };
var dt_'.$table_id.' = $("#'.$table_id.'").DataTable(settings_datatable);
$("#'.$form_id.'_search_bt").click(function (){ $("#'.$form_id.'_search_bt").click(function (){
dt_'.$table_id.'.draw().page(0) dt_'.$table_id.'.draw().page(0)

View File

@ -2652,8 +2652,8 @@ function visual_map_process_wizard_add_modules(
$image, $image,
$id_layout, $id_layout,
$range, $range,
$width=0, $width,
$height=0, $height,
$period, $period,
$process_value, $process_value,
$percentileitem_width, $percentileitem_width,
@ -2669,6 +2669,14 @@ function visual_map_process_wizard_add_modules(
$fontf='lato', $fontf='lato',
$fonts='12pt' $fonts='12pt'
) { ) {
if (empty($width) === true) {
$width = 0;
}
if (empty($height) === true) {
$height = 0;
}
if (empty($id_modules)) { if (empty($id_modules)) {
$return = ui_print_error_message( $return = ui_print_error_message(
__('No modules selected'), __('No modules selected'),
@ -2923,8 +2931,8 @@ function visual_map_process_wizard_add_agents(
$image, $image,
$id_layout, $id_layout,
$range, $range,
$width=0, $width,
$height=0, $height,
$period, $period,
$process_value, $process_value,
$percentileitem_width, $percentileitem_width,
@ -2942,6 +2950,14 @@ function visual_map_process_wizard_add_agents(
) { ) {
global $config; global $config;
if (empty($width) === true) {
$width = 0;
}
if (empty($height) === true) {
$height = 0;
}
if (empty($id_agents)) { if (empty($id_agents)) {
$return = ui_print_error_message( $return = ui_print_error_message(
__('No agents selected'), __('No agents selected'),
@ -4171,8 +4187,14 @@ function visual_map_get_layout_status($layout_id, $status_data=[], $depth=0)
* *
* @return string The text for the parent. * @return string The text for the parent.
*/ */
function visual_map_create_internal_name_item($label=null, $type, $image, $agent=null, $id_module, $idData) function visual_map_create_internal_name_item(
{ $label=null,
$type='',
$image='',
$agent=null,
$id_module=0,
$idData=''
) {
$text = ''; $text = '';
if (empty($label)) { if (empty($label)) {

View File

@ -1,5 +1,7 @@
<?php <?php
global $config; global $config;
global $pandora_version;
global $build_version;
require_once __DIR__.'/config.php'; require_once __DIR__.'/config.php';

View File

@ -494,7 +494,7 @@ function vbar_graph(
'weight' => $options['x']['font']['weight'], 'weight' => $options['x']['font']['weight'],
'family' => $options['x']['font']['family'], 'family' => $options['x']['font']['family'],
'variant' => $options['x']['font']['variant'], 'variant' => $options['x']['font']['variant'],
'color' => $options['x']['font']['color'], 'color' => ($options['agent_view'] === true) ? 'black' : $options['x']['font']['color'],
], ],
'show' => $options['x']['show'], 'show' => $options['x']['show'],
'position' => $options['x']['position'], 'position' => $options['x']['position'],
@ -516,7 +516,7 @@ function vbar_graph(
'weight' => $options['y']['font']['weight'], 'weight' => $options['y']['font']['weight'],
'family' => $options['y']['font']['family'], 'family' => $options['y']['font']['family'],
'variant' => $options['y']['font']['variant'], 'variant' => $options['y']['font']['variant'],
'color' => $options['y']['font']['color'], 'color' => ($options['agent_view'] === true) ? 'black' : $options['y']['font']['color'],
], ],
'show' => $options['y']['show'], 'show' => $options['y']['show'],
'position' => $options['y']['position'], 'position' => $options['y']['position'],
@ -534,8 +534,8 @@ function vbar_graph(
'aboveData' => $options['grid']['aboveData'], 'aboveData' => $options['grid']['aboveData'],
'color' => $options['grid']['color'], 'color' => $options['grid']['color'],
'backgroundColor' => $options['grid']['backgroundColor'], 'backgroundColor' => $options['grid']['backgroundColor'],
'margin' => $options['grid']['margin'], 'margin' => ($options['agent_view'] === true) ? 6 : $options['grid']['margin'],
'labelMargin' => $options['grid']['labelMargin'], 'labelMargin' => ($options['agent_view'] === true) ? 12 : $options['grid']['labelMargin'],
'axisMargin' => $options['grid']['axisMargin'], 'axisMargin' => $options['grid']['axisMargin'],
'markings' => $options['grid']['markings'], 'markings' => $options['grid']['markings'],
'borderWidth' => $options['grid']['borderWidth'], 'borderWidth' => $options['grid']['borderWidth'],
@ -561,6 +561,10 @@ function vbar_graph(
], ],
]; ];
if ($options['agent_view'] === true) {
$params['agent_view'] = true;
}
if (empty($params['data']) === true) { if (empty($params['data']) === true) {
return graph_nodata_image( return graph_nodata_image(
0, 0,

View File

@ -816,13 +816,13 @@ function pandoraFlotSlicebar(
} }
}, },
grid: { grid: {
borderWidth: 1, borderWidth: 0,
borderColor: "#C1C1C1", borderColor: "transparent",
tickColor: "#fff" tickColor: "#fff"
}, },
xaxes: [ xaxes: [
{ {
show: true, show: show_date,
tickFormatter: xFormatter, tickFormatter: xFormatter,
color: "", color: "",
tickSize: intervaltick, tickSize: intervaltick,

View File

@ -670,6 +670,10 @@ function flot_vcolumn_chart(array $options)
$style .= 'height:'.$options['generals']['pdf']['height'].'px;'; $style .= 'height:'.$options['generals']['pdf']['height'].'px;';
} }
if ($options['agent_view'] === true) {
$style = 'width: 95%; height: 85px';
}
$class = ''; $class = '';
if ($options['generals']['rotate'] === true) { if ($options['generals']['rotate'] === true) {
$class = 'bars-graph-rotate'; $class = 'bars-graph-rotate';

View File

@ -2869,7 +2869,7 @@ function donutNarrowGraph(
arc = d3.svg arc = d3.svg
.arc() .arc()
.outerRadius(radius) .outerRadius(radius)
.innerRadius(radius - radius / 6); .innerRadius(radius - radius / 4);
svg = donutbody svg = donutbody
.append("svg") .append("svg")

View File

@ -1,4 +1,4 @@
/* global $ */ /* global $ jQuery */
/* exported load_modal */ /* exported load_modal */
var ENTERPRISE_DIR = "enterprise"; var ENTERPRISE_DIR = "enterprise";
@ -2020,6 +2020,7 @@ function progressBarSvg(option) {
return svg; return svg;
} }
// eslint-disable-next-line no-unused-vars
function inArray(needle, haystack) { function inArray(needle, haystack) {
var length = haystack.length; var length = haystack.length;
for (var i = 0; i < length; i++) { for (var i = 0; i < length; i++) {
@ -2028,6 +2029,65 @@ function inArray(needle, haystack) {
return false; return false;
} }
// eslint-disable-next-line no-unused-vars
function agent_multiple_change(e, info) {
info = JSON.parse(atob(info));
jQuery.post(
"ajax.php",
{
page: "operation/agentes/ver_agente",
get_modules_group_json: 1,
selection: $("#" + info.selectionModulesNameId).val(),
id_agents: $("#" + info.agent_name.replace("[]", "")).val(),
select_mode: 1
},
function(data) {
var name = info.modules_name.replace("[]", "");
$("#" + name).html("");
$("#checkbox-" + name + "-check-all").prop("checked", false);
if (data) {
jQuery.each(data, function(id, value) {
var option = $("<option></option>")
.attr("value", id)
.html(value);
$("#" + name).append(option);
});
}
},
"json"
);
}
// eslint-disable-next-line no-unused-vars
function selection_multiple_change(info) {
info = JSON.parse(atob(info));
jQuery.post(
"ajax.php",
{
page: "operation/agentes/ver_agente",
get_modules_group_json: 1,
id_agents: $("#" + info.agent_name.replace("[]", "")).val(),
selection: $("#" + info.selectionModulesNameId).val(),
select_mode: 1
},
function(data) {
var name = info.modules_name.replace("[]", "");
$("#" + name).html("");
// Check module all.
$("#checkbox-" + name + "-check-all").prop("checked", false);
if (data) {
jQuery.each(data, function(id, value) {
var option = $("<option></option>")
.attr("value", id)
.html(value);
$("#" + name).append(option);
});
}
},
"json"
);
}
/* /*
* Creates a progressbar. * Creates a progressbar.
* @param id the id of the div we want to transform in a progressbar. * @param id the id of the div we want to transform in a progressbar.

View File

@ -1,4 +1,4 @@
/*global jQuery, $, forced_title_callback, confirmDialog*/ /*global jQuery, $, forced_title_callback, confirmDialog, progressTimeBar*/
// Show the modal window of an event // Show the modal window of an event
function show_event_dialog(event, dialog_page) { function show_event_dialog(event, dialog_page) {
@ -1028,3 +1028,256 @@ function process_buffers(buffers) {
}); });
} }
} }
function openSoundEventModal(settings) {
settings = JSON.parse(atob(settings));
// Check modal exists and is open.
if (
$("#modal-sound").hasClass("ui-dialog-content") &&
$("#modal-sound").dialog("isOpen")
) {
return;
}
// Initialize modal.
$("#modal-sound")
.empty()
.dialog({
title: settings.title,
resizable: false,
modal: true,
position: { my: "right top", at: "right bottom", of: window },
overlay: {
opacity: 0.5,
background: "black"
},
width: 600,
height: 600,
open: function() {
$.ajax({
method: "post",
url: settings.url,
data: {
page: settings.page,
drawConsoleSound: 1
},
dataType: "html",
success: function(data) {
$("#modal-sound").append(data);
$("#tabs-sound-modal").tabs({
disabled: [1]
});
// Test sound.
$("#button-melody_sound").click(function() {
var sound = false;
if ($("#id_sound_event").length == 0) {
sound = true;
}
test_sound_button(sound);
});
// Play Stop.
$("#button-start-search").click(function() {
var mode = $("#hidden-mode_alert").val();
var action = false;
if (mode == 0) {
action = true;
}
action_events_sound(action, settings);
});
// Silence Alert.
$("#button-no-alerts").click(function() {
if ($("#button-no-alerts").hasClass("silence-alerts") === true) {
// Remove audio.
remove_audio();
// Clean events.
$("#tabs-sound-modal .elements-discovered-alerts ul").empty();
$("#tabs-sound-modal .empty-discovered-alerts").removeClass(
"invisible_important"
);
// Clean progress.
$("#progressbar_time").empty();
// Change img button.
$("#button-no-alerts")
.removeClass("silence-alerts")
.addClass("alerts");
// Change value button.
$("#button-no-alerts").val(settings.noAlert);
// Background button.
$(".container-button-alert").removeClass("fired");
// New progress.
listen_event_sound(settings);
}
});
},
error: function(error) {
console.error(error);
}
});
},
close: function() {
remove_audio();
$(this).dialog("destroy");
}
})
.show();
}
function test_sound_button(test_sound) {
if (test_sound === true) {
add_audio();
} else {
remove_audio();
}
}
function action_events_sound(mode, settings) {
if (mode === true) {
// Enable tabs.
$("#tabs-sound-modal").tabs("option", "disabled", [0]);
// Active tabs.
$("#tabs-sound-modal").tabs("option", "active", 1);
// Change mode.
$("#hidden-mode_alert").val(1);
// Change img button.
$("#button-start-search")
.removeClass("play")
.addClass("stop");
// Change value button.
$("#button-start-search").val(settings.stop);
// Add Progress bar.
listen_event_sound(settings);
} else {
// Enable tabs.
$("#tabs-sound-modal").tabs("option", "disabled", [1]);
// Active tabs.
$("#tabs-sound-modal").tabs("option", "active", 0);
// Change mode.
$("#hidden-mode_alert").val(0);
// Change img button.
$("#button-start-search")
.removeClass("stop")
.addClass("play");
// Change value button.
$("#button-start-search").val(settings.start);
// Remove progress bar.
$("#progressbar_time").empty();
// Remove audio.
remove_audio();
// Clean events.
$("#tabs-sound-modal .elements-discovered-alerts ul").empty();
$("#tabs-sound-modal .empty-discovered-alerts").removeClass(
"invisible_important"
);
// Change img button.
$("#button-no-alerts")
.removeClass("silence-alerts")
.addClass("alerts");
// Change value button.
$("#button-no-alerts").val(settings.noAlert);
// Background button.
$(".container-button-alert").removeClass("fired");
}
}
function add_audio() {
var sound = "./include/sounds/" + $("#tabs-sound-modal #sound_id").val();
$(".actions-sound-modal").append(
"<audio id='id_sound_event' src='" +
sound +
"' autoplay='true' hidden='true' loop='false'>"
);
}
function remove_audio() {
$(".actions-sound-modal audio").remove();
}
function listen_event_sound(settings) {
progressTimeBar(
"progressbar_time",
$("#interval").val(),
"infinite",
function() {
// Search events.
check_event_sound(settings);
}
);
}
function check_event_sound(settings) {
jQuery.post(
"./ajax.php",
{
page: "include/ajax/events",
get_events_fired: 1,
filter_id: $("#tabs-sound-modal #filter_id").val(),
interval: $("#tabs-sound-modal #interval").val(),
time_sound: $("#tabs-sound-modal #time_sound").val()
},
function(data) {
if (data != false) {
// Hide empty.
$("#tabs-sound-modal .empty-discovered-alerts").addClass(
"invisible_important"
);
// Change img button.
$("#button-no-alerts")
.removeClass("alerts")
.addClass("silence-alerts");
// Change value button.
$("#button-no-alerts").val(settings.silenceAlarm);
// Background button.
$(".container-button-alert").addClass("fired");
// Remove audio.
remove_audio();
// Apend audio.
add_audio();
// Add elements.
data.forEach(function(element) {
var li = document.createElement("li");
li.insertAdjacentHTML(
"beforeend",
'<div class="li-priority">' + element.priority + "</div>"
);
li.insertAdjacentHTML(
"beforeend",
'<div class="li-type">' + element.type + "</div>"
);
li.insertAdjacentHTML(
"beforeend",
'<div class="li-title">' + element.message + "</div>"
);
li.insertAdjacentHTML(
"beforeend",
'<div class="li-time">' + element.timestamp + "</div>"
);
$("#tabs-sound-modal .elements-discovered-alerts ul").append(li);
});
// -100 delay sound.
setTimeout(
remove_audio,
parseInt($("#tabs-sound-modal #time_sound").val()) * 1000 - 100
);
}
},
"json"
);
}

View File

@ -416,6 +416,11 @@ class Widget
$className .= '\OsQuickReportWidget'; $className .= '\OsQuickReportWidget';
break; break;
case 'ColorModuleTabs':
case 'BlockHistogram':
$className .= '\\'.$name;
break;
default: default:
$className = false; $className = false;
break; break;

View File

@ -0,0 +1,663 @@
<?php
/**
* Widget block histogram modules Pandora FMS Console
*
* @category Console Class
* @package Pandora FMS
* @subpackage Widget
* @version 1.0.0
* @license See below
*
* ______ ___ _______ _______ ________
* | __ \.-----.--.--.--| |.-----.----.-----. | ___| | | __|
* | __/| _ | | _ || _ | _| _ | | ___| |__ |
* |___| |___._|__|__|_____||_____|__| |___._| |___| |__|_|__|_______|
*
* ============================================================================
* Copyright (c) 2005-2022 Artica Soluciones Tecnologicas
* Please see http://pandorafms.org for full contribution list
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation for version 2.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* ============================================================================
*/
namespace PandoraFMS\Dashboard;
use PandoraFMS\Enterprise\Metaconsole\Node;
global $config;
/**
* URL Widgets
*/
class BlockHistogram extends Widget
{
/**
* Name widget.
*
* @var string
*/
protected $name;
/**
* Title widget.
*
* @var string
*/
protected $title;
/**
* Page widget;
*
* @var string
*/
protected $page;
/**
* Class name widget.
*
* @var [type]
*/
protected $className;
/**
* Values options for each widget.
*
* @var [type]
*/
protected $values;
/**
* Configuration required.
*
* @var boolean
*/
protected $configurationRequired;
/**
* Error load widget.
*
* @var boolean
*/
protected $loadError;
/**
* Width.
*
* @var integer
*/
protected $width;
/**
* Heigth.
*
* @var integer
*/
protected $height;
/**
* Grid Width.
*
* @var integer
*/
protected $gridWidth;
/**
* Cell ID.
*
* @var integer
*/
protected $cellId;
/**
* Construct.
*
* @param integer $cellId Cell ID.
* @param integer $dashboardId Dashboard ID.
* @param integer $widgetId Widget ID.
* @param integer|null $width New width.
* @param integer|null $height New height.
* @param integer|null $gridWidth Grid width.
*/
public function __construct(
int $cellId,
int $dashboardId=0,
int $widgetId=0,
?int $width=0,
?int $height=0,
?int $gridWidth=0
) {
global $config;
// WARNING: Do not edit. This chunk must be in the constructor.
parent::__construct(
$cellId,
$dashboardId,
$widgetId
);
// Width.
$this->width = $width;
// Height.
$this->height = $height;
// Grid Width.
$this->gridWidth = $gridWidth;
// Cell Id.
$this->cellId = $cellId;
// Options.
$this->values = $this->decoders($this->getOptionsWidget());
// Positions.
$this->position = $this->getPositionWidget();
// Page.
$this->page = basename(__FILE__);
// ClassName.
$class = new \ReflectionClass($this);
$this->className = $class->getShortName();
// Title.
$this->title = __('Block histogram');
// Name.
if (empty($this->name) === true) {
$this->name = 'single_graph';
}
// This forces at least a first configuration.
$this->configurationRequired = false;
if (empty($this->values['moduleBlockHistogram']) === true) {
$this->configurationRequired = true;
}
$this->overflow_scrollbars = false;
}
/**
* Decoders hack for retrocompability.
*
* @param array $decoder Values.
*
* @return array Returns the values with the correct key.
*/
public function decoders(array $decoder): array
{
$values = [];
// Retrieve global - common inputs.
$values = parent::decoders($decoder);
$values['agentsBlockHistogram'] = [];
if (isset($decoder['agentsBlockHistogram']) === true) {
if (isset($decoder['agentsBlockHistogram'][0]) === true
&& empty($decoder['agentsBlockHistogram']) === false
) {
$values['agentsBlockHistogram'] = explode(
',',
$decoder['agentsBlockHistogram'][0]
);
}
}
if (isset($decoder['selectionBlockHistogram']) === true) {
$values['selectionBlockHistogram'] = $decoder['selectionBlockHistogram'];
}
$values['moduleBlockHistogram'] = [];
if (isset($decoder['moduleBlockHistogram']) === true) {
if (empty($decoder['moduleBlockHistogram']) === false) {
$values['moduleBlockHistogram'] = $decoder['moduleBlockHistogram'];
}
}
if (isset($decoder['period']) === true) {
$values['period'] = $decoder['period'];
}
if (isset($decoder['fontColor']) === true) {
$values['fontColor'] = $decoder['fontColor'];
}
$values['label'] = 'module';
if (isset($decoder['label']) === true) {
$values['label'] = $decoder['label'];
}
return $values;
}
/**
* Generates inputs for form (specific).
*
* @return array Of inputs.
*
* @throws Exception On error.
*/
public function getFormInputs(): array
{
$values = $this->values;
// Retrieve global - common inputs.
$inputs = parent::getFormInputs();
// Default values.
if (isset($values['period']) === false) {
$values['period'] = SECONDS_1DAY;
}
if (empty($values['fontColor']) === true) {
$values['fontColor'] = '#2c3e50';
}
$inputs[] = [
'label' => __('Font color'),
'arguments' => [
'wrapper' => 'div',
'name' => 'fontColor',
'type' => 'color',
'value' => $values['fontColor'],
'return' => true,
],
];
// Type Label.
$fields = [
'module' => __('Module'),
'agent' => __('Agent'),
'agent_module' => __('Agent / module'),
];
$inputs[] = [
'label' => __('Label'),
'arguments' => [
'type' => 'select',
'fields' => $fields,
'name' => 'label',
'selected' => $values['label'],
'return' => true,
],
];
// Periodicity.
$inputs[] = [
'label' => __('Interval'),
'arguments' => [
'name' => 'period',
'type' => 'interval',
'value' => $values['period'],
'nothing' => __('None'),
'nothing_value' => 0,
'style_icon' => 'flex-grow: 0',
],
];
$inputs[] = [
'arguments' => [
'type' => 'select_multiple_modules_filtered_select2',
'agent_values' => agents_get_agents_selected(0),
'agent_name' => 'agentsBlockHistogram[]',
'agent_ids' => $values['agentsBlockHistogram'],
'selectionModules' => $values['selectionBlockHistogram'],
'selectionModulesNameId' => 'selectionBlockHistogram',
'modules_ids' => $values['moduleBlockHistogram'],
'modules_name' => 'moduleBlockHistogram[]',
],
];
return $inputs;
}
/**
* Get Post for widget.
*
* @return array
*/
public function getPost():array
{
// Retrieve global - common inputs.
$values = parent::getPost();
$values['agentsBlockHistogram'] = \get_parameter(
'agentsBlockHistogram',
[]
);
$values['selectionBlockHistogram'] = \get_parameter(
'selectionBlockHistogram',
0
);
$values['moduleBlockHistogram'] = \get_parameter(
'moduleBlockHistogram'
);
$agColor = [];
if (isset($values['agentsBlockHistogram'][0]) === true
&& empty($values['agentsBlockHistogram'][0]) === false
) {
$agColor = explode(',', $values['agentsBlockHistogram'][0]);
}
$agModule = [];
if (isset($values['moduleBlockHistogram'][0]) === true
&& empty($values['moduleBlockHistogram'][0]) === false
) {
$agModule = explode(',', $values['moduleBlockHistogram'][0]);
}
$values['moduleBlockHistogram'] = get_same_modules_all(
$agColor,
$agModule
);
$values['period'] = \get_parameter('period', 0);
$values['fontColor'] = \get_parameter('fontColor', '#2c3e50');
$values['label'] = \get_parameter('label', 'agent');
return $values;
}
/**
* Draw widget.
*
* @return string;
*/
public function load()
{
global $config;
$size = parent::getSize();
$output = '';
if (is_metaconsole() === true) {
$modules_nodes = array_reduce(
$this->values['moduleBlockHistogram'],
function ($carry, $item) {
$explode = explode('|', $item);
$carry[$explode[0]][] = $explode[1];
return $carry;
},
[]
);
$modules = [];
foreach ($modules_nodes as $n => $mod) {
try {
$node = new Node((int) $n);
$node->connect();
$node_mods = $this->getInfoModules($mod);
if (empty($node_mods) === false) {
foreach ($node_mods as $value) {
$value['id_node'] = $n;
$value['server_name'] = $node->toArray()['server_name'];
$modules[] = $value;
}
}
$node->disconnect();
} catch (\Exception $e) {
// Unexistent agent.
$node->disconnect();
}
}
} else {
$modules = $this->getInfoModules(
$this->values['moduleBlockHistogram']
);
}
if ($modules !== false && empty($modules) === false) {
$total_modules = count($modules);
$output .= '<div class="container-histograms" style="width: '.$size['width'].'px;">';
$output .= '<table class="table-container-histograms" style="color:'.$this->values['fontColor'].'">';
foreach ($modules as $key => $module) {
$last = false;
if (($total_modules - 1) === $key) {
$last = true;
}
if (is_metaconsole() === true) {
try {
$node = new Node((int) $module['id_node']);
$node->connect();
$output .= $this->drawHistograms($module, $last);
$node->disconnect();
} catch (\Exception $e) {
// Unexistent agent.
$node->disconnect();
}
} else {
$output .= $this->drawHistograms($module, $last);
}
}
$output .= '</table>';
$output .= '</div>';
} else {
$output .= '<div class="container-center">';
$output .= \ui_print_info_message(
__('Not found modules'),
'',
true
);
$output .= '</div>';
}
return $output;
}
/**
* Get info modules.
*
* @param array $modules Modules.
*
* @return array Data.
*/
private function getInfoModules(array $modules): array
{
$where = sprintf(
'tagente_modulo.id_agente_modulo IN (%s)',
implode(',', $modules)
);
$sql = sprintf(
'SELECT tagente_modulo.id_agente_modulo AS `id`,
tagente_modulo.nombre AS `name`,
tagente_modulo.unit AS `unit`,
tagente.alias AS `agent_alias`,
tagente.id_agente AS `agent_id`
FROM tagente_modulo
INNER JOIN tagente
ON tagente_modulo.id_agente = tagente.id_agente
WHERE %s',
$where
);
$modules = db_get_all_rows_sql($sql);
if ($modules === false) {
$modules = [];
}
return $modules;
}
/**
* Draw histogram module.
*
* @param array $data Info module.
* @param boolean $last Last histogram.
*
* @return string
*/
private function drawHistograms(array $data, bool $last):string
{
global $config;
$size = parent::getSize();
// Desactive scroll bars only this item.
$id_agent = $data['agent_id'];
$id_module = $data['id'];
$period = $this->values['period'];
switch ($this->values['label']) {
case 'module':
$label = ui_print_truncate_text(
$data['name'],
25,
false,
true,
true,
'[&hellip;]',
''
);
break;
case 'agent_module':
$label = ui_print_truncate_text(
$data['agent_alias'].' / '.$data['name'],
25,
false,
true,
true,
);
break;
default:
case 'agent':
$label = ui_print_truncate_text(
$data['agent_alias'],
25,
false,
true,
true,
'[&hellip;]',
''
);
break;
}
$size_label = 10;
$id_group = \agents_get_agent_group($id_agent);
$height_graph = 30;
if ($last === true) {
if ($period > 86500) {
$height_graph = 60;
} else {
$height_graph = 50;
}
}
$content = [
'id_agent_module' => $id_module,
'period' => $period,
'time_from' => '00:00:00',
'time_to' => '00:00:00',
'id_group' => $id_group,
'sizeForTicks' => ($size['width'] - 200),
'showLabelTicks' => ($last === true) ? true : false,
'height_graph' => $height_graph,
[
['id_agent_module' => $id_module],
]
];
$graph = \reporting_module_histogram_graph(
['datetime' => time()],
$content
);
$style = 'min-width:200px;';
if ($last === false) {
if ($period > 86500) {
$style .= 'width:calc(100% - 24px); margin-left: 12px;';
} else {
$style .= 'width:calc(100% - 16px); margin-left: 8px;';
}
} else {
$style .= 'height:60px;';
}
$st = 'font-size:'.$size_label.'px;';
if (is_metaconsole() === false) {
$st .= 'height: 28px;';
}
$output = '<tr>';
$output .= '<td style="width: 170px; vertical-align: initial;">';
$output .= '<div class="widget-histogram-label" style="'.$st.'">';
$output .= $label;
$output .= '</div>';
$output .= '</td>';
$output .= '<td>';
$output .= '<div class="widget-histogram-chart" style="'.$style.'">';
$output .= $graph['chart'];
$output .= '</div>';
$output .= '</td>';
$output .= '</tr>';
return $output;
}
/**
* Get description.
*
* @return string.
*/
public static function getDescription()
{
return __('Block histogram');
}
/**
* Get Name.
*
* @return string.
*/
public static function getName()
{
return 'BlockHistogram';
}
/**
* Get size Modal Configuration.
*
* @return array
*/
public function getSizeModalConfiguration(): array
{
$size = [
'width' => (is_metaconsole() === true) ? 700 : 500,
'height' => 670,
];
return $size;
}
}

View File

@ -0,0 +1,567 @@
<?php
/**
* Widget Color tabs modules Pandora FMS Console
*
* @category Console Class
* @package Pandora FMS
* @subpackage Widget
* @version 1.0.0
* @license See below
*
* ______ ___ _______ _______ ________
* | __ \.-----.--.--.--| |.-----.----.-----. | ___| | | __|
* | __/| _ | | _ || _ | _| _ | | ___| |__ |
* |___| |___._|__|__|_____||_____|__| |___._| |___| |__|_|__|_______|
*
* ============================================================================
* Copyright (c) 2005-2022 Artica Soluciones Tecnologicas
* Please see http://pandorafms.org for full contribution list
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation for version 2.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* ============================================================================
*/
namespace PandoraFMS\Dashboard;
use PandoraFMS\Enterprise\Metaconsole\Node;
global $config;
/**
* URL Widgets
*/
class ColorModuleTabs extends Widget
{
/**
* Name widget.
*
* @var string
*/
protected $name;
/**
* Title widget.
*
* @var string
*/
protected $title;
/**
* Page widget;
*
* @var string
*/
protected $page;
/**
* Class name widget.
*
* @var [type]
*/
protected $className;
/**
* Values options for each widget.
*
* @var [type]
*/
protected $values;
/**
* Configuration required.
*
* @var boolean
*/
protected $configurationRequired;
/**
* Error load widget.
*
* @var boolean
*/
protected $loadError;
/**
* Width.
*
* @var integer
*/
protected $width;
/**
* Heigth.
*
* @var integer
*/
protected $height;
/**
* Grid Width.
*
* @var integer
*/
protected $gridWidth;
/**
* Cell ID.
*
* @var integer
*/
protected $cellId;
/**
* Construct.
*
* @param integer $cellId Cell ID.
* @param integer $dashboardId Dashboard ID.
* @param integer $widgetId Widget ID.
* @param integer|null $width New width.
* @param integer|null $height New height.
* @param integer|null $gridWidth Grid width.
*/
public function __construct(
int $cellId,
int $dashboardId=0,
int $widgetId=0,
?int $width=0,
?int $height=0,
?int $gridWidth=0
) {
global $config;
// WARNING: Do not edit. This chunk must be in the constructor.
parent::__construct(
$cellId,
$dashboardId,
$widgetId
);
// Width.
$this->width = $width;
// Height.
$this->height = $height;
// Grid Width.
$this->gridWidth = $gridWidth;
// Cell Id.
$this->cellId = $cellId;
// Options.
$this->values = $this->decoders($this->getOptionsWidget());
// Positions.
$this->position = $this->getPositionWidget();
// Page.
$this->page = basename(__FILE__);
// ClassName.
$class = new \ReflectionClass($this);
$this->className = $class->getShortName();
// Title.
$this->title = __('Color tabs modules');
// Name.
if (empty($this->name) === true) {
$this->name = 'single_graph';
}
// This forces at least a first configuration.
$this->configurationRequired = false;
if (empty($this->values['moduleColorModuleTabs']) === true) {
$this->configurationRequired = true;
}
$this->overflow_scrollbars = false;
}
/**
* Decoders hack for retrocompability.
*
* @param array $decoder Values.
*
* @return array Returns the values with the correct key.
*/
public function decoders(array $decoder): array
{
$values = [];
// Retrieve global - common inputs.
$values = parent::decoders($decoder);
$values['agentsColorModuleTabs'] = [];
if (isset($decoder['agentsColorModuleTabs']) === true) {
if (isset($decoder['agentsColorModuleTabs'][0]) === true
&& empty($decoder['agentsColorModuleTabs']) === false
) {
$values['agentsColorModuleTabs'] = explode(
',',
$decoder['agentsColorModuleTabs'][0]
);
}
}
if (isset($decoder['selectionColorModuleTabs']) === true) {
$values['selectionColorModuleTabs'] = $decoder['selectionColorModuleTabs'];
}
$values['moduleColorModuleTabs'] = [];
if (isset($decoder['moduleColorModuleTabs']) === true) {
if (empty($decoder['moduleColorModuleTabs']) === false) {
$values['moduleColorModuleTabs'] = $decoder['moduleColorModuleTabs'];
}
}
if (isset($decoder['formatData']) === true) {
$values['formatData'] = $decoder['formatData'];
}
$values['label'] = 'module';
if (isset($decoder['label']) === true) {
$values['label'] = $decoder['label'];
}
return $values;
}
/**
* Generates inputs for form (specific).
*
* @return array Of inputs.
*
* @throws Exception On error.
*/
public function getFormInputs(): array
{
$values = $this->values;
// Retrieve global - common inputs.
$inputs = parent::getFormInputs();
// Type Label.
$fields = [
'module' => __('Module'),
'agent' => __('Agent'),
'agent_module' => __('Agent / module'),
];
$inputs[] = [
'label' => __('Label'),
'arguments' => [
'type' => 'select',
'fields' => $fields,
'name' => 'label',
'selected' => $values['label'],
'return' => true,
],
];
$inputs[] = [
'arguments' => [
'type' => 'select_multiple_modules_filtered_select2',
'agent_values' => agents_get_agents_selected(0),
'agent_name' => 'agentsColorModuleTabs[]',
'agent_ids' => $values['agentsColorModuleTabs'],
'selectionModules' => $values['selectionColorModuleTabs'],
'selectionModulesNameId' => 'selectionColorModuleTabs',
'modules_ids' => $values['moduleColorModuleTabs'],
'modules_name' => 'moduleColorModuleTabs[]',
],
];
// Format Data.
$inputs[] = [
'label' => __('Format Data'),
'arguments' => [
'name' => 'formatData',
'id' => 'formatData',
'type' => 'switch',
'value' => $values['formatData'],
],
];
return $inputs;
}
/**
* Get Post for widget.
*
* @return array
*/
public function getPost():array
{
// Retrieve global - common inputs.
$values = parent::getPost();
$values['agentsColorModuleTabs'] = \get_parameter(
'agentsColorModuleTabs',
[]
);
$values['selectionColorModuleTabs'] = \get_parameter(
'selectionColorModuleTabs',
0
);
$values['moduleColorModuleTabs'] = \get_parameter(
'moduleColorModuleTabs'
);
$agColor = [];
if (isset($values['agentsColorModuleTabs'][0]) === true
&& empty($values['agentsColorModuleTabs'][0]) === false
) {
$agColor = explode(',', $values['agentsColorModuleTabs'][0]);
}
$agModule = [];
if (isset($values['moduleColorModuleTabs'][0]) === true
&& empty($values['moduleColorModuleTabs'][0]) === false
) {
$agModule = explode(',', $values['moduleColorModuleTabs'][0]);
}
$values['moduleColorModuleTabs'] = get_same_modules_all(
$agColor,
$agModule
);
$values['formatData'] = \get_parameter_switch('formatData', 0);
$values['label'] = \get_parameter('label', 'module');
return $values;
}
/**
* Draw widget.
*
* @return string;
*/
public function load()
{
global $config;
$size = parent::getSize();
$output = '';
if (is_metaconsole() === true) {
$modules_nodes = array_reduce(
$this->values['moduleColorModuleTabs'],
function ($carry, $item) {
$explode = explode('|', $item);
$carry[$explode[0]][] = $explode[1];
return $carry;
},
[]
);
$modules = [];
foreach ($modules_nodes as $n => $mod) {
try {
$node = new Node((int) $n);
$node->connect();
$node_mods = $this->getInfoModules($mod);
if (empty($node_mods) === false) {
foreach ($node_mods as $value) {
$value['id_node'] = $n;
$value['server_name'] = $node->toArray()['server_name'];
$modules[] = $value;
}
}
$node->disconnect();
} catch (\Exception $e) {
// Unexistent agent.
$node->disconnect();
}
}
} else {
$modules = $this->getInfoModules(
$this->values['moduleColorModuleTabs']
);
}
if ($modules !== false && empty($modules) === false) {
$output .= '<div class="container-tabs">';
foreach ($modules as $module) {
$output .= $this->drawTabs($module);
}
$output .= '</div>';
} else {
$output .= '<div class="container-center">';
$output .= \ui_print_info_message(
__('Not found modules'),
'',
true
);
$output .= '</div>';
}
return $output;
}
/**
* Get info modules.
*
* @param array $modules Modules.
*
* @return array Data.
*/
private function getInfoModules(array $modules): array
{
$where = sprintf(
'tagente_modulo.id_agente_modulo IN (%s)',
implode(',', $modules)
);
$sql = sprintf(
'SELECT tagente_modulo.id_agente_modulo AS `id`,
tagente_modulo.nombre AS `name`,
tagente_modulo.unit AS `unit`,
tagente_estado.datos AS `data`,
tagente_estado.timestamp AS `timestamp`,
tagente_estado.estado AS `status`,
tagente.alias
FROM tagente_modulo
LEFT JOIN tagente_estado
ON tagente_modulo.id_agente_modulo = tagente_estado.id_agente_modulo
LEFT JOIN tagente
ON tagente_modulo.id_agente = tagente.id_agente
WHERE %s',
$where
);
$modules = db_get_all_rows_sql($sql);
if ($modules === false) {
$modules = [];
}
return $modules;
}
/**
* Draw tab module.
*
* @param array $data Info module.
*
* @return string Output.
*/
private function drawTabs(array $data):string
{
global $config;
$background = modules_get_color_status($data['status'], true);
$color = modules_get_textcolor_status($data['status']);
$style = 'background-color:'.$background.'; color:'.$color.';';
$output = '<div class="widget-module-tabs" style="'.$style.'">';
$output .= '<span class="widget-module-tabs-title">';
if (is_metaconsole() === true) {
$output .= $data['server_name'];
$output .= '<br>';
}
$name = '';
switch ($this->values['label']) {
case 'agent':
$name = $data['alias'];
break;
case 'agent_module':
$name = $data['alias'].' / '.$data['name'];
break;
default:
case 'module':
$name = $data['name'];
break;
}
$output .= $name;
$output .= '</span>';
$output .= '<span class="widget-module-tabs-data">';
if ($data['data'] !== null && $data['data'] !== '') {
if (isset($this->values['formatData']) === true
&& (bool) $this->values['formatData'] === true
) {
$output .= format_for_graph(
$data['data'],
$config['graph_precision']
);
} else {
$output .= sla_truncate(
$data['data'],
$config['graph_precision']
);
}
} else {
$output .= '--';
}
$output .= '<span class="widget-module-tabs-unit">';
$output .= ' '.$data['unit'];
$output .= '</span>';
$output .= '</span>';
$output .= '</div>';
return $output;
}
/**
* Get description.
*
* @return string.
*/
public static function getDescription()
{
return __('Color tabs modules');
}
/**
* Get Name.
*
* @return string.
*/
public static function getName()
{
return 'ColorModuleTabs';
}
/**
* Get size Modal Configuration.
*
* @return array
*/
public function getSizeModalConfiguration(): array
{
$size = [
'width' => (is_metaconsole() === true) ? 700 : 600,
'height' => 610,
];
return $size;
}
}

View File

@ -615,6 +615,10 @@ class EventsListWidget extends Widget
$fields = $default_fields; $fields = $default_fields;
} }
if (empty($filter['search']) === false || empty($filter['user_comment']) === false) {
$fields[] = 'user_comment';
}
// Get column names. // Get column names.
$column_names = events_get_column_names($fields, true); $column_names = events_get_column_names($fields, true);

View File

@ -193,6 +193,10 @@ class GroupsStatusWidget extends Widget
$values['groupId'] = $decoder['groupId']; $values['groupId'] = $decoder['groupId'];
} }
if (isset($decoder['groupRecursion']) === true) {
$values['groupRecursion'] = $decoder['groupRecursion'];
}
return $values; return $values;
} }
@ -224,6 +228,16 @@ class GroupsStatusWidget extends Widget
], ],
]; ];
$inputs[] = [
'label' => __('Group recursion'),
'arguments' => [
'name' => 'groupRecursion',
'id' => 'groupRecursion',
'type' => 'switch',
'value' => $values['groupRecursion'],
],
];
return $inputs; return $inputs;
} }
@ -239,6 +253,7 @@ class GroupsStatusWidget extends Widget
$values = parent::getPost(); $values = parent::getPost();
$values['groupId'] = \get_parameter('groupId', 0); $values['groupId'] = \get_parameter('groupId', 0);
$values['groupRecursion'] = \get_parameter_switch('groupRecursion', 0);
return $values; return $values;
} }
@ -260,9 +275,12 @@ class GroupsStatusWidget extends Widget
$output = ''; $output = '';
$user_groups = \users_get_groups(false, 'AR', false); $stats = \reporting_get_group_stats_resume(
$this->values['groupId'],
$stats = \reporting_get_group_stats_resume($this->values['groupId'], 'AR', true); 'AR',
true,
(bool) $this->values['groupRecursion']
);
$data = '<div class="widget-groups-status"><span>'; $data = '<div class="widget-groups-status"><span>';
$data .= ui_print_group_icon( $data .= ui_print_group_icon(
@ -393,7 +411,7 @@ class GroupsStatusWidget extends Widget
$table->data[0][0] .= '</span>'; $table->data[0][0] .= '</span>';
$table->data[0][1] = '<span>'; $table->data[0][1] = '<span>';
$table->data[0][1] .= '<b>'; $table->data[0][1] .= '<b>';
$table->data[0][1] .= $stats['monitor_total']; $table->data[0][1] .= $stats['total_checks'];
$table->data[0][1] .= '</b>'; $table->data[0][1] .= '</b>';
$table->data[0][1] .= '</span>'; $table->data[0][1] .= '</span>';

View File

@ -1,10 +1,10 @@
<?php <?php
/** /**
* Widget URL Pandora FMS Console * Widget Simple graph Pandora FMS Console
* *
* @category Console Class * @category Console Class
* @package Pandora FMS * @package Pandora FMS
* @subpackage Widget URL * @subpackage Widget
* @version 1.0.0 * @version 1.0.0
* @license See below * @license See below
* *
@ -14,7 +14,7 @@
* |___| |___._|__|__|_____||_____|__| |___._| |___| |__|_|__|_______| * |___| |___._|__|__|_____||_____|__| |___._| |___| |__|_|__|_______|
* *
* ============================================================================ * ============================================================================
* Copyright (c) 2005-2021 Artica Soluciones Tecnologicas * Copyright (c) 2005-2022 Artica Soluciones Tecnologicas
* Please see http://pandorafms.org for full contribution list * Please see http://pandorafms.org for full contribution list
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * modify it under the terms of the GNU General Public License
@ -279,7 +279,6 @@ class SingleGraphWidget extends Widget
'label' => __('Module'), 'label' => __('Module'),
'arguments' => [ 'arguments' => [
'type' => 'autocomplete_module', 'type' => 'autocomplete_module',
'fields' => $fields,
'name' => 'moduleId', 'name' => 'moduleId',
'selected' => $values['moduleId'], 'selected' => $values['moduleId'],
'return' => true, 'return' => true,
@ -353,8 +352,8 @@ class SingleGraphWidget extends Widget
include_once $config['homedir'].'/include/functions_agents.php'; include_once $config['homedir'].'/include/functions_agents.php';
include_once $config['homedir'].'/include/functions_modules.php'; include_once $config['homedir'].'/include/functions_modules.php';
$module_name = \modules_get_agentmodule_name($id_module); $module_name = \modules_get_agentmodule_name($this->values['moduleId']);
$units_name = \modules_get_unit($id_module); $units_name = \modules_get_unit($this->values['moduleId']);
$trickHight = 10; $trickHight = 10;
if ($this->values['showLegend'] === 1) { if ($this->values['showLegend'] === 1) {

View File

@ -185,6 +185,7 @@ class TacticalWidget extends Widget
if (empty($this->values['statusMonitor']) === true if (empty($this->values['statusMonitor']) === true
&& empty($this->values['serverPerformance']) === true && empty($this->values['serverPerformance']) === true
&& empty($this->values['summary']) === true && empty($this->values['summary']) === true
&& empty($this->values['groupId']) === true
) { ) {
$this->configurationRequired = true; $this->configurationRequired = true;
} }
@ -226,6 +227,18 @@ class TacticalWidget extends Widget
$values['summary'] = $decoder['summary']; $values['summary'] = $decoder['summary'];
} }
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; return $values;
} }
@ -292,6 +305,43 @@ class TacticalWidget extends Widget
], ],
]; ];
// Groups.
$return_all_group = false;
// Restrict access to group.
$selected_groups = [];
if ($values['groupId']) {
$selected_groups = explode(',', $values['groupId'][0]);
if (users_can_manage_group_all('AR') === true
|| ($selected_groups[0] !== ''
&& in_array(0, $selected_groups) === true)
) {
// Return all group if user has permissions
// or it is a currently selected group.
$return_all_group = true;
}
} else {
if (users_can_manage_group_all('AR') === true) {
$return_all_group = true;
}
}
$inputs[] = [
'label' => __('Groups'),
'arguments' => [
'type' => 'select_groups',
'name' => 'groupId[]',
'returnAllGroup' => true,
'privilege' => 'AR',
'selected' => $selected_groups,
'return' => true,
'multiple' => true,
'returnAllGroup' => $return_all_group,
'required' => true,
],
];
return $inputs; return $inputs;
} }
@ -311,6 +361,7 @@ class TacticalWidget extends Widget
'serverPerformance' 'serverPerformance'
); );
$values['summary'] = \get_parameter_switch('summary'); $values['summary'] = \get_parameter_switch('summary');
$values['groupId'] = \get_parameter('groupId', []);
return $values; return $values;
} }
@ -327,7 +378,7 @@ class TacticalWidget extends Widget
$output = ''; $output = '';
$all_data = \tactical_status_modules_agents($config['id_user']); $all_data = \tactical_status_modules_agents($config['id_user'], false, 'AR', $this->values['groupId'][0]);
$data = []; $data = [];
@ -503,7 +554,7 @@ class TacticalWidget extends Widget
{ {
$size = [ $size = [
'width' => 450, 'width' => 450,
'height' => 370, 'height' => 515,
]; ];
return $size; return $size;

View File

@ -146,7 +146,7 @@ class Event extends Entity
* @param boolean $return_sql Return sql or execute it. * @param boolean $return_sql Return sql or execute it.
* @param string $having Having. * @param string $having Having.
* *
* @return array|string|false Found events or SQL query or error. * @return array Found events or SQL query or error.
* @throws \Exception On error. * @throws \Exception On error.
*/ */
public static function search( public static function search(
@ -160,7 +160,7 @@ class Event extends Entity
bool $return_sql=false, bool $return_sql=false,
string $having='' string $having=''
):array { ):array {
return \events_get_all( $result = \events_get_all(
$fields, $fields,
$filter, $filter,
$offset, $offset,
@ -171,6 +171,13 @@ class Event extends Entity
$return_sql, $return_sql,
$having $having
); );
// Always return an array.
if (empty($result) === true) {
$result = [];
}
return $result;
} }

View File

@ -573,6 +573,91 @@ div#main_pure {
margin: 0; margin: 0;
} }
form.modal-dashboard ul.wizard li label {
max-width: 30%;
}
form.modal-dashboard ul.wizard li.agents_select2,
form.modal-dashboard ul.wizard li.modules_select2 {
align-items: center;
justify-content: center;
}
form.modal-dashboard
ul.wizard
li.agents_select2
div.flex-row-center
div.flex-column,
form.modal-dashboard
ul.wizard
li.modules_select2
div.flex-row-center
div.flex-column {
flex: 0;
height: 45px;
}
.ui-dialog .ui-dialog-title {
top: -3px !important;
}
.select2-container--default
.select2-selection--multiple
.select2-selection__choice {
margin: 0px;
}
.container-tabs {
width: 100%;
height: calc(100% + 80px);
display: flex;
flex-direction: row;
justify-content: flex-start;
flex-wrap: wrap;
}
.widget-module-tabs {
flex: 1;
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
min-width: 100px;
min-height: 95px;
margin: 2px;
padding: 5px;
}
.widget-module-tabs-title {
word-break: break-word;
}
.widget-module-tabs-data {
font-size: 1.5em;
font-weight: bolder;
}
.widget-module-tabs-unit {
font-size: smaller;
font-style: italic;
}
.container-histograms {
min-width: 400px;
}
.table-container-histograms {
width: 100%;
}
.container-histograms .widget-histogram-chart {
height: 28px;
}
.container-histograms .widget-histogram-label {
padding-top: 10px;
text-align: initial;
}
.content-widget .dataTables_wrapper { .content-widget .dataTables_wrapper {
width: 98%; width: 98%;
margin-top: 5px; margin-top: 5px;
@ -591,3 +676,7 @@ div#main_pure {
margin-top: 0px !important; margin-top: 0px !important;
padding: 0.5em 1em 0em 0em !important; padding: 0.5em 1em 0em 0em !important;
} }
.select2-selection__rendered {
max-height: 75px !important;
}

View File

@ -159,10 +159,26 @@
fill: #cccccc; fill: #cccccc;
} }
.notinit_10,
.notinit_9,
.notinit_8,
.notinit { .notinit {
fill: #4a83f3; fill: #4a83f3;
} }
.notinit_7,
.notinit_6,
.notinit_5,
.notinit_4 {
fill: #6695f5;
}
.notinit_3,
.notinit_2,
.notinit_1 {
fill: #79a3f6;
}
.hover { .hover {
cursor: pointer; cursor: pointer;
} }

View File

@ -5625,12 +5625,12 @@ div#bullets_modules div {
} }
.agent_details_col_left { .agent_details_col_left {
width: 40%; width: 49%;
min-width: 300px; min-width: 450px;
} }
.agent_details_col_right { .agent_details_col_right {
width: 59%; width: 49%;
min-width: 480px; min-width: 450px;
} }
.agent_access_rate_events { .agent_access_rate_events {
@ -5641,14 +5641,15 @@ div#bullets_modules div {
} }
.white_table_graph#table_access_rate { .white_table_graph#table_access_rate {
flex: 1 1 auto; margin-left: 1px;
min-width: 450px; margin-right: 1px;
margin-right: 1%; width: 49%;
} }
.white_table_graph#table_events { .white_table_graph#table_events {
flex: 1 1 auto; margin-left: 1px;
min-width: 450px; margin-right: 1px;
width: 49%;
} }
@media screen and (max-width: 1150px) { @media screen and (max-width: 1150px) {
@ -5687,7 +5688,7 @@ div#status_pie {
justify-content: flex-end; justify-content: flex-end;
align-items: center; align-items: center;
border-bottom: 1px solid #e2e2e2; border-bottom: 1px solid #e2e2e2;
padding: 6px 20px; padding: 8px 20px;
} }
.agent_details_content { .agent_details_content {
@ -7501,6 +7502,11 @@ div.graph div.legend table {
align-items: center; align-items: center;
} }
.flex_justify {
display: flex;
justify-content: center;
}
.span_priority { .span_priority {
width: 20px; width: 20px;
height: 10px; height: 10px;
@ -9083,3 +9089,33 @@ div#err_msg_centralised {
margin-bottom: 4px !important; margin-bottom: 4px !important;
padding: 2px 5px !important; padding: 2px 5px !important;
} }
.dataTables_wrapper {
overflow: auto;
}
.dataTables_wrapper .dataTables_processing {
margin-top: -37px !important;
top: 50px !important;
padding-top: 0px !important;
height: 0px !important;
background: transparent !important;
}
.dataTables_wrapper .dataTables_processing .processing-datatables-inside {
display: flex;
flex-direction: row;
justify-content: center;
align-items: center;
height: 100%;
}
.dataTables_wrapper .dataTables_processing .processing-datatables-inside img {
margin-left: 20px;
}
.loading-search-datatables-button {
float: right;
margin-right: -110px;
margin-top: 13px;
}

View File

@ -0,0 +1,300 @@
/*
* Css Modal Sound events.
*/
#modal-sound {
display: flex;
flex-direction: column;
justify-content: space-between;
padding: 0px 20px !important;
}
#tabs-sound-modal {
margin-top: 20px;
}
.actions-sound-modal {
margin-bottom: 20px;
}
#tabs-sound-modal h3.console-configuration {
color: #000000;
font-size: 16px;
line-height: 19px;
text-align: left;
text-transform: none;
margin: 0px;
}
#tabs-sound-modal ul.tabs-sound-modal-options {
display: flex;
justify-content: flex-end;
background-color: transparent;
border: 0px;
border-bottom: 1px solid #eaeaea;
height: 45px;
}
#tabs-sound-modal ul.tabs-sound-modal-options li {
margin: 0px;
padding: 0px;
border: 0px;
background: transparent;
}
#tabs-sound-modal ul.tabs-sound-modal-options li.ui-tabs-active {
border-bottom: 2px solid #82b92e;
}
#tabs-sound-modal ul.wizard li label {
color: #95a3bf;
font-size: 13px;
line-height: 16px;
text-align: left;
}
#tabs-sound-modal ul.wizard li.interval-sounds,
#tabs-sound-modal ul.wizard li.test-sounds {
display: flex;
flex-direction: row;
justify-content: space-between;
align-items: center;
margin-top: 18px;
}
#tabs-sound-modal ul.wizard li.interval-sounds label,
#tabs-sound-modal ul.wizard li.test-sounds label {
flex: 0;
width: inherit;
position: absolute;
top: -12px;
left: 50%;
}
#tabs-sound-modal ul.wizard li.interval-sounds label:first-of-type,
#tabs-sound-modal ul.wizard li.test-sounds label:first-of-type {
left: 0;
}
#tabs-sound-modal ul.wizard li.interval-sounds .select2 {
width: 48% !important;
max-width: 100% !important;
}
#tabs-sound-modal ul.wizard li.test-sounds .select2 {
width: 70% !important;
max-width: 100% !important;
}
#tabs-sound-modal ul.wizard li.test-sounds input[type="button"] {
border: 1px solid #dddddd;
border-radius: 4px;
width: 131px;
height: 38px;
color: #95a3bf;
font-size: 14px;
padding: 0px;
padding-right: 40px;
}
#tabs-sound-modal button.upd,
input.upd {
background-image: url(../../images/sound_wave.png);
background-position: 90px 8px;
}
#tabs-sound-modal ul.wizard .select2 {
max-width: 100% !important;
}
#tabs-sound-modal .select2-selection {
border: 0px;
border-radius: 0px;
border-bottom: 1px solid #aaa;
}
#tabs-sound-modal .select2-container,
#tabs-sound-modal .select2-selection__rendered {
padding-left: 0px;
color: #555555;
font-size: 15px;
line-height: 25px;
text-align: left;
}
#tabs-sound-modal div h3.title-discovered-alerts {
margin: 0px;
color: #000000;
font-size: 16px;
line-height: 19px;
text-align: left;
text-transform: none;
margin-bottom: 10px;
}
#tabs-sound-modal div span.text-discovered-alerts {
color: #95a3bf;
font-size: 13px;
line-height: 16px;
text-align: center;
}
#tabs-sound-modal div .empty-discovered-alerts {
display: flex;
flex-direction: column;
justify-content: space-evenly;
align-items: center;
height: 250px;
}
#tabs-sound-modal div .elements-discovered-alerts {
overflow: auto;
max-height: 300px;
}
#tabs-sound-modal div .elements-discovered-alerts ul {
width: 99%;
}
#tabs-sound-modal div .elements-discovered-alerts ul li {
border: 1px solid #eaeaea;
height: 46px;
display: flex;
flex-direction: row;
justify-content: center;
align-items: center;
width: 100%;
color: #555555;
font-size: 12px;
line-height: 20px;
text-align: left;
}
#tabs-sound-modal div .elements-discovered-alerts ul li div.li-priority {
flex: 0;
padding: 10px;
}
#tabs-sound-modal
div
.elements-discovered-alerts
ul
li
div.li-priority
.mini-criticity {
border-radius: 5px;
width: 6px;
height: 30px;
}
#tabs-sound-modal div .elements-discovered-alerts ul li div.li-type {
flex: 0;
padding-right: 10px;
}
#tabs-sound-modal div .elements-discovered-alerts ul li div.li-time {
flex: 0 1 100px;
text-align: end;
padding-right: 10px;
}
#tabs-sound-modal div .elements-discovered-alerts ul li div.li-title {
width: 100%;
}
.actions-sound-modal .buttons-sound-modal {
display: flex;
flex-direction: row;
justify-content: space-between;
align-items: center;
}
.actions-sound-modal .buttons-sound-modal input[type="button"] {
border: 1px solid #dddddd;
border-radius: 4px;
width: 107px;
height: 50px;
font-size: 18px;
line-height: 24px;
text-align: left;
}
.actions-sound-modal .buttons-sound-modal button.play,
.actions-sound-modal .buttons-sound-modal input[type="button"].play {
background: url(../../images/play-white.png), transparent;
background-repeat: no-repeat;
background-position: 70px 17px;
color: #ffffff;
padding-left: 20px;
}
.actions-sound-modal .buttons-sound-modal button.stop,
.actions-sound-modal .buttons-sound-modal input[type="button"].stop {
background: url(../../images/stop.png), transparent;
background-repeat: no-repeat;
background-position: 70px 17px;
color: #ffffff;
padding-left: 20px;
}
.actions-sound-modal .buttons-sound-modal button.alerts,
.actions-sound-modal .buttons-sound-modal input[type="button"].alerts {
width: 154px;
color: #95a3bf;
background: url(../../images/alarm-off.png), transparent;
background-repeat: no-repeat;
background-position: 108px 9px;
padding-left: 20px;
}
.actions-sound-modal .buttons-sound-modal button.silence-alerts,
.actions-sound-modal .buttons-sound-modal input[type="button"].silence-alerts {
width: 184px;
color: #ffffff;
background: url(../../images/silence-alerts.png), transparent;
background-repeat: no-repeat;
background-position: 138px 9px;
padding-left: 20px;
}
.actions-sound-modal .container-button-play {
background: radial-gradient(118.26% 33.15%, #82b92e 0%, #1d4e4a 100%);
border-radius: 4px;
}
.actions-sound-modal .container-button-alert.fired {
background: #ee2132;
border-radius: 4px;
}
.actions-sound-modal .progressbar {
width: 100%;
margin: 4px 2px;
border-radius: 4px;
}
.actions-sound-modal .progressbar .inner {
height: 10px;
border-radius: 4px;
animation: progressbar-countdown;
/* Placeholder, this will be updated using javascript */
animation-duration: 40s;
/* We stop in the end */
animation-iteration-count: 1;
/* Stay on pause when the animation is finished finished */
animation-fill-mode: forwards;
/* We start paused, we start the animation using javascript */
animation-play-state: paused;
/* We want a linear animation, ease-out is standard */
animation-timing-function: linear;
}
@keyframes progressbar-countdown {
0% {
width: 100%;
background: #82b92e;
}
100% {
width: 0%;
background: #e63c52;
}
}

View File

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

Some files were not shown because too many files have changed in this diff Show More