From 084aec2453e494930b256a691701ba4224b1117b Mon Sep 17 00:00:00 2001 From: mdtrooper <tres.14159@gmail.com> Date: Mon, 25 Oct 2010 15:49:56 +0000 Subject: [PATCH] 2010-10-21 Miguel de Dios <miguel.dedios@artica.es> * extensions/module_groups.php: show color for when the alert fired, and added cluetip for more details. Pending task: #3041855 git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@3458 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f --- pandora_console/ChangeLog | 7 + pandora_console/extensions/module_groups.php | 141 +++++++++++++++---- 2 files changed, 124 insertions(+), 24 deletions(-) diff --git a/pandora_console/ChangeLog b/pandora_console/ChangeLog index 775ae4f609..0c256db877 100644 --- a/pandora_console/ChangeLog +++ b/pandora_console/ChangeLog @@ -1,3 +1,10 @@ +2010-10-21 Miguel de Dios <miguel.dedios@artica.es> + + * extensions/module_groups.php: show color for when the alert fired, and + added cluetip for more details. + + Pending task: #3041855 + 2010-10-25 Ramon Novoa <rnovoa@artica.es> * include/pchart_graph.php, include/fgraph.php: Added baseline support diff --git a/pandora_console/extensions/module_groups.php b/pandora_console/extensions/module_groups.php index 6bb4576637..fb54cfd92a 100644 --- a/pandora_console/extensions/module_groups.php +++ b/pandora_console/extensions/module_groups.php @@ -12,6 +12,63 @@ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. */ +// Load global vars +global $config; + +if (is_ajax ()) { + check_login (); + + require_once('include/functions_agents.php'); + + $get_info_alert_module_group = (bool)get_parameter('get_info_alert_module_group'); + $module_group = (int)get_parameter('module_group'); + $id_agent_group = (int)get_parameter('id_agent_group'); + + if ($get_info_alert_module_group) { + $agents = get_group_agents($id_agent_group); + if (!empty($agents)) { + $alerts = get_agent_alerts_simple($agents); + + foreach ($alerts as $alert) { + $module = get_db_row_filter('tagente_modulo', array('id_agente_modulo' => $alert['id_agent_module'])); + + if ($module_group == $module['id_module_group']) { + if ($alert["times_fired"] > 0) { + echo '<strong>' . __('Number fired of alerts').': </strong> ' . $alert["times_fired"] . '<br />'; + $agent = get_db_row('tagente', 'id_agente', $module['id_agente']); + echo '<strong>' . __('Agent').': </strong>'; + echo safe_output($agent['nombre']) . '<br />'; + echo '<strong>' . __('Module') . ': </strong>'; + echo safe_output($module['nombre']) . '<br />'; + $template = get_db_row('talert_templates', 'id' , $alert['id_alert_template']); + echo '<strong>' . __('Alert template') . ': </strong>'; + echo safe_output($template['name']) . '<br />'; + + $sql = 'SELECT * + FROM talert_template_module_actions AS t1 + INNER JOIN talert_actions AS t2 ON t1.id_alert_action = t2.id + WHERE t1.id_alert_template_module = ' . $template['id'] . ' OR t2.id = ' . $template['id_alert_action'] . ';'; + + $actions = get_db_all_rows_sql($sql); + if ($actions === false) { + $actions = array(); + } + + echo '<strong>' . __('Actions') . ': </strong>' . '<br />'; + echo '<ul style="margin-top: 0px; margin-left: 30px;">'; + foreach ($actions as $action) { + echo '<li style="list-style: disc;">' . $action['name'] . '</li>'; + } + echo '</ul>'; + if ($alert != end($alerts)) { + echo '<hr />'; + } + } + } + } + } + } +} /** * Translate the array texts using gettext @@ -61,7 +118,8 @@ function mainModuleGroups() { //The content of table $tableData = array(); - //Create rows and celds + + //Create rows and cells foreach ($agentGroups as $idAgentGroup => $name) { $row = array(); @@ -72,6 +130,23 @@ function mainModuleGroups() { $query = sprintf($sql,$idAgentGroup, $idModelGroup); $rowsDB = get_db_all_rows_sql ($query); + + $agents = get_group_agents($idAgentGroup); + if (!empty($agents)) { + $alerts = get_agent_alerts_simple($agents); + + foreach ($alerts as $alert) { + $module = get_db_row_filter('tagente_modulo', array('id_agente_modulo' => $alert['id_agent_module'])); + + if ($idModelGroup == $module['id_module_group']) { + $fired = false; + if ($alert["times_fired"] > 0) { + $fired = true; + } + } + } + } + $states = array(); if ($rowsDB !== false) { foreach ($rowsDB as $rowDB) { @@ -92,11 +167,11 @@ function mainModuleGroups() { $alinkEnd = ''; } else { - // TODO: ADD Alerts fired status - /*if (array_key_exists(4,$states)) { + + if ($fired) { $color = '#ffa300'; //Orange when the cell for this model group and agent has at least one alert fired. - }*/ - if (array_key_exists(1,$states)) { + } + else if (array_key_exists(1,$states)) { $color = '#cc0000'; //Red when the cell for this model group and agent has at least one module in critical state and the rest in any state. $font_color = '#ffffff'; } @@ -111,9 +186,9 @@ function mainModuleGroups() { } - $alinkStart = '<a href="index.php?sec=estado&sec2=operation/agentes/status_monitor&status=-1&ag_group=' . $idAgentGroup . - '&modulegroup=' . $idModelGroup . '". - style="color: ' . $font_color . '; font-size: 18px;";>'; + $alinkStart = '<a class="info_cell" rel="ajax.php?page=extensions/module_groups&get_info_alert_module_group=1&module_group=' . $idModelGroup . '&id_agent_group=' . $idAgentGroup . '" + href="index.php?sec=estado&sec2=operation/agentes/status_monitor&status=-1&ag_group=' . $idAgentGroup . + '&modulegroup=' . $idModelGroup . '" style="color: ' . $font_color . '; font-size: 18px;";>'; $alinkEnd = '</a>'; } @@ -133,24 +208,42 @@ function mainModuleGroups() { echo "<p>" . __("The colours meaning:") . "<ul style='float: left;'>" . - '<li style="clear: both;"> - <div style="float: left; background: #cc0000; height: 20px; width: 80px;margin-right: 5px; margin-bottom: 5px;"> </div>' . - __("Red cell when the module group and agent have at least one module in critical status and the others in any status") . - '</li>' . - '<li style="clear: both;"> - <div style="float: left; background: #fce94f; height: 20px; width: 80px;margin-right: 5px; margin-bottom: 5px;"> </div>' . - __("Yellow cell when the module group and agent have at least one in warning status and the others in grey or green status") . - '</li>' . - '<li style="clear: both;"> - <div style="float: left; background: #8ae234; height: 20px; width: 80px;margin-right: 5px; margin-bottom: 5px;"> </div>' . - __("Green cell when the module group and agent have all modules in OK status") . - '</li>' . - '<li style="clear: both;"> - <div style="float: left; background: #babdb6; height: 20px; width: 80px;margin-right: 5px; margin-bottom: 5px;"> </div>' . - __("Grey cell when the module group and agent have at least one in unknown status and the others in green status") . - '</li>' . + '<li style="clear: both;"> + <div style="float: left; background: #ffa300; height: 20px; width: 80px;margin-right: 5px; margin-bottom: 5px;"> </div>' . + __("Orange cell when the module group and agent have at least one alarm fired.") . + '</li>' . + '<li style="clear: both;"> + <div style="float: left; background: #cc0000; height: 20px; width: 80px;margin-right: 5px; margin-bottom: 5px;"> </div>' . + __("Red cell when the module group and agent have at least one module in critical status and the others in any status") . + '</li>' . + '<li style="clear: both;"> + <div style="float: left; background: #fce94f; height: 20px; width: 80px;margin-right: 5px; margin-bottom: 5px;"> </div>' . + __("Yellow cell when the module group and agent have at least one in warning status and the others in grey or green status") . + '</li>' . + '<li style="clear: both;"> + <div style="float: left; background: #8ae234; height: 20px; width: 80px;margin-right: 5px; margin-bottom: 5px;"> </div>' . + __("Green cell when the module group and agent have all modules in OK status") . + '</li>' . + '<li style="clear: both;"> + <div style="float: left; background: #babdb6; height: 20px; width: 80px;margin-right: 5px; margin-bottom: 5px;"> </div>' . + __("Grey cell when the module group and agent have at least one in unknown status and the others in green status") . + '</li>' . "</ul>" . "</p>"; + + require_css_file('cluetip'); + require_jquery_file('cluetip'); + ?> + <script> + $(document).ready (function () { + $("a.info_cell").cluetip ({ + arrows: true, + attribute: 'rel', + cluetipClass: 'default' + }); + }); + </script> + <?php } add_operation_menu_option(__("Modules groups"), 'estado', 'module_groups/icon_menu.png');