From fa5263c4d0a6b9729d5956b69454b06298c70c7b Mon Sep 17 00:00:00 2001 From: slerena Date: Fri, 13 Apr 2007 18:47:58 +0000 Subject: [PATCH] 2007-04-13 Sancho Lerena * include/functions_db.php: Added function add_address() not finished!. * pandoradb.sql: Added field "notify_email" in tincidencia. More changes are coming in incident management coming from FRITS project. Added tnews * index.php: VERY IMPORTANT: Added Session locking concurrency speedup, taken from http://es2.php.net/manual/en/ref.session.php#64525. This solve GUI lookups when one page it's processing huge data and one user cannot access to other pages. This is a common PHP issue for bad-susing SESSION functions. * operation/agentes/estado_grupo.php: Added checks for timeout in agents. Now render gray icons/boxes if agent is completely timeout (with no modules in time). * operation/agentes/estado_generalagente.php: Show IP address in combo. More changes are coming to agent address management (multiaddress). * general/logoff.php: Fixed, "babel" string :-) * general/logon_ok.php: Added news display in main logon screen. * godmode/agentes/configurar_agente.php: Delete address code, not finished. git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@422 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f --- pandora_console/ChangeLog | 31 ++++++++++++++ pandora_console/general/logoff.php | 2 +- pandora_console/general/logon_ok.php | 24 +++++------ .../godmode/agentes/configurar_agente.php | 8 ++++ pandora_console/include/config.php | 6 +-- pandora_console/include/functions_db.php | 34 ++++++++++++++++ pandora_console/index.php | 3 ++ .../agentes/estado_generalagente.php | 21 +++++++++- .../operation/agentes/estado_grupo.php | 40 ++++++++++++++++--- pandora_console/pandoradb.sql | 12 +++++- 10 files changed, 157 insertions(+), 24 deletions(-) diff --git a/pandora_console/ChangeLog b/pandora_console/ChangeLog index a95ad72c6f..5eb8237410 100644 --- a/pandora_console/ChangeLog +++ b/pandora_console/ChangeLog @@ -1,3 +1,34 @@ +2007-04-13 Sancho Lerena + + * include/functions_db.php: Added function add_address() not finished!. + + * pandoradb.sql: Added field "notify_email" in tincidencia. More + changes are coming in incident management coming from FRITS + project. Added tnews + + * index.php: VERY IMPORTANT: Added Session locking concurrency + speedup, taken from + http://es2.php.net/manual/en/ref.session.php#64525. This solve GUI + lookups when one page it's processing huge data and one user + cannot access to other pages. This is a common PHP issue for + bad-susing SESSION functions. + + + * operation/agentes/estado_grupo.php: Added checks for timeout in + agents. Now render gray icons/boxes if agent is completely timeout + (with no modules in time). + + * operation/agentes/estado_generalagente.php: Show IP address in + combo. More changes are coming to agent address management + (multiaddress). + + * general/logoff.php: Fixed, "babel" string :-) + + * general/logon_ok.php: Added news display in main logon screen. + + * godmode/agentes/configurar_agente.php: Delete address code, not + finished. + 2007-04-11 Manuel Arostegui * install.php: Text corrections. diff --git a/pandora_console/general/logoff.php b/pandora_console/general/logoff.php index a3eecba7d0..73f9d10464 100644 --- a/pandora_console/general/logoff.php +++ b/pandora_console/general/logoff.php @@ -25,7 +25,7 @@
logo
- +
'.$REMOTE_ADDR.''; ?>
diff --git a/pandora_console/general/logon_ok.php b/pandora_console/general/logon_ok.php index 3ce780122f..30b47f2344 100644 --- a/pandora_console/general/logon_ok.php +++ b/pandora_console/general/logon_ok.php @@ -86,25 +86,23 @@ // Site news ! echo '

' . $lang_label["site_news"] . '

'; - echo ''; - - $sql_news = "SELECT * FROM tnews ORDER by utimestamp LIMIT 3"; - $result_news = mysql_query ($sql_news); - while ($row = mysql_fetch_array ($result_news)) { - - echo '
'; - echo $lang_label["at"]. " ". $row["utimestamp"] ." ".$lang_label["user"]. " ". $row["author"]." ".$lang_label["says"].": \"".$row["subject"]."\""; - echo '
'; - echo clean_output_breaks($row["text"]); - echo ''; + if ($result_news = mysql_query ($sql_news)){ + echo ''; + while ($row = mysql_fetch_array ($result_news)) { + + echo '
'; + echo $lang_label["at"]. " ". $row["utimestamp"] ." ".$lang_label["user"]. " ". $row["author"]." ".$lang_label["says"].": \"".$row["subject"]."\""; + echo '
'; + echo clean_output_breaks($row["text"]); + echo ''; + } + echo "
"; } - echo "
"; // Site stats echo '

' . $lang_label["stat_title"] . '

'; - echo ''; $query1 = "SELECT COUNT(id_usuario) FROM tusuario"; $result = mysql_query ($query1); diff --git a/pandora_console/godmode/agentes/configurar_agente.php b/pandora_console/godmode/agentes/configurar_agente.php index 796fdfc41c..dd9c6c9ba0 100644 --- a/pandora_console/godmode/agentes/configurar_agente.php +++ b/pandora_console/godmode/agentes/configurar_agente.php @@ -182,6 +182,14 @@ if (isset($_GET["delete_alert"])){ // if modified some parameter echo "

".$lang_label["delete_alert_ok"]."

"; } + +// Delete IP address +if (isset($_POST["delete_ip"])){ + echo "DELETING IP ADDRESS ".$_POST["delete_ip"]; + echo "
"; +} + + // Create alert // ============= if (isset($_POST["insert_alert"])){ // if created alert diff --git a/pandora_console/include/config.php b/pandora_console/include/config.php index 26f748bc3b..24d7e47de2 100644 --- a/pandora_console/include/config.php +++ b/pandora_console/include/config.php @@ -1,8 +1,8 @@ \ No newline at end of file +?> diff --git a/pandora_console/include/functions_db.php b/pandora_console/include/functions_db.php index 6accb15bd7..a4dd272576 100644 --- a/pandora_console/include/functions_db.php +++ b/pandora_console/include/functions_db.php @@ -917,6 +917,40 @@ function give_network_profile_name ($id_np){ return $pro; } +// --------------------------------------------------------------- +// Associate IP address to an agent +// --------------------------------------------------------------- + +function agent_add_address ($id_agent, $ip_address) { + require("config.php"); + $query1="SELECT * FROM taddress_agent WHERE id_agent= $id_agent"; + $resq1=mysql_query($query1); + $address_exist = 0; + while ($rowdup=mysql_fetch_array($resq1)){ + $sql_3='SELECT ip FROM taddress WHERE id_a = '.$rowdup["id_a"]; + $result_3=mysql_query($sql_3); + $row3=mysql_fetch_array($result_3); + if ($row3[0] == $ip_address) + $address_exist = 1; + } + if ($address_exist == 1){ + // Add address + + } + + + $sql_2='SELECT id_a FROM taddress_agent WHERE id_agent = '.$id_agent; + $result_t=mysql_query($sql_2); + while ($row=mysql_fetch_array($result_t)){ + $sql_3='SELECT ip FROM taddress WHERE id_a = '.$row[0]; + $result_3=mysql_query($sql_3); + $row3=mysql_fetch_array($result_3); + if ($direccion_agente != $row3[0]) + echo "'; echo ' - diff --git a/pandora_console/operation/agentes/estado_grupo.php b/pandora_console/operation/agentes/estado_grupo.php index 48f785322f..c6dad99523 100644 --- a/pandora_console/operation/agentes/estado_grupo.php +++ b/pandora_console/operation/agentes/estado_grupo.php @@ -70,6 +70,7 @@ $grupo[$array_index]["ok"] = 0; $grupo[$array_index]["bad"] = 0; $grupo[$array_index]["alerts"] = 0; + $grupo[$array_index]["down"] = 0; $grupo[$array_index]["icon"] = dame_grupo_icono ($migrupo); $grupo[$array_index]["id_grupo"] = $migrupo; $grupo[$array_index]["group"] = dame_nombre_grupo ($migrupo); @@ -82,8 +83,20 @@ if ($row0[0] > 0) $existen_agentes = 1; + // Get timestamp status (down or not for each agent) + $sql1 = "SELECT intervalo, ultimo_contacto FROM tagente where id_grupo = $migrupo"; + if ($result1 = mysql_query ($sql1)) + while ($row1 = mysql_fetch_array ($result1)) { + // Check unknown contact status for whole agent + $ultimo_contacto = $row1[1]; + $agent_interval = $row1[0]; + $ahora=date("Y/m/d H:i:s"); + $seconds = strtotime($ahora) - strtotime($ultimo_contacto); + if ($seconds >= ($agent_interval*2)) + $grupo[$array_index]["down"]++; + } // SQL Join to get monitor status for agents belong this group - $sql1 = "SELECT tagente.id_agente, tagente_estado.estado, tagente_estado.datos FROM tagente, tagente_estado WHERE tagente.disabled = 0 AND tagente.id_grupo = $migrupo AND tagente.id_agente = tagente_estado.id_agente AND tagente_estado.estado != 100"; + $sql1 = "SELECT tagente.id_agente, tagente_estado.estado, tagente_estado.datos FROM tagente, tagente_estado WHERE tagente.disabled = 0 AND tagente.id_grupo = $migrupo AND tagente.id_agente = tagente_estado.id_agente AND tagente_estado.estado != 100"; if ($result1 = mysql_query ($sql1)){ while ($row1 = mysql_fetch_array ($result1)) { $id_agente = $row1[0]; @@ -140,10 +153,20 @@ $icono_type=$icono_type." "; } - - // Bu default green border - $celda = " + + + + "; - if ($config_show_lastalerts == 1) $celda .= "
'.$lang_label["ip_address"].''.salida_limpia($direccion_agente); + '; + + + // Show all address for this agent, show first the main IP (taken from tagente table) + echo ""; + + + + if ($agent_type == 0) { echo '
'.$lang_label["os"].'"; + // Show grey light if there are agent down for this group + if ($grupo[$real_count]["down"] > 0 ){ + $icono_type=$icono_type." + "; + } + + // By default green border + $celda = ""; + + // Grey border if agent down + if ($grupo[$real_count]["down"] > 0) + $celda = ""; + // Yellow border if agents with alerts if ($grupo[$real_count]["alerts"] > 0) $celda = ""; @@ -155,6 +178,7 @@ // Orange if alerts and down modules if (($grupo[$real_count]["bad"] > 0) && ($grupo[$real_count]["alerts"] > 0)) $celda = ""; + $celda .= "". $grupo[$real_count]["bad"]."
+ + ".$lang_label["down"].": ". + $grupo[$real_count]["down"]."
diff --git a/pandora_console/pandoradb.sql b/pandora_console/pandoradb.sql index 7ac3151b8c..14b3fdde39 100644 --- a/pandora_console/pandoradb.sql +++ b/pandora_console/pandoradb.sql @@ -397,6 +397,7 @@ CREATE TABLE `tincidencia` ( `id_grupo` mediumint(9) NOT NULL default '0', `actualizacion` datetime NOT NULL default '0000-00-00 00:00:00', `id_creator` varchar(60) default NULL, + `notify_email` TINYINT UNSIGNED NOT NULL DEFAULT 0, PRIMARY KEY (`id_incidencia`), KEY `incident_index_1` (`id_usuario`,`id_incidencia`) ) ENGINE=InnoDB; @@ -701,6 +702,15 @@ CREATE TABLE `vistas_consola` ( `nombre` varchar(50) NOT NULL, `descripcion` varchar(250) NOT NULL, PRIMARY KEY (`idVista`) -) ENGINE=InnoDB AUTO_INCREMENT=7 DEFAULT CHARSET=latin1; +) ENGINE=InnoDB AUTO_INCREMENT=7; +CREATE TABLE `tnews` ( + `id_news` INTEGER UNSIGNED NOT NULL AUTO_INCREMENT, + `author` varchar(255) NOT NULL DEFAULT '', + `subject` varchar(255) NOT NULL DEFAULT '', + `text` TEXT NOT NULL DEFAULT '', + `utimestamp` DATETIME NOT NULL DEFAULT 0, + PRIMARY KEY(`id_news`) +) +ENGINE = InnoDB; \ No newline at end of file