".__('Pandora Agents')." > ".__('Group view').""; // Update network modules for this group // Check for Network FLAG change request // Made it a subquery, much faster on both the database and server side if (isset ($_GET["update_netgroup"])) { if (give_acl ($config['id_user'], $_GET["update_netgroup"], "AW")) { $sql = sprintf ("UPDATE tagente_modulo SET `flag` = 1 WHERE `id_agente` = ANY(SELECT id_agente FROM tagente WHERE `id_grupo` = %d)",$_GET["update_netgroup"]); process_sql ($sql); } } // Get group list that user has access $groups = get_user_groups ($config['id_user']); $groups_info = array (); $total_agents = 0; $now = time (); // Prepare data to show // For each valid group for this user, take data from agent and modules foreach ($groups as $id_group => $group_name) { $sql = sprintf ("SELECT COUNT(id_agente) FROM tagente WHERE id_grupo = %d AND disabled = 0", $id_group); $agents = get_db_sql ($sql); if ($agents == 0) continue; $total_agents += $agents; $group_info = array ('agent' => $agents, 'ok' => 0, 'bad' => 0, 'alerts' => 0, 'down' => 0, 'icon' => dame_grupo_icono ($id_group), 'id_group' => $id_group, 'name' => $group_name); // SQL Join to get monitor status for agents belong this group $sql = sprintf ("SELECT tagente_estado.datos, tagente_estado.current_interval, tagente_estado.utimestamp FROM tagente, tagente_estado, tagente_modulo WHERE tagente.disabled = 0 AND tagente.id_grupo = %d AND tagente.id_agente = tagente_estado.id_agente AND tagente_estado.estado != 100 AND tagente_estado.id_agente_modulo = tagente_modulo.id_agente_modulo AND tagente_modulo.disabled = 0 AND tagente_estado.utimestamp != 0", $id_group); $result = get_db_all_rows_sql ($sql); foreach ($result as $module) { //if ($config["show_unknown"] > 0) { //this needs to be filled out somehow, but this was a serious bug. If that config var is set, it would short circuit both ok++ and bad++ returning empty for everything //} $seconds = $now - $module['utimestamp']; // Down = module/agent down (as in it didn't monitor in time) // Bad = module bad (as in it did monitor but it returned 0) if ($seconds >= ($module['current_interval'] * 2)) { $group_info["down"]++; } elseif ($module['datos'] != 0) { $group_info["ok"]++; } else { $group_info["bad"]++; } } if ($config["show_lastalerts"] == 1) { // How many alerts has been fired recently for this group: // SQL Join to get alert status for agents belong this group $sql = sprintf ("SELECT SUM(talerta_agente_modulo.times_fired) FROM tagente_modulo, talerta_agente_modulo, tagente WHERE tagente.disabled = 0 AND tagente.id_grupo = %d AND tagente.id_agente = tagente_modulo.id_agente AND talerta_agente_modulo.id_agente_modulo = tagente_modulo.id_agente_modulo", $id_group); $group_info["alerts"] = get_db_sql ($sql); } array_push ($groups_info, $group_info); } if ($total_agents == 0) { echo '
'.__('There are no defined groups').'
'; if (give_acl ($config['id_user'], 0, "LM") || give_acl ($config['id_user'], 0, "AW") || give_acl ($config['id_user'], 0, "PM") || give_acl ($config['id_user'], 0, "DM") || give_acl ($config['id_user'], 0, "UM")) { echo ' 
'; print_submit_button (__('Create group'), 'crt', false, 'class="sub next"'); echo '
'; } return; } $group_size = sizeof ($groups_info); $ancho = ceil (sqrt ($group_size + 1)); $cells_across = $ancho; if ($ancho > 5) { //If the cells would cross the line (more than 5) $over = $ancho - 5; //Calculate how much we are over $cells_across -= $over; //Take what we're over off cells_across $ancho += $over; //And add them to ancho (which holds depth) } $real_count = 0; echo ''; for ($table = 0; $table < $ancho; $table++) { if ($real_count >= $group_size) { continue; } echo ''; //foreach ($groups_info as $group) { for ($table_row = 0; $table_row < $cells_across; $table_row++) { if ($real_count >= $group_size) { continue; } $group_info = $groups_info[$real_count]; $group_name = $group_info["name"]; $icono_grupo = $group_info["icon"]; $icono_type = ""; if ($group_info["bad"] > 0) { $icono_type .= ''; } if ($group_info["ok"] > 0) { $icono_type .= ''; } // Show yellow light if there are recent alerts fired for this group if ($group_info["alerts"] > 0 ) { $icono_type .= ''; } // Show grey light if there are agent down for this group if ($group_info["down"] > 0 ) { $icono_type .= ''; } // Show red flag is group has disabled alert system if (give_disabled_group ($group_info["id_group"])) { $icono_type .= ''; } // By default green border $celda = '"; } echo "
'; // Grey border if agent down if ($config["show_unknown"] > 0) { if ($group_info["down"] > 0) $celda = ''; } // Yellow border if agents with alerts if ($group_info["alerts"] > 0) $celda = ''; // Red border if agents bad if ($group_info["bad"] > 0) $celda = ''; // Orange if alerts and down modules if (($group_info["bad"] > 0) && ($group_info["alerts"] > 0)) $celda = ''; $celda .= ''; // Add group icon $celda .= ''; // Add float info table $celda .= '
'.__('Agents').':
'.$group_info["agent"].'
'; if ($config["show_unknown"] > 0) { $celda .= ''; } if ($config["show_lastalerts"] == 1) $celda .= ''; $celda .= "
'.__('Monitors').':
'.__('Ok').': '.$group_info["ok"].'
'.__('Fail').': '.$group_info["bad"].'
'.__('Down').': '.$group_info["down"].'
'.__('Alerts').': '.$group_info["alerts"].'
"; // Render network exec module button, only when this group is writtable by user if (give_acl ($config['id_user'], $group_info["id_group"], "AW")) { $celda .= ' '; } $celda .= '

'.$icono_type.'

'.$group_name.''; echo $celda; $real_count++; } echo "
"; ?>