From b46c9ce64e5173d7a743b53dee545ffacc3ca904 Mon Sep 17 00:00:00 2001 From: mdtrooper Date: Wed, 6 Oct 2010 12:24:21 +0000 Subject: [PATCH] 2010-10-06 Miguel de Dios * operation/agentes/status_monitor.php, operation/agentes/estado_ultimopaquete.php, operation/agentes/estado_monitores.php, godmode/agentes/module_manager.php: fixed the icon of policy in list of modules, now show when the module is unlinked. And cleaned source code style. Fixes: #3078716 git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@3351 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f --- pandora_console/ChangeLog | 10 ++++ .../godmode/agentes/module_manager.php | 13 ++++- .../operation/agentes/estado_monitores.php | 53 +++++++++++++------ .../agentes/estado_ultimopaquete.php | 17 ++++-- .../operation/agentes/status_monitor.php | 27 ++++++++++ 5 files changed, 98 insertions(+), 22 deletions(-) diff --git a/pandora_console/ChangeLog b/pandora_console/ChangeLog index 712259e692..3b20264d7e 100644 --- a/pandora_console/ChangeLog +++ b/pandora_console/ChangeLog @@ -1,3 +1,13 @@ +2010-10-06 Miguel de Dios + + * operation/agentes/status_monitor.php, + operation/agentes/estado_ultimopaquete.php, + operation/agentes/estado_monitores.php, godmode/agentes/module_manager.php: + fixed the icon of policy in list of modules, now show when the module is + unlinked. And cleaned source code style. + + Fixes: #3078716 + 2010-10-06 Sergio Martin * include/fgraph.php diff --git a/pandora_console/godmode/agentes/module_manager.php b/pandora_console/godmode/agentes/module_manager.php index 7b0275567a..617f8f1f13 100644 --- a/pandora_console/godmode/agentes/module_manager.php +++ b/pandora_console/godmode/agentes/module_manager.php @@ -294,10 +294,19 @@ foreach ($modules as $module) { if ($policyInfo === false) $data[1] = ''; else { - $img = 'images/policies.png'; + $linked = isModuleLinked($module['id_agente_modulo']); + + if ($linked) { + $img = 'images/policies.png'; + $title = $policyInfo['name_policy']; + } + else { + $img = 'images/unlinkpolicy.png'; + $title = __('(Unlinked) ') . $policyInfo['name_policy']; + } $data[1] = '' . - print_image($img,true, array('title' => $policyInfo['name_policy'])) . + print_image($img,true, array('title' => $title)) . ''; } } diff --git a/pandora_console/operation/agentes/estado_monitores.php b/pandora_console/operation/agentes/estado_monitores.php index 64f3f60fea..b0006bf71b 100644 --- a/pandora_console/operation/agentes/estado_monitores.php +++ b/pandora_console/operation/agentes/estado_monitores.php @@ -192,21 +192,33 @@ foreach ($modules as $module) { if (($module["id_modulo"] != 1) && ($module["id_tipo_modulo"] != 100)) { if ($module["flag"] == 0) { $data[0] = ''; - } else { + } + else { $data[0] = ''; } - } else { + } + else { $data[0] = ''; } if ($isFunctionPolicies !== ENTERPRISE_NOT_HOOK) { if($module["id_policy_module"] != 0) { - $img = 'images/policies.png'; + $linked = isModuleLinked($module['id_agente_modulo']); $id_policy = get_db_value_sql('SELECT id_policy FROM tpolicy_modules WHERE id = '.$module["id_policy_module"]); $name_policy = get_db_value_sql('SELECT name FROM tpolicies WHERE id = '.$id_policy); $policyInfo = infoModulePolicy($module["id_policy_module"]); + + if ($linked) { + $img = 'images/policies.png'; + $title = $name_policy; + } + else { + $img = 'images/unlinkpolicy.png'; + $title = __('(Unlinked) ') . $name_policy; + } + $data[1] = '' . - print_image($img,true, array('title' => $name_policy)) . + print_image($img,true, array('title' => $title)) . ''; } else { @@ -228,13 +240,16 @@ foreach ($modules as $module) { if ($module["estado"] == 1) { $status = STATUS_MODULE_CRITICAL; $title = __('CRITICAL'); - } elseif ($module["estado"] == 2) { + } + elseif ($module["estado"] == 2) { $status = STATUS_MODULE_WARNING; $title = __('WARNING'); - } elseif ($module["estado"] == 0) { + } + elseif ($module["estado"] == 0) { $status = STATUS_MODULE_OK; $title = __('NORMAL'); - } elseif ($module["estado"] == 3) { + } + elseif ($module["estado"] == 3) { $last_status = get_agentmodule_last_status($module['id_agente_modulo']); switch($last_status) { case 0: @@ -254,7 +269,8 @@ foreach ($modules as $module) { if (is_numeric($module["datos"])) { $title .= ": " . format_for_graph($module["datos"]); - } else { + } + else { $title .= ": " . substr(safe_output($module["datos"]),0,42); } @@ -262,18 +278,19 @@ foreach ($modules as $module) { if ($module["id_tipo_modulo"] == 24) { // log4x switch($module["datos"]) { - case 10: $salida = "TRACE"; $style="font-weight:bold; color:darkgreen;"; break; - case 20: $salida = "DEBUG"; $style="font-weight:bold; color:darkgreen;"; break; - case 30: $salida = "INFO"; $style="font-weight:bold; color:darkgreen;"; break; - case 40: $salida = "WARN"; $style="font-weight:bold; color:darkorange;"; break; - case 50: $salida = "ERROR"; $style="font-weight:bold; color:red;"; break; - case 60: $salida = "FATAL"; $style="font-weight:bold; color:red;"; break; + case 10: $salida = "TRACE"; $style="font-weight:bold; color:darkgreen;"; break; + case 20: $salida = "DEBUG"; $style="font-weight:bold; color:darkgreen;"; break; + case 30: $salida = "INFO"; $style="font-weight:bold; color:darkgreen;"; break; + case 40: $salida = "WARN"; $style="font-weight:bold; color:darkorange;"; break; + case 50: $salida = "ERROR"; $style="font-weight:bold; color:red;"; break; + case 60: $salida = "FATAL"; $style="font-weight:bold; color:red;"; break; } $salida = "$salida"; } else { if (is_numeric($module["datos"])){ $salida = format_numeric($module["datos"]); - } else { + } + else { $salida = "".substr(safe_output($module["datos"]),0,12).""; } } @@ -297,7 +314,8 @@ foreach ($modules as $module) { if ($module['estado'] == 3) { $data[8] = ''; - } else { + } + else { $data[8] = ''; } $data[8] .= print_timestamp ($module["utimestamp"], true); @@ -309,7 +327,8 @@ foreach ($modules as $module) { if (empty ($table->data)) { echo '
'.__('This agent doesn\'t have any active monitors').'
'; -} else { +} +else { echo "

".__('Full list of monitors')."

"; print_table ($table); } diff --git a/pandora_console/operation/agentes/estado_ultimopaquete.php b/pandora_console/operation/agentes/estado_ultimopaquete.php index a4f21898ab..c04e2bda68 100644 --- a/pandora_console/operation/agentes/estado_ultimopaquete.php +++ b/pandora_console/operation/agentes/estado_ultimopaquete.php @@ -221,13 +221,24 @@ foreach ($modules as $module) { if ($isFunctionPolicies !== ENTERPRISE_NOT_HOOK) { if($module["id_policy_module"] != 0) { - echo ""; - $img = 'images/policies.png'; + $linked = isModuleLinked($module['id_agente_modulo']); $id_policy = get_db_value_sql('SELECT id_policy FROM tpolicy_modules WHERE id = '.$module["id_policy_module"]); $name_policy = get_db_value_sql('SELECT name FROM tpolicies WHERE id = '.$id_policy); $policyInfo = infoModulePolicy($module["id_policy_module"]); + + if ($linked) { + $img = 'images/policies.png'; + $title = $name_policy; + } + else { + $img = 'images/unlinkpolicy.png'; + $title = __('(Unlinked) ') . $name_policy; + } + + echo ""; + echo'' . - print_image($img,true, array('title' => $name_policy)) . + print_image($img,true, array('title' => $title)) . ''; echo ""; } diff --git a/pandora_console/operation/agentes/status_monitor.php b/pandora_console/operation/agentes/status_monitor.php index a89f4a8697..974310294c 100644 --- a/pandora_console/operation/agentes/status_monitor.php +++ b/pandora_console/operation/agentes/status_monitor.php @@ -28,6 +28,8 @@ if (! give_acl ($config['id_user'], 0, "AR") && ! give_acl ($config['id_user'], return; } +$isFunctionPolicies = enterprise_include_once ('include/functions_policies.php'); + print_page_header ("Monitor detail", "images/bricks.png", false); @@ -177,6 +179,9 @@ $table->data = array (); $table->size = array (); $table->align = array (); +if ($isFunctionPolicies !== ENTERPRISE_NOT_HOOK) + $table->head[0] = "" . __('P.') . ""; + $table->head[1] = __('Agent'); $table->head[2] = __('Type'); @@ -211,6 +216,28 @@ foreach ($result as $row) { $data = array (); + if ($isFunctionPolicies !== ENTERPRISE_NOT_HOOK) { + $policyInfo = infoModulePolicy($row['id_agente_modulo']); + if ($policyInfo === false) + $data[0] = ''; + else { + $linked = isModuleLinked($row['id_agente_modulo']); + + if ($linked) { + $img = 'images/policies.png'; + $title = $policyInfo['name_policy']; + } + else { + $img = 'images/unlinkpolicy.png'; + $title = __('(Unlinked) ') . $policyInfo['name_policy']; + } + + $data[0] = '' . + print_image($img,true, array('title' => $title)) . + ''; + } + } + $data[1] = ''; $data[1] .= substr ($row["agent_name"], 0, 25); $data[1] .= '';