From 8a8293a1dddc6ebbca43bac4133f1e6203703459 Mon Sep 17 00:00:00 2001 From: zarzuelo Date: Wed, 7 Dec 2011 14:19:05 +0000 Subject: [PATCH] 2011-12-07 Sergio Martin * include/functions_modules.php godmode/agentes/module_manager_editor_common.php godmode/agentes/module_manager.php: Added status column in godmode view of modules and added delete button in edition module view * operation/agentes/estado_monitores.php: Fixed missed extra query to not show modules of foreign policies git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@5239 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f --- pandora_console/ChangeLog | 11 +++ .../godmode/agentes/module_manager.php | 37 ++++++---- .../agentes/module_manager_editor_common.php | 9 +++ pandora_console/include/functions_modules.php | 73 +++++++++++++------ .../operation/agentes/estado_monitores.php | 53 +++----------- 5 files changed, 104 insertions(+), 79 deletions(-) diff --git a/pandora_console/ChangeLog b/pandora_console/ChangeLog index a5a1c0cb7b..1093654b59 100644 --- a/pandora_console/ChangeLog +++ b/pandora_console/ChangeLog @@ -1,3 +1,14 @@ +2011-12-07 Sergio Martin + + * include/functions_modules.php + godmode/agentes/module_manager_editor_common.php + godmode/agentes/module_manager.php: Added status column in + godmode view of modules and added delete button in + edition module view + + * operation/agentes/estado_monitores.php: Fixed missed + extra query to not show modules of foreign policies + 2011-12-07 Juan Manuel Ramon * operation/agentes/estado_agente.php: Added filter by summarized diff --git a/pandora_console/godmode/agentes/module_manager.php b/pandora_console/godmode/agentes/module_manager.php index b43bfe1346..93bc975c32 100644 --- a/pandora_console/godmode/agentes/module_manager.php +++ b/pandora_console/godmode/agentes/module_manager.php @@ -342,20 +342,21 @@ $table->head[4] = __('Interval') . ' ' . '' . html_print_image("images/sort_up.png", true, array("style" => $selectIntervalUp)) . '' . '' . html_print_image("images/sort_down.png", true, array("style" => $selectIntervalDown)) . ''; $table->head[5] = __('Description'); -$table->head[6] = __('Warn'); +$table->head[6] = __('Status'); +$table->head[7] = __('Warn'); -$table->head[7] = __('Action'); +$table->head[8] = __('Action'); $table->rowstyle = array(); $table->style = array (); $table->style[0] = 'font-weight: bold'; $table->size = array (); $table->size[2] = '55px'; -$table->size[7] = '100px'; +$table->size[8] = '100px'; $table->align = array (); $table->align[2] = 'center'; -$table->align[7] = 'left'; +$table->align[8] = 'left'; $table->data = array (); $agent_interval = agents_get_interval ($id_agente); @@ -477,30 +478,36 @@ foreach ($modules as $module) { $data[5] = ui_print_truncate_text($module['descripcion'], 50, false); + $module_status = db_get_row('tagente_estado', 'id_agente_modulo', $module['id_agente_modulo']); + + modules_get_status($module['id_agente_modulo'], $module_status['estado'], $module_status['datos'], $status, $title); + + $data[6] = ui_print_status_image($status, $title, true); + // MAX / MIN values - $data[6] = ui_print_module_warn_value ($module["max_warning"], $module["min_warning"], $module["str_warning"], $module["max_critical"], $module["min_critical"], $module["str_critical"]); + $data[7] = ui_print_module_warn_value ($module["max_warning"], $module["min_warning"], $module["str_warning"], $module["max_critical"], $module["min_critical"], $module["str_critical"]); // Delete module - $data[7] = html_print_checkbox('id_delete[]', $module['id_agente_modulo'], false, true); - $data[7] .= ' '; - $data[7] .= html_print_image ('images/cross.png', true, + $data[8] .= html_print_image ('images/cross.png', true, array ('title' => __('Delete'))); - $data[7] .= ' '; - $data[7] .= ' '; - $data[7] .= html_print_image ('images/copy.png', true, + $data[8] .= html_print_image ('images/copy.png', true, array ('title' => __('Duplicate'))); - $data[7] .= ' '; + $data[8] .= ' '; // Make a data normalization if (isset($numericModules[$type])) { if ($numericModules[$type] === true) { - $data[7] .= ' '; - $data[7] .= html_print_image ('images/chart_curve.png', true, + $data[8] .= ' '; + $data[8] .= html_print_image ('images/chart_curve.png', true, array ('title' => __('Normalize'))); - $data[7] .= ''; + $data[8] .= ''; } } diff --git a/pandora_console/godmode/agentes/module_manager_editor_common.php b/pandora_console/godmode/agentes/module_manager_editor_common.php index 91557122d9..ac7c58b6f9 100644 --- a/pandora_console/godmode/agentes/module_manager_editor_common.php +++ b/pandora_console/godmode/agentes/module_manager_editor_common.php @@ -124,6 +124,15 @@ $table_simple->style[2] = 'font-weight: bold; vertical-align: top'; $table_simple->data[0][0] = __('Name'); $table_simple->data[0][1] = html_print_input_text ('name', io_safe_output($name), '', 50, 100, true, $disabledBecauseInPolicy); + +if (isset($id_agent_module) && isset($id_agente)) { + $table_simple->data[0][1] .= ' '; + $table_simple->data[0][1] .= html_print_image ('images/cross.png', true, + array ('title' => __('Delete module'))); + $table_simple->data[0][1] .= ' '; +} + $table_simple->data[0][2] = __('Disabled'); $table_simple->data[0][3] = html_print_checkbox ("disabled", 1, $disabled, true); diff --git a/pandora_console/include/functions_modules.php b/pandora_console/include/functions_modules.php index 4d5e75bc63..2e7e80f9fa 100644 --- a/pandora_console/include/functions_modules.php +++ b/pandora_console/include/functions_modules.php @@ -995,29 +995,6 @@ function modules_get_agentmodule_last_status($id_agentmodule = 0) { return $status_row['last_status']; } -/** - * Get the worst status of all modules of the agents of a group. - * - * @param int Id module to check. - * - * @return int Worst status of a module for all of its agents. - * The value -1 is returned in case the agent has exceed its interval. <-- DISABLED - */ -function modules_get_status ($id_module = 0) { - $time = get_system_time (); - - $status = db_get_sql ("SELECT estado - FROM tagente_estado, tagente_modulo - WHERE tagente_estado.id_agente_modulo = tagente_modulo.id_agente_modulo - AND tagente_modulo.disabled = 0 - AND tagente_modulo.delete_pending = 0 - AND tagente_modulo.id_agente_modulo = ".$id_module); - - // TODO: Check any alert for that agent who has recept alerts fired - - return $status; -} - /** * Get the current value of an agent module. * @@ -1188,4 +1165,54 @@ function modules_get_modulegroup_name ($modulegroup_id) { return (string) db_get_value ('name', 'tmodule_group', 'id_mg', (int) $modulegroup_id); } +/** + * Gets a module status an modify the status and title reference variables + * + * @param mixed The module data (Necessary $module['datos'] and $module['estado'] + * @param int status reference variable + * @param string title reference variable + * + */ +function modules_get_status($id_agent_module, $db_status, $data, &$status, &$title) { + $status = STATUS_MODULE_WARNING; + $title = ""; + + if ($db_status == 1) { + $status = STATUS_MODULE_CRITICAL; + $title = __('CRITICAL'); + } + elseif ($db_status == 2) { + $status = STATUS_MODULE_WARNING; + $title = __('WARNING'); + } + elseif ($db_status == 0) { + $status = STATUS_MODULE_OK; + $title = __('NORMAL'); + } + elseif ($db_status == 3) { + $last_status = modules_get_agentmodule_last_status($id_agent_module); + switch($last_status) { + case 0: + $status = STATUS_MODULE_OK; + $title = __('UNKNOWN')." - ".__('Last status')." ".__('NORMAL'); + break; + case 1: + $status = STATUS_MODULE_CRITICAL; + $title = __('UNKNOWN')." - ".__('Last status')." ".__('CRITICAL'); + break; + case 2: + $status = STATUS_MODULE_WARNING; + $title = __('UNKNOWN')." - ".__('Last status')." ".__('WARNING'); + break; + } + } + + if (is_numeric($data)) { + $title .= ": " . format_for_graph($data); + } + else { + $title .= ": " . substr(io_safe_output($data),0,42); + } +} + ?> diff --git a/pandora_console/operation/agentes/estado_monitores.php b/pandora_console/operation/agentes/estado_monitores.php index 2232b26fb8..a6d605f1e6 100644 --- a/pandora_console/operation/agentes/estado_monitores.php +++ b/pandora_console/operation/agentes/estado_monitores.php @@ -152,6 +152,15 @@ switch ($config["dbtype"]) { break; } +// Get the enterprise acl sql condition +$extra_sql = enterprise_hook('policies_get_modules_sql_condition', array($id_agente)); + +if($extra_sql == ENTERPRISE_NOT_HOOK) { + $extra_sql = ''; +}else if ($extra_sql != '') { + $extra_sql = "(($extra_sql) OR id_policy_module = 0) AND"; +} + // Get all module from agent switch ($config["dbtype"]) { case "mysql": @@ -172,8 +181,8 @@ switch ($config["dbtype"]) { SELECT * FROM tagente_estado, (SELECT * FROM tagente_modulo WHERE id_agente = %d AND disabled = 0 AND delete_pending = 0) tagente_modulo LEFT JOIN tmodule_group ON tagente_modulo.id_module_group = tmodule_group.id_mg WHERE tagente_estado.id_agente_modulo = tagente_modulo.id_agente_modulo - AND tagente_estado.utimestamp != 0 - ORDER BY tagente_modulo.id_module_group , %s %s", $id_agente, $order['field'], $order['order']); + AND %s tagente_estado.utimestamp != 0 + ORDER BY tagente_modulo.id_module_group , %s %s", $id_agente, $extra_sql, $order['field'], $order['order']); break; // If Dbms is Oracle then field_list in sql statement has to be recoded. See oracle_list_all_field_table() case "oracle": @@ -330,46 +339,8 @@ foreach ($modules as $module) { html_print_image("images/tag_red.png", true, array("id" => 'tag-details-'.$module['id_agente_modulo'], "class" => "img_help")) . ' '; } $data[4] = ui_print_string_substr ($module["descripcion"], 40, true, 9); - - $status = STATUS_MODULE_WARNING; - $title = ""; - - if ($module["estado"] == 1) { - $status = STATUS_MODULE_CRITICAL; - $title = __('CRITICAL'); - } - elseif ($module["estado"] == 2) { - $status = STATUS_MODULE_WARNING; - $title = __('WARNING'); - } - elseif ($module["estado"] == 0) { - $status = STATUS_MODULE_OK; - $title = __('NORMAL'); - } - elseif ($module["estado"] == 3) { - $last_status = modules_get_agentmodule_last_status($module['id_agente_modulo']); - switch($last_status) { - case 0: - $status = STATUS_MODULE_OK; - $title = __('UNKNOWN')." - ".__('Last status')." ".__('NORMAL'); - break; - case 1: - $status = STATUS_MODULE_CRITICAL; - $title = __('UNKNOWN')." - ".__('Last status')." ".__('CRITICAL'); - break; - case 2: - $status = STATUS_MODULE_WARNING; - $title = __('UNKNOWN')." - ".__('Last status')." ".__('WARNING'); - break; - } - } - if (is_numeric($module["datos"])) { - $title .= ": " . format_for_graph($module["datos"]); - } - else { - $title .= ": " . substr(io_safe_output($module["datos"]),0,42); - } + modules_get_status($module['id_agente_modulo'], $module['estado'], $module['datos'], $status, $title); $data[5] = ui_print_status_image($status, $title, true);