From 084aec2453e494930b256a691701ba4224b1117b Mon Sep 17 00:00:00 2001 From: mdtrooper Date: Mon, 25 Oct 2010 15:49:56 +0000 Subject: [PATCH] 2010-10-21 Miguel de Dios * 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 + + * 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 * 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 '' . __('Number fired of alerts').': ' . $alert["times_fired"] . '
'; + $agent = get_db_row('tagente', 'id_agente', $module['id_agente']); + echo '' . __('Agent').': '; + echo safe_output($agent['nombre']) . '
'; + echo '' . __('Module') . ': '; + echo safe_output($module['nombre']) . '
'; + $template = get_db_row('talert_templates', 'id' , $alert['id_alert_template']); + echo '' . __('Alert template') . ': '; + echo safe_output($template['name']) . '
'; + + $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 '' . __('Actions') . ': ' . '
'; + echo '
    '; + foreach ($actions as $action) { + echo '
  • ' . $action['name'] . '
  • '; + } + echo '
'; + if ($alert != end($alerts)) { + echo '
'; + } + } + } + } + } + } +} /** * 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 = ''; + $alinkStart = ''; $alinkEnd = ''; } @@ -133,24 +208,42 @@ function mainModuleGroups() { echo "

" . __("The colours meaning:") . "

    " . - '
  • -
     
    ' . - __("Red cell when the module group and agent have at least one module in critical status and the others in any status") . - '
  • ' . - '
  • -
     
    ' . - __("Yellow cell when the module group and agent have at least one in warning status and the others in grey or green status") . - '
  • ' . - '
  • -
     
    ' . - __("Green cell when the module group and agent have all modules in OK status") . - '
  • ' . - '
  • -
     
    ' . - __("Grey cell when the module group and agent have at least one in unknown status and the others in green status") . - '
  • ' . + '
  • +
     
    ' . + __("Orange cell when the module group and agent have at least one alarm fired.") . + '
  • ' . + '
  • +
     
    ' . + __("Red cell when the module group and agent have at least one module in critical status and the others in any status") . + '
  • ' . + '
  • +
     
    ' . + __("Yellow cell when the module group and agent have at least one in warning status and the others in grey or green status") . + '
  • ' . + '
  • +
     
    ' . + __("Green cell when the module group and agent have all modules in OK status") . + '
  • ' . + '
  • +
     
    ' . + __("Grey cell when the module group and agent have at least one in unknown status and the others in green status") . + '
  • ' . "
" . "

"; + + require_css_file('cluetip'); + require_jquery_file('cluetip'); + ?> + +