2006-12-15 Esteban Sanchez <estebans@artica.es>

* operation/agentes/estado_grupo.php: Huge style correction. There is
        too much work left.


git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@322 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
esanchezm 2006-12-15 15:25:19 +00:00
parent 99b25df07d
commit 80bccca21d
5 changed files with 323 additions and 281 deletions

View File

@ -1,3 +1,8 @@
2006-12-15 Esteban Sanchez <estebans@artica.es>
* operation/agentes/estado_grupo.php: Huge style correction. There is
too much work left.
2006-12-14 Raul Mateos <raulofpandora@gmail.com>
* operation/messages/message.php: Updated style for not found items.

View File

@ -19,102 +19,108 @@
echo "<div class='jus'>";
$nick = $_SESSION['id_usuario'];
echo "<h1>".$lang_label["welcome_title"]."</h1>";
echo "<h1>" . $lang_label["welcome_title"] . "</h1>";
echo $lang_label["main_text"];
echo "<br><br>";
echo $lang_label["has_connected"]." <b>".$nick."</b> - ";
if (dame_admin($nick)==1){
echo $lang_label["administrator"].'. ';
}
else {
echo $lang_label["normal_user"].'. ';
echo "<br /><br />";
echo $lang_label["has_connected"] . " <b>" . $nick . "</b> - ";
if (dame_admin ($nick) == 1) {
echo $lang_label["administrator"] . '. ';
} else {
echo $lang_label["normal_user"] . '. ';
}
echo "<div id='activity'>";
// Show last activity from this user
echo "<h2>".$lang_label["user_last_activity"]."</h2>";
echo "<h2>" . $lang_label["user_last_activity"] . "</h2>";
// Show table header
echo '<table cellpadding="3" cellspacing="3" width="700"><tr>';
echo '<th>'.$lang_label["user"].'</th>';
echo '<th>'.$lang_label["action"].'</th>';
echo '<th class="w130">'.$lang_label["date"].'</th>';
echo '<th>'.$lang_label["src_address"].'</th>';
echo '<th class="w200">'.$lang_label["comments"].'</th></tr>';
echo '<th>' . $lang_label["user"] . '</th>';
echo '<th>' . $lang_label["action"] . '</th>';
echo '<th class="w130">' . $lang_label["date"] . '</th>';
echo '<th>' . $lang_label["src_address"] . '</th>';
echo '<th class="w200">' . $lang_label["comments"] . '</th></tr>';
// Skip offset records
$query1="SELECT * FROM tsesion WHERE (TO_DAYS(fecha) > TO_DAYS(NOW()) -7) AND ID_usuario = '".$nick."' ORDER BY fecha DESC limit 15";
$query1="SELECT * FROM tsesion WHERE (TO_DAYS(fecha) > TO_DAYS(NOW()) - 7) AND ID_usuario = '" . $nick . "' ORDER BY fecha DESC limit 15";
$result=mysql_query($query1);
$result = mysql_query ($query1);
$contador = 5; // Max items
$color = 1;
while (($row=mysql_fetch_array($result)) and ($contador > 0))
{
while (($row = mysql_fetch_array ($result)) and ($contador > 0)) {
if ($color == 1){
$tdcolor = "datos";
$color = 0;
}
else {
} else {
$tdcolor = "datos2";
$color = 1;
}
$usuario=$row["ID_usuario"];
echo '<tr><td class="'.$tdcolor.'"><b class="'.$tdcolor.'f9">'.$usuario."</b>";
echo '<td class="'.$tdcolor.'f9">';
$usuario = $row["ID_usuario"];
echo '<tr><td class="' . $tdcolor . '">';
echo '"<b class="' . $tdcolor . 'f9">' . $usuario . '</b>';
echo '<td class="' . $tdcolor . 'f9">';
echo $row["accion"];
echo '<td class="'.$tdcolor.'f9">';
echo '<td class="' . $tdcolor . 'f9">';
echo $row["fecha"];
echo '<td class="'.$tdcolor.'f9">';
echo '<td class="' . $tdcolor . 'f9">';
echo $row["IP_origen"];
echo '<td class="'.$tdcolor.'f9">';
echo '<td class="' . $tdcolor . 'f9">';
echo $row["descripcion"];
echo '</tr>';
$contador--;
}
echo "<tr><td colspan='5'><div class='raya'></div></td></tr></table></div>";
$sql='SELECT COUNT(*) FROM tmensajes WHERE id_usuario_destino="'.$nick.'" AND estado="FALSE";';
$resultado=mysql_query($sql);
$row=mysql_fetch_array($resultado);
if ($row["COUNT(*)"]!=0){
echo "<div style='margin-left: 8px'>".$lang_label["new_message_bra"]."<b><a href='index.php?sec=messages&sec2=operation/messages/message'>". $row["COUNT(*)"] . "</b> <img src='images/mail.gif' border='0'></a>".$lang_label["new_message_ket"]."</div>";
}
$sql='SELECT COUNT(*) FROM tmensajes WHERE id_usuario_destino="' . $nick . '" AND estado="FALSE";';
$resultado = mysql_query ($sql);
$row = mysql_fetch_array ($resultado);
if ($row["COUNT(*)"] != 0){
echo '<div style="margin-left: 8px">' . $lang_label["new_message_bra"];
echo '<b><a href="index.php?sec=messages&sec2=operation/messages/message">';
echo $row["COUNT(*)"] . '</b> <img src="images/mail.gif" border="0"></a>';
echo $lang_label["new_message_ket"] . '</div>';
}
echo "<h2>".$lang_label["stat_title"]."</h2>";
echo '<h2>' . $lang_label["stat_title"] . '</h2>';
$query1="SELECT COUNT(*) FROM tusuario";
$result=mysql_query($query1);
$row=mysql_fetch_array($result);
echo "<img src='images/usuarios.gif' align='middle' alt=''>&nbsp;&nbsp;";
echo $lang_label["there_are"].$row[0]." ".$lang_label["user_defined"];
echo "<br><br>";
$query1 = "SELECT COUNT(*) FROM tusuario";
$result = mysql_query ($query1);
$row = mysql_fetch_array ($result);
echo '<img src="images/usuarios.gif" align="middle" alt="">&nbsp;&nbsp;';
echo $lang_label["there_are"] . $row[0] . ' ' . $lang_label["user_defined"];
echo '<br /><br />';
$query1="SELECT COUNT(*) FROM tagente";
$result=mysql_query($query1);
$row=mysql_fetch_array($result);
echo "<img src='images/agentes.gif' align='middle' alt=''>&nbsp;&nbsp;";
echo $lang_label["there_are"].$row[0]." ".$lang_label["agent_defined"];
echo "<br><br>";
$query1 = "SELECT COUNT(*) FROM tagente";
$result = mysql_query ($query1);
$row = mysql_fetch_array ($result);
echo '<img src="images/agentes.gif" align="middle" alt="">&nbsp;&nbsp;';
echo $lang_label["there_are"] . $row[0] .' ' . $lang_label["agent_defined"];
echo '<br /><br />';
$query1="SELECT COUNT(id_agente_datos) FROM tagente_datos";
$result=mysql_query($query1);
$row=mysql_fetch_array($result);
echo "<img src='images/datos.gif' align='middle' alt=''>&nbsp;&nbsp;";
echo $lang_label["there_are"].$row[0]." ".$lang_label["data_harvested"];
echo "<br><br>";
$query1 = "SELECT COUNT(id_agente_datos) FROM tagente_datos";
$result = mysql_query ($query1);
$row = mysql_fetch_array ($result);
echo '<img src="images/datos.gif" align="middle" alt="">&nbsp;&nbsp;';
echo $lang_label["there_are"] . $row[0] . ' ' . $lang_label["data_harvested"];
echo '<br /><br />';
$query1="SELECT COUNT(*) FROM talerta_agente_modulo";
$result=mysql_query($query1);
$row=mysql_fetch_array($result);
echo "<img src='images/alertas.gif' align='middle' alt=''>&nbsp;&nbsp;";
echo $lang_label["there_are"].$row[0]." ".$lang_label["alert_defined"];
echo "<br><br>";
$query1 = "SELECT COUNT(*) FROM talerta_agente_modulo";
$result = mysql_query ($query1);
$row = mysql_fetch_array ($result);
echo '<img src="images/alertas.gif" align="middle" alt="">&nbsp;&nbsp;';
echo $lang_label["there_are"] . $row[0] .' ' . $lang_label["alert_defined"];
echo '<br /><br />';
$query1="SELECT * FROM tagente_estado ORDER BY timestamp DESC";
$result=mysql_query($query1);
$row=mysql_fetch_array($result);
$query1 = "SELECT * FROM tagente_estado ORDER BY timestamp DESC";
$result = mysql_query($query1);
$row = mysql_fetch_array($result);
// Take the first element only
echo "<img src='images/time.gif' align='middle' alt=''>&nbsp;&nbsp;";
echo $lang_label["data_timestamp"].$row["timestamp"];
echo "</div>";
?>
echo '<img src="images/time.gif" align="middle" alt="">&nbsp;&nbsp;';
echo $lang_label["data_timestamp"] . $row["timestamp"];
echo '</div>';
?>

View File

@ -10,22 +10,26 @@
<div id='ver'><?php echo $pandora_version; ?></div>
<?php
require("operation/menu.php");
if (! isset ($_SESSION["id_usuario"])){
echo '<div class="f10">'.$lang_label["not_connected"];
echo '<br><br>';
echo '<form method="post" action="index.php?login=1">
<div class="f9b">Login</div><input class="login" type="text" name="nick">
<div class="f9b">Password</div><input class="login" type="password" name="pass">
<div><input name="login" type="submit" class="sub" value="'.$lang_label["login"].'"></div>
<br>IP: <b class="f10">'.$REMOTE_ADDR.'</b><br></div>';
}
else {
$iduser=$_SESSION['id_usuario'];
require("godmode/menu.php");
echo '<div class="w155f10"><form method="post" action="index.php?logoff=1"><input type="hidden" name="bye" value="bye"><input name="logoff" type="submit" class="sub" value="'.$lang_label["logout"].'"></form>'
.$lang_label["has_connected"].' <br>[<b class="f10">'.$iduser.'</b>]<br>';
echo "<br>IP: <b class='f10'>".$REMOTE_ADDR."</b><br></div><div>&nbsp;</div>";
require("links_menu.php");
require ("operation/menu.php");
if (! isset ($_SESSION["id_usuario"])) {
echo '<div class="f10">' . $lang_label["not_connected"];
echo '<br /><br />';
echo '<form method="post" action="index.php?login=1">';
echo '<div class="f9b">Login</div><input class="login" type="text" name="nick">';
echo '<div class="f9b">Password</div><input class="login" type="password" name="pass">';
echo '<div><input name="login" type="submit" class="sub" value="' . $lang_label["login"] .'"></div>';
echo '<br />IP: <b class="f10">' . $REMOTE_ADDR . '</b><br /></div>';
} else {
$iduser = $_SESSION['id_usuario'];
require ("godmode/menu.php");
echo '<div class="w155f10"><form method="post" action="index.php?logoff=1">';
echo '<input type="hidden" name="bye" value="bye">';
echo '<input name="logoff" type="submit" class="sub" value="' . $lang_label["logout"] . '">';
echo '</form>' . $lang_label["has_connected"] . '<br />';
echo '[<b class="f10">' . $iduser . '</b>]<br />';
echo "<br />IP: <b class='f10'>" . $REMOTE_ADDR . "</b><br /></div><div>&nbsp;</div>";
require ("links_menu.php");
}
?>
?>

View File

@ -30,15 +30,14 @@ require("include/functions_db.php");
<?php
// Refresh page
if (isset ($_GET["refr"])){
$intervalo = entrada_limpia($_GET["refr"]);
$intervalo = entrada_limpia ($_GET["refr"]);
// Agent selection filters and refresh
if (isset ($_POST["ag_group"])){
if (isset ($_POST["ag_group"])) {
$ag_group = $_POST["ag_group"];
$query='http://'.$_SERVER['SERVER_NAME'].$_SERVER['REQUEST_URI'].'&ag_group_refresh='.$ag_group;
echo '<meta http-equiv="refresh" content="'.$intervalo.'; URL='.$query.'">';
}
else
echo '<meta http-equiv="refresh" content="'.$intervalo.'">';
$query = 'http://' . $_SERVER['SERVER_NAME'] . $_SERVER['REQUEST_URI'] . '&ag_group_refresh=' . $ag_group;
echo '<meta http-equiv="refresh" content="' . $intervalo . '; URL=' . $query . '">';
} else
echo '<meta http-equiv="refresh" content="' . $intervalo . '">';
}
?>
<title>Pandora FMS - <?php echo $lang_label["header_title"]; ?></title>
@ -54,96 +53,108 @@ if (isset ($_GET["refr"])){
<link rel="stylesheet" href="include/styles/pandora.css" type="text/css">
</head>
<body>
<?php
<?php
// Show custom background
echo "<body background='images/backgrounds/$config_bgimage'>";
$REMOTE_ADDR = getenv("REMOTE_ADDR");
echo '<body background="images/backgrounds/' . $config_bgimage . '">';
$REMOTE_ADDR = getenv ("REMOTE_ADDR");
global $REMOTE_ADDR;
if ( (! isset($_SESSION['id_usuario'])) AND (isset($_GET["login"]))){ // Login process
$nick = entrada_limpia($_POST["nick"]);
$pass = entrada_limpia($_POST["pass"]);
// Login process
if ( (! isset ($_SESSION['id_usuario'])) AND (isset ($_GET["login"]))) {
$nick = entrada_limpia ($_POST["nick"]);
$pass = entrada_limpia ($_POST["pass"]);
// Connect to Database
$sql1='SELECT * FROM tusuario WHERE id_usuario = "'.$nick.'"';
$result=mysql_query($sql1);
// Every registry
if ($row=mysql_fetch_array($result)){
if ($row["password"]==md5($pass)){
// Login OK
// Nick could be uppercase or lowercase (select in mysql is not case sensitive)
// We get DB nick to put in PHP Session variable, to avoid problems with case-sensitive usernames :)
$sql1 = 'SELECT * FROM tusuario WHERE id_usuario = "'.$nick.'"';
$result = mysql_query ($sql1);
// For every registry
if ($row = mysql_fetch_array ($result)){
if ($row["password"] == md5 ($pass)){
// Login OK
// Nick could be uppercase or lowercase (select in MySQL
// is not case sensitive)
// We get DB nick to put in PHP Session variable,
// to avoid problems with case-sensitive usernames.
// Thanks to David Muñiz for Bug discovery :)
$nick = $row["id_usuario"];
unset($_GET["sec2"]);
$_GET["sec"]="general/logon_ok";
update_user_contact($nick);
logon_db($nick,$REMOTE_ADDR);
$_SESSION['id_usuario']=$nick;
unset ($_GET["sec2"]);
$_GET["sec"] = "general/logon_ok";
update_user_contact ($nick);
logon_db ($nick, $REMOTE_ADDR);
$_SESSION['id_usuario'] = $nick;
}
else { // Login failed (bad password)
unset($_GET["sec2"]);
} else {
// Login failed (bad password)
unset ($_GET["sec2"]);
include "general/logon_failed.php";
// change password to do not show all string
$primera = substr($pass,0,1);
$ultima = substr($pass,strlen($pass)-1,1);
$pass = $primera."****".$ultima;
audit_db($nick,$REMOTE_ADDR,"Logon Failed","Incorrect password: ".$nick." / ".$pass);
$primera = substr ($pass,0,1);
$ultima = substr ($pass, strlen ($pass) - 1, 1);
$pass = $primera . "****" . $ultima;
audit_db ($nick, $REMOTE_ADDR, "Logon Failed",
"Incorrect password: " . $nick . " / " . $pass);
include "general/footer.php";
exit;
}
}
else { // User not known
unset($_GET["sec2"]);
else {
// User not known
unset ($_GET["sec2"]);
include "general/logon_failed.php";
$primera = substr($pass,0,1);
$ultima = substr($pass,strlen($pass)-1,1);
$pass = $primera."****".$ultima;
audit_db($nick,$REMOTE_ADDR,"Logon Failed","Invalid username: ".$nick." / ".$pass);
$primera = substr ($pass, 0, 1);
$ultima = substr ($pass, strlen ($pass) - 1, 1);
$pass = $primera . "****" . $ultima;
audit_db ($nick, $REMOTE_ADDR, "Logon Failed",
"Invalid username: " . $nick . " / " . $pass);
include "general/footer.php";
exit;
}
}
// If there is no user connected
elseif (! isset($_SESSION['id_usuario'])) {
} elseif (! isset ($_SESSION['id_usuario'])) {
// There is no user connected
include "general/login_page.php";
exit;
}
if (isset($_GET["logoff"])){ // LOG OFF
unset($_GET["sec2"]);
$_GET["sec"]="general/logoff";
$iduser=$_SESSION["id_usuario"];
logoff_db($iduser,$REMOTE_ADDR);
session_unregister("id_usuario");
if (isset ($_GET["logoff"])) {
// Log off
unset ($_GET["sec2"]);
$_GET["sec"] = "general/logoff";
$iduser = $_SESSION["id_usuario"];
logoff_db ($iduser, $REMOTE_ADDR);
session_unregister ("id_usuario");
}
?>
<div id="page">
<div id="menu"><?php require("general/main_menu.php"); ?></div>
<div id="menu"><?php require ("general/main_menu.php"); ?></div>
<div id="main">
<div id='head'><?php require("general/header.php"); ?></div>
<?php
if (isset($_GET["sec2"])){
$pagina = parametro_limpio($_GET["sec2"]);
if ($pagina <> "") {
if(file_exists($pagina.".php")) {
require($pagina.".php");
if (isset ($_GET["sec2"])) {
$pagina = parametro_limpio ($_GET["sec2"]);
if ($pagina <> "") {
if (file_exists ($pagina . ".php")) {
require ($pagina . ".php");
} else {
echo "<br><b class='error'>Sorry! I can't find the page!</b>";
}
else print "<br><b class='error'>Sorry! I can't find the page!</b>";
}
}
elseif (isset($_GET["sec"] )){
$pagina = parametro_limpio($_GET["sec"]);
if(file_exists($pagina.".php")) {
require($pagina.".php");
} elseif (isset ($_GET["sec"])) {
$pagina = parametro_limpio ($_GET["sec"]);
if (file_exists ($pagina . ".php")) {
require ($pagina . ".php");
} else {
echo "<br><b class='error'>Sorry! I can't find the page!</b>";
}
else print "<br><b class='error'>Sorry! I can't find the page!</b>";
} else {
require ("general/logon_ok.php"); //default
}
else
require("general/logon_ok.php"); //default
?>
</div>
</div>
<?php require("general/footer.php") ?>
</body>
</html>
</html>

View File

@ -20,129 +20,145 @@
// Load global vars
require("include/config.php");
if (comprueba_login() == 0)
if (give_acl($id_user, 0, "AR")==1) {
echo "<h2>".$lang_label["ag_title"]."</h2>";
echo "<h3>".$lang_label["group_view"]."<a href='help/".$help_code."/chap3.php#324' target='_help' class='help'>&nbsp;<span>".$lang_label["help"]."</span></a></h3>";
$iduser_temp=$_SESSION['id_usuario'];
if (comprueba_login () == 0) {
if (give_acl ($id_user, 0, "AR") == 1) {
echo "<h2>".$lang_label["ag_title"]."</h2>";
echo "<h3>".$lang_label["group_view"]."<a href='help/".$help_code."/chap3.php#324' target='_help' class='help'>&nbsp;<span>".$lang_label["help"]."</span></a></h3>";
$iduser_temp = $_SESSION['id_usuario'];
$sql1 = 'SELECT * FROM tgrupo';
$result2 = mysql_query ($sql1);
if (mysql_num_rows ($result2)) {
while ($row = mysql_fetch_array ($result2)) {
if ($row["id_grupo"] != 1 &&
give_acl($iduser_temp,$row["id_grupo"], "AR") == 1) {
$mis_grupos[]=$row["id_grupo"]; //All my groups in an array
}
}
// Update network modules for this group
// Check for Network FLAG change request
if (isset ($_GET["update_netgroup"])) {
if (give_acl ($id_user, $_GET["update_netgroup"], "AW") == 1) {
$sql = "SELECT * FROM tagente WHERE id_grupo = ".$_GET["update_netgroup"];
$result = mysql_query ($sql);
while ($row = mysql_fetch_array ($result)) {
$id_agente = $row["id_agente"];
$query2 ="UPDATE tagente_modulo SET flag=1 WHERE id_agente = ".$id_agente;
$res = mysql_query ($query2);
}
}
}
$contador_grupo = 0;
$contador_agente = 0;
$array_index = 0;
// Recorro cada grupo para ver el estado de todos los modulos
foreach ($mis_grupos as $migrupo) {
if ($migrupo != "") {
$grupo[$array_index]["agent"] = 0;
$grupo[$array_index]["ok"] = 0;
$grupo[$array_index]["down"] = 0;
$grupo[$array_index]["bad"] = 0;
$grupo[$array_index]["alerts"] = 0;
$grupo[$array_index]["data"] = 0;
$grupo[$array_index]["icon"] = dame_grupo_icono ($migrupo);
$grupo[$array_index]["id_grupo"] = $migrupo;
$existen_agentes =0;
$sql1 = "SELECT * FROM tagente WHERE disabled=0 AND id_grupo =".$migrupo;
if ($result1 = mysql_query ($sql1)) {
while ($row1 = mysql_fetch_array ($result1)) {
$existen_agentes = 1;
$intervalo = $row1["intervalo"];
$id_agente = $row1["id_agente"];
// Check for recent alerts
if (check_alert_fired($id_agente) == 1) {
$grupo[$array_index]["alerts"]++;
}
$grupo[$array_index]["agent"]++;
$grupo[$array_index]["group"] = dame_nombre_grupo ($migrupo);
// Estado grupo, agent
$contador_agente++;
$sql3 = "SELECT * FROM tagente_estado WHERE id_agente = ".$row1["id_agente"];
$result3 = mysql_query ($sql3);
while ($row3 = mysql_fetch_array ($result3)) {
$estado = $row3["estado"];
// Get module interval
$ahora = date ("Y/m/d H:i:s");
$sql4 = "SELECT * FROM tagente_modulo WHERE id_agente_modulo = ".$row3["id_agente_modulo"];
$result4 = mysql_query ($sql4);
if ($row4 = mysql_fetch_array ($result4)) {
$module_interval = $row4["module_interval"];
if ($module_interval > 0) {
$intervalo_comp = $module_interval;
} else {
$intervalo_comp = $intervalo;
}
}
$ultimo_contacto_modulo = $row3["timestamp"];
$sql1='SELECT * FROM tgrupo';
$result2=mysql_query($sql1);
if (mysql_num_rows($result2)){
while ($row=mysql_fetch_array($result2)){
if ($row["id_grupo"]!=1)
if (give_acl($iduser_temp,$row["id_grupo"], "AR") == 1)
$mis_grupos[]=$row["id_grupo"]; //All my groups in an array
}
// Update network modules for this group
// Check for Network FLAG change request
if (isset($_GET["update_netgroup"])){
if (give_acl($id_user, $_GET["update_netgroup"], "AW")==1){
$sql = "SELECT * FROM tagente WHERE id_grupo = ".$_GET["update_netgroup"];
$result=mysql_query($sql);
while ($row=mysql_fetch_array($result)){
$id_agente = $row["id_agente"];
$query2 ="UPDATE tagente_modulo SET flag=1 WHERE id_agente = ".$id_agente;
$res=mysql_query($query2);
}
}
}
$contador_grupo = 0;
$contador_agente=0;
$array_index = 0;
// Recorro cada grupo para ver el estado de todos los modulos
foreach ($mis_grupos as $migrupo)
if ($migrupo != "") {
$grupo[$array_index]["agent"]=0;
$grupo[$array_index]["ok"]=0;
$grupo[$array_index]["down"]=0;
$grupo[$array_index]["bad"]=0;
$grupo[$array_index]["alerts"]=0;
$grupo[$array_index]["data"]=0;
$grupo[$array_index]["icon"]=dame_grupo_icono($migrupo);
$grupo[$array_index]["id_grupo"]=$migrupo;
$existen_agentes =0;
$sql1="SELECT * FROM tagente WHERE disabled=0 AND id_grupo =".$migrupo;
if ($result1=mysql_query($sql1)){
while ($row1 = mysql_fetch_array($result1)){
$existen_agentes =1;
$intervalo = $row1["intervalo"];
$id_agente=$row1["id_agente"]; // Bugsolved 0607113 <slerena@gmail.com>
// Check for recent alerts
if (check_alert_fired($id_agente) == 1){
$grupo[$array_index]["alerts"]++;
}
$grupo[$array_index]["agent"]++;
$grupo[$array_index]["group"]=dame_nombre_grupo($migrupo);
$contador_agente++; // Estado grupo, agent
$sql3="SELECT * FROM tagente_estado WHERE id_agente = ".$row1["id_agente"];
$result3=mysql_query($sql3);
while ($row3 = mysql_fetch_array($result3)){
$estado = $row3["estado"];
// Get module interval
$ahora=date("Y/m/d H:i:s");
$sql4="SELECT * FROM tagente_modulo WHERE id_agente_modulo = ".$row3["id_agente_modulo"];
$result4=mysql_query($sql4);
if ($row4 = mysql_fetch_array($result4)){
$module_interval = $row4["module_interval"];
if ($module_interval > 0)
$intervalo_comp = $module_interval;
else {
$intervalo_comp = $intervalo;
// Defines if module is down (interval x 2 > time last contact)
if ($ultimo_contacto_modulo != "2000-00-00 00:00:00") {
$seconds = strtotime ($ahora) - strtotime ($ultimo_contacto_modulo);
if ($seconds >= ($intervalo_comp * 2)) {
$grupo[$array_index]["down"]++;
} elseif ($estado != 100) {
if ($row3["datos"] != 0) {
$grupo[$array_index]["ok"]++;
} else {
$grupo[$array_index]["bad"]++;
}
} elseif ($estado == 100) // For data module, not monitors
$grupo[$array_index]["data"]++; // Data module
}
}
}
}
$ultimo_contacto_modulo = $row3["timestamp"];
# Defines if module is down (interval x 2 > time last contact)
if ($ultimo_contacto_modulo != "2000-00-00 00:00:00"){
$seconds = strtotime($ahora) - strtotime($ultimo_contacto_modulo);
if ($seconds >= ($intervalo_comp*2)){
$grupo[$array_index]["down"]++;
}
elseif ($estado != 100) {
if ($row3["datos"] !=0)
$grupo[$array_index]["ok"]++;
else
$grupo[$array_index]["bad"]++;
} elseif ($estado == 100) // For data module, not monitors
$grupo[$array_index]["data"]++; // Data module
if ($existen_agentes == 1){
$array_index++;
}
}
}
}
if ($existen_agentes == 1){
$array_index++;
}
}
if ($contador_agente!=0) {
$ancho = ceil(sqrt($array_index+1));
$real_count =0;
echo "<table cellpadding=10 cellspacing=10>";
for ($table=0;$table < $ancho;$table++){
echo "<tr class='bot'>";
for ($table_row=0;$table_row < $ancho;$table_row++){
if ($real_count < $array_index){
$group_name = $grupo[$real_count]["group"];
$icono_grupo = $grupo[$real_count]["icon"];
$icono_type="";
if ($grupo[$real_count]["down"]>0) {
$icono_type="<img src='images/dot_down.gif' alt=''>";
}
if ($grupo[$real_count]["bad"]>0) {
$icono_type=$icono_type."<img src='images/dot_red.gif' alt=''>";
}
if ($grupo[$real_count]["ok"]>0) {
$icono_type=$icono_type."<img src='images/dot_green.gif' alt=''>";
}
if ($grupo[$real_count]["data"]>0) {
$icono_type=$icono_type."<img src='images/dot_white.gif' alt=''>";
}
// Show yellow light if there are recent alerts fired for this group
if ($grupo[$real_count]["alerts"] > 0 ){
$icono_type=$icono_type."<img src='images/dot_yellow.gif' alt=''>";
}
// TOOLTIP.
$celda = "<td class='bot' width=100><a href='index.php?sec=estado&amp;sec2=operation/agentes/estado_agente&amp;refr=60&amp;group_id=".$grupo[$real_count]["id_grupo"]."' class='info'><img class='top' src='images/groups/".$icono_grupo."_1.gif' border='0' alt=''>&nbsp;
if ($contador_agente != 0) {
$ancho = ceil(sqrt($array_index+1));
$real_count =0;
echo "<table cellpadding=10 cellspacing=10>";
for ($table=0; $table < $ancho; $table++) {
echo "<tr class='bot'>";
for ($table_row=0; $table_row < $ancho; $table_row++) {
if ($real_count < $array_index) {
$group_name = $grupo[$real_count]["group"];
$icono_grupo = $grupo[$real_count]["icon"];
$icono_type = "";
if ($grupo[$real_count]["down"] > 0) {
$icono_type = "<img src='images/dot_down.gif' alt=''>";
}
if ($grupo[$real_count]["bad"] > 0) {
$icono_type = $icono_type."<img src='images/dot_red.gif' alt=''>";
}
if ($grupo[$real_count]["ok"] > 0) {
$icono_type = $icono_type."<img src='images/dot_green.gif' alt=''>";
}
if ($grupo[$real_count]["data"] > 0) {
$icono_type = $icono_type."<img src='images/dot_white.gif' alt=''>";
}
// Show yellow light if there are recent alerts fired for this group
if ($grupo[$real_count]["alerts"] > 0 ){
$icono_type=$icono_type."<img src='images/dot_yellow.gif' alt=''>";
}
/* FIXME: This line is ugly */
// TOOLTIP.
$celda = "<td class='bot' width=100><a href='index.php?sec=estado&amp;sec2=operation/agentes/estado_agente&amp;refr=60&amp;group_id=".$grupo[$real_count]["id_grupo"]."' class='info'><img class='top' src='images/groups/".$icono_grupo."_1.gif' border='0' alt=''>&nbsp;
<span>
<table cellspacing='2' cellpadding='0' style='margin-left:20px'>
<tr><td colspan='2' width='91' class='lb'>".$lang_label["agents"].": </td></tr>
@ -154,28 +170,28 @@ if (comprueba_login() == 0)
<tr><td class='datos'><img src='images/b_red.gif' align='top' alt='' border='0'> ".$lang_label["fail"].": </td><td class='datos'><font class='redb'>".$grupo[$real_count]["bad"]."</font></td></tr>
<tr><td class='datos'><img src='images/b_yellow.gif' align='top' alt='' border='0'> ".$lang_label["alerts"].": </td><td class='datos'><font class='grey'>".$grupo[$real_count]["alerts"]."</font></td></tr>
</table></span></a>";
// Render network exec module button, only when this group is writtable by user
if (give_acl($id_user, $grupo[$real_count]["id_grupo"], "AW")==1){
$celda = $celda . "<a href='index.php?sec=estado&sec2=operation/agentes/estado_grupo&update_netgroup=".$grupo[$real_count]["id_grupo"]."'><img src='images/target.gif' border=0></a>";
// Render network exec module button, only when this group is writtable by user
if (give_acl ($id_user, $grupo[$real_count]["id_grupo"], "AW") == 1) {
$celda .= "<a href='index.php?sec=estado&sec2=operation/agentes/estado_grupo&update_netgroup=".$grupo[$real_count]["id_grupo"]."'><img src='images/target.gif' border=0></a>";
}
$celda .= "<br><br>".$icono_type."<br><br><font class='gr'>".$group_name."</font>";
echo $celda;
}
$real_count++;
}
$celda = $celda . "<br><br>".$icono_type."<br><br><font class='gr'>".$group_name."</font>";
echo $celda;
echo "</tr>";
}
$real_count++;
echo "</table>";
} else {
echo "<div class='nf'>".$lang_label["no_agent_def"]."</div>";
}
echo "</tr>";
} else {
echo "<div class='nf'>".$lang_label["no_agent"]."</div>";
}
echo "</table>";
} else {
echo "<div class='nf'>".$lang_label["no_agent_def"]."</div>";
}
audit_db ($id_user, $REMOTE_ADDR, "ACL Violation", "Trying to access Agent view (Grouped)");
require ("general/noaccess.php");
}
else {
echo "<div class='nf'>".$lang_label["no_agent"]."</div>";
}
}
else {
audit_db($id_user,$REMOTE_ADDR, "ACL Violation","Trying to access Agent view (Grouped)");
require ("general/noaccess.php");
}
?>