pandorafms/pandora_console/operation/agentes/estado_grupo.php

268 lines
8.8 KiB
PHP
Raw Normal View History

<?php
2008-04-01 Sancho Lerena <slerena@gmail.com> * pandoradb_data.sql: Alert type 0 is not 1. 1-3 are reserved. Removed prediction module (nosense since it uses normal modules). * include/functions_db.php: Added wrapper give_db_value to get_db_value because A LOT of code uses old syntax and this makes too many errors. * include/functions.php: Fixed pagination issues with blocksize config. * pandoradb.sql: Change alert command lenght and added some comments for future implementation of alert criticity and others. * operation/incidents/incident.php: Fixed some bugs calling to old funcions / variables. * operation/events/events.php: Fixed some bugs calling to old funcions / variables. Removed graph and simplified header. * operation/agentes/estado_alertas.php: Changed get_db_value call and removed (Raul) button to create alert from here. * operation/agentes/estado_grupo.php: Implemented support for optional view of down modules and fired alerts. * operation/agentes/ver_agente.php, operation/agentes/datos_agente.php: Uses of new get_db_value and new session id variable. * images/mod_async_string.png: Added image. * images/mod_async_inc.png: Added image. * images/mod_image_png.png: Added image. * images/mod_async_data.png: Added image. * images/mod_async_proc.png: Added image. * images/mod_image_jpg.png: Added image. * godmode/setup/setup.php: Several fixes. * godmode/agentes/alert_manager.php: Several changes for new alert manager. Not finished. Interim commit. * godmode/agentes/configurar_agente.php: More changes needed to alert editor. * godmode/agentes/alert_manager_editor.php: New file for alert management. * godmode/modules/module_list.php: Some updates, removed invalid column. * godmode/alerts/modify_alert.php: Alert types < 4 cannot be modified (this includes combined, internal audit and Pandora FMS log). git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@783 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2008-04-01 15:53:11 +02:00
// Pandora FMS - the Free Monitoring System
// ========================================
2008-04-01 Sancho Lerena <slerena@gmail.com> * pandoradb_data.sql: Alert type 0 is not 1. 1-3 are reserved. Removed prediction module (nosense since it uses normal modules). * include/functions_db.php: Added wrapper give_db_value to get_db_value because A LOT of code uses old syntax and this makes too many errors. * include/functions.php: Fixed pagination issues with blocksize config. * pandoradb.sql: Change alert command lenght and added some comments for future implementation of alert criticity and others. * operation/incidents/incident.php: Fixed some bugs calling to old funcions / variables. * operation/events/events.php: Fixed some bugs calling to old funcions / variables. Removed graph and simplified header. * operation/agentes/estado_alertas.php: Changed get_db_value call and removed (Raul) button to create alert from here. * operation/agentes/estado_grupo.php: Implemented support for optional view of down modules and fired alerts. * operation/agentes/ver_agente.php, operation/agentes/datos_agente.php: Uses of new get_db_value and new session id variable. * images/mod_async_string.png: Added image. * images/mod_async_inc.png: Added image. * images/mod_image_png.png: Added image. * images/mod_async_data.png: Added image. * images/mod_async_proc.png: Added image. * images/mod_image_jpg.png: Added image. * godmode/setup/setup.php: Several fixes. * godmode/agentes/alert_manager.php: Several changes for new alert manager. Not finished. Interim commit. * godmode/agentes/configurar_agente.php: More changes needed to alert editor. * godmode/agentes/alert_manager_editor.php: New file for alert management. * godmode/modules/module_list.php: Some updates, removed invalid column. * godmode/alerts/modify_alert.php: Alert types < 4 cannot be modified (this includes combined, internal audit and Pandora FMS log). git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@783 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2008-04-01 15:53:11 +02:00
// Copyright (c) 2008 Artica Soluciones Tecnológicas, http://www.artica.es
// Please see http://pandora.sourceforge.net 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
2008-04-01 Sancho Lerena <slerena@gmail.com> * pandoradb_data.sql: Alert type 0 is not 1. 1-3 are reserved. Removed prediction module (nosense since it uses normal modules). * include/functions_db.php: Added wrapper give_db_value to get_db_value because A LOT of code uses old syntax and this makes too many errors. * include/functions.php: Fixed pagination issues with blocksize config. * pandoradb.sql: Change alert command lenght and added some comments for future implementation of alert criticity and others. * operation/incidents/incident.php: Fixed some bugs calling to old funcions / variables. * operation/events/events.php: Fixed some bugs calling to old funcions / variables. Removed graph and simplified header. * operation/agentes/estado_alertas.php: Changed get_db_value call and removed (Raul) button to create alert from here. * operation/agentes/estado_grupo.php: Implemented support for optional view of down modules and fired alerts. * operation/agentes/ver_agente.php, operation/agentes/datos_agente.php: Uses of new get_db_value and new session id variable. * images/mod_async_string.png: Added image. * images/mod_async_inc.png: Added image. * images/mod_image_png.png: Added image. * images/mod_async_data.png: Added image. * images/mod_async_proc.png: Added image. * images/mod_image_jpg.png: Added image. * godmode/setup/setup.php: Several fixes. * godmode/agentes/alert_manager.php: Several changes for new alert manager. Not finished. Interim commit. * godmode/agentes/configurar_agente.php: More changes needed to alert editor. * godmode/agentes/alert_manager_editor.php: New file for alert management. * godmode/modules/module_list.php: Some updates, removed invalid column. * godmode/alerts/modify_alert.php: Alert types < 4 cannot be modified (this includes combined, internal audit and Pandora FMS log). git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@783 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2008-04-01 15:53:11 +02:00
// 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.
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
// Load global vars
require ("include/config.php");
if (! isset($config["show_lastalerts"]))
$config["show_lastalerts"] = 1;
if (give_acl ($id_user, 0, "AR") != 1) {
audit_db ($id_user, $REMOTE_ADDR, "ACL Violation",
"Trying to access Agent view (Grouped)");
require ("general/noaccess.php");
exit;
}
echo "<h2>".$lang_label["ag_title"]." &gt; ".$lang_label["group_view"]."</h2>";
// 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 ($id_user, $_GET["update_netgroup"], "AW") == 1) {
$sql = sprintf ("UPDATE tagente_modulo SET `flag` = '1' WHERE `id_agente` = ANY(SELECT id_agente FROM tagente WHERE `id_grupo` = '%d')",$_GET["update_netgroup"]);
mysql_query ($sql);
}
}
// Get group list that user has access
$groups = get_user_groups ($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;
2007-03-28 Sancho Lerena <slerena@artica.es> * tip.css, pandora.css: Some updates to fix render in tooltips and datos3 background color. * config.php: Version update. * operation/menu.php: Added reporting suboption: Custom Graph Builder. * operation/reporting/graph_builder.php: New custom and combined graphic generator that uses new function from fgraph graphic_combined_module(). * reporting/fgraph.php: new function graphic_combined_module() to generate combined graphs. Needs to finish implementation to show alerts and evetns (most work done). Function grafico_db_agentes_purge() now uses Pear Graph instead jpgraph. * operation/agents/exportdata.php: Now uses indexes and improve the overall speed. * operation/agents/estado_grupo.php: Rewritten version, much more fast than previous. * operation/events/events.php: Fixed code to mass delete/update and added some audit control points. * pandora_db.php: audit_db() now uses utimestamp. event_insert() now uses utimestamp. Added function give_agent_id_from_module_id(). * operation/agents/estado_ultimopaquete.php: Now render in red timestamp for "outdated" data. Fixes some minor problems with module groups and interval rendering. * operation/agents/estado_monitores.php: now uses utimestamp. * operation/agents/ver_agente.php: Uses lang_label labels for some texts. Fixed image bug. * operation/servers/view_server.php: Added version of server and some cosmetic adjustments. * godmode/db/db_main.php: Applied new graphic. * godmode/agentes/module_manager.php: Now sort by modulegroup. git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@405 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2007-03-28 18:07:29 +02:00
$total_agents += $agents;
$group_info = array ('agent' => 0,
'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 = mysql_query ($sql);
while ($module = mysql_fetch_array ($result)) {
if ($config["show_unknown"] > 0) {
$seconds = $now - $module['utimestamp'];
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 "<div class='nf'>".$lang_label["no_group_def"]."</div>";
$id_user = $_SESSION["id_usuario"];
if ( (give_acl($id_user, 0, "LM")==1) OR (give_acl($id_user, 0, "AW")==1 ) OR (give_acl($id_user, 0, "PM")==1) OR (give_acl($id_user, 0, "DM")==1) OR (give_acl($id_user, 0, "UM")==1 )){
echo "&nbsp;<form method='post' action='index.php?sec=gagente&sec2=godmode/groups/configure_group&create_g=1'><input type='submit' class='sub next' name='crt'
value='".$lang_label["create_group"]."'></form>";
}
return;
}
$group_size = sizeof ($groups_info);
$ancho = ceil (sqrt ($group_size + 1));
$real_count = 0;
echo "<table cellpadding=10 cellspacing=10 border=0>";
for ($table = 0; $table < $ancho; $table++) {
if ($real_count >= $group_size) {
continue;
}
echo "<tr class='bot'>";
//foreach ($groups_info as $group) {
for ($table_row = 0; $table_row < $ancho; $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 .= '<img src="images/dot_red.png"
title="'.lang_string ('modules_bad').'">';
}
if ($group_info["ok"] > 0) {
$icono_type .= '<img src="images/dot_green.png"
title="'.lang_string ('modules_ok').'">';
}
2007-03-28 Sancho Lerena <slerena@artica.es> * tip.css, pandora.css: Some updates to fix render in tooltips and datos3 background color. * config.php: Version update. * operation/menu.php: Added reporting suboption: Custom Graph Builder. * operation/reporting/graph_builder.php: New custom and combined graphic generator that uses new function from fgraph graphic_combined_module(). * reporting/fgraph.php: new function graphic_combined_module() to generate combined graphs. Needs to finish implementation to show alerts and evetns (most work done). Function grafico_db_agentes_purge() now uses Pear Graph instead jpgraph. * operation/agents/exportdata.php: Now uses indexes and improve the overall speed. * operation/agents/estado_grupo.php: Rewritten version, much more fast than previous. * operation/events/events.php: Fixed code to mass delete/update and added some audit control points. * pandora_db.php: audit_db() now uses utimestamp. event_insert() now uses utimestamp. Added function give_agent_id_from_module_id(). * operation/agents/estado_ultimopaquete.php: Now render in red timestamp for "outdated" data. Fixes some minor problems with module groups and interval rendering. * operation/agents/estado_monitores.php: now uses utimestamp. * operation/agents/ver_agente.php: Uses lang_label labels for some texts. Fixed image bug. * operation/servers/view_server.php: Added version of server and some cosmetic adjustments. * godmode/db/db_main.php: Applied new graphic. * godmode/agentes/module_manager.php: Now sort by modulegroup. git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@405 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2007-03-28 18:07:29 +02:00
// Show yellow light if there are recent alerts fired for this group
if ($group_info["alerts"] > 0 ) {
$icono_type .= '<img src="images/dot_yellow.png"
title="'.lang_string ('alerts_fired').'">';
}
// Show grey light if there are agent down for this group
if ($group_info["down"] > 0 ) {
$icono_type .= '<img src="images/dot_white.png"
title="'.lang_string ('agents_down').'">';
}
// Show red flag is group has disabled alert system
if (give_disabled_group ($group_info["id_group"])) {
$icono_type .= '<img src="images/flag_red.png"
title="'.lang_string ('disabled_alerts').'">';
}
// By default green border
$celda = "<td class='top' style='border: 5px solid #aeff21;' width='100'>";
// Grey border if agent down
if ($config["show_unknown"] > 0) {
if ($group_info["down"] > 0)
$celda = "<td class='top' style='border: 5px solid #aabbaa;' width='100'>";
}
// Yellow border if agents with alerts
if ($group_info["alerts"] > 0)
$celda = "<td class='top' style='border: 5px solid #ffea00;' width='100'>";
// Red border if agents bad
if ($group_info["bad"] > 0)
$celda = "<td class='top' style='border: 5px solid #ff0000;' width='100'>";
// Orange if alerts and down modules
if (($group_info["bad"] > 0) && ($group_info["alerts"] > 0))
$celda = "<td class='top' style='border: 5px solid #ffbb00;' width='100'>";
$celda .= "<a href='index.php?sec=estado&amp;
sec2=operation/agentes/estado_agente&amp;
refr=60&amp;
group_id=".$group_info["id_group"]."'
class='info'>";
// Add group icon
$celda .= "<img class='top'
src='images/groups_small/".$icono_grupo.".png' height='32' width='32' alt=''>";
// Add float info table
$celda .= "
<span>
<table cellspacing='2' cellpadding='0'
style='margin-left:2px;'>
<tr><th colspan='2' width='91'>".
$lang_label["agents"].": </th></tr>
<tr><td colspan='2' class='datos' align='center'><b>".
$group_info["agent"]."</b></td></tr>
</table>
<table cellspacing='2' cellpadding='0'
style='margin-left:2px'>
<tr>
<th colspan='2' width='90'>".
ucfirst ($lang_label["monitors"]).":</th>
</tr>
<tr>
<td class='datos'>
<img src='images/b_green.png' align='top' alt='' >
".$lang_label["ok"].": </td>
<td class='datos'>
<font class='greenb'>".$group_info["ok"]."</font>
</td>
</tr>
<tr>
<td class='datos'>
<img src='images/b_red.png' align='top' alt=''>
".$lang_label["fail"].": </td>
<td class='datos'><font class='redb'>".
$group_info["bad"]."</font></td>
</tr>";
if ($config["show_unknown"] > 0){
$celda .= "
<tr>
<td class='datos'>
<img src='images/b_white.png' align='top' alt=''>
".$lang_label["down"].": </td>
<td class='datos'><font class='redb'>".
$group_info["down"]."</font></td></tr>";
}
if ($config["show_lastalerts"] == 1)
$celda .= "<tr>
<td class='datos'>
<img src='images/b_yellow.png' align='top' alt=''>
".$lang_label["alerts"].": </td>
<td class='datos'><font class='grey'>".
$group_info["alerts"]."</font></td>
</tr>";
$celda .= "</table></span></a>";
// Render network exec module button, only when this group is writtable by user
if (give_acl ($id_user, $group_info["id_group"], "AW") == 1) {
$celda .= "&nbsp;<a href='index.php?
sec=estado&
sec2=operation/agentes/estado_grupo&
update_netgroup=".$group_info["id_group"]."'>
<img src='images/target.png'></a>";
}
$celda .= "<br><br>".
$icono_type."<br><br>
<span class='gr'>".$group_name."</span>";
echo $celda;
$real_count++;
}
echo "</tr>";
}
echo "</table>";
?>