2012-07-06 Miguel de Dios <miguel.dedios@artica.es>
* godmode/reporting/visual_console_builder.editor.js, godmode/reporting/visual_console_builder.elements.php, include/functions_visual_map.php, include/ajax/visual_console_builder.ajax.php, include/functions_visual_map_editor.php: uploaded some fixes and changes for the visualmap, for example refactored some part of print the visualmap in operation. * include/functions_html.php: fixed when included from standarlone file from enterprise structure directory. * include/constants.php: added constants for avoid magic numbers into the code of Visualmaps. * include/graphs/functions_gd.php, include/functions.php, include/functions_io.php, include/functions_modules.php, include/functions_ui.php: cleaned source code style. git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@6747 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
parent
8bf7d40fc2
commit
a489b4800e
|
@ -1,3 +1,23 @@
|
|||
2012-07-06 Miguel de Dios <miguel.dedios@artica.es>
|
||||
|
||||
* godmode/reporting/visual_console_builder.editor.js,
|
||||
godmode/reporting/visual_console_builder.elements.php,
|
||||
include/functions_visual_map.php,
|
||||
include/ajax/visual_console_builder.ajax.php,
|
||||
include/functions_visual_map_editor.php: uploaded some fixes and
|
||||
changes for the visualmap, for example refactored some part of
|
||||
print the visualmap in operation.
|
||||
|
||||
* include/functions_html.php: fixed when included from standarlone
|
||||
file from enterprise structure directory.
|
||||
|
||||
* include/constants.php: added constants for avoid magic numbers
|
||||
into the code of Visualmaps.
|
||||
|
||||
* include/graphs/functions_gd.php, include/functions.php,
|
||||
include/functions_io.php, include/functions_modules.php,
|
||||
include/functions_ui.php: cleaned source code style.
|
||||
|
||||
2012-07-06 Sergio Martin <sergio.martin@artica.es>
|
||||
|
||||
* pandoradb.sql
|
||||
|
|
|
@ -49,7 +49,6 @@ function visual_map_main() {
|
|||
draw_lines(lines, 'background', true);
|
||||
}
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
function eventsTextAgent() {
|
||||
|
@ -681,6 +680,10 @@ function hiddenFields(item) {
|
|||
|
||||
$("#module_graph_size_row").css('display', 'none');
|
||||
$("#module_graph_size_row." + item).css('display', '');
|
||||
|
||||
if (typeof(enterprise_hiddenFields) == 'function') {
|
||||
enterprise_hiddenFields(item);
|
||||
}
|
||||
}
|
||||
|
||||
function cleanFields() {
|
||||
|
|
|
@ -45,9 +45,6 @@ foreach ($all_images as $image_file) {
|
|||
$images_list[$image_file] = $image_file;
|
||||
}
|
||||
|
||||
$layoutDataTypes = visual_map_get_layout_data_types();
|
||||
|
||||
|
||||
$table->width = '100%';
|
||||
$table->head = array ();
|
||||
$table->head['icon'] = '';
|
||||
|
|
|
@ -499,6 +499,9 @@ switch ($action) {
|
|||
|
||||
echo json_encode($size);
|
||||
break;
|
||||
default:
|
||||
enterprise_hook("enterprise_visualmap_ajax");
|
||||
break;
|
||||
}
|
||||
|
||||
/* visual map element status check */
|
||||
|
|
|
@ -131,4 +131,19 @@ define('PROCESS_VALUE_NONE', 0);
|
|||
define('PROCESS_VALUE_MIN', 1);
|
||||
define('PROCESS_VALUE_MAX', 2);
|
||||
define('PROCESS_VALUE_AVG', 3);
|
||||
//Status
|
||||
define('VISUAL_MAP_STATUS_CRITICAL_BAD', 1);
|
||||
define('VISUAL_MAP_STATUS_CRITICAL_ALERT', 4);
|
||||
define('VISUAL_MAP_STATUS_NORMAL', 0);
|
||||
define('VISUAL_MAP_STATUS_WARNING', 2);
|
||||
define('VISUAL_MAP_STATUS_UNKNOW', 3);
|
||||
|
||||
|
||||
|
||||
/* Service constants */
|
||||
//Status
|
||||
define('SERVICE_STATUS_UNKNOW', -1);
|
||||
define('SERVICE_STATUS_NORMAL', 0);
|
||||
define('SERVICE_STATUS_CRITICAL', 1);
|
||||
define('SERVICE_STATUS_WARNING', 2);
|
||||
?>
|
|
@ -136,6 +136,7 @@ function safe_url_extraclean ($string, $default_string = '') {
|
|||
*/
|
||||
function no_permission () {
|
||||
require ("config.php");
|
||||
|
||||
echo "<h3 class='error'>".__('You don\'t have access')."</h3>";
|
||||
echo html_print_image('images/noaccess.png', true, array("alt" => 'No access', "width" => '120')) . "<br /><br />";
|
||||
echo "<table width=550>";
|
||||
|
@ -144,6 +145,7 @@ function no_permission () {
|
|||
echo "</table>";
|
||||
echo "<tr><td><td><td><td>";
|
||||
include "general/footer.php";
|
||||
|
||||
exit;
|
||||
}
|
||||
|
||||
|
@ -155,6 +157,7 @@ function no_permission () {
|
|||
*/
|
||||
function unmanaged_error ($error = "") {
|
||||
require_once ("config.php");
|
||||
|
||||
echo "<h3 class='error'>".__('Unmanaged error')."</h3>";
|
||||
echo html_print_image('images/error.png', true, array("alt" => 'error')) . "<br /><br />";
|
||||
echo "<table width=550>";
|
||||
|
@ -165,6 +168,7 @@ function unmanaged_error ($error = "") {
|
|||
echo "</table>";
|
||||
echo "<tr><td><td><td><td>";
|
||||
include "general/footer.php";
|
||||
|
||||
exit;
|
||||
}
|
||||
|
||||
|
@ -656,6 +660,7 @@ function get_parameter_post ($name, $default = "") {
|
|||
*/
|
||||
function get_alert_priority ($priority = 0) {
|
||||
global $config;
|
||||
|
||||
switch ($priority) {
|
||||
case 0:
|
||||
return __('Maintenance');
|
||||
|
@ -679,6 +684,7 @@ function get_alert_priority ($priority = 0) {
|
|||
return __('Major');
|
||||
break;
|
||||
}
|
||||
|
||||
return '';
|
||||
}
|
||||
|
||||
|
@ -697,7 +703,8 @@ function get_alert_days ($row) {
|
|||
|
||||
if ($check == 7) {
|
||||
return __('All');
|
||||
} elseif ($check == 0) {
|
||||
}
|
||||
elseif ($check == 0) {
|
||||
return __('None');
|
||||
}
|
||||
|
||||
|
@ -731,14 +738,16 @@ function get_alert_days ($row) {
|
|||
* @return string A string with the concatenated values
|
||||
*/
|
||||
function get_alert_times ($row2) {
|
||||
if ($row2["time_from"]){
|
||||
if ($row2["time_from"]) {
|
||||
$time_from_table = $row2["time_from"];
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
$time_from_table = __('N/A');
|
||||
}
|
||||
if ($row2["time_to"]){
|
||||
if ($row2["time_to"]) {
|
||||
$time_to_table = $row2["time_to"];
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
$time_to_table = __('N/A');
|
||||
}
|
||||
if ($time_to_table == $time_from_table)
|
||||
|
@ -960,12 +969,12 @@ function enterprise_include ($filename) {
|
|||
global $config;
|
||||
|
||||
// Load enterprise extensions
|
||||
$filepath = realpath ($config["homedir"].'/'.ENTERPRISE_DIR.'/'.$filename);
|
||||
$filepath = realpath ($config["homedir"] . '/' . ENTERPRISE_DIR . '/' . $filename);
|
||||
|
||||
if ($filepath === false)
|
||||
return ENTERPRISE_NOT_HOOK;
|
||||
|
||||
if (strncmp ($config["homedir"], $filepath, strlen ($config["homedir"])) != 0){
|
||||
if (strncmp ($config["homedir"], $filepath, strlen ($config["homedir"])) != 0) {
|
||||
return ENTERPRISE_NOT_HOOK;
|
||||
}
|
||||
|
||||
|
|
|
@ -28,6 +28,11 @@ if (!isset($config)) {
|
|||
require_once(str_repeat("../", $i) . "config.php");
|
||||
break; // Skip config.php loading after load the first one
|
||||
}
|
||||
else if(file_exists(str_repeat("../", $i) . 'include/config.php')) {
|
||||
//For path from the enterprise structure dirs.
|
||||
require_once(str_repeat("../", $i) . "include/config.php");
|
||||
break; // Skip config.php loading after load the first one
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -153,7 +153,8 @@ function io_ascii_to_html($num) {
|
|||
|
||||
if ($num <= 15) {
|
||||
return "�".dechex($num).";";
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
return "&#x".dechex($num).";";
|
||||
}
|
||||
}
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
* @subpackage UI
|
||||
*/
|
||||
|
||||
require_once($config['homedir'].'/include/functions_agents.php');
|
||||
require_once($config['homedir'] . '/include/functions_agents.php');
|
||||
require_once($config['homedir'] . '/include/functions_modules.php');
|
||||
require_once($config['homedir'] . '/include/functions.php');
|
||||
require_once($config['homedir'] . '/include/functions_groups.php');
|
||||
|
|
|
@ -71,23 +71,23 @@ function visual_map_print_item($layoutData) {
|
|||
|
||||
$status = visual_map_get_status_element($layoutData);
|
||||
switch ($status) {
|
||||
case 1:
|
||||
case VISUAL_MAP_STATUS_CRITICAL_BAD:
|
||||
//Critical (BAD)
|
||||
$colorStatus = "#ff0000";
|
||||
break;
|
||||
case 4:
|
||||
case VISUAL_MAP_STATUS_CRITICAL_ALERT:
|
||||
//Critical (ALERT)
|
||||
$colorStatus = "#ff8800";
|
||||
break;
|
||||
case 0:
|
||||
case VISUAL_MAP_STATUS_NORMAL:
|
||||
//Normal (OK)
|
||||
$colorStatus = "#00ff00";
|
||||
break;
|
||||
case 2:
|
||||
case VISUAL_MAP_STATUS_WARNING:
|
||||
//Warning
|
||||
$colorStatus = "#ffff00";
|
||||
break;
|
||||
case 3:
|
||||
case VISUAL_MAP_STATUS_UNKNOW:
|
||||
default:
|
||||
//Unknown
|
||||
// Default is Blue (Other)
|
||||
|
@ -716,17 +716,17 @@ function visual_map_get_status_element($layoutData) {
|
|||
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;
|
||||
$status = VISUAL_MAP_STATUS_UNKNOW;
|
||||
}
|
||||
else {
|
||||
$status = 3;
|
||||
$status = VISUAL_MAP_STATUS_UNKNOW;
|
||||
$id_agent = 0;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
//If it's a graph, a progress bar or a data tag, ALWAYS report status OK
|
||||
//(=0) to avoid confussions here.
|
||||
$status = 0;
|
||||
$status = VISUAL_MAP_STATUS_NORMAL;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -742,6 +742,8 @@ function visual_map_get_status_element($layoutData) {
|
|||
* @param bool $draw_lines
|
||||
*/
|
||||
function visual_map_print_visual_map ($id_layout, $show_links = true, $draw_lines = true, $width = null, $height = null, $home_url = '') {
|
||||
enterprise_include_once('include/functions_visual_map.php');
|
||||
|
||||
//TODO: USE THE SAME CODE THAT THE VISUAL MAP EDITOR
|
||||
global $config;
|
||||
|
||||
|
@ -773,45 +775,51 @@ function visual_map_print_visual_map ($id_layout, $show_links = true, $draw_line
|
|||
style="z-index: 0; position:relative; width:'.$mapWidth.'px; height:'.$mapHeight.'px;">';
|
||||
echo "<img src='" . $backgroundImage . "' width='100%' height='100%' />";
|
||||
$layout_datas = db_get_all_rows_field_filter ('tlayout_data', 'id_layout', $id_layout);
|
||||
if (empty($layout_datas))
|
||||
$layout_datas = array();
|
||||
$lines = array ();
|
||||
|
||||
if ($layout_datas !== false) {
|
||||
foreach ($layout_datas as $layout_data) {
|
||||
switch ($layout_data['type']) {
|
||||
case STATIC_GRAPH:
|
||||
case PERCENTILE_BAR:
|
||||
case MODULE_GRAPH:
|
||||
case SIMPLE_VALUE:
|
||||
case SIMPLE_VALUE_MAX:
|
||||
case SIMPLE_VALUE_MIN:
|
||||
case SIMPLE_VALUE_AVG:
|
||||
case PERCENTILE_BUBBLE:
|
||||
// Pending delete and disable modules must be ignored
|
||||
$delete_pending_module = db_get_value ("delete_pending",
|
||||
"tagente_modulo", "id_agente_modulo",
|
||||
$layout_data["id_agente_modulo"]);
|
||||
$disabled_module = db_get_value ("disabled", "tagente_modulo",
|
||||
"id_agente_modulo", $layout_data["id_agente_modulo"]);
|
||||
|
||||
if ($delete_pending_module == 1 || $disabled_module == 1)
|
||||
continue;
|
||||
break;
|
||||
case SERVICE:
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
$id_agent = 0;
|
||||
$layout_data['label'] = io_safe_output($layout_data['label']);
|
||||
// ****************************************************************
|
||||
// Get parent status (Could be an agent, module, map, others doesnt have parent info)
|
||||
// ****************************************************************
|
||||
|
||||
// Pending delete and disable modules must be ignored
|
||||
$delete_pending_module = db_get_value ("delete_pending", "tagente_modulo", "id_agente_modulo", $layout_data["id_agente_modulo"]);
|
||||
$disabled_module = db_get_value ("disabled", "tagente_modulo", "id_agente_modulo", $layout_data["id_agente_modulo"]);
|
||||
// *************************************************************
|
||||
// Get parent status (Could be an agent, module, map,
|
||||
// others doesnt have parent info)
|
||||
// **************************************************************
|
||||
|
||||
if($delete_pending_module == 1 || $disabled_module == 1)
|
||||
continue;
|
||||
|
||||
if ($layout_data["parent_item"] != 0){
|
||||
if ($layout_data["parent_item"] != 0) {
|
||||
$id_agent_module_parent = db_get_value ("id_agente_modulo", "tlayout_data", "id", $layout_data["parent_item"]);
|
||||
$id_agent_parent = db_get_value ("id_agent", "tlayout_data", "id", $layout_data["parent_item"]);
|
||||
$id_layout_linked = db_get_value ("id_layout_linked", "tlayout_data", "id", $layout_data["parent_item"]);
|
||||
|
||||
// Module
|
||||
if ($id_agent_module_parent != 0) {
|
||||
$status_parent = modules_get_agentmodule_status ($id_agent_module_parent);
|
||||
// Agent
|
||||
}
|
||||
elseif ($id_agent_parent != 0) {
|
||||
$status_parent = agents_get_status ($id_agent_parent);
|
||||
}
|
||||
// Another layout/map
|
||||
elseif ($id_layout_linked != 0) {
|
||||
$status_parent = visual_map_get_layout_status ($id_layout_linked);
|
||||
}
|
||||
|
||||
else {
|
||||
$status_parent = 3;
|
||||
}
|
||||
$layout_data_parent = db_get_row_filter('tlayout_data',
|
||||
array('id' => $layout_data["parent_item"]));
|
||||
|
||||
$status_parent = visual_map_get_status_element($layout_data_parent);
|
||||
}
|
||||
else {
|
||||
$id_agent_module_parent = 0;
|
||||
|
@ -822,55 +830,44 @@ function visual_map_print_visual_map ($id_layout, $show_links = true, $draw_line
|
|||
// ****************************************************************
|
||||
// Get STATUS of current object
|
||||
// ****************************************************************
|
||||
$status = visual_map_get_status_element($layout_data);
|
||||
|
||||
// Linked to other layout ?? - Only if not module defined
|
||||
if ($layout_data['id_layout_linked'] != 0) {
|
||||
$status = visual_map_get_layout_status ($layout_data['id_layout_linked']);
|
||||
|
||||
// Single object
|
||||
}
|
||||
elseif (($layout_data["type"] == 0)
|
||||
|| ($layout_data["type"] == 3)
|
||||
|| ($layout_data["type"] == 9)
|
||||
|| ($layout_data["type"] == 4)) {
|
||||
// Status for a simple module
|
||||
if ($layout_data['id_agente_modulo'] != 0) {
|
||||
$status = modules_get_agentmodule_status ($layout_data['id_agente_modulo']);
|
||||
$id_agent = db_get_value ("id_agente", "tagente_estado", "id_agente_modulo", $layout_data['id_agente_modulo']);
|
||||
|
||||
// Status for a whole agent, if agente_modulo was == 0
|
||||
}
|
||||
elseif ($layout_data['id_agent'] != 0) {
|
||||
$status = agents_get_status ($layout_data["id_agent"]);
|
||||
if ($status == -1) // agents_get_status return -1 for unknown!
|
||||
$status = 3;
|
||||
$id_agent = $layout_data["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 = "#ff0000";
|
||||
break;
|
||||
case VISUAL_MAP_STATUS_CRITICAL_ALERT:
|
||||
//Critical (ALERT)
|
||||
$colorStatus = "#ff8800";
|
||||
break;
|
||||
case VISUAL_MAP_STATUS_NORMAL:
|
||||
//Normal (OK)
|
||||
$colorStatus = "#00ff00";
|
||||
break;
|
||||
case VISUAL_MAP_STATUS_WARNING:
|
||||
//Warning
|
||||
$colorStatus = "#ffff00";
|
||||
break;
|
||||
case VISUAL_MAP_STATUS_UNKNOW:
|
||||
default:
|
||||
//Unknown
|
||||
$colorStatus = "#5A5AFF";
|
||||
// Default is Grey (Other)
|
||||
break;
|
||||
}
|
||||
|
||||
// ****************************************************************
|
||||
// STATIC IMAGE (type = 0)
|
||||
// ****************************************************************
|
||||
if ($layout_data['type'] == 0) {
|
||||
// Link image
|
||||
//index.php?sec=estado&sec2=operation/agentes/ver_agente&id_agente=1
|
||||
if ($status == 0) // Bad monitor
|
||||
switch ($layout_data['type']) {
|
||||
case STATIC_GRAPH:
|
||||
if ($status == VISUAL_MAP_STATUS_CRITICAL_BAD)
|
||||
$z_index = 3;
|
||||
elseif ($status == 2) // Warning
|
||||
elseif ($status == VISUAL_MAP_STATUS_WARNING)
|
||||
$z_index = 2;
|
||||
elseif ($status == 4) // Alert
|
||||
elseif ($status == VISUAL_MAP_STATUS_CRITICAL_ALERT)
|
||||
$z_index = 4;
|
||||
else
|
||||
$z_index = 1; // Print BAD over good
|
||||
$z_index = 1;
|
||||
|
||||
// Draw image
|
||||
if ($resizedMap)
|
||||
|
@ -878,10 +875,8 @@ function visual_map_print_visual_map ($id_layout, $show_links = true, $draw_line
|
|||
else
|
||||
echo '<div style="left: 0px; top: 0px; text-align: center; z-index: '.$z_index.'; '.($layout_data['label_color'][0] == '#' ? 'color: '.$layout_data['label_color'].';' : '').' position: absolute; margin-left: '.$layout_data['pos_x'].'px; margin-top:'.$layout_data['pos_y'].'px;" id="layout-data-'.$layout_data['id'].'" class="layout-data">';
|
||||
|
||||
if (!isset ($id_agent))
|
||||
$id_agent = 0;
|
||||
|
||||
if ($show_links) {
|
||||
if (!isset($id_agent)) $id_agent = 0;
|
||||
if (($id_agent > 0) && ($layout_data['id_layout_linked'] == "" || $layout_data['id_layout_linked'] == 0)) {
|
||||
|
||||
//Extract id service if it is a prediction module.
|
||||
|
@ -915,7 +910,6 @@ function visual_map_print_visual_map ($id_layout, $show_links = true, $draw_line
|
|||
echo '<a href="#">';
|
||||
}
|
||||
}
|
||||
|
||||
$img_style = array ();
|
||||
$img_style["title"] = $layout_data["label"];
|
||||
|
||||
|
@ -927,30 +921,27 @@ function visual_map_print_visual_map ($id_layout, $show_links = true, $draw_line
|
|||
}
|
||||
|
||||
$img = "images/console/icons/".$layout_data["image"];
|
||||
|
||||
switch ($status) {
|
||||
case 1:
|
||||
//Critical (BAD)
|
||||
case VISUAL_MAP_STATUS_CRITICAL_BAD:
|
||||
$img .= "_bad.png";
|
||||
break;
|
||||
case 4:
|
||||
//Critical (ALERT)
|
||||
case VISUAL_MAP_STATUS_CRITICAL_ALERT:
|
||||
$img = "4".$img."_bad.png";
|
||||
break;
|
||||
case 0:
|
||||
//Normal (OK)
|
||||
case VISUAL_MAP_STATUS_NORMAL:
|
||||
$img .= "_ok.png";
|
||||
break;
|
||||
case 2:
|
||||
//Warning
|
||||
case VISUAL_MAP_STATUS_WARNING:
|
||||
$img .= "_warning.png";
|
||||
break;
|
||||
case 3:
|
||||
//Unknown
|
||||
case VISUAL_MAP_STATUS_UNKNOW:
|
||||
default:
|
||||
$img .= ".png";
|
||||
// Default is Grey (Other)
|
||||
$img .= ".png";
|
||||
break;
|
||||
}
|
||||
|
||||
$borderStyle = '';
|
||||
if(substr($img,0,1) == '4') {
|
||||
$img_style['border'] ='2px solid #ffa300;';
|
||||
|
@ -980,21 +971,22 @@ function visual_map_print_visual_map ($id_layout, $show_links = true, $draw_line
|
|||
|
||||
html_print_image ($img, false, $img_style);
|
||||
|
||||
echo "</a>";
|
||||
|
||||
// Print label if valid label_color (only testing for starting with #) otherwise print nothing
|
||||
if ($layout_data['label_color'][0] == '#') {
|
||||
echo "<br />";
|
||||
echo $layout_data['label'];
|
||||
}
|
||||
echo "</div>";
|
||||
}
|
||||
|
||||
switch ($layout_data['type']) {
|
||||
case 4:
|
||||
// ****************************************************************
|
||||
// LABEL (type = 4)
|
||||
// ****************************************************************
|
||||
echo "</a>";
|
||||
break;
|
||||
case PERCENTILE_BAR:
|
||||
break;
|
||||
case MODULE_GRAPH:
|
||||
break;
|
||||
case SIMPLE_VALUE:
|
||||
break;
|
||||
case LABEL:
|
||||
$z_index = 4;
|
||||
if ($resizedMap)
|
||||
echo '<div style="left: 0px; top: 0px; text-align: center; z-index: '.$z_index.'; '.($layout_data['label_color'][0] == '#' ? 'color: '.$layout_data['label_color'].';' : '').' position: absolute; margin-left: '.((integer)($proportion * $layout_data['pos_x'])).'px; margin-top:'.((integer)($proportion * $layout_data['pos_y'])).'px;" id="layout-data-'.$layout_data['id'].'" class="layout-data">';
|
||||
|
@ -1022,10 +1014,7 @@ function visual_map_print_visual_map ($id_layout, $show_links = true, $draw_line
|
|||
if ($endTagA) echo "</a>";
|
||||
echo "</div>";
|
||||
break;
|
||||
case 5:
|
||||
// ****************************************************************
|
||||
// ICON (type = 5)
|
||||
// ****************************************************************
|
||||
case ICON:
|
||||
$z_index = 4;
|
||||
if ($resizedMap)
|
||||
echo '<div style="left: 0px; top: 0px; text-align: center; z-index: '.$z_index.'; '.($layout_data['label_color'][0] == '#' ? 'color: '.$layout_data['label_color'].';' : '').' position: absolute; margin-left: '.((integer)($proportion * $layout_data['pos_x'])).'px; margin-top:'.((integer)($proportion * $layout_data['pos_y'])).'px;" id="layout-data-'.$layout_data['id'].'" class="layout-data">';
|
||||
|
@ -1091,13 +1080,10 @@ function visual_map_print_visual_map ($id_layout, $show_links = true, $draw_line
|
|||
|
||||
echo "</div>";
|
||||
break;
|
||||
case 2:
|
||||
case 6:
|
||||
case 7:
|
||||
case 8:
|
||||
// ****************************************************************
|
||||
// SIMPLE DATA VALUE (type = 2)
|
||||
// ****************************************************************
|
||||
case SIMPLE_VALUE:
|
||||
case SIMPLE_VALUE_MAX:
|
||||
case SIMPLE_VALUE_MIN:
|
||||
case SIMPLE_VALUE_AVG:
|
||||
$unit_text = db_get_sql ('SELECT unit FROM tagente_modulo WHERE id_agente_modulo = ' . $layout_data['id_agente_modulo']);
|
||||
$unit_text = trim(io_safe_output($unit_text));
|
||||
|
||||
|
@ -1136,14 +1122,14 @@ function visual_map_print_visual_map ($id_layout, $show_links = true, $draw_line
|
|||
echo '<strong>'.$layout_data['label']. ' ';
|
||||
//TODO: change interface to add a period parameter, now is set to 1 day
|
||||
switch ($layout_data['type']) {
|
||||
case 2:
|
||||
case SIMPLE_VALUE:
|
||||
$value = db_get_value ('datos', 'tagente_estado', 'id_agente_modulo', $layout_data['id_agente_modulo']);
|
||||
$value = format_for_graph($value, 2);
|
||||
if (!empty($unit_text))
|
||||
$value .= " " . $unit_text;
|
||||
echo $value;
|
||||
break;
|
||||
case 6:
|
||||
case SIMPLE_VALUE_MAX:
|
||||
$value = reporting_get_agentmodule_data_max ($layout_data['id_agente_modulo'], $layout_data['period'], 0);
|
||||
if ($value === false) {
|
||||
$value = __('Unknown');
|
||||
|
@ -1155,7 +1141,7 @@ function visual_map_print_visual_map ($id_layout, $show_links = true, $draw_line
|
|||
}
|
||||
echo $value;
|
||||
break;
|
||||
case 7:
|
||||
case SIMPLE_VALUE_MIN:
|
||||
$value = reporting_get_agentmodule_data_min ($layout_data['id_agente_modulo'], $layout_data['period'], 0);
|
||||
if ($value === false) {
|
||||
$value = __('Unknown');
|
||||
|
@ -1167,7 +1153,7 @@ function visual_map_print_visual_map ($id_layout, $show_links = true, $draw_line
|
|||
}
|
||||
echo $value;
|
||||
break;
|
||||
case 8:
|
||||
case SIMPLE_VALUE_AVG:
|
||||
$value = reporting_get_agentmodule_data_average($layout_data['id_agente_modulo'], $layout_data['period'], 0);
|
||||
if ($value === false) {
|
||||
$value = __('Unknown');
|
||||
|
@ -1186,40 +1172,8 @@ function visual_map_print_visual_map ($id_layout, $show_links = true, $draw_line
|
|||
|
||||
echo '</div>';
|
||||
break;
|
||||
case 3:
|
||||
// ****************************************************************
|
||||
// Progress bar
|
||||
// ****************************************************************
|
||||
case 9:
|
||||
// ****************************************************************
|
||||
// Progress bubble
|
||||
// ****************************************************************
|
||||
|
||||
switch ($status) {
|
||||
case 1:
|
||||
//Critical (BAD)
|
||||
$colorStatus = "#ff0000";
|
||||
break;
|
||||
case 4:
|
||||
//Critical (ALERT)
|
||||
$colorStatus = "#ff8800";
|
||||
break;
|
||||
case 0:
|
||||
//Normal (OK)
|
||||
$colorStatus = "#00ff00";
|
||||
break;
|
||||
case 2:
|
||||
//Warning
|
||||
$colorStatus = "#ffff00";
|
||||
break;
|
||||
case 3:
|
||||
//Unknown
|
||||
default:
|
||||
$colorStatus = "#5A5AFF";
|
||||
// Default is Grey (Other)
|
||||
break;
|
||||
}
|
||||
|
||||
case PERCENTILE_BAR:
|
||||
case PERCENTILE_BUBBLE:
|
||||
if ($resizedMap)
|
||||
echo '<div style="left: 0px; top: 0px; text-align: center; z-index: 1; color: '.$layout_data['label_color'].'; position: absolute; margin-left: '.((integer)($proportion *$layout_data['pos_x'])).'px; margin-top:'.((integer)($proportion *$layout_data['pos_y'])).'px;" id="layout-data-'.$layout_data['id'].'" class="layout-data">';
|
||||
else
|
||||
|
@ -1307,12 +1261,7 @@ function visual_map_print_visual_map ($id_layout, $show_links = true, $draw_line
|
|||
|
||||
echo '</div>';
|
||||
break;
|
||||
case 1;
|
||||
// ****************************************************************
|
||||
// Single module graph
|
||||
// ****************************************************************
|
||||
// SINGLE GRAPH (type = 1)
|
||||
|
||||
case MODULE_GRAPH:
|
||||
if ($resizedMap) {
|
||||
$layout_data['width'] = ((integer)($proportion * $layout_data['width']));
|
||||
$layout_data['height'] = ((integer)($proportion * $layout_data['height']));
|
||||
|
@ -1363,6 +1312,10 @@ function visual_map_print_visual_map ($id_layout, $show_links = true, $draw_line
|
|||
echo "</a>";
|
||||
echo "</div>";
|
||||
break;
|
||||
default:
|
||||
enterprise_hook("enterprise_visual_map_print_item",
|
||||
array($layout_data, $status, $colorStatus));
|
||||
break;
|
||||
}
|
||||
|
||||
// ****************************************************************
|
||||
|
@ -1375,24 +1328,23 @@ function visual_map_print_visual_map ($id_layout, $show_links = true, $draw_line
|
|||
$line['node_end'] = 'layout-data-'.$layout_data["id"];
|
||||
switch ($status_parent) {
|
||||
default:
|
||||
case 3:
|
||||
case VISUAL_MAP_STATUS_UNKNOW:
|
||||
$line["color"] = "#ccc"; // Gray
|
||||
break;
|
||||
case 2:
|
||||
case VISUAL_MAP_STATUS_WARNING:
|
||||
$line["color"] = "#20f6f6"; // Yellow
|
||||
break;
|
||||
case 0:
|
||||
case VISUAL_MAP_STATUS_NORMAL:
|
||||
$line["color"] = "#00ff00"; // Green
|
||||
break;
|
||||
case 4:
|
||||
case 1:
|
||||
case VISUAL_MAP_STATUS_CRITICAL_ALERT:
|
||||
case VISUAL_MAP_STATUS_CRITICAL_BAD:
|
||||
$line["color"] = "#ff0000"; // Red
|
||||
break;
|
||||
}
|
||||
array_push ($lines, $line);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($draw_lines) {
|
||||
/* If you want lines in the map, call using Javascript:
|
||||
|
@ -1411,19 +1363,6 @@ function visual_map_print_visual_map ($id_layout, $show_links = true, $draw_line
|
|||
echo "</div>";
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array Layout data types
|
||||
*/
|
||||
function visual_map_get_layout_data_types () {
|
||||
$types = array ();
|
||||
$types[0] = __('Static graph');
|
||||
$types[1] = __('Module graph');
|
||||
$types[2] = __('Simple value');
|
||||
$types[3] = __('Percentile bar');
|
||||
|
||||
return $types;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a list with the layouts for a user.
|
||||
*
|
||||
|
@ -1473,7 +1412,6 @@ function visual_map_get_user_layouts ($id_user = 0, $only_names = false, $filter
|
|||
return $retval;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the status of a layout.
|
||||
*
|
||||
|
@ -1487,13 +1425,13 @@ function visual_map_get_user_layouts ($id_user = 0, $only_names = false, $filter
|
|||
* @return bool The status of the given layout. True if it's OK, false if not.
|
||||
*/
|
||||
function visual_map_get_layout_status ($id_layout = 0, $depth = 0) {
|
||||
$temp_status = 0;
|
||||
$temp_total = 0;
|
||||
$temp_status = VISUAL_MAP_STATUS_NORMAL;
|
||||
$temp_total = VISUAL_MAP_STATUS_NORMAL;
|
||||
$depth++; // For recursion depth checking
|
||||
|
||||
// TODO: Implement this limit as a configurable item in setup
|
||||
if ($depth > 10) {
|
||||
return 3; // No status data if we need to exit by a excesive recursion
|
||||
return VISUAL_MAP_STATUS_UNKNOW; // No status data if we need to exit by a excesive recursion
|
||||
}
|
||||
|
||||
$id_layout = (int) $id_layout;
|
||||
|
@ -1501,7 +1439,7 @@ function visual_map_get_layout_status ($id_layout = 0, $depth = 0) {
|
|||
$result = db_get_all_rows_filter ('tlayout_data', array ('id_layout' => $id_layout),
|
||||
array ('id_agente_modulo', 'parent_item', 'id_layout_linked', 'id_agent', 'type'));
|
||||
if ($result === false)
|
||||
return 0;
|
||||
return VISUAL_MAP_STATUS_NORMAL;
|
||||
|
||||
foreach ($result as $rownum => $data) {
|
||||
if (($data["id_layout_linked"] == 0 && $data["id_agente_modulo"] == 0 && $data["id_agent"] == 0) || $data['type'] != 0)
|
||||
|
@ -1519,8 +1457,8 @@ function visual_map_get_layout_status ($id_layout = 0, $depth = 0) {
|
|||
else {
|
||||
$status = agents_get_status ($data["id_agent"]);
|
||||
}
|
||||
if ($status == 1)
|
||||
return 1;
|
||||
if ($status == VISUAL_MAP_STATUS_CRITICAL_BAD)
|
||||
return VISUAL_MAP_STATUS_CRITICAL_BAD;
|
||||
if ($status > $temp_total)
|
||||
$temp_total = $status;
|
||||
}
|
||||
|
|
|
@ -43,7 +43,7 @@ function visual_map_editor_print_item_palette($visualConsole_id, $background) {
|
|||
|
||||
|
||||
echo '<div id="properties_panel" style="display: none; position: absolute; border: 2px solid #114105; padding: 5px; background: white; z-index: 90;">';
|
||||
//----------------------------Hiden Form----------------------------------------
|
||||
//----------------------------Hiden Form----------------------------
|
||||
?>
|
||||
<table class="databox" border="0" cellpadding="4" cellspacing="4" width="300">
|
||||
<caption>
|
||||
|
|
|
@ -12,13 +12,14 @@
|
|||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU Lesser General Public License for more details.
|
||||
|
||||
// If is called from index
|
||||
if(file_exists('include/functions.php')) {
|
||||
if (file_exists('include/functions.php')) {
|
||||
// If is called from index
|
||||
include_once('include/functions.php');
|
||||
include_once('include/functions_html.php');
|
||||
include_once('include/graphs/functions_utils.php');
|
||||
} // If is called through url
|
||||
else if(file_exists('../functions.php')) {
|
||||
}
|
||||
else if (file_exists('../functions.php')) {
|
||||
// If is called through url
|
||||
include_once('../functions.php');
|
||||
include_once('../functions_html.php');
|
||||
include_once('functions_utils.php');
|
||||
|
@ -45,7 +46,7 @@ if($id_graph && in_array($graph_type, $types)) {
|
|||
$graph['fontsize'] = 6;
|
||||
}
|
||||
|
||||
switch($graph_type) {
|
||||
switch ($graph_type) {
|
||||
case 'histogram':
|
||||
gd_histogram ($graph['width'],
|
||||
$graph['height'],
|
||||
|
@ -105,7 +106,8 @@ function gd_histogram ($width, $height, $mode, $data, $max_value, $font, $title,
|
|||
|
||||
if ($mode != 2) {
|
||||
$size_per = ($max_value / ($width-40));
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
$size_per = ($max_value / ($width));
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue