From a53219c9919ce5821217e1b07dfb203bff4a1f9f Mon Sep 17 00:00:00 2001 From: raulmateos Date: Wed, 5 Jul 2006 13:33:13 +0000 Subject: [PATCH] - Update agents files with options for not showing tables if there aren't monitor/alerts/data (an old wanted feature) (Pandora Console) git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@89 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f --- .../operation/agentes/estado_alertas.php | 52 ++++++++++-------- .../agentes/estado_generalagente.php | 2 +- .../operation/agentes/estado_grupo.php | 6 +++ .../operation/agentes/estado_monitores.php | 42 ++++++++------- .../agentes/estado_ultimopaquete.php | 4 +- .../operation/agentes/status_monitor.php | 53 ++++++++++++------- 6 files changed, 97 insertions(+), 62 deletions(-) diff --git a/pandora_console/operation/agentes/estado_alertas.php b/pandora_console/operation/agentes/estado_alertas.php index b352f7d11f..92f5436a61 100644 --- a/pandora_console/operation/agentes/estado_alertas.php +++ b/pandora_console/operation/agentes/estado_alertas.php @@ -11,11 +11,11 @@ if (comprueba_login() == 0) { if ((give_acl($id_user, 0, "AR")==1) or (give_acl($id_user,0,"AW")) or (dame_admin($id_user)==1)) { if (isset($_GET["id_agente"])){ + echo "

".$lang_label["alert_listing"]."".$lang_label["help"]."

"; $id_agente = $_GET["id_agente"]; $query_gen='SELECT talerta_agente_modulo.id_alerta, talerta_agente_modulo.descripcion, talerta_agente_modulo.last_fired, talerta_agente_modulo.times_fired, tagente_modulo.nombre, talerta_agente_modulo.dis_max, talerta_agente_modulo.dis_min, talerta_agente_modulo.max_alerts, talerta_agente_modulo.time_threshold, talerta_agente_modulo.min_alerts, talerta_agente_modulo.id_agente_modulo, tagente_modulo.id_agente_modulo FROM tagente_modulo, talerta_agente_modulo WHERE tagente_modulo.id_agente = '.$id_agente.' AND tagente_modulo.id_agente_modulo = talerta_agente_modulo.id_agente_modulo order by tagente_modulo.nombre'; $result_gen=mysql_query($query_gen); if (mysql_num_rows ($result_gen)) { - echo "

".$lang_label["alert_listing"]."".$lang_label["help"]."

"; echo ""; echo ""; $color=1; @@ -43,7 +43,7 @@ if (comprueba_login() == 0) { } echo '
".$lang_label["type"]."".$lang_label["name"]."".$lang_label["description"]."".$lang_label["min_max"]."".$lang_label["time_threshold"]."".$lang_label["last_fired"]."".$lang_label["times_fired"]."".$lang_label["status"]."
'; } - else echo "- ".$lang_label["no_alerts"].""; + else echo "".$lang_label["no_alerts"].""; } else { @@ -97,15 +97,7 @@ if (comprueba_login() == 0) { $result=mysql_query($sql); if (mysql_num_rows($result)){ - echo ""; - echo " - ".$lang_label["fired"]; - echo "  "; - echo ""; - echo " - ".$lang_label["not_fired"]; - echo ""; - echo "
"; - echo ""; - echo ""; + $string=''; $color=1; while ($row=mysql_fetch_array($result)){ //while there are agents if ($row["disabled"] == 0) { @@ -123,21 +115,39 @@ if (comprueba_login() == 0) { $tdcolor = "datos2"; $color = 1; } - echo "
ID".$lang_label["type"]."".$lang_label["description"]."".$lang_label["last_fired"]."".$lang_label["times_fired"]."".$lang_label["status"]."
".$nombre_agente.""; - echo "".dame_nombre_alerta($data["id_alerta"]); - echo "".$data["descripcion"]; - echo "".$data["last_fired"]; - echo "".$data["times_fired"]; + if (!isset($string)) {$string='';} + $string=$string."
".$nombre_agente.""; + $string=$string."".dame_nombre_alerta($data["id_alerta"]); + $string=$string."".$data["descripcion"]; + $string=$string."".$data["last_fired"]; + $string=$string."".$data["times_fired"]; if ($data["times_fired"] <> 0) - echo ""; + $string=$string.""; else - echo ""; + $string=$string.""; } - } //end result + } else if($ag_group>1) {unset($string);} //end result + } //end disabled=0 + } //end while - echo "
"; - } else echo "". $lang_label["no_agent"].$lang_label["no_agent_alert"].""; + if (isset($string)) { + echo ""; + echo " - ".$lang_label["fired"]; + echo "  "; + echo ""; + echo " - ".$lang_label["not_fired"]; + echo ""; + echo "
"; + echo ""; + echo ""; + echo $string; //built table of alerts + echo "
ID".$lang_label["type"]."".$lang_label["description"]."".$lang_label["last_fired"]."".$lang_label["times_fired"]."".$lang_label["status"]."
"; + } + else { + echo "".$lang_label["no_alert"].""; + } + } else echo "". $lang_label["no_agent"].$lang_label["no_agent_alert"].""; } } //end acl } //end login diff --git a/pandora_console/operation/agentes/estado_generalagente.php b/pandora_console/operation/agentes/estado_generalagente.php index f29ceacff5..7b481d7c0d 100644 --- a/pandora_console/operation/agentes/estado_generalagente.php +++ b/pandora_console/operation/agentes/estado_generalagente.php @@ -121,4 +121,4 @@ if (comprueba_login() == 0) { } -?> +?> \ No newline at end of file diff --git a/pandora_console/operation/agentes/estado_grupo.php b/pandora_console/operation/agentes/estado_grupo.php index 302ee6dabd..e442f0b3d7 100644 --- a/pandora_console/operation/agentes/estado_grupo.php +++ b/pandora_console/operation/agentes/estado_grupo.php @@ -16,6 +16,7 @@ if (comprueba_login() == 0) $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) @@ -54,6 +55,7 @@ if (comprueba_login() == 0) $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; $id_agente=$row1["id_agente"]; @@ -163,6 +165,10 @@ if (comprueba_login() == 0) echo ""; } echo ""; + } + else { + echo ''.$lang_label["no_agent"].''; + } } else { audit_db($id_user,$REMOTE_ADDR, "ACL Violation","Trying to access Agent view (Grouped)"); diff --git a/pandora_console/operation/agentes/estado_monitores.php b/pandora_console/operation/agentes/estado_monitores.php index a60b1126c5..be641baa36 100644 --- a/pandora_console/operation/agentes/estado_monitores.php +++ b/pandora_console/operation/agentes/estado_monitores.php @@ -13,15 +13,13 @@ if (comprueba_login() == 0) { if (isset($_GET["id_agente"])){ $id_agente = $_GET["id_agente"]; } - + echo "

".$lang_label["monitor_listing"]." ".$lang_label["help"]."

"; // Get all module from agent $sql_t='SELECT * FROM tagente_estado, tagente_modulo WHERE tagente_estado.id_agente_modulo = tagente_modulo.id_agente_modulo AND tagente_modulo.id_agente='.$id_agente.' order by tagente_modulo.nombre'; $result_t=mysql_query($sql_t); if (mysql_num_rows ($result_t)) { - echo "

".$lang_label["monitor_listing"]." ".$lang_label["help"]."

"; - echo ""; - echo ""; - echo "
".$lang_label["type"]."".$lang_label["module_name"]."".$lang_label["description"]."".$lang_label["status"]."".$lang_label["interval"]."".$lang_label["last_contact"]; $color=0; + $string=''; while ($row_t=mysql_fetch_array($result_t)){ # For evey module in the status table $est_modulo = $row_t["nombre"]; @@ -55,33 +53,39 @@ if (comprueba_login() == 0) { else $agent_down = 0; - echo "
".$est_tipo; - echo "".$est_modulo; - echo "".substr($est_description,0,32); + if (!isset($string)) {$string='';} + $string=$string."
".$est_tipo; + $string=$string."".$est_modulo; + $string=$string."".substr($est_description,0,32); // echo "".$row3["datos"]; if ($agent_down == 1) - echo ""; + $string=$string.""; else if ($est_estado == 1) if ($est_cambio ==1) - echo ""; + $string=$string.""; else - echo ""; + $string=$string.""; else - echo ""; - echo ""; - echo $temp_interval; - echo ""; + $string=$string.""; + $string=$string."".$temp_interval; + $string=$string.""; if ($agent_down == 1) // Si el agente esta down, lo mostramos en negrita y en rojo - echo ""; - - echo $row_t["timestamp"]; + $string=$string.""; + $string=$string.$row_t["timestamp"].""; } + else unset($string); } + if (isset($string)) { + echo ""; + echo $string; echo '
".$lang_label["type"]."".$lang_label["module_name"]."".$lang_label["description"]."".$lang_label["status"]."".$lang_label["interval"]."".$lang_label["last_contact"]."
'; } + else { + echo "".$lang_label["no_monitors"].""; + } + } else - echo "- ".$lang_label["no_monitors"].""; + echo "".$lang_label["no_monitors"].""; } ?> \ No newline at end of file diff --git a/pandora_console/operation/agentes/estado_ultimopaquete.php b/pandora_console/operation/agentes/estado_ultimopaquete.php index 9b6835d46d..219b0610a7 100644 --- a/pandora_console/operation/agentes/estado_ultimopaquete.php +++ b/pandora_console/operation/agentes/estado_ultimopaquete.php @@ -72,9 +72,9 @@ if (comprueba_login() == 0) { //$sql3='SELECT * FROM tagente_modulo WHERE id_agente = '.$id_agente.' order by id_module_group'; $label_group=0; $last_label = ""; + echo "

".$lang_label["last_data_chunk"]." ".$lang_label["help"]."

"; $result3=mysql_query($sql3); if (mysql_num_rows ($result3)) { - echo "

".$lang_label["last_data_chunk"]." ".$lang_label["help"]."

"; echo "
X".$lang_label["module_name"]; echo "".$lang_label["type"]."".$lang_label["int"]."".$lang_label["description"]."".$lang_label["data"]."".$lang_label["graph"]."".$lang_label["raw_data"]."".$lang_label["timestamp"]; $texto=''; @@ -176,6 +176,6 @@ if (comprueba_login() == 0) { } echo '
'; } -else echo "- ".$lang_label["no_modules"].""; +else echo "".$lang_label["no_modules"].""; } ?> \ No newline at end of file diff --git a/pandora_console/operation/agentes/status_monitor.php b/pandora_console/operation/agentes/status_monitor.php index a33d8afdef..6fae856a38 100644 --- a/pandora_console/operation/agentes/status_monitor.php +++ b/pandora_console/operation/agentes/status_monitor.php @@ -91,12 +91,11 @@ if (comprueba_login() == 0) { echo "
"; echo "
"; - + $color =1; $result=mysql_query($sql); if (mysql_num_rows($result)){ - echo ""; - echo ""; - while ($row=mysql_fetch_array($result)){ //while there are agents + $string=''; + while ($row=mysql_fetch_array($result)){ //while there are agents if ($row["disabled"] == 0) { if ((isset($ag_modulename)) && ($ag_modulename != "---")) $query_gen='SELECT * FROM tagente_modulo WHERE id_agente = '.$row["id_agente"].' AND nombre = "'.entrada_limpia($_POST["ag_modulename"]).'" AND ( (id_tipo_modulo = 2) OR (id_tipo_modulo = 9) OR (id_tipo_modulo = 12) OR (id_tipo_modulo = 18) OR (id_tipo_modulo = 6))'; @@ -105,33 +104,45 @@ if (comprueba_login() == 0) { $result_gen=mysql_query($query_gen); if (mysql_num_rows ($result_gen)) { while ($data=mysql_fetch_array($result_gen)){ - echo ""; - echo ""; } } + else unset($string); } } + if (isset($string)) { + echo "
".$lang_label["agent"]."".$lang_label["type"]."".$lang_label["name"]."".$lang_label["description"]."".$lang_label["max_min"]."".$lang_label["interval"]."".$lang_label["status"]."".$lang_label["timestamp"]."
".dame_nombre_agente($data["id_agente"]).""; - echo ""; - echo ""; - echo "".$data["nombre"]; - echo "".substr($data["descripcion"],0,30); - echo "".$data["max"]."/".$data["min"]; - echo ""; - if ($data["module_interval"] == 0){ - echo give_agentinterval($data["id_agente"]); + if ($color == 1){ + $tdcolor="datos"; + $color =0; } else { - echo $data["module_interval"]; + $tdcolor="datos2"; + $color =1; + } + if (!isset($string)) {$string='';} + $string=$string."
"; + $string=$string."".dame_nombre_agente($data["id_agente"]).""; + $string=$string.""; + $string=$string.""; + $string=$string."".$data["nombre"]; + $string=$string."".substr($data["descripcion"],0,30); + $string=$string."".$data["max"]."/".$data["min"]; + $string=$string.""; + if ($data["module_interval"] == 0){ + $string=$string.give_agentinterval($data["id_agente"]); + } else { + $string=$string.$data["module_interval"]; } $query_gen2='SELECT * FROM tagente_estado WHERE id_agente_modulo = '.$data["id_agente_modulo"]; $result_gen2=mysql_query($query_gen2); $data2=mysql_fetch_array($result_gen2); - echo ""; + $string=$string.""; if ($data2["datos"] > 0){ - echo ""; + $string=$string.""; } else { - echo ""; + $string=$string.""; } - echo "".$data2["timestamp"]; + $string=$string."".$data2["timestamp"]."
"; + echo $string; //the built table of monitors echo "
".$lang_label["agent"]."".$lang_label["type"]."".$lang_label["name"]."".$lang_label["description"]."".$lang_label["max_min"]."".$lang_label["interval"]."".$lang_label["status"]."".$lang_label["timestamp"]."
"; echo "
"; echo ""; echo "
"; @@ -139,6 +150,10 @@ if (comprueba_login() == 0) { echo ""; echo " - ".$lang_label["red_light"]."
"; + } + else { + echo "".$lang_label["no_monitors_g"].""; + } } else { echo "".$lang_label["no_agent"].""; }