2010-03-23 18:46:08 +01:00
|
|
|
<?php
|
|
|
|
// Pandora FMS - http://pandorafms.com
|
|
|
|
// ==================================================
|
|
|
|
// Copyright (c) 2005-2009 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.
|
|
|
|
// Login check
|
|
|
|
global $config;
|
|
|
|
|
2018-12-11 19:14:14 +01:00
|
|
|
check_login();
|
2015-06-16 17:44:15 +02:00
|
|
|
|
2015-05-04 21:18:38 +02:00
|
|
|
$get_image_path_status = get_parameter('get_image_path_status', 0);
|
2019-01-30 16:18:44 +01:00
|
|
|
if ($get_image_path_status) {
|
|
|
|
$img_src = get_parameter('img_src');
|
|
|
|
$only_src = get_parameter('only_src', 0);
|
|
|
|
|
|
|
|
$result = [];
|
|
|
|
|
|
|
|
$result['bad'] = html_print_image($img_src.'_bad.png', true, '', $only_src);
|
|
|
|
$result['ok'] = html_print_image($img_src.'_ok.png', true, '', $only_src);
|
|
|
|
$result['warning'] = html_print_image($img_src.'_warning.png', true, '', $only_src);
|
|
|
|
$result['normal'] = html_print_image($img_src.'.png', true, '', $only_src);
|
|
|
|
|
|
|
|
echo json_encode($result);
|
|
|
|
return;
|
2015-05-04 21:18:38 +02:00
|
|
|
}
|
|
|
|
|
2015-04-09 14:00:37 +02:00
|
|
|
$id_visual_console = get_parameter('id_visual_console', null);
|
|
|
|
|
|
|
|
// WARNING: CHECK THE ENTIRE FUNCTIONALITY
|
|
|
|
// Visual console id required
|
|
|
|
if (empty($id_visual_console)) {
|
2019-01-30 16:18:44 +01:00
|
|
|
db_pandora_audit(
|
|
|
|
'ACL Violation',
|
|
|
|
'Trying to access report builder'
|
|
|
|
);
|
|
|
|
include 'general/noaccess.php';
|
|
|
|
exit;
|
2015-04-09 14:00:37 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// Get the group id for the ACL checks
|
|
|
|
$group_id = db_get_value('id_group', 'tlayout', 'id', $id_visual_console);
|
|
|
|
if ($group_id === false) {
|
2019-01-30 16:18:44 +01:00
|
|
|
db_pandora_audit(
|
|
|
|
'ACL Violation',
|
|
|
|
'Trying to access report builder'
|
|
|
|
);
|
|
|
|
include 'general/noaccess.php';
|
|
|
|
exit;
|
2010-03-23 18:46:08 +01:00
|
|
|
}
|
|
|
|
|
2015-04-09 14:00:37 +02:00
|
|
|
// ACL for the existing visual console
|
|
|
|
// if (!isset($vconsole_read))
|
2019-01-30 16:18:44 +01:00
|
|
|
// $vconsole_read = check_acl ($config['id_user'], $group_id, "VR");
|
|
|
|
if (!isset($vconsole_write)) {
|
|
|
|
$vconsole_write = check_acl($config['id_user'], $group_id, 'VW');
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!isset($vconsole_manage)) {
|
|
|
|
$vconsole_manage = check_acl($config['id_user'], $group_id, 'VM');
|
|
|
|
}
|
2015-04-09 14:00:37 +02:00
|
|
|
|
|
|
|
if (!$vconsole_write && !$vconsole_manage) {
|
2019-01-30 16:18:44 +01:00
|
|
|
db_pandora_audit(
|
|
|
|
'ACL Violation',
|
|
|
|
'Trying to access report builder'
|
|
|
|
);
|
|
|
|
include 'general/noaccess.php';
|
|
|
|
exit;
|
2015-04-09 14:00:37 +02:00
|
|
|
}
|
2012-07-03 Miguel de Dios <miguel.dedios@artica.es>
* ajax.php: added support for the enterprise, because some case
this file can't call enterprise functions.
* godmode/reporting/visual_console_builder.wizard.php,
godmode/reporting/visual_console_builder.php,
godmode/reporting/visual_console_builder.editor.js,
godmode/reporting/visual_console_builder.elements.php,
godmode/reporting/visual_console_builder.editor.php,
godmode/reporting/visual_console_builder.constans.php (delete),
include/functions_visual_map_editor.php,
include/ajax/visual_console_builder.ajax.php,
include/functions_visual_map.php: some parts of code had been
refactored because it is necesary for to add enterprise feature to
Visual map.
* include/constants.php: cleaned source code style and added and
reordened the constants for visual maps.
* include/functions_html.php, include/styles/pandora.css,
include/functions_ui.php, include/functions.php, index.php: cleaned
source code style.
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@6732 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2012-07-03 17:39:37 +02:00
|
|
|
|
2019-01-30 16:18:44 +01:00
|
|
|
// Fix ajax to avoid include the file, 'functions_graph.php'.
|
2011-05-06 09:12:58 +02:00
|
|
|
$ajax = true;
|
|
|
|
|
2019-01-30 16:18:44 +01:00
|
|
|
require_once $config['homedir'].'/include/functions_visual_map.php';
|
|
|
|
require_once $config['homedir'].'/include/functions_agents.php';
|
|
|
|
require_once $config['homedir'].'/include/functions_graph.php';
|
|
|
|
require_once $config['homedir'].'/include/functions_custom_graphs.php';
|
2012-07-03 Miguel de Dios <miguel.dedios@artica.es>
* ajax.php: added support for the enterprise, because some case
this file can't call enterprise functions.
* godmode/reporting/visual_console_builder.wizard.php,
godmode/reporting/visual_console_builder.php,
godmode/reporting/visual_console_builder.editor.js,
godmode/reporting/visual_console_builder.elements.php,
godmode/reporting/visual_console_builder.editor.php,
godmode/reporting/visual_console_builder.constans.php (delete),
include/functions_visual_map_editor.php,
include/ajax/visual_console_builder.ajax.php,
include/functions_visual_map.php: some parts of code had been
refactored because it is necesary for to add enterprise feature to
Visual map.
* include/constants.php: cleaned source code style and added and
reordened the constants for visual maps.
* include/functions_html.php, include/styles/pandora.css,
include/functions_ui.php, include/functions.php, index.php: cleaned
source code style.
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@6732 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2012-07-03 17:39:37 +02:00
|
|
|
enterprise_include_once('include/functions_visual_map.php');
|
2010-03-23 18:46:08 +01:00
|
|
|
|
|
|
|
$action = get_parameter('action');
|
|
|
|
$type = get_parameter('type');
|
2010-03-31 11:13:54 +02:00
|
|
|
|
2010-03-23 18:46:08 +01:00
|
|
|
$id_element = get_parameter('id_element', null);
|
2010-03-31 11:13:54 +02:00
|
|
|
|
2010-03-23 18:46:08 +01:00
|
|
|
$image = get_parameter('image', null);
|
|
|
|
$background = get_parameter('background', null);
|
2014-06-13 09:53:50 +02:00
|
|
|
$background_color = get_parameter('background_color', null);
|
2011-02-16 14:26:28 +01:00
|
|
|
$label = get_parameter('label', '');
|
2010-03-23 18:46:08 +01:00
|
|
|
$left = get_parameter('left', null);
|
|
|
|
$top = get_parameter('top', null);
|
|
|
|
$agent = get_parameter('agent', null);
|
2010-03-29 15:58:08 +02:00
|
|
|
$id_module = get_parameter('module', null);
|
2015-10-01 13:42:37 +02:00
|
|
|
$period = get_parameter('period', null);
|
2017-07-12 13:34:20 +02:00
|
|
|
$event_max_time_row = get_parameter('event_max_time_row', null);
|
2010-03-23 18:46:08 +01:00
|
|
|
$width = get_parameter('width', null);
|
|
|
|
$height = get_parameter('height', null);
|
|
|
|
$parent = get_parameter('parent', null);
|
|
|
|
$map_linked = get_parameter('map_linked', null);
|
2018-09-10 11:25:44 +02:00
|
|
|
$linked_map_node_id = get_parameter('linked_map_node_id', null);
|
2018-09-18 15:44:55 +02:00
|
|
|
$linked_map_status_calculation_type = get_parameter('linked_map_status_calculation_type', null);
|
2018-09-04 17:23:42 +02:00
|
|
|
|
2017-11-08 12:49:03 +01:00
|
|
|
$map_linked_weight = get_parameter('map_linked_weight', null);
|
2018-09-04 17:23:42 +02:00
|
|
|
if ($map_linked_weight !== null) {
|
2019-01-30 16:18:44 +01:00
|
|
|
$map_linked_weight = (int) $map_linked_weight;
|
2018-09-04 17:23:42 +02:00
|
|
|
}
|
2019-01-30 16:18:44 +01:00
|
|
|
|
2018-09-04 17:23:42 +02:00
|
|
|
$linked_map_status_service_critical = get_parameter('linked_map_status_service_critical', null);
|
|
|
|
if ($linked_map_status_service_critical !== null) {
|
2019-01-30 16:18:44 +01:00
|
|
|
$linked_map_status_service_critical = (float) $linked_map_status_service_critical;
|
2018-09-04 17:23:42 +02:00
|
|
|
}
|
2019-01-30 16:18:44 +01:00
|
|
|
|
2018-09-04 17:23:42 +02:00
|
|
|
$linked_map_status_service_warning = get_parameter('linked_map_status_service_warning', null);
|
|
|
|
if ($linked_map_status_service_warning !== null) {
|
2019-01-30 16:18:44 +01:00
|
|
|
$linked_map_status_service_warning = (float) $linked_map_status_service_warning;
|
2018-09-04 17:23:42 +02:00
|
|
|
}
|
|
|
|
|
2017-11-08 15:01:44 +01:00
|
|
|
$element_group = get_parameter('element_group', null);
|
2017-12-01 12:14:56 +01:00
|
|
|
$width_percentile = get_parameter('width_percentile', 0);
|
2017-11-14 08:50:12 +01:00
|
|
|
$bars_graph_height = get_parameter('bars_graph_height', null);
|
2010-03-29 15:58:08 +02:00
|
|
|
$max_percentile = get_parameter('max_percentile', null);
|
2010-03-29 20:31:22 +02:00
|
|
|
$height_module_graph = get_parameter('height_module_graph', null);
|
|
|
|
$width_module_graph = get_parameter('width_module_graph', null);
|
2017-10-26 16:13:27 +02:00
|
|
|
$bars_graph_type = get_parameter('bars_graph_type', null);
|
2011-04-13 17:11:51 +02:00
|
|
|
$id_agent_module = get_parameter('id_agent_module', 0);
|
2012-06-11 21:13:20 +02:00
|
|
|
$process_simple_value = get_parameter('process_simple_value', PROCESS_VALUE_NONE);
|
2012-03-05 Miguel de Dios <miguel.dedios@artica.es>
* extensions/update_manager/main.php, general/shortcut_bar.php,
godmode/reporting/reporting_builder.item_editor.php,
godmode/reporting/reporting_builder.php,
godmode/reporting/reporting_builder.preview.php, include/functions_api.php,
include/functions_html.php, include/htmlawed.php, include/pchart_graph.php,
operation/events/events_list.php, operation/netflow/nf_live_view.php:
cleaned source code style.
* godmode/menu.php, godmode/agentes/manage_config_remote.php: removed the
enterprise feature that have been wrong for years.
* general/header.php: changed to load the jquery-ui and jquery javascript
library to last version.
* extensions/insert_data.php, extensions/snmp_explorer.php,
godmode/agentes/agent_manager.php, include/ajax/agent.php,
include/javascript/pandora.js, operation/agentes/exportdata.php,
operation/events/events.php: changed the unknow plugin autocomplete for
the autocomple from jquery-ui.
* include/functions_ui.php: cleaned source code style and into the function
"ui_process_page_head" added the blacklist hardwrote for to use old jquery.
* include/styles/jquery-ui-1.8.17.custom.css,
include/javascript/jquery-1.7.1.min.js,
include/javascript/jquery.jquery-ui-1.8.17.custom.min.js: added the last
version of Jquery and Jquery-ui.
Merge from the branch "pandora_4.0"
* godmode/reporting/visual_console_builder.constans.php,
godmode/reporting/visual_console_builder.editor.js,
godmode/reporting/visual_console_builder.editor.php,
include/functions_visual_map.php,
include/ajax/visual_console_builder.ajax.php,
include/javascript/pandora_visual_console.js: changed the unknow
plugin autocomplete for the autocomple from jquery-ui and added function to
paint a Bubble Chart (http://en.wikipedia.org/wiki/Bubble_chart) with the
name "progress_bubble".
* images/percentile_item.disabled.png, images/percentile_item.png: added
images for button of percentile item (new item in visual map).
* include/styles/pandora.css: added the style for the new button percentile
item.
* include/functions_graph.php, include/graphs/fgraph.php,
include/graphs/functions_gd.php: cleaned source code style, and added the
params to set text and color in the function "progress_bar" and added
function to paint a Bubble Chart (http://en.wikipedia.org/wiki/Bubble_chart)
with the name "progress_bubble".
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@5693 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2012-03-05 18:56:56 +01:00
|
|
|
$type_percentile = get_parameter('type_percentile', 'percentile');
|
|
|
|
$value_show = get_parameter('value_show', 'percent');
|
2012-12-11 Miguel de Dios <miguel.dedios@artica.es>
* extras/pandoradb_migrate_4.0.x_to_5.0.mysql.sql,
extras/pandoradb_migrate_4.0.x_to_5.0.oracle.sql,
extras/pandoradb_migrate_4.0.x_to_5.0.postgreSQL.sql, pandoradb.sql,
pandoradb.postgreSQL.sql, pandoradb.oracle.sql: in the table
"tlayout_data" added the column "id_metaconsole" for to show
visualmaps in the metaconsole.
* operation/visual_console/render_view.php,
include/functions_visual_map.php, operation/agentes/ver_agente.php,
godmode/reporting/visual_console_builder.wizard.php,
godmode/reporting/visual_console_builder.php,
godmode/reporting/visual_console_builder.data.php,
godmode/reporting/visual_console_builder.editor.js,
godmode/reporting/visual_console_builder.elements.php,
godmode/reporting/visual_console_builder.editor.php,
godmode/reporting/map_builder.php,
include/ajax/visual_console_builder.ajax.php,
include/ajax/agent.php, include/functions_visual_map_editor.php,
* operation/agentes/datos_agente.php,
include/functions_netflow.php: cleaned source code style.
* include/functions_ui.php: in function
"ui_require_javascript_file_enterprise" fixed when need a
enterprise javascript instead metaconsole enterprise path.
* include/javascript/pandora.js: fixed the function
"agent_changed_by_multiple_agents" that needs in the metaconsole.
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@7258 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2012-12-11 16:01:45 +01:00
|
|
|
$metaconsole = get_parameter('metaconsole', 0);
|
|
|
|
$server_name = get_parameter('server_name', null);
|
2019-01-30 16:18:44 +01:00
|
|
|
$server_id = (int) get_parameter('server_id', 0);
|
2012-12-11 Miguel de Dios <miguel.dedios@artica.es>
* extras/pandoradb_migrate_4.0.x_to_5.0.mysql.sql,
extras/pandoradb_migrate_4.0.x_to_5.0.oracle.sql,
extras/pandoradb_migrate_4.0.x_to_5.0.postgreSQL.sql, pandoradb.sql,
pandoradb.postgreSQL.sql, pandoradb.oracle.sql: in the table
"tlayout_data" added the column "id_metaconsole" for to show
visualmaps in the metaconsole.
* operation/visual_console/render_view.php,
include/functions_visual_map.php, operation/agentes/ver_agente.php,
godmode/reporting/visual_console_builder.wizard.php,
godmode/reporting/visual_console_builder.php,
godmode/reporting/visual_console_builder.data.php,
godmode/reporting/visual_console_builder.editor.js,
godmode/reporting/visual_console_builder.elements.php,
godmode/reporting/visual_console_builder.editor.php,
godmode/reporting/map_builder.php,
include/ajax/visual_console_builder.ajax.php,
include/ajax/agent.php, include/functions_visual_map_editor.php,
* operation/agentes/datos_agente.php,
include/functions_netflow.php: cleaned source code style.
* include/functions_ui.php: in function
"ui_require_javascript_file_enterprise" fixed when need a
enterprise javascript instead metaconsole enterprise path.
* include/javascript/pandora.js: fixed the function
"agent_changed_by_multiple_agents" that needs in the metaconsole.
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@7258 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2012-12-11 16:01:45 +01:00
|
|
|
$id_agent = get_parameter('id_agent', null);
|
2017-11-10 15:03:52 +01:00
|
|
|
$id_agent_string = get_parameter('id_agent_string', null);
|
2012-12-11 Miguel de Dios <miguel.dedios@artica.es>
* extras/pandoradb_migrate_4.0.x_to_5.0.mysql.sql,
extras/pandoradb_migrate_4.0.x_to_5.0.oracle.sql,
extras/pandoradb_migrate_4.0.x_to_5.0.postgreSQL.sql, pandoradb.sql,
pandoradb.postgreSQL.sql, pandoradb.oracle.sql: in the table
"tlayout_data" added the column "id_metaconsole" for to show
visualmaps in the metaconsole.
* operation/visual_console/render_view.php,
include/functions_visual_map.php, operation/agentes/ver_agente.php,
godmode/reporting/visual_console_builder.wizard.php,
godmode/reporting/visual_console_builder.php,
godmode/reporting/visual_console_builder.data.php,
godmode/reporting/visual_console_builder.editor.js,
godmode/reporting/visual_console_builder.elements.php,
godmode/reporting/visual_console_builder.editor.php,
godmode/reporting/map_builder.php,
include/ajax/visual_console_builder.ajax.php,
include/ajax/agent.php, include/functions_visual_map_editor.php,
* operation/agentes/datos_agente.php,
include/functions_netflow.php: cleaned source code style.
* include/functions_ui.php: in function
"ui_require_javascript_file_enterprise" fixed when need a
enterprise javascript instead metaconsole enterprise path.
* include/javascript/pandora.js: fixed the function
"agent_changed_by_multiple_agents" that needs in the metaconsole.
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@7258 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2012-12-11 16:01:45 +01:00
|
|
|
$id_metaconsole = get_parameter('id_metaconsole', null);
|
2019-01-30 16:18:44 +01:00
|
|
|
$id_group = (int) get_parameter('id_group', 0);
|
2014-05-27 Miguel de Dios <miguel.dedios@artica.es>
* extras/pandoradb_migrate_5.0.x_to_5.1.postgreSQL.sql,
extras/pandoradb_migrate_5.0.x_to_5.1.oracle.sql,
extras/pandoradb_migrate_5.0.x_to_5.1.mysql.sql,
godmode/reporting/visual_console_builder.editor.js,
include/functions_custom_graphs.php,
include/ajax/visual_console_builder.ajax.php,
include/functions_graph.php, include/functions_visual_map.php,
include/functions_visual_map_editor.php, pandoradb.sql,
pandoradb.postgreSQL.sql, pandoradb.oracle.sql,
operation/reporting/graph_viewer.php, pandoradb_data.sql: added the
custom graphs into the visualmaps.
Incident: #367
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@10018 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2014-05-27 14:59:56 +02:00
|
|
|
$id_custom_graph = get_parameter('id_custom_graph', null);
|
2019-01-30 16:18:44 +01:00
|
|
|
$border_width = (int) get_parameter('border_width', 0);
|
2014-11-21 10:42:14 +01:00
|
|
|
$border_color = get_parameter('border_color', '');
|
2017-11-08 09:55:36 +01:00
|
|
|
$grid_color = get_parameter('grid_color', '');
|
2017-11-08 10:21:09 +01:00
|
|
|
$resume_color = get_parameter('resume_color', '');
|
2014-11-21 10:42:14 +01:00
|
|
|
$fill_color = get_parameter('fill_color', '');
|
2017-10-05 13:10:19 +02:00
|
|
|
$percentile_color = get_parameter('percentile_color', '');
|
2017-11-06 08:35:42 +01:00
|
|
|
$percentile_label = io_safe_output(get_parameter('percentile_label', ''));
|
2017-10-06 14:04:20 +02:00
|
|
|
$percentile_label_color = get_parameter('percentile_label_color', '');
|
2019-01-30 16:18:44 +01:00
|
|
|
$width_box = (int) get_parameter('width_box', 0);
|
|
|
|
$height_box = (int) get_parameter('height_box', 0);
|
|
|
|
$line_start_x = (int) get_parameter('line_start_x', 0);
|
|
|
|
$line_start_y = (int) get_parameter('line_start_y', 0);
|
|
|
|
$line_end_x = (int) get_parameter('line_end_x', 0);
|
|
|
|
$line_end_y = (int) get_parameter('line_end_y', 0);
|
|
|
|
$line_width = (int) get_parameter('line_width', 0);
|
2014-11-24 16:40:59 +01:00
|
|
|
$line_color = get_parameter('line_color', '');
|
2010-03-23 18:46:08 +01:00
|
|
|
|
2011-02-28 12:23:12 +01:00
|
|
|
$get_element_status = get_parameter('get_element_status', 0);
|
|
|
|
|
2012-08-21 10:52:44 +02:00
|
|
|
$enable_link = get_parameter('enable_link', 1);
|
2017-10-23 18:54:57 +02:00
|
|
|
$show_on_top = get_parameter('show_on_top', 0);
|
2016-11-16 18:58:27 +01:00
|
|
|
$type_graph = get_parameter('type_graph', 'area');
|
2017-01-16 13:31:56 +01:00
|
|
|
$label_position = get_parameter('label_position', 'down');
|
2017-08-31 15:09:04 +02:00
|
|
|
$show_statistics = get_parameter('show_statistics', 0);
|
2012-08-21 10:52:44 +02:00
|
|
|
|
2017-12-01 12:14:56 +01:00
|
|
|
$clock_animation = get_parameter('clock_animation', 'analogic_1');
|
|
|
|
$time_format = get_parameter('time_format', 'time');
|
|
|
|
$timezone = get_parameter('timezone', 'Europe/Madrid');
|
|
|
|
|
2018-09-26 11:00:44 +02:00
|
|
|
$show_last_value = get_parameter('show_last_value', null);
|
|
|
|
|
2019-01-30 16:18:44 +01:00
|
|
|
$diameter = (int) get_parameter('diameter', $width);
|
|
|
|
$default_color = get_parameter('default_color', '#FFFFFF');
|
|
|
|
$color_range_from_values = get_parameter('color_range_from_values', []);
|
|
|
|
$color_range_to_values = get_parameter('color_range_to_values', []);
|
|
|
|
$color_range_colors = get_parameter('color_range_colors', []);
|
2019-05-28 18:34:07 +02:00
|
|
|
$cache_expiration = (int) get_parameter('cache_expiration');
|
2018-12-11 19:14:14 +01:00
|
|
|
|
2010-03-23 18:46:08 +01:00
|
|
|
switch ($action) {
|
2019-01-30 16:18:44 +01:00
|
|
|
case 'get_font':
|
|
|
|
$return = [];
|
|
|
|
$return['font'] = $config['fontpath'];
|
|
|
|
echo json_encode($return);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 'get_image_from_module':
|
|
|
|
$layoutData = db_get_row_filter('tlayout_data', ['id' => $id_element]);
|
|
|
|
$sql = 'SELECT datos FROM tagente_estado WHERE id_agente_modulo = '.$layoutData['id_agente_modulo'];
|
|
|
|
ob_clean();
|
|
|
|
$result = db_get_sql($sql);
|
|
|
|
$image = strpos($result, 'data:image');
|
|
|
|
|
|
|
|
if ($image === false) {
|
|
|
|
$return['correct'] = false;
|
|
|
|
} else {
|
|
|
|
$return['correct'] = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
echo json_encode($return);
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 'get_module_type_string':
|
|
|
|
$data = [];
|
|
|
|
|
|
|
|
$layoutData = db_get_row_filter('tlayout_data', ['id' => $id_element]);
|
|
|
|
|
|
|
|
if ($layoutData['id_metaconsole'] != 0) {
|
|
|
|
$connection = db_get_row_filter('tmetaconsole_setup', $layoutData['id_metaconsole']);
|
|
|
|
|
|
|
|
if (metaconsole_load_external_db($connection) != NOERR) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
$is_string = db_get_value_filter(
|
|
|
|
'id_tipo_modulo',
|
|
|
|
'tagente_modulo',
|
|
|
|
[
|
|
|
|
'id_agente' => $id_agent,
|
|
|
|
'id_agente_modulo' => $id_module,
|
|
|
|
]
|
|
|
|
);
|
|
|
|
|
|
|
|
if ($layoutData['id_metaconsole'] != 0) {
|
|
|
|
metaconsole_restore_db();
|
|
|
|
}
|
|
|
|
|
|
|
|
$return = [];
|
|
|
|
if (($is_string == 17) || ($is_string == 23) || ($is_string == 3)
|
|
|
|
|| ($is_string == 10) || ($is_string == 33)
|
|
|
|
) {
|
|
|
|
$return['no_data'] = false;
|
|
|
|
} else {
|
|
|
|
$return['no_data'] = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
echo json_encode($return);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 'get_module_events':
|
|
|
|
$data = [];
|
|
|
|
|
|
|
|
$date = get_system_time();
|
|
|
|
$datelimit = ($date - $event_max_time_row);
|
|
|
|
|
|
|
|
$events = db_get_row_filter(
|
|
|
|
'tevento',
|
|
|
|
['id_agente' => $id_agent,
|
|
|
|
'id_agentmodule' => $id_module,
|
|
|
|
'utimestamp > '.$datelimit,
|
|
|
|
'utimestamp < '.$date
|
|
|
|
],
|
|
|
|
'criticity, utimestamp'
|
|
|
|
);
|
|
|
|
|
|
|
|
$return = [];
|
|
|
|
if (!$events) {
|
|
|
|
$return['no_data'] = true;
|
|
|
|
if (!empty($id_metaconsole)) {
|
|
|
|
$connection = db_get_row_filter(
|
|
|
|
'tmetaconsole_setup',
|
|
|
|
$id_metaconsole
|
|
|
|
);
|
|
|
|
if (metaconsole_load_external_db($connection) != NOERR) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
$return['url'] = true;
|
|
|
|
if (!empty($id_metaconsole)) {
|
|
|
|
metaconsole_restore_db();
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
$return['no_data'] = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
echo json_encode($return);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 'get_image_sparse':
|
|
|
|
// Metaconsole db connection
|
|
|
|
if (!empty($id_metaconsole)) {
|
|
|
|
$connection = db_get_row_filter(
|
|
|
|
'tmetaconsole_setup',
|
|
|
|
$id_metaconsole
|
|
|
|
);
|
|
|
|
if (metaconsole_load_external_db($connection) != NOERR) {
|
|
|
|
// ui_print_error_message ("Error connecting to ".$server_name);
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
$params = [
|
|
|
|
'period' => $period,
|
|
|
|
'width' => $width,
|
|
|
|
'height' => $height,
|
|
|
|
'vconsole' => true,
|
|
|
|
'backgroundColor' => $background_color,
|
|
|
|
];
|
|
|
|
|
|
|
|
$params_combined = ['id_graph' => $id_custom_graph];
|
|
|
|
|
|
|
|
if ($id_custom_graph != 0) {
|
|
|
|
$img = graphic_combined_module(
|
|
|
|
false,
|
|
|
|
$params,
|
|
|
|
$params_combined
|
|
|
|
);
|
|
|
|
} else {
|
|
|
|
$params = [
|
|
|
|
'agent_module_id' => $id_agent_module,
|
|
|
|
'period' => $period,
|
|
|
|
'show_events' => false,
|
|
|
|
'width' => $width,
|
|
|
|
'height' => $height,
|
|
|
|
'menu' => false,
|
|
|
|
'backgroundColor' => $background_color,
|
|
|
|
'vconsole' => true,
|
|
|
|
'type_graph' => $config['type_module_charts'],
|
|
|
|
];
|
|
|
|
$img = grafico_modulo_sparse($params);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Restore db connection
|
|
|
|
if (!empty($id_metaconsole)) {
|
|
|
|
metaconsole_restore_db();
|
|
|
|
}
|
|
|
|
|
|
|
|
$data_image = [];
|
|
|
|
preg_match("/src=[\'\"](.*)[\'\"]/", $img, $matches);
|
|
|
|
$url = $matches[1];
|
|
|
|
|
|
|
|
if (empty($url) && ($type == 'module_graph')) {
|
|
|
|
$data_image['url'] = $img;
|
|
|
|
$data_image['no_data'] = true;
|
|
|
|
$data_image['message'] = __('No data to show');
|
|
|
|
} else {
|
|
|
|
$data_image['url'] = $matches[1];
|
|
|
|
$data_image['no_data'] = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
echo json_encode($data_image);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 'get_layout_data':
|
|
|
|
if (is_metaconsole()) {
|
|
|
|
$server_data = metaconsole_get_connection_by_id($server_id);
|
|
|
|
// Establishes connection
|
|
|
|
if (metaconsole_load_external_db($server_data) !== NOERR) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
$layoutData = db_get_row_filter(
|
|
|
|
'tlayout_data',
|
|
|
|
['id' => $id_element]
|
|
|
|
);
|
|
|
|
|
|
|
|
if (is_metaconsole()) {
|
|
|
|
metaconsole_restore_db();
|
|
|
|
}
|
|
|
|
|
|
|
|
$layoutData['height'] = $layoutData['height'];
|
|
|
|
$layoutData['width'] = $layoutData['width'];
|
|
|
|
echo json_encode($layoutData);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 'get_module_value':
|
|
|
|
global $config;
|
|
|
|
|
|
|
|
$unit_text = false;
|
|
|
|
$layoutData = db_get_row_filter('tlayout_data', ['id' => $id_element]);
|
|
|
|
switch ($layoutData['type']) {
|
|
|
|
case SIMPLE_VALUE:
|
|
|
|
case SIMPLE_VALUE_MAX:
|
|
|
|
case SIMPLE_VALUE_MIN:
|
|
|
|
case SIMPLE_VALUE_AVG:
|
|
|
|
$type = visual_map_get_simple_value_type($process_simple_value);
|
|
|
|
|
|
|
|
|
|
|
|
// Metaconsole db connection
|
|
|
|
if ($layoutData['id_metaconsole'] != 0) {
|
|
|
|
$connection = db_get_row_filter(
|
|
|
|
'tmetaconsole_setup',
|
|
|
|
['id' => $layoutData['id_metaconsole']]
|
|
|
|
);
|
|
|
|
if (metaconsole_load_external_db($connection) != NOERR) {
|
|
|
|
// ui_print_error_message ("Error connecting to ".$server_name);
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
$returnValue = visual_map_get_simple_value(
|
|
|
|
$type,
|
|
|
|
$layoutData['id_agente_modulo'],
|
|
|
|
$period
|
|
|
|
);
|
|
|
|
|
|
|
|
// Restore db connection
|
|
|
|
if ($layoutData['id_metaconsole'] != 0) {
|
|
|
|
metaconsole_restore_db();
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case PERCENTILE_BAR:
|
|
|
|
case PERCENTILE_BUBBLE:
|
|
|
|
default:
|
|
|
|
// Metaconsole db connection
|
|
|
|
if ($layoutData['id_metaconsole'] != 0) {
|
|
|
|
$connection = db_get_row_filter(
|
|
|
|
'tmetaconsole_setup',
|
|
|
|
['id' => $layoutData['id_metaconsole']]
|
|
|
|
);
|
|
|
|
if (metaconsole_load_external_db($connection) != NOERR) {
|
|
|
|
// ui_print_error_message ("Error connecting to ".$server_name);
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
$returnValue = db_get_sql(
|
|
|
|
'SELECT datos
|
2012-12-05 Miguel de Dios <miguel.dedios@artica.es>
* extensions/update_manager/lib/libupdate_manager_client.php,
extensions/update_manager/lib/libupdate_manager.php,
operation/agentes/ver_agente.php,
operation/agentes/status_monitor.php,
operation/agentes/estado_ultimopaquete.php,
operation/agentes/estado_agente.php,
operation/integria_incidents/incident.php,
operation/reporting/reporting_xml.php,
godmode/reporting/visual_console_builder.editor.js,
godmode/reporting/visual_console_builder.wizard.php,
godmode/reporting/visual_console_builder.elements.php,
include/functions_visual_map.php,
include/functions_visual_map_editor.php: uploaded the changes of
source code style previous to my next commit for to make the next
commit more easy.
* godmode/reporting/visual_console_builder.php: set empty string
for the new visualmap.
* include/ajax/visual_console_builder.ajax.php: fixed the regular
expresion to extract the url for the graph.
* include/functions_html.php: fixed into the function
"html_print_select_groups" lost code for to show the selectbox.
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@7230 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2012-12-05 15:20:47 +01:00
|
|
|
FROM tagente_estado
|
2019-01-30 16:18:44 +01:00
|
|
|
WHERE id_agente_modulo = '.$layoutData['id_agente_modulo']
|
|
|
|
);
|
|
|
|
$no_data = false;
|
|
|
|
$status_no_data = '';
|
|
|
|
if ((!$returnValue || $returnValue == 0)
|
|
|
|
&& ($layoutData['type'] == PERCENTILE_BUBBLE || $layoutData['type'] == PERCENTILE_BAR)
|
|
|
|
) {
|
|
|
|
$status_no_data = COL_UNKNOWN;
|
|
|
|
$no_data = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (($layoutData['type'] == PERCENTILE_BAR)
|
|
|
|
|| ($layoutData['type'] == PERCENTILE_BUBBLE)
|
|
|
|
) {
|
|
|
|
if ($value_show == 'value') {
|
|
|
|
$returnValue = format_for_graph($returnValue, 2);
|
|
|
|
|
|
|
|
$unit_text_db = db_get_sql(
|
|
|
|
'SELECT unit
|
2012-12-05 Miguel de Dios <miguel.dedios@artica.es>
* extensions/update_manager/lib/libupdate_manager_client.php,
extensions/update_manager/lib/libupdate_manager.php,
operation/agentes/ver_agente.php,
operation/agentes/status_monitor.php,
operation/agentes/estado_ultimopaquete.php,
operation/agentes/estado_agente.php,
operation/integria_incidents/incident.php,
operation/reporting/reporting_xml.php,
godmode/reporting/visual_console_builder.editor.js,
godmode/reporting/visual_console_builder.wizard.php,
godmode/reporting/visual_console_builder.elements.php,
include/functions_visual_map.php,
include/functions_visual_map_editor.php: uploaded the changes of
source code style previous to my next commit for to make the next
commit more easy.
* godmode/reporting/visual_console_builder.php: set empty string
for the new visualmap.
* include/ajax/visual_console_builder.ajax.php: fixed the regular
expresion to extract the url for the graph.
* include/functions_html.php: fixed into the function
"html_print_select_groups" lost code for to show the selectbox.
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@7230 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2012-12-05 15:20:47 +01:00
|
|
|
FROM tagente_modulo
|
2019-01-30 16:18:44 +01:00
|
|
|
WHERE id_agente_modulo = '.$layoutData['id_agente_modulo']
|
|
|
|
);
|
|
|
|
$unit_text_db = trim(io_safe_output($unit_text_db));
|
|
|
|
|
|
|
|
if ($value_show == 'value') {
|
|
|
|
// Set empty string unit at the moment
|
|
|
|
// and change for old false value
|
|
|
|
$unit_text = '';
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!empty($unit_text_db)) {
|
|
|
|
$unit_text = $unit_text_db;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Restore db connection
|
|
|
|
if ($layoutData['id_metaconsole'] != 0) {
|
|
|
|
metaconsole_restore_db();
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Linked to other layout ?? - Only if not module defined
|
|
|
|
if ($layoutData['id_layout_linked'] != 0) {
|
|
|
|
$status = visual_map_get_layout_status($layoutData['id_layout_linked'], $layoutData);
|
|
|
|
|
|
|
|
// Single object
|
|
|
|
} else if (($layoutData['type'] == STATIC_GRAPH)
|
|
|
|
|| ($layoutData['type'] == PERCENTILE_BAR)
|
|
|
|
|| ($layoutData['type'] == LABEL)
|
|
|
|
) {
|
|
|
|
// Status for a simple module
|
|
|
|
if ($layoutData['id_agente_modulo'] != 0) {
|
|
|
|
$status = modules_get_agentmodule_status($layoutData['id_agente_modulo']);
|
|
|
|
$id_agent = db_get_value('id_agente', 'tagente_estado', 'id_agente_modulo', $layoutData['id_agente_modulo']);
|
|
|
|
|
|
|
|
// Status for a whole agent, if agente_modulo was == 0
|
|
|
|
} else if ($layoutData['id_agent'] != 0) {
|
|
|
|
$status = agents_get_status($layoutData['id_agent']);
|
|
|
|
if ($status == -1) {
|
|
|
|
// agents_get_status return -1 for unknown!
|
|
|
|
$status = 3;
|
|
|
|
}
|
|
|
|
|
|
|
|
$id_agent = $layoutData['id_agent'];
|
|
|
|
} else {
|
|
|
|
$status = 3;
|
|
|
|
$id_agent = 0;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
// If it's a graph, a progress bar or a data tag, ALWAYS report
|
|
|
|
// status OK (=0) to avoid confussions here.
|
|
|
|
$status = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
switch ($status) {
|
|
|
|
case VISUAL_MAP_STATUS_CRITICAL_BAD:
|
|
|
|
// Critical (BAD)
|
|
|
|
$colorStatus = COL_CRITICAL;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case VISUAL_MAP_STATUS_CRITICAL_ALERT:
|
|
|
|
// Critical (ALERT)
|
|
|
|
$colorStatus = COL_ALERTFIRED;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case VISUAL_MAP_STATUS_NORMAL:
|
|
|
|
// Normal (OK)
|
|
|
|
$colorStatus = COL_NORMAL;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case VISUAL_MAP_STATUS_WARNING:
|
|
|
|
// Warning
|
|
|
|
$colorStatus = COL_WARNING;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case VISUAL_MAP_STATUS_UNKNOWN:
|
|
|
|
// Unknown
|
|
|
|
default:
|
|
|
|
$colorStatus = COL_UNKNOWN;
|
|
|
|
// Default is Grey (Other)
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
// ~ $returnValue_value = explode(' ', $returnValue);
|
|
|
|
$return = [];
|
|
|
|
if ($returnValue_value[1] != '') {
|
|
|
|
// ~ $return['value'] = remove_right_zeros(number_format($returnValue_value[0], $config['graph_precision'])) . " " . $returnValue_value[1];
|
|
|
|
} else {
|
|
|
|
// ~ $return['value'] = remove_right_zeros(number_format($returnValue_value[0], $config['graph_precision']));
|
|
|
|
}
|
|
|
|
|
|
|
|
$return['value'] = $returnValue;
|
|
|
|
$return['max_percentile'] = $layoutData['height'];
|
|
|
|
$return['width_percentile'] = $layoutData['width'];
|
|
|
|
$return['unit_text'] = $unit_text;
|
|
|
|
if ($no_data) {
|
|
|
|
$return['colorRGB'] = implode('|', html_html2rgb($status_no_data));
|
|
|
|
} else {
|
|
|
|
$return['colorRGB'] = implode('|', html_html2rgb($colorStatus));
|
|
|
|
}
|
|
|
|
|
|
|
|
echo json_encode($return);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 'get_color_line':
|
|
|
|
$layoutData = db_get_row_filter('tlayout_data', ['id' => $id_element]);
|
|
|
|
$parent = db_get_row_filter('tlayout_data', ['id' => $layoutData['parent_item']]);
|
|
|
|
|
|
|
|
$return = [];
|
|
|
|
$return['color_line'] = visual_map_get_color_line_status($parent);
|
|
|
|
echo json_encode($return);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 'get_image':
|
|
|
|
$layoutData = db_get_row_filter('tlayout_data', ['id' => $id_element]);
|
|
|
|
|
|
|
|
$return = [];
|
|
|
|
$return['image'] = visual_map_get_image_status_element($layoutData);
|
|
|
|
if (substr($return['image'], 0, 1) == '4') {
|
|
|
|
$return['image'] = substr_replace($return['image'], '', 0, 1);
|
|
|
|
}
|
|
|
|
|
|
|
|
echo json_encode($return);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 'get_color_cloud':
|
|
|
|
$layoutData = db_get_row_filter('tlayout_data', ['id' => $id_element]);
|
|
|
|
echo visual_map_get_color_cloud_element($layoutData);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 'update':
|
|
|
|
case 'move':
|
|
|
|
$values = [];
|
|
|
|
|
|
|
|
$values['label_position'] = $label_position;
|
|
|
|
$values['show_on_top'] = $show_on_top;
|
|
|
|
|
2019-05-29 13:54:14 +02:00
|
|
|
switch ($type) {
|
|
|
|
case 'line_item':
|
|
|
|
case 'box_item':
|
|
|
|
case 'clock':
|
|
|
|
case 'icon':
|
|
|
|
case 'label':
|
|
|
|
$values['cache_expiration'] = 0;
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
$values['cache_expiration'] = $cache_expiration;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
// In Graphs, background color is stored in column image (sorry).
|
2019-01-30 16:18:44 +01:00
|
|
|
if ($type == 'module_graph') {
|
|
|
|
$values['image'] = $background_color;
|
|
|
|
$values['type_graph'] = $type_graph;
|
|
|
|
}
|
|
|
|
|
|
|
|
switch ($type) {
|
|
|
|
case 'background':
|
|
|
|
$values = [];
|
|
|
|
if ($background !== null) {
|
|
|
|
$values['background'] = $background;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($width !== null) {
|
|
|
|
$values['width'] = $width;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($height !== null) {
|
|
|
|
$values['height'] = $height;
|
|
|
|
}
|
|
|
|
|
|
|
|
$result = db_process_sql_update(
|
|
|
|
'tlayout',
|
|
|
|
$values,
|
|
|
|
['id' => $id_visual_console]
|
|
|
|
);
|
|
|
|
echo (int) $result;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 'simple_value':
|
|
|
|
case 'percentile_bar':
|
|
|
|
case 'percentile_item':
|
|
|
|
case 'static_graph':
|
|
|
|
case 'module_graph':
|
|
|
|
case 'label':
|
|
|
|
case 'icon':
|
|
|
|
case 'auto_sla_graph':
|
|
|
|
case 'bars_graph':
|
|
|
|
case 'donut_graph':
|
|
|
|
default:
|
|
|
|
if ($type == 'label') {
|
|
|
|
$values['type'] = LABEL;
|
|
|
|
$values['label'] = $label;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($enable_link !== null) {
|
|
|
|
$values['enable_link'] = $enable_link;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($show_on_top !== null) {
|
|
|
|
$values['show_on_top'] = $show_on_top;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($label !== null) {
|
|
|
|
$values['label'] = $label;
|
|
|
|
}
|
|
|
|
|
|
|
|
switch ($type) {
|
|
|
|
// -- line_item --
|
|
|
|
case 'handler_end':
|
|
|
|
// ---------------
|
|
|
|
if ($left !== null) {
|
|
|
|
$values['width'] = $left;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($top !== null) {
|
|
|
|
$values['height'] = $top;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
if ($left !== null) {
|
|
|
|
$values['pos_x'] = $left;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($top !== null) {
|
|
|
|
$values['pos_y'] = $top;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (defined('METACONSOLE') && $metaconsole) {
|
|
|
|
if ($server_name !== null) {
|
|
|
|
$values['id_metaconsole'] = db_get_value(
|
|
|
|
'id',
|
|
|
|
'tmetaconsole_setup',
|
|
|
|
'server_name',
|
|
|
|
$server_name
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($server_id > 0) {
|
|
|
|
$values['id_metaconsole'] = $server_id;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if ($id_agent !== null) {
|
|
|
|
$values['id_agent'] = $id_agent;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($linked_map_node_id !== null) {
|
|
|
|
$values['linked_layout_node_id'] = (int) $linked_map_node_id;
|
|
|
|
}
|
|
|
|
} else if ($id_agent == 0) {
|
|
|
|
$values['id_agent'] = 0;
|
|
|
|
} else if (!empty($id_agent)) {
|
|
|
|
$values['id_agent'] = $id_agent;
|
|
|
|
} else if ($agent !== null) {
|
|
|
|
$id_agent = agents_get_agent_id($agent);
|
|
|
|
$values['id_agent'] = $id_agent;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($id_module !== null) {
|
|
|
|
$values['id_agente_modulo'] = $id_module;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($parent !== null) {
|
|
|
|
$values['parent_item'] = $parent;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($map_linked !== null) {
|
|
|
|
$values['id_layout_linked'] = $map_linked;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($linked_map_status_calculation_type !== null) {
|
|
|
|
$values['linked_layout_status_type'] = $linked_map_status_calculation_type;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($map_linked_weight !== null) {
|
|
|
|
if ($map_linked_weight > 100) {
|
|
|
|
$map_linked_weight = 100;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($map_linked_weight < 0) {
|
|
|
|
$map_linked_weight = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
$values['id_layout_linked_weight'] = $map_linked_weight;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($linked_map_status_service_critical !== null) {
|
|
|
|
if ($linked_map_status_service_critical > 100) {
|
|
|
|
$linked_map_status_service_critical = 100;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($linked_map_status_service_critical < 0) {
|
|
|
|
$linked_map_status_service_critical = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
$values['linked_layout_status_as_service_critical'] = $linked_map_status_service_critical;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($linked_map_status_service_warning !== null) {
|
|
|
|
if ($linked_map_status_service_warning > 100) {
|
|
|
|
$linked_map_status_service_warning = 100;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($linked_map_status_service_warning < 0) {
|
|
|
|
$linked_map_status_service_warning = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
$values['linked_layout_status_as_service_warning'] = $linked_map_status_service_warning;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($element_group !== null) {
|
|
|
|
$values['element_group'] = $element_group;
|
|
|
|
}
|
|
|
|
|
|
|
|
switch ($type) {
|
|
|
|
// -- line_item ------------------------------------
|
|
|
|
case 'handler_start':
|
|
|
|
case 'handler_end':
|
|
|
|
$values['border_width'] = $line_width;
|
|
|
|
$values['border_color'] = $line_color;
|
|
|
|
break;
|
|
|
|
|
|
|
|
// -------------------------------------------------
|
|
|
|
case 'auto_sla_graph':
|
|
|
|
$values['type'] = AUTO_SLA_GRAPH;
|
|
|
|
if ($event_max_time_row !== null) {
|
|
|
|
$values['period'] = $event_max_time_row;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($width !== null) {
|
|
|
|
$values['width'] = $width;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($height !== null) {
|
|
|
|
$values['height'] = $height;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 'donut_graph':
|
|
|
|
if ($width_percentile !== null) {
|
|
|
|
$values['width'] = $width_percentile;
|
|
|
|
$values['height'] = $width_percentile;
|
|
|
|
}
|
|
|
|
|
|
|
|
$values['border_color'] = $resume_color;
|
|
|
|
$values['type'] = DONUT_GRAPH;
|
|
|
|
$values['id_agent'] = $id_agent_string;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 'box_item':
|
|
|
|
$values['border_width'] = $border_width;
|
|
|
|
$values['border_color'] = $border_color;
|
|
|
|
$values['fill_color'] = $fill_color;
|
|
|
|
$values['period'] = $period;
|
|
|
|
$values['width'] = $width_box;
|
|
|
|
$values['height'] = $height_box;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 'group_item':
|
|
|
|
$values['id_group'] = $id_group;
|
|
|
|
if ($image !== null) {
|
|
|
|
$values['image'] = $image;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($width !== null) {
|
|
|
|
$values['width'] = $width;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($height !== null) {
|
|
|
|
$values['height'] = $height;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($show_statistics !== null) {
|
|
|
|
$values['show_statistics'] = $show_statistics;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 'module_graph':
|
|
|
|
if ($height_module_graph !== null) {
|
|
|
|
$values['height'] = $height_module_graph;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($width_module_graph !== null) {
|
|
|
|
$values['width'] = $width_module_graph;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($period !== null) {
|
|
|
|
$values['period'] = $period;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($id_custom_graph !== null) {
|
|
|
|
$values['id_custom_graph'] = $id_custom_graph;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (is_metaconsole()) {
|
|
|
|
if ($values['id_custom_graph'] != 0) {
|
|
|
|
$explode_id = explode('|', $values['id_custom_graph']);
|
|
|
|
$values['id_custom_graph'] = $explode_id[0];
|
|
|
|
$values['id_metaconsole'] = $explode_id[1];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 'bars_graph':
|
|
|
|
if ($width_percentile !== null) {
|
|
|
|
$values['width'] = $width_percentile;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($bars_graph_height !== null) {
|
|
|
|
$values['height'] = $bars_graph_height;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($bars_graph_type !== null) {
|
|
|
|
$values['type_graph'] = $bars_graph_type;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($background_color !== null) {
|
|
|
|
$values['image'] = $background_color;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($grid_color !== null) {
|
|
|
|
$values['border_color'] = $grid_color;
|
|
|
|
}
|
|
|
|
|
|
|
|
$values['id_agent'] = $id_agent_string;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 'percentile_item':
|
|
|
|
case 'percentile_bar':
|
|
|
|
if ($action == 'update') {
|
|
|
|
if ($width_percentile !== null) {
|
|
|
|
$values['width'] = $width_percentile;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($max_percentile !== null) {
|
|
|
|
$values['height'] = $max_percentile;
|
|
|
|
}
|
|
|
|
|
|
|
|
$values['type'] = PERCENTILE_BAR;
|
|
|
|
if ($type_percentile == 'percentile') {
|
|
|
|
$values['type'] = PERCENTILE_BAR;
|
|
|
|
} else if ($type_percentile == 'circular_progress_bar') {
|
|
|
|
$values['type'] = CIRCULAR_PROGRESS_BAR;
|
|
|
|
} else if ($type_percentile == 'interior_circular_progress_bar') {
|
|
|
|
$values['type'] = CIRCULAR_INTERIOR_PROGRESS_BAR;
|
|
|
|
} else if ($type_percentile == 'bubble') {
|
|
|
|
$values['type'] = PERCENTILE_BUBBLE;
|
|
|
|
}
|
|
|
|
|
|
|
|
$values['image'] = $value_show;
|
|
|
|
|
|
|
|
$values['border_color'] = $percentile_color;
|
|
|
|
$values['fill_color'] = $percentile_label_color;
|
|
|
|
$values['label'] = $percentile_label;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 'icon':
|
|
|
|
case 'static_graph':
|
|
|
|
if ($image !== null) {
|
|
|
|
$values['image'] = $image;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($width !== null) {
|
|
|
|
$values['width'] = $width;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($height !== null) {
|
|
|
|
$values['height'] = $height;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($show_last_value !== null) {
|
|
|
|
$values['show_last_value'] = $show_last_value;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 'simple_value':
|
|
|
|
if ($action == 'update') {
|
|
|
|
$values['type'] = visual_map_get_simple_value_type(
|
|
|
|
$process_simple_value
|
|
|
|
);
|
|
|
|
$values['period'] = $period;
|
|
|
|
$values['width'] = $width;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 'clock':
|
|
|
|
if ($clock_animation !== null) {
|
|
|
|
$values['clock_animation'] = $clock_animation;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($time_format !== null) {
|
|
|
|
$values['time_format'] = $time_format;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($timezone !== null) {
|
|
|
|
$values['timezone'] = $timezone;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($width !== null) {
|
|
|
|
$values['width'] = $width_percentile;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($fill_color !== null) {
|
|
|
|
$values['fill_color'] = $fill_color;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 'color_cloud':
|
|
|
|
$values['width'] = $diameter;
|
|
|
|
$values['height'] = $diameter;
|
|
|
|
// Fill Color Cloud values
|
|
|
|
$extra = [
|
|
|
|
'default_color' => $default_color,
|
|
|
|
'color_ranges' => [],
|
|
|
|
];
|
|
|
|
|
|
|
|
$num_ranges = count($color_range_colors);
|
|
|
|
for ($i = 0; $i < $num_ranges; $i++) {
|
|
|
|
if (!isset($color_range_from_values[$i])
|
|
|
|
|| !isset($color_range_to_values[$i])
|
|
|
|
|| !isset($color_range_colors[$i])
|
|
|
|
) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
$extra['color_ranges'][] = [
|
|
|
|
'from_value' => (float) $color_range_from_values[$i],
|
|
|
|
'to_value' => (float) $color_range_to_values[$i],
|
|
|
|
'color' => $color_range_colors[$i],
|
|
|
|
// already html encoded
|
|
|
|
];
|
|
|
|
}
|
|
|
|
|
|
|
|
// Yes, we are using the label to store the extra info.
|
|
|
|
// Sorry not sorry.
|
|
|
|
$values['label'] = json_encode($extra);
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
if (enterprise_installed()) {
|
|
|
|
if ($image !== null) {
|
|
|
|
$values['image'] = $image;
|
|
|
|
}
|
|
|
|
|
|
|
|
enterprise_ajax_update_values($action, $type, $values);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($action == 'move') {
|
|
|
|
// Don't change the label because only change the positions
|
|
|
|
unset($values['label']);
|
|
|
|
unset($values['label_position']);
|
|
|
|
// Don't change this values when move
|
|
|
|
unset($values['id_agent']);
|
|
|
|
unset($values['id_agente_modulo']);
|
|
|
|
unset($values['enable_link']);
|
|
|
|
unset($values['show_on_top']);
|
|
|
|
unset($values['id_layout_linked']);
|
|
|
|
unset($values['element_group']);
|
|
|
|
unset($values['id_layout_linked_weight']);
|
2019-05-09 12:44:58 +02:00
|
|
|
unset($values['cache_expiration']);
|
2019-01-30 16:18:44 +01:00
|
|
|
// Don't change background color in graphs when move
|
|
|
|
switch ($type) {
|
|
|
|
case 'group_item':
|
|
|
|
unset($values['id_group']);
|
|
|
|
unset($values['show_statistics']);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 'module_graph':
|
|
|
|
unset($values['image']);
|
|
|
|
unset($values['type_graph']);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 'bars_graph':
|
|
|
|
unset($values['image']);
|
|
|
|
unset($values['type_graph']);
|
|
|
|
unset($values['border_color']);
|
|
|
|
unset($values['width']);
|
|
|
|
unset($values['id_agent']);
|
|
|
|
unset($values['height']);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 'donut_graph':
|
|
|
|
unset($values['border_color']);
|
|
|
|
unset($values['width']);
|
|
|
|
unset($values['id_agent']);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 'clock':
|
|
|
|
unset($values['clock_animation']);
|
|
|
|
unset($values['time_format']);
|
|
|
|
unset($values['timezone']);
|
|
|
|
unset($values['fill_color']);
|
|
|
|
unset($values['width']);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 'box_item':
|
|
|
|
unset($values['border_width']);
|
|
|
|
unset($values['border_color']);
|
|
|
|
unset($values['fill_color']);
|
|
|
|
unset($values['period']);
|
|
|
|
unset($values['width']);
|
|
|
|
unset($values['height']);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 'color_cloud':
|
|
|
|
unset($values['width']);
|
|
|
|
unset($values['height']);
|
|
|
|
unset($values['diameter']);
|
|
|
|
unset($values['label']);
|
|
|
|
break;
|
|
|
|
|
|
|
|
// -- line_item --
|
|
|
|
case 'handler_start':
|
|
|
|
case 'handler_end':
|
|
|
|
// ---------------
|
|
|
|
unset($values['border_width']);
|
|
|
|
unset($values['border_color']);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
$item_in_db = db_get_row_filter('tlayout_data', ['id' => $id_element]);
|
|
|
|
|
|
|
|
if (($item_in_db['parent_item'] == 0) && ($values['parent_item'] != 0)) {
|
|
|
|
$new_line = 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
$result = db_process_sql_update(
|
|
|
|
'tlayout_data',
|
|
|
|
$values,
|
|
|
|
['id' => $id_element]
|
|
|
|
);
|
|
|
|
|
2019-05-27 16:40:09 +02:00
|
|
|
// Invalidate the item's cache.
|
|
|
|
if ($result !== false && $result > 0) {
|
|
|
|
db_process_sql_delete(
|
|
|
|
'tvisual_console_elements_cache',
|
|
|
|
[
|
|
|
|
'vc_item_id' => (int) $id_element,
|
|
|
|
]
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2019-01-30 16:18:44 +01:00
|
|
|
$return_val = [];
|
|
|
|
$return_val['correct'] = (int) $result;
|
|
|
|
$return_val['new_line'] = $new_line;
|
|
|
|
|
|
|
|
echo json_encode($return_val);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 'load':
|
|
|
|
switch ($type) {
|
|
|
|
case 'background':
|
|
|
|
$backgroundFields = db_get_row_filter(
|
|
|
|
'tlayout',
|
|
|
|
['id' => $id_visual_console],
|
|
|
|
[
|
|
|
|
'background',
|
|
|
|
'height',
|
|
|
|
'width',
|
|
|
|
]
|
|
|
|
);
|
|
|
|
echo json_encode($backgroundFields);
|
|
|
|
break;
|
|
|
|
|
|
|
|
// -- line_item --
|
|
|
|
case 'handler_start':
|
|
|
|
case 'handler_end':
|
|
|
|
// ---------------
|
|
|
|
case 'box_item':
|
|
|
|
case 'percentile_bar':
|
|
|
|
case 'percentile_item':
|
|
|
|
case 'static_graph':
|
|
|
|
case 'group_item':
|
|
|
|
case 'module_graph':
|
|
|
|
case 'bars_graph':
|
|
|
|
case 'simple_value':
|
|
|
|
case 'label':
|
|
|
|
case 'icon':
|
|
|
|
case 'clock':
|
|
|
|
case 'auto_sla_graph':
|
|
|
|
case 'donut_graph':
|
|
|
|
case 'color_cloud':
|
|
|
|
$elementFields = db_get_row_filter(
|
|
|
|
'tlayout_data',
|
|
|
|
['id' => $id_element]
|
|
|
|
);
|
|
|
|
|
|
|
|
// Metaconsole db connection
|
|
|
|
if ($elementFields['id_metaconsole'] != 0) {
|
|
|
|
$connection = db_get_row_filter(
|
|
|
|
'tmetaconsole_setup',
|
|
|
|
['id' => $elementFields['id_metaconsole']]
|
|
|
|
);
|
|
|
|
|
|
|
|
$elementFields['id_server_name'] = $connection['server_name'];
|
|
|
|
|
|
|
|
if (metaconsole_load_external_db($connection) != NOERR) {
|
|
|
|
// ui_print_error_message ("Error connecting to ".$server_name);
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (!empty($connection['server_name'])) {
|
|
|
|
$elementFields['agent_name'] = io_safe_output(agents_get_alias($elementFields['id_agent'])).' ('.io_safe_output($connection['server_name']).')';
|
|
|
|
} else {
|
|
|
|
$elementFields['agent_name'] = io_safe_output(agents_get_alias($elementFields['id_agent']));
|
|
|
|
}
|
|
|
|
|
|
|
|
// Make the html of select box of modules about id_agent.
|
|
|
|
if (($elementFields['id_agent'] != 0)
|
|
|
|
&& ($elementFields['id_layout_linked'] == 0)
|
|
|
|
) {
|
|
|
|
$modules = agents_get_modules(
|
|
|
|
$elementFields['id_agent'],
|
|
|
|
false,
|
|
|
|
[
|
|
|
|
'disabled' => 0,
|
|
|
|
'id_agente' => $elementFields['id_agent'],
|
|
|
|
]
|
|
|
|
);
|
|
|
|
|
|
|
|
$elementFields['modules_html'] = '<option value="0">--</option>';
|
|
|
|
foreach ($modules as $id => $name) {
|
|
|
|
$elementFields['modules_html'] .= '<option value="'.$id.'">'.io_safe_output($name).'</option>';
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
$elementFields['modules_html'] = '<option value="0">'.__('Any').'</option>';
|
|
|
|
}
|
|
|
|
|
|
|
|
// Restore db connection
|
|
|
|
if ($elementFields['id_metaconsole'] != 0) {
|
|
|
|
metaconsole_restore_db();
|
|
|
|
}
|
|
|
|
|
|
|
|
if (isset($elementFields['id_layout_linked_weight'])) {
|
|
|
|
$elementFields['id_layout_linked_weight'] = (int) $elementFields['id_layout_linked_weight'];
|
|
|
|
}
|
|
|
|
|
|
|
|
if (isset($elementFields['linked_layout_status_as_service_critical'])) {
|
|
|
|
$elementFields['linked_layout_status_as_service_critical'] = (float) $elementFields['linked_layout_status_as_service_critical'];
|
|
|
|
}
|
|
|
|
|
|
|
|
if (isset($elementFields['linked_layout_status_as_service_warning'])) {
|
|
|
|
$elementFields['linked_layout_status_as_service_warning'] = (float) $elementFields['linked_layout_status_as_service_warning'];
|
|
|
|
}
|
|
|
|
|
|
|
|
switch ($type) {
|
|
|
|
case 'auto_sla_graph':
|
|
|
|
$elementFields['event_max_time_row'] = $elementFields['period'];
|
|
|
|
case 'percentile_item':
|
|
|
|
case 'percentile_bar':
|
|
|
|
$elementFields['width_percentile'] = $elementFields['width'];
|
|
|
|
$elementFields['max_percentile'] = $elementFields['height'];
|
|
|
|
|
|
|
|
$elementFields['value_show'] = $elementFields['image'];
|
|
|
|
|
|
|
|
$elementFields['type_percentile'] = 'percentile';
|
|
|
|
if ($elementFields['type'] == PERCENTILE_BAR) {
|
|
|
|
$elementFields['type_percentile'] = 'percentile';
|
|
|
|
} else if ($elementFields['type'] == PERCENTILE_BUBBLE) {
|
|
|
|
$elementFields['type_percentile'] = 'bubble';
|
|
|
|
} else if ($elementFields['type'] == CIRCULAR_PROGRESS_BAR) {
|
|
|
|
$elementFields['type_percentile'] = 'circular_progress_bar';
|
|
|
|
} else if ($elementFields['type'] == CIRCULAR_INTERIOR_PROGRESS_BAR) {
|
|
|
|
$elementFields['type_percentile'] = 'interior_circular_progress_bar';
|
|
|
|
}
|
|
|
|
|
|
|
|
$elementFields['percentile_color'] = $elementFields['border_color'];
|
|
|
|
$elementFields['percentile_label_color'] = $elementFields['fill_color'];
|
|
|
|
$elementFields['percentile_label'] = $elementFields['label'];
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 'donut_graph':
|
|
|
|
$elementFields['width_percentile'] = $elementFields['width'];
|
|
|
|
$elementFields['resume_color'] = $elementFields['border_color'];
|
|
|
|
$elementFields['id_agent_string'] = $elementFields['id_agent'];
|
|
|
|
if (($elementFields['id_agent_string'] != 0)
|
|
|
|
&& ($elementFields['id_layout_linked'] == 0)
|
|
|
|
) {
|
|
|
|
$modules = agents_get_modules(
|
|
|
|
$elementFields['id_agent'],
|
|
|
|
false,
|
|
|
|
[
|
|
|
|
'disabled' => 0,
|
|
|
|
'id_agente' => $elementFields['id_agent'],
|
|
|
|
'tagente_modulo.id_tipo_modulo IN' => '(17,23,3,10,33)',
|
|
|
|
]
|
|
|
|
);
|
|
|
|
|
|
|
|
$elementFields['modules_html'] = '<option value="0">--</option>';
|
|
|
|
foreach ($modules as $id => $name) {
|
|
|
|
$elementFields['modules_html'] .= '<option value="'.$id.'">'.io_safe_output($name).'</option>';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 'module_graph':
|
|
|
|
$elementFields['width_module_graph'] = $elementFields['width'];
|
|
|
|
$elementFields['height_module_graph'] = $elementFields['height'];
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 'clock':
|
|
|
|
$elementFields['width_percentile'] = $elementFields['width'];
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 'bars_graph':
|
|
|
|
$elementFields['width_percentile'] = $elementFields['width'];
|
|
|
|
$elementFields['bars_graph_height'] = $elementFields['height'];
|
|
|
|
$elementFields['bars_graph_type'] = $elementFields['type_graph'];
|
|
|
|
$elementFields['grid_color'] = $elementFields['border_color'];
|
|
|
|
$elementFields['id_agent_string'] = $elementFields['id_agent'];
|
|
|
|
if (($elementFields['id_agent_string'] != 0)
|
|
|
|
&& ($elementFields['id_layout_linked'] == 0)
|
|
|
|
) {
|
|
|
|
$modules = agents_get_modules(
|
|
|
|
$elementFields['id_agent'],
|
|
|
|
false,
|
|
|
|
[
|
|
|
|
'disabled' => 0,
|
|
|
|
'id_agente' => $elementFields['id_agent'],
|
|
|
|
'tagente_modulo.id_tipo_modulo IN' => '(1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,18,17,23,3,10,33)',
|
|
|
|
]
|
|
|
|
);
|
|
|
|
|
|
|
|
$elementFields['modules_html'] = '<option value="0">--</option>';
|
|
|
|
foreach ($modules as $id => $name) {
|
|
|
|
$elementFields['modules_html'] .= '<option value="'.$id.'">'.io_safe_output($name).'</option>';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 'box_item':
|
|
|
|
$elementFields['width_box'] = $elementFields['width'];
|
|
|
|
$elementFields['height_box'] = $elementFields['height'];
|
|
|
|
$elementFields['border_color'] = $elementFields['border_color'];
|
|
|
|
$elementFields['border_width'] = $elementFields['border_width'];
|
|
|
|
$elementFields['fill_color'] = $elementFields['fill_color'];
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 'color_cloud':
|
|
|
|
$elementFields['diameter'] = $elementFields['width'];
|
|
|
|
$elementFields['dynamic_data'] = null;
|
|
|
|
try {
|
|
|
|
// Yes, it's using the label field to store the extra data
|
|
|
|
$elementFields['dynamic_data'] = json_decode($elementFields['label'], true);
|
|
|
|
} catch (Exception $ex) {
|
|
|
|
}
|
|
|
|
|
|
|
|
$elementFields['label'] = '';
|
|
|
|
break;
|
|
|
|
|
|
|
|
// -- line_item --
|
|
|
|
case 'handler_start':
|
|
|
|
case 'handler_end':
|
|
|
|
// ---------------
|
|
|
|
$elementFields['line_width'] = $elementFields['border_width'];
|
|
|
|
$elementFields['line_color'] = $elementFields['border_color'];
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Support for max, min and svg process on simple value items
|
|
|
|
if ($type == 'simple_value') {
|
|
|
|
switch ($elementFields['type']) {
|
|
|
|
case SIMPLE_VALUE:
|
|
|
|
$elementFields['process_value'] = 0;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case SIMPLE_VALUE_MAX:
|
|
|
|
$elementFields['process_value'] = 2;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case SIMPLE_VALUE_MIN:
|
|
|
|
$elementFields['process_value'] = 1;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case SIMPLE_VALUE_AVG:
|
|
|
|
$elementFields['process_value'] = 3;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
$elementFields['label'] = io_safe_output($elementFields['label']);
|
|
|
|
echo json_encode($elementFields);
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
enterprise_hook('enterprise_ajax_load_values', [$type, $id_element]);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 'insert':
|
|
|
|
$values = [];
|
|
|
|
$values['id_layout'] = $id_visual_console;
|
|
|
|
$values['label'] = $label;
|
|
|
|
$values['pos_x'] = $left;
|
|
|
|
$values['pos_y'] = $top;
|
|
|
|
$values['label_position'] = $label_position;
|
|
|
|
|
|
|
|
if (defined('METACONSOLE') && $metaconsole) {
|
|
|
|
if ($server_id > 0) {
|
|
|
|
$values['id_metaconsole'] = $server_id;
|
|
|
|
} else {
|
|
|
|
$values['id_metaconsole'] = db_get_value(
|
|
|
|
'id',
|
|
|
|
'tmetaconsole_setup',
|
|
|
|
'server_name',
|
|
|
|
$server_name
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
$values['id_agent'] = $id_agent;
|
|
|
|
} else {
|
|
|
|
if (!empty($id_agent)) {
|
|
|
|
$values['id_agent'] = $id_agent;
|
|
|
|
} else if (!empty($agent)) {
|
|
|
|
$values['id_agent'] = agents_get_agent_id($agent);
|
|
|
|
} else {
|
|
|
|
$values['id_agent'] = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
$values['id_agente_modulo'] = $id_module;
|
|
|
|
$values['id_layout_linked'] = $map_linked;
|
|
|
|
|
|
|
|
if (defined('METACONSOLE') && $metaconsole) {
|
|
|
|
$values['linked_layout_node_id'] = (int) $linked_map_node_id;
|
|
|
|
}
|
|
|
|
|
|
|
|
$values['linked_layout_status_type'] = $linked_map_status_calculation_type;
|
|
|
|
|
|
|
|
if ($map_linked_weight !== null) {
|
|
|
|
if ($map_linked_weight > 100) {
|
|
|
|
$map_linked_weight = 100;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($map_linked_weight < 0) {
|
|
|
|
$map_linked_weight = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
$values['id_layout_linked_weight'] = $map_linked_weight;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($linked_map_status_service_critical !== null) {
|
|
|
|
if ($linked_map_status_service_critical > 100) {
|
|
|
|
$linked_map_status_service_critical = 100;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($linked_map_status_service_critical < 0) {
|
|
|
|
$linked_map_status_service_critical = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
$values['linked_layout_status_as_service_critical'] = $linked_map_status_service_critical;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($linked_map_status_service_warning !== null) {
|
|
|
|
if ($linked_map_status_service_warning > 100) {
|
|
|
|
$linked_map_status_service_warning = 100;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($linked_map_status_service_warning < 0) {
|
|
|
|
$linked_map_status_service_warning = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
$values['linked_layout_status_as_service_warning'] = $linked_map_status_service_warning;
|
|
|
|
}
|
|
|
|
|
|
|
|
$values['element_group'] = $element_group;
|
|
|
|
$values['parent_item'] = $parent;
|
|
|
|
$values['enable_link'] = $enable_link;
|
|
|
|
$values['show_on_top'] = $show_on_top;
|
|
|
|
$values['image'] = $background_color;
|
|
|
|
$values['type_graph'] = $type_graph;
|
|
|
|
$values['id_custom_graph'] = $id_custom_graph;
|
2019-05-29 13:54:14 +02:00
|
|
|
|
|
|
|
switch ($type) {
|
|
|
|
case 'line_item':
|
|
|
|
case 'box_item':
|
|
|
|
case 'clock':
|
|
|
|
case 'icon':
|
|
|
|
case 'label':
|
|
|
|
$values['cache_expiration'] = 0;
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
$values['cache_expiration'] = $cache_expiration;
|
|
|
|
break;
|
|
|
|
}
|
2019-01-30 16:18:44 +01:00
|
|
|
|
|
|
|
switch ($type) {
|
|
|
|
case 'line_item':
|
|
|
|
$values['type'] = LINE_ITEM;
|
|
|
|
$values['border_width'] = $line_width;
|
|
|
|
$values['border_color'] = $line_color;
|
|
|
|
$values['pos_x'] = $line_start_x;
|
|
|
|
$values['pos_y'] = $line_start_y;
|
|
|
|
$values['width'] = $line_end_x;
|
|
|
|
$values['height'] = $line_end_y;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 'box_item':
|
|
|
|
$values['type'] = BOX_ITEM;
|
|
|
|
$values['border_width'] = $border_width;
|
|
|
|
$values['border_color'] = $border_color;
|
|
|
|
$values['fill_color'] = $fill_color;
|
|
|
|
$values['period'] = $period;
|
|
|
|
$values['width'] = $width_box;
|
|
|
|
$values['height'] = $height_box;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 'donut_graph':
|
|
|
|
$values['type'] = DONUT_GRAPH;
|
|
|
|
$values['width'] = $width_percentile;
|
|
|
|
$values['height'] = $width_percentile;
|
|
|
|
$values['border_color'] = $resume_color;
|
|
|
|
$values['id_agent'] = $id_agent_string;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 'module_graph':
|
|
|
|
$values['type'] = MODULE_GRAPH;
|
|
|
|
|
|
|
|
if (is_metaconsole()) {
|
|
|
|
if ($values['id_custom_graph'] != 0) {
|
|
|
|
$explode_id = explode('|', $values['id_custom_graph']);
|
|
|
|
$values['id_custom_graph'] = $explode_id[0];
|
|
|
|
$values['id_metaconsole'] = $explode_id[1];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($values['id_custom_graph'] > 0) {
|
|
|
|
$values['height'] = $height_module_graph;
|
|
|
|
$values['width'] = $width_module_graph;
|
|
|
|
|
|
|
|
if (is_metaconsole()) {
|
|
|
|
$server_data = metaconsole_get_connection_by_id($values['id_metaconsole']);
|
|
|
|
// Establishes connection
|
|
|
|
if (metaconsole_load_external_db($server_data) !== NOERR) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
$graph_conf = db_get_row('tgraph', 'id_graph', $values['id_custom_graph']);
|
|
|
|
|
|
|
|
if (is_metaconsole()) {
|
|
|
|
metaconsole_restore_db();
|
|
|
|
}
|
|
|
|
|
|
|
|
$graph_stacked = $graph_conf['stacked'];
|
|
|
|
if ($graph_stacked == CUSTOM_GRAPH_BULLET_CHART) {
|
|
|
|
$values['height'] = 50;
|
|
|
|
} else if ($graph_stacked == CUSTOM_GRAPH_GAUGE) {
|
|
|
|
if ($height_module_graph < 150) {
|
|
|
|
$values['height'] = 150;
|
|
|
|
} else if (($height_module_graph >= 150)
|
|
|
|
&& ($height_module_graph < 250)
|
|
|
|
) {
|
|
|
|
$values['height'] = $graph_conf['height'];
|
|
|
|
} else if ($height_module_graph >= 250) {
|
|
|
|
$values['height'] = 200;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
$values['height'] = $height_module_graph;
|
|
|
|
$values['width'] = $width_module_graph;
|
|
|
|
}
|
|
|
|
|
|
|
|
$values['period'] = $period;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 'bars_graph':
|
|
|
|
$values['type'] = BARS_GRAPH;
|
|
|
|
$values['width'] = $width_percentile;
|
|
|
|
$values['height'] = $bars_graph_height;
|
|
|
|
$values['type_graph'] = $bars_graph_type;
|
|
|
|
$values['image'] = $background_color;
|
|
|
|
$values['border_color'] = $grid_color;
|
|
|
|
$values['id_agent'] = $id_agent_string;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 'clock':
|
|
|
|
$values['type'] = CLOCK;
|
|
|
|
$values['width'] = $width_percentile;
|
|
|
|
$values['clock_animation'] = $clock_animation;
|
|
|
|
$values['fill_color'] = $fill_color;
|
|
|
|
$values['time_format'] = $time_format;
|
|
|
|
$values['timezone'] = $timezone;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 'auto_sla_graph':
|
|
|
|
$values['type'] = AUTO_SLA_GRAPH;
|
|
|
|
$values['period'] = $event_max_time_row;
|
|
|
|
$values['width'] = $width;
|
|
|
|
$values['height'] = $height;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 'percentile_item':
|
|
|
|
case 'percentile_bar':
|
|
|
|
if ($type_percentile == 'percentile') {
|
|
|
|
$values['type'] = PERCENTILE_BAR;
|
|
|
|
} else if ($type_percentile == 'circular_progress_bar') {
|
|
|
|
$values['type'] = CIRCULAR_PROGRESS_BAR;
|
|
|
|
} else if ($type_percentile == 'interior_circular_progress_bar') {
|
|
|
|
$values['type'] = CIRCULAR_INTERIOR_PROGRESS_BAR;
|
|
|
|
} else {
|
|
|
|
$values['type'] = PERCENTILE_BUBBLE;
|
|
|
|
}
|
|
|
|
|
|
|
|
$values['border_color'] = $percentile_color;
|
|
|
|
$values['image'] = $value_show;
|
|
|
|
// Hack to save it show percent o value.
|
|
|
|
$values['width'] = $width_percentile;
|
|
|
|
$values['height'] = $max_percentile;
|
|
|
|
$values['fill_color'] = $percentile_label_color;
|
|
|
|
$values['label'] = $percentile_label;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 'static_graph':
|
|
|
|
$values['type'] = STATIC_GRAPH;
|
|
|
|
$values['image'] = $image;
|
|
|
|
$values['width'] = $width;
|
|
|
|
$values['height'] = $height;
|
|
|
|
$values['show_last_value'] = $show_last_value;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 'group_item':
|
|
|
|
$values['type'] = GROUP_ITEM;
|
|
|
|
$values['image'] = $image;
|
|
|
|
$values['width'] = $width;
|
|
|
|
$values['height'] = $height;
|
|
|
|
$values['id_group'] = $id_group;
|
|
|
|
$values['show_statistics'] = $show_statistics;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 'simple_value':
|
|
|
|
// This allows min, max and avg process in a simple value
|
|
|
|
$values['type'] = visual_map_get_simple_value_type($process_simple_value);
|
|
|
|
$values['period'] = $period;
|
|
|
|
$values['width'] = $width;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 'label':
|
|
|
|
$values['type'] = LABEL;
|
|
|
|
$values['label'] = $label;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 'icon':
|
|
|
|
$values['type'] = ICON;
|
|
|
|
$values['image'] = $image;
|
|
|
|
$values['width'] = $width;
|
|
|
|
$values['height'] = $height;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 'color_cloud':
|
|
|
|
$values['type'] = COLOR_CLOUD;
|
|
|
|
$values['width'] = $diameter;
|
|
|
|
$values['height'] = $diameter;
|
|
|
|
|
|
|
|
$extra = [
|
|
|
|
'default_color' => $default_color,
|
|
|
|
'color_ranges' => [],
|
|
|
|
];
|
|
|
|
|
|
|
|
$num_ranges = count($color_range_colors);
|
|
|
|
for ($i = 0; $i < $num_ranges; $i++) {
|
|
|
|
if (!isset($color_range_from_values[$i])
|
|
|
|
|| !isset($color_range_to_values[$i])
|
|
|
|
|| !isset($color_range_colors[$i])
|
|
|
|
) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
$extra['color_ranges'][] = [
|
|
|
|
'from_value' => (int) $color_range_from_values[$i],
|
|
|
|
'to_value' => (int) $color_range_to_values[$i],
|
|
|
|
'color' => $color_range_colors[$i],
|
|
|
|
// already html encoded
|
|
|
|
];
|
|
|
|
}
|
|
|
|
|
|
|
|
// Yes, we are using the label to store the extra info.
|
|
|
|
// Sorry not sorry.
|
|
|
|
$values['label'] = json_encode($extra);
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
if (enterprise_installed()) {
|
|
|
|
enterprise_ajax_insert_fill_values_insert($type, $values);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
$idData = db_process_sql_insert('tlayout_data', $values);
|
|
|
|
|
|
|
|
$return = [];
|
|
|
|
if ($idData === false) {
|
|
|
|
$return['correct'] = 0;
|
|
|
|
} else {
|
|
|
|
$text = visual_map_create_internal_name_item($label, $type, $image, $agent, $id_module, $idData);
|
|
|
|
|
|
|
|
$return['correct'] = 1;
|
|
|
|
$return['id_data'] = $idData;
|
|
|
|
$return['text'] = $text;
|
|
|
|
}
|
|
|
|
|
|
|
|
echo json_encode($return);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 'copy':
|
|
|
|
|
|
|
|
$values = db_get_row_filter(
|
|
|
|
'tlayout_data',
|
|
|
|
['id' => $id_element]
|
|
|
|
);
|
|
|
|
|
|
|
|
unset($values['id']);
|
|
|
|
$values['pos_x'] = ($values['pos_x'] + 20);
|
|
|
|
$values['pos_y'] = ($values['pos_y'] + 20);
|
|
|
|
|
|
|
|
$idData = db_process_sql_insert('tlayout_data', $values);
|
|
|
|
|
|
|
|
$return = [];
|
|
|
|
if ($idData === false) {
|
|
|
|
$return['correct'] = 0;
|
|
|
|
} else {
|
|
|
|
$text = visual_map_create_internal_name_item($label, $type, $image, $agent, $id_module, $idData);
|
|
|
|
|
|
|
|
$values['left'] = $values['pos_x'];
|
|
|
|
$values['top'] = $values['pos_y'];
|
|
|
|
$values['parent'] = $values['parent_item'];
|
|
|
|
$return['values'] = $values;
|
|
|
|
$return['correct'] = 1;
|
|
|
|
$return['id_data'] = $idData;
|
|
|
|
$return['text'] = $text;
|
|
|
|
$return['type'] = visual_map_type_in_js($values['type']);
|
|
|
|
|
|
|
|
switch ($values['type']) {
|
|
|
|
case BOX_ITEM:
|
|
|
|
$return['values']['width_box'] = $values['width'];
|
|
|
|
$return['values']['height_box'] = $values['height'];
|
|
|
|
break;
|
|
|
|
|
|
|
|
case CIRCULAR_PROGRESS_BAR:
|
|
|
|
$return['values']['type_percentile'] = 'bubble';
|
|
|
|
break;
|
|
|
|
|
|
|
|
case CIRCULAR_INTERIOR_PROGRESS_BAR:
|
|
|
|
$return['values']['type_percentile'] = 'circular_progress_bar';
|
|
|
|
break;
|
|
|
|
|
|
|
|
case PERCENTILE_BUBBLE:
|
|
|
|
$return['values']['type_percentile'] = 'interior_circular_progress_bar';
|
|
|
|
break;
|
|
|
|
|
|
|
|
case PERCENTILE_BAR:
|
|
|
|
$return['values']['type_percentile'] = 'percentile';
|
|
|
|
break;
|
|
|
|
|
|
|
|
case COLOR_CLOUD:
|
|
|
|
$return['values']['diameter'] = $values['width'];
|
|
|
|
|
|
|
|
try {
|
|
|
|
// Yes, it's using the label field to store the extra data
|
|
|
|
$return['values']['dynamic_data'] = json_decode($values['label'], true);
|
|
|
|
} catch (Exception $ex) {
|
|
|
|
$return['values']['dynamic_data'] = [];
|
|
|
|
}
|
|
|
|
|
|
|
|
$values['label'] = '';
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Don't move this piece of code
|
|
|
|
$return['values']['label'] = io_safe_output($values['label']);
|
|
|
|
|
|
|
|
echo json_encode($return);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 'delete':
|
|
|
|
if (db_process_sql_delete('tlayout_data', ['id' => $id_element, 'id_layout' => $id_visual_console]) === false) {
|
|
|
|
$return['correct'] = 0;
|
|
|
|
} else {
|
|
|
|
$return['correct'] = 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
echo json_encode($return);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 'get_original_size_background':
|
|
|
|
$replace = strlen($config['homeurl'].'/');
|
|
|
|
|
|
|
|
if (substr($background, 0, $replace) == $config['homeurl'].'/') {
|
|
|
|
$size = getimagesize(substr($background, $replace));
|
|
|
|
} else {
|
|
|
|
$size = getimagesize($background);
|
|
|
|
}
|
|
|
|
|
|
|
|
echo json_encode($size);
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
enterprise_hook('enterprise_visualmap_ajax');
|
|
|
|
break;
|
2010-03-23 18:46:08 +01:00
|
|
|
}
|
2011-02-28 12:23:12 +01:00
|
|
|
|
2019-01-30 16:18:44 +01:00
|
|
|
// visual map element status check
|
2012-06-11 14:26:20 +02:00
|
|
|
if ($get_element_status) {
|
2019-01-30 16:18:44 +01:00
|
|
|
$layoutData = db_get_row_filter(
|
|
|
|
'tlayout_data',
|
|
|
|
['id' => $id_element]
|
|
|
|
);
|
|
|
|
|
|
|
|
$res = visual_map_get_status_element($layoutData);
|
|
|
|
echo $res;
|
2011-02-28 12:23:12 +01:00
|
|
|
|
2019-01-30 16:18:44 +01:00
|
|
|
return;
|
|
|
|
}
|