Fixed the slow visualmaps (and maybe in other places) with a item group
This commit is contained in:
parent
c1760a345d
commit
537df06e5e
|
@ -71,6 +71,11 @@ echo "<div id='background_grid'
|
|||
|
||||
//Print the layout datas from the DB.
|
||||
foreach ($layoutDatas as $layoutData) {
|
||||
|
||||
$layoutData['status_calculated'] =
|
||||
visual_map_get_status_element($layoutData);
|
||||
|
||||
|
||||
// Pending delete and disable modules must be ignored
|
||||
$delete_pending_module = db_get_value ("delete_pending",
|
||||
"tagente_modulo", "id_agente_modulo", $layoutData["id_agente_modulo"]);
|
||||
|
@ -80,8 +85,12 @@ foreach ($layoutDatas as $layoutData) {
|
|||
if ($delete_pending_module == 1 || $disabled_module == 1)
|
||||
continue;
|
||||
|
||||
|
||||
visual_map_print_item($layoutData);
|
||||
html_print_input_hidden('status_' . $layoutData['id'], visual_map_get_status_element($layoutData));
|
||||
|
||||
|
||||
html_print_input_hidden('status_' . $layoutData['id'], $layoutData['status_calculated']);
|
||||
|
||||
}
|
||||
|
||||
echo "<img style='position: absolute; top: 0px; left: 0px;' id='background_img' src='" . $metaconsole_hack . "images/console/background/" . $background . "' width='100%' height='100%' />";
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
// GNU General Public License for more details.
|
||||
|
||||
require_once ($config['homedir'].'/include/functions_users.php');
|
||||
require_once ($config['homedir'].'/include/functions_reporting.php');
|
||||
|
||||
/**
|
||||
* Check if the group is in use in the Pandora DB.
|
||||
|
@ -531,30 +532,18 @@ function groups_get_groups_tree_recursive($groups, $trash = 0, $trash2 = 0) {
|
|||
* @return int Status of the agents.
|
||||
*/
|
||||
function groups_get_status ($id_group = 0) {
|
||||
$agents = agents_get_group_agents($id_group);
|
||||
$data = reporting_get_group_stats($id_group);
|
||||
|
||||
$agents_status = array();
|
||||
foreach ($agents as $key => $agent) {
|
||||
$agents_status[] = agents_get_status($key);
|
||||
}
|
||||
|
||||
$childrens = groups_get_childrens($id_group);
|
||||
|
||||
foreach ($childrens as $key => $child) {
|
||||
$agents_status[] = groups_get_status($key);
|
||||
}
|
||||
|
||||
// Status is 0 for normal, 1 for critical, 2 for warning and 3/-1 for unknown. 4 for fired alerts
|
||||
if (is_int(array_search(AGENT_STATUS_ALERT_FIRED, $agents_status))) {
|
||||
if ($data['monitor_alerts_fired'] > 0) {
|
||||
return AGENT_STATUS_ALERT_FIRED;
|
||||
}
|
||||
elseif (is_int(array_search(AGENT_STATUS_CRITICAL, $agents_status))) {
|
||||
elseif ($data['agent_critical'] > 0) {
|
||||
return AGENT_STATUS_CRITICAL;
|
||||
}
|
||||
elseif (is_int(array_search(AGENT_STATUS_WARNING, $agents_status))) {
|
||||
elseif ($data['agent_warning'] > 0) {
|
||||
return AGENT_STATUS_WARNING;
|
||||
}
|
||||
elseif (is_int(array_search(AGENT_STATUS_UNKNOWN, $agents_status))) {
|
||||
elseif ($data['agent_unknown'] > 0) {
|
||||
return AGENT_STATUS_UNKNOWN;
|
||||
}
|
||||
else {
|
||||
|
@ -869,11 +858,12 @@ function groups_get_group_row($id_group, $group_all, $group, &$printed_groups) {
|
|||
// Get stats for this group
|
||||
$data = reporting_get_group_stats($id_group);
|
||||
|
||||
|
||||
if ($data["total_agents"] == 0) {
|
||||
if (!empty($group['childs'])) {
|
||||
$group_childrens = groups_get_childrens($id_group, null, true);
|
||||
$group_childrens_agents = groups_total_agents(array_keys($group_childrens));
|
||||
|
||||
|
||||
if (empty($group_childrens_agents)) {
|
||||
return; // Skip empty groups
|
||||
}
|
||||
|
|
|
@ -70,7 +70,7 @@ function visual_map_print_item($layoutData) {
|
|||
|
||||
$text = '<span id="text_' . $id . '" class="text">' . $label . '</span>';
|
||||
|
||||
$status = visual_map_get_status_element($layoutData);
|
||||
$status = $layoutData['status_calculated'];
|
||||
|
||||
switch ($status) {
|
||||
case VISUAL_MAP_STATUS_CRITICAL_BAD:
|
||||
|
@ -100,7 +100,8 @@ function visual_map_print_item($layoutData) {
|
|||
switch ($type) {
|
||||
case STATIC_GRAPH:
|
||||
if ($layoutData['image'] != null) {
|
||||
$img = visual_map_get_image_status_element($layoutData);
|
||||
$img = visual_map_get_image_status_element($layoutData,
|
||||
$layoutData['status_calculated']);
|
||||
if (substr($img,0,1) == '4') {
|
||||
$borderStyle ='border: 2px solid ' . COL_ALERTFIRED . ';';
|
||||
$img = substr_replace($img, '', 0,1);
|
||||
|
@ -127,7 +128,8 @@ function visual_map_print_item($layoutData) {
|
|||
|
||||
case GROUP_ITEM:
|
||||
if ($layoutData['image'] != null) {
|
||||
$img = visual_map_get_image_status_element($layoutData);
|
||||
$img = visual_map_get_image_status_element($layoutData,
|
||||
$layoutData['status_calculated']);
|
||||
if (substr($img,0,1) == '4') {
|
||||
$borderStyle ='border: 2px solid ' . COL_ALERTFIRED . ';';
|
||||
$img = substr_replace($img, '', 0,1);
|
||||
|
@ -294,7 +296,8 @@ function visual_map_print_item($layoutData) {
|
|||
break;
|
||||
case ICON:
|
||||
if ($layoutData['image'] != null) {
|
||||
$img = visual_map_get_image_status_element($layoutData);
|
||||
$img = visual_map_get_image_status_element($layoutData,
|
||||
$layoutData['status_calculated']);
|
||||
}
|
||||
|
||||
if (($width != 0) && ($height != 0)) {
|
||||
|
@ -869,7 +872,7 @@ function visual_map_get_color_line_status($layoutData) {
|
|||
*
|
||||
* @return string The image with the relative path to pandora console directory.
|
||||
*/
|
||||
function visual_map_get_image_status_element($layoutData) {
|
||||
function visual_map_get_image_status_element($layoutData, $status = false) {
|
||||
$img = "images/console/icons/" . $layoutData["image"];
|
||||
|
||||
if ($layoutData['type'] == 5) {
|
||||
|
@ -877,7 +880,11 @@ function visual_map_get_image_status_element($layoutData) {
|
|||
$img .= ".png";
|
||||
}
|
||||
else {
|
||||
switch (visual_map_get_status_element($layoutData)) {
|
||||
if ($status === false) {
|
||||
$status = visual_map_get_status_element($layoutData);
|
||||
}
|
||||
|
||||
switch ($status) {
|
||||
case 1:
|
||||
//Critical (BAD)
|
||||
$img .= "_bad.png";
|
||||
|
|
Loading…
Reference in New Issue