$alert['id_agent_module'])); if ($module_group == $module['id_module_group']) { if ($alert["times_fired"] > 0) { $data = true; echo '' . __('Number fired of alerts').': ' . $alert["times_fired"] . '
'; $agent = db_get_row('tagente', 'id_agente', $module['id_agente']); echo '' . __('Agent').': '; echo io_safe_output($agent['nombre']) . '
'; echo '' . __('Module') . ': '; echo io_safe_output($module['nombre']) . '
'; $template = db_get_row('talert_templates', 'id' , $alert['id_alert_template']); echo '' . __('Alert template') . ': '; echo io_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 = db_get_all_rows_sql($sql); if ($actions === false) { $actions = array(); } echo '' . __('Actions') . ': ' . '
'; echo ''; if ($alert != end($alerts)) { echo '
'; } } } } if(!$data){ echo 'These module/s have no alerts or alert/s are not fired'; } } else{ echo 'No available data'; } } else{ echo 'No available data'; } } /** * Translate the array texts using gettext */ function translate(&$item, $key) { $item = __($item); } /** * The main function of module groups and the enter point to * execute the code. */ function mainModuleGroups() { global $config; //the useful global var of Pandora Console, it has many data can you use require_once ('include/functions_reporting.php'); require_once($config['homedir'] . "/include/functions_agents.php"); require_once($config['homedir'] . "/include/functions_users.php"); //The big query switch ($config["dbtype"]) { case "mysql": $sql = "SELECT COUNT(id_agente) AS count, estado FROM tagente_estado WHERE utimestamp != 0 AND id_agente IN (SELECT id_agente FROM tagente WHERE id_grupo = %d AND disabled IS FALSE) AND id_agente_modulo IN (SELECT id_agente_modulo FROM tagente_modulo WHERE id_module_group = %d AND disabled IS FALSE AND delete_pending IS FALSE) GROUP BY estado"; break; case "postgresql": $sql = "SELECT COUNT(id_agente) AS count, estado FROM tagente_estado WHERE utimestamp != 0 AND id_agente IN (SELECT id_agente FROM tagente WHERE id_grupo = %d AND disabled = 0) AND id_agente_modulo IN (SELECT id_agente_modulo FROM tagente_modulo WHERE id_module_group = %d AND disabled = 0 AND delete_pending = 0) GROUP BY estado"; break; case "oracle": $sql = "SELECT COUNT(id_agente) AS count, estado FROM tagente_estado WHERE utimestamp != 0 AND id_agente IN (SELECT id_agente FROM tagente WHERE id_grupo = %d AND (disabled IS NOT NULL AND disabled <> 0)) AND id_agente_modulo IN (SELECT id_agente_modulo FROM tagente_modulo WHERE id_module_group = %d AND (disabled IS NOT NULL AND disabled <> 0) AND (delete_pending IS NOT NULL AND delete_pending <> 0)) GROUP BY estado"; break; } ui_print_page_header (__("Combined table of agent group and module group"), "images/brick.png", false, "", false, ''); echo "

" . __("This table shows in columns the modules group and in rows agents group. The cell shows all modules") . "

"; $agentGroups = users_get_groups ($config['id_user'], "AR", false); $modelGroups = users_get_all_model_groups(); if(!empty($agentGroups) && !empty($modelGroups)) { array_walk($modelGroups, 'translate'); //Translate all head titles to language is set foreach ($modelGroups as $i => $n) { $modelGroups[$i] = ui_print_truncate_text($n, 20); } $head = $modelGroups; array_unshift($head, ' '); //Metaobject use in html_print_table $table = null; $table->align[0] = 'right'; //Align to right the first column. $table->style[0] = 'color: #ffffff; background-color: #778866; font-weight: bolder;'; $table->head = $head; $table->width = '98%'; //The content of table $tableData = array(); $fired = false; //Create rows and cells foreach ($agentGroups as $idAgentGroup => $name) { $row = array(); array_push($row, ui_print_truncate_text($name, 20)); foreach ($modelGroups as $idModelGroup => $modelGroup) { $query = sprintf($sql,$idAgentGroup, $idModelGroup); $rowsDB = db_get_all_rows_sql ($query); $agents = agents_get_group_agents($idAgentGroup); if (!empty($agents)) { $alerts = agents_get_alerts_simple(array_keys($agents)); foreach ($alerts as $alert) { $module = db_get_row_filter('tagente_modulo', array('id_agente_modulo' => $alert['id_agent_module'])); if ($idModelGroup == $module['id_module_group']) { if ($alert["times_fired"] > 0) { $fired = true; } } } } $states = array(); if ($rowsDB !== false) { foreach ($rowsDB as $rowDB) { $states[$rowDB['estado']] = $rowDB['count']; } } $count = 0; foreach ($states as $idState => $state) { $count += $state; } $color = 'transparent'; //Defaut color for cell $font_color = '#000000'; //Default font color for cell if ($count == 0) { $color = '#eeeeee'; //Soft grey when the cell for this model group and agent group hasn't modules. $alinkStart = ''; $alinkEnd = ''; } else { if ($fired) { $color = '#ffa300'; //Orange when the cell for this model group and agent has at least one alert fired. } 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'; } elseif (array_key_exists(2,$states)) { $color = '#fce94f'; //Yellow when the cell for this model group and agent has at least one in warning state and the rest in green state. } elseif (array_key_exists(3,$states)) { $color = '#babdb6'; //Grey when the cell for this model group and agent has at least one module in unknown state and the rest in any state. } elseif (array_key_exists(0,$states)) { $color = '#8ae234'; //Green when the cell for this model group and agent has OK state all modules. } $alinkStart = ''; $alinkEnd = ''; } array_push($row, '
' . $alinkStart . $count . $alinkEnd . '
'); } array_push($tableData,$row); } $table->data = $tableData; echo "
"; html_print_table($table); echo "
"; echo "

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

" . "

"; } else { echo "
".__('There are no defined groups or module groups')."
"; } ui_require_css_file('cluetip'); ui_require_jquery_file('cluetip'); ?>