fixed errors in reports alerts

(cherry picked from commit 85dddf0b56f2816451f690481308717b2568b3e0)
This commit is contained in:
daniel 2017-01-03 19:31:35 +01:00
parent 0205bf3914
commit 4afaf5190a
4 changed files with 394 additions and 310 deletions

View File

@ -1311,6 +1311,85 @@ function alerts_get_alert_agent_module_actions ($id_alert_agent_module, $fields
return $retval; return $retval;
} }
/**
* Returns the actions applied to an alert assigned to a module in a hash.
* @param unsigned int id_agent_module
*
* @return hash with the actions
*
* hash[template1][action1] <- fired
* hash[template1][action2] <- fired
* hash[template1][action3] <- fired
* hash[template2][action1] <- fired
*/
function alerts_get_effective_alert_actions($id_agent_module) {
if (empty ($id_agent_module))
return false;
$default_sql = 'select tm.id, t.name as template, a.name as action, tm.last_fired as last_execution from talert_templates t, talert_actions a, talert_template_modules tm where tm.id_alert_template=t.id and t.id_alert_action=a.id and tm.id_agent_module=' . $id_agent_module;
$actions = db_get_all_rows_sql ($default_sql);
$custom_sql = 'select tm.id, t.name as template, a.name as action, tma.last_execution from talert_actions a, talert_template_module_actions tma, talert_template_modules tm, talert_templates t where tma.id_alert_template_module=tm.id and tma.id_alert_action=a.id and tm.id_alert_template = t.id and tm.id_agent_module=' . $id_agent_module;
$custom_actions = db_get_all_rows_sql($custom_sql);
$no_actions_sql = 'select tm.id, t.name as template from talert_templates t, talert_template_modules tm where tm.id_alert_template=t.id and tm.id_agent_module=' . $id_agent_module;
$no_actions = db_get_all_rows_sql ($no_actions_sql);
$nactions = 0;
$return = array();
if ($actions !== false) {
foreach ($actions as $a) {
if (!isset($return[$a["template"]]["id"])){
$return[$a["template"]]["id"] = $a["id"];
}
if (!isset($return[$a["template"]]["default"])){
$return[$a["template"]]["default"] = array();
}
$return[$a["template"]]["default"][$nactions]["fired"] = $a["last_execution"];
$return[$a["template"]]["default"][$nactions]["name"] = $a["action"];
$nactions++;
}
}
if ($custom_actions !== false) {
foreach ($custom_actions as $a) {
if (!isset($return[$a["template"]]["id"])){
$return[$a["template"]]["id"] = $a["id"];
}
if (!isset($return[$a["template"]]["custom"])){
$return[$a["template"]]["custom"] = array();
}
$return[$a["template"]]["custom"][$nactions]["fired"] = $a["last_execution"];
$return[$a["template"]]["custom"][$nactions]["name"] = $a["action"];
$nactions++;
}
}
if ($no_actions !== false){
foreach ($no_actions as $a) {
if (!isset($return[$a["template"]]["id"])){
$return[$a["template"]]["id"] = $a["id"];
}
if (!isset($return[$a["template"]]["unavailable"])){
$return[$a["template"]]["unavailable"] = array();
}
$return[$a["template"]]["unavailable"][$nactions]["fired"] = 0;
$return[$a["template"]]["unavailable"][$nactions]["name"] = __("No actions defined");
$nactions++;
}
}
if ($nactions == 0) {
return false;
}
return $return;
}
/** /**
* Validates an alert id or an array of alert id's. * Validates an alert id or an array of alert id's.
* *

View File

@ -221,7 +221,7 @@ function events_get_events_grouped($sql_post, $offset = 0,
// Override the column 'user_comment' with the column 'user_comments' when oracle // Override the column 'user_comment' with the column 'user_comments' when oracle
if (!empty($events) && $config["dbtype"] == "oracle") { if (!empty($events) && $config["dbtype"] == "oracle") {
array_walk($events, function(&$value, $key) { array_walk($events, function(&$value, $key) {
set_if_defined($value['user_comments'], $value['user_comments']); set_if_defined($value['user_comment'], $value['user_comments']);
}); });
} }

View File

@ -1292,7 +1292,7 @@ function reporting_event_report_group($report, $content,
$return['failed'] = __('No events'); $return['failed'] = __('No events');
} }
else { else {
$return['data'] = $data; $return['data'] = array_reverse($data);
} }
@ -1456,7 +1456,7 @@ function reporting_event_report_module($report, $content) {
$return['failed'] = __('No events'); $return['failed'] = __('No events');
} }
else { else {
$return['data'] = $data; $return['data'] = array_reverse($data);
} }
if ($config['metaconsole']) { if ($config['metaconsole']) {
@ -2632,6 +2632,32 @@ function reporting_network_interfaces_report($report, $content,
return reporting_check_structure_content($return); return reporting_check_structure_content($return);
} }
/**
* reporting alert get fired
*/
function reporting_alert_get_fired($id_agent_module, $id_alert_template_module, $period, $datetime) {
$fired = array();
$firedTimes = get_module_alert_fired(
$id_agent_module,
$id_alert_template_module,
$period,
$datetime);
if (empty($firedTimes)) {
$firedTimes = array();
$firedTimes[0]['timestamp'] = '----------------------------';
}
foreach ($firedTimes as $fireTime) {
$fired[] = $fireTime['timestamp'];
}
return $fired;
}
/**
* Reporting alert report group
*/
function reporting_alert_report_group($report, $content) { function reporting_alert_report_group($report, $content) {
global $config; global $config;
@ -2658,8 +2684,8 @@ function reporting_alert_report_group($report, $content) {
$return["date"] = reporting_get_date_text($report, $content); $return["date"] = reporting_get_date_text($report, $content);
if ($content['id_group'] == 0) { if ($content['id_group'] == 0) {
$alerts = db_get_all_rows_sql(' $agent_modules = db_get_all_rows_sql('
SELECT * SELECT distinct(id_agent_module)
FROM talert_template_modules FROM talert_template_modules
WHERE disabled = 0 WHERE disabled = 0
AND id_agent_module IN ( AND id_agent_module IN (
@ -2667,8 +2693,8 @@ function reporting_alert_report_group($report, $content) {
FROM tagente_modulo)'); FROM tagente_modulo)');
} }
else { else {
$alerts = db_get_all_rows_sql(' $agent_modules = db_get_all_rows_sql('
SELECT * SELECT distinct(id_agent_module)
FROM talert_template_modules FROM talert_template_modules
WHERE disabled = 0 WHERE disabled = 0
AND id_agent_module IN ( AND id_agent_module IN (
@ -2686,71 +2712,95 @@ function reporting_alert_report_group($report, $content) {
$data = array(); $data = array();
foreach ($alerts as $alert) { foreach ($agent_modules as $agent_module) {
$data_row = array(); $data_row = array();
$data_row['disabled'] = $alert['disabled'];
$data_row['agent'] = io_safe_output(agents_get_name( $data_row['agent'] = io_safe_output(agents_get_name(
agents_get_agent_id_by_module_id($alert['id_agent_module']))); agents_get_agent_id_by_module_id($agent_module['id_agent_module'])));
$data_row['module'] = db_get_value_filter('nombre', 'tagente_modulo', $data_row['module'] = db_get_value_filter('nombre', 'tagente_modulo',
array('id_agente_modulo' => $alert['id_agent_module'])); array('id_agente_modulo' => $agent_module['id_agent_module']));
$data_row['template'] = db_get_value_filter('name', 'talert_templates',
array('id' => $alert['id_alert_template'])); // Alerts over $id_agent_module
$alerts = alerts_get_effective_alert_actions($agent_module['id_agent_module']);
$actions = alerts_get_alert_agent_module_actions ($alert['id']);
if ($alerts === false){
if (!empty($actions)) { continue;
$row = db_get_row_sql('SELECT id_alert_action
FROM talert_templates
WHERE id IN (SELECT id_alert_template
FROM talert_template_modules
WHERE id = ' . $alert['id'] . ')');
$id_action = 0;
if (!empty($row))
$id_action = $row['id_alert_action'];
// Prevent from void action
if (empty($id_action))
$id_action = 0;
} }
else {
$actions = db_get_all_rows_sql('SELECT name $ntemplates = 0;
FROM talert_actions
WHERE id = ' . $id_action); foreach ($alerts as $template => $actions) {
$data_action = array();
$data_action['actions'] = array();
$naction = 0;
if (isset($actions["custom"])) {
foreach ($actions["custom"] as $action) {
$data_action[$naction]["name"] = $action["name"];
$fired = $action["fired"];
if ($fired == 0){
$data_action[$naction]['fired'] = '----------------------------';
}
else {
$data_action[$naction]['fired'] = $fired;
}
$naction++;
}
}
elseif (isset($actions["default"])) {
foreach ($actions["default"] as $action) {
$data_action[$naction]["name"] = $action["name"];
$fired = $action["fired"];
if ($fired == 0){
$data_action[$naction]['fired'] = '----------------------------';
}
else {
$data_action[$naction]['fired'] = $fired;
}
$naction++;
}
}
elseif(isset($actions["unavailable"])) {
foreach ($actions["unavailable"] as $action) {
$data_action[$naction]["name"] = $action["name"];
$fired = $action["fired"];
if ($fired == 0){
$data_action[$naction]['fired'] = '----------------------------';
}
else {
$data_action[$naction]['fired'] = $fired;
}
$naction++;
}
}
$module_actions = array();
$module_actions["template"] = $template;
$module_actions["template_fired"] = reporting_alert_get_fired(
$agent_module['id_agent_module'],
$actions["id"],
(int) $content["period"],
(int) $report["datetime"]);
$module_actions["actions"] = $data_action;
$data_row['alerts'][$ntemplates] = $module_actions;
$ntemplates++;
} }
$data_row['action'] = array(); if ($ntemplates > 0) {
foreach ($actions as $action) { $data[] = $data_row;
$data_row['action'][] = $action['name'];
} }
$data_row['fired'] = array();
$firedTimes = get_module_alert_fired(
$alert['id_agent_module'],
$alert['id'],
(int) $content['period'],
(int) $report["datetime"]);
if (empty($firedTimes)) {
$firedTimes = array();
$firedTimes[0]['timestamp'] = '----------------------------';
}
foreach ($firedTimes as $fireTime) {
$data_row['fired'][] = $fireTime['timestamp'];
}
$data[] = $data_row;
} }
$return['data'] = $data; $return["data"] = $data;
if ($config['metaconsole']) { if ($config['metaconsole']) {
metaconsole_restore_db(); metaconsole_restore_db();
} }
return reporting_check_structure_content($return); return reporting_check_structure_content($return);
} }
@ -2778,83 +2828,92 @@ function reporting_alert_report_agent($report, $content) {
$return["description"] = $content["description"]; $return["description"] = $content["description"];
$return["date"] = reporting_get_date_text($report, $content); $return["date"] = reporting_get_date_text($report, $content);
$return['label'] = (isset($content['style']['label'])) ? $content['style']['label'] : ''; $return['label'] = (isset($content['style']['label'])) ? $content['style']['label'] : '';
$alerts = agents_get_alerts($content['id_agent']); $module_list = agents_get_modules($content['id_agent']);
if (isset($alerts['simple'])) {
$alerts = $alerts['simple'];
}
else {
$alerts = array();
}
$data = array(); $data = array();
foreach ($module_list as $id => $module_name) {
if (is_array($alerts) || is_object($alerts)) {
foreach ($alerts as $alert) {
$data_row = array();
$data_row['disabled'] = $alert['disabled'];
$data_row['module'] = db_get_value_filter('nombre', 'tagente_modulo',
array('id_agente_modulo' => $alert['id_agent_module']));
$data_row['template'] = db_get_value_filter('name', 'talert_templates',
array('id' => $alert['id_alert_template']));
$actions = alerts_get_alert_agent_module_actions ($alert['id']);
if (!empty($actions)) { $data_row = array();
$row = db_get_row_sql('SELECT id_alert_action $data_row['agent'] = $agent_name;
FROM talert_templates $data_row['module'] = $module_name;
WHERE id IN (SELECT id_alert_template
FROM talert_template_modules // Alerts over $id_agent_module
WHERE id = ' . $alert['id_alert_template'] . ')'); $alerts = alerts_get_effective_alert_actions($id);
$id_action = 0; if ($alerts === false){
if (!empty($row)) continue;
$id_action = $row['id_alert_action']; }
// Prevent from void action $ntemplates = 0;
if (empty($id_action))
$id_action = 0; foreach ($alerts as $template => $actions) {
}
else { $data_action = array();
$actions = db_get_all_rows_sql('SELECT name $data_action['actions'] = array();
FROM talert_actions
WHERE id = ' . $id_action);
}
if (empty($actions)) { $naction = 0;
$actions = array(); if (isset($actions["custom"])) {
foreach ($actions["custom"] as $action) {
$data_action[$naction]["name"] = $action["name"];
$fired = $action["fired"];
if ($fired == 0){
$data_action[$naction]['fired'] = '----------------------------';
}
else {
$data_action[$naction]['fired'] = $fired;
}
$naction++;
}
}
elseif (isset($actions["default"])) {
foreach ($actions["default"] as $action) {
$data_action[$naction]["name"] = $action["name"];
$fired = $action["fired"];
if ($fired == 0){
$data_action[$naction]['fired'] = '----------------------------';
}
else {
$data_action[$naction]['fired'] = $fired;
}
$naction++;
}
}
elseif(isset($actions["unavailable"])) {
foreach ($actions["unavailable"] as $action) {
$data_action[$naction]["name"] = $action["name"];
$fired = $action["fired"];
if ($fired == 0){
$data_action[$naction]['fired'] = '----------------------------';
}
else {
$data_action[$naction]['fired'] = $fired;
}
$naction++;
}
} }
$data_row['action'] = array(); $module_actions = array();
foreach ($actions as $action) {
$data_row['action'][] = $action['name'];
}
$data_row['fired'] = array(); $module_actions["template"] = $template;
$firedTimes = get_module_alert_fired( $module_actions["template_fired"] = reporting_alert_get_fired(
$alert['id_agent_module'], $id,
$alert['id'], $actions["id"],
(int) $content['period'], (int) $content["period"],
(int) $report["datetime"]); (int) $report["datetime"]);
$module_actions["actions"] = $data_action;
if (empty($firedTimes)) {
$firedTimes = array();
$firedTimes[0]['timestamp'] = '----------------------------';
}
foreach ($firedTimes as $fireTime) { $data_row['alerts'][$ntemplates] = $module_actions;
$data_row['fired'][] = $fireTime['timestamp']; $ntemplates++;
} }
if ($ntemplates > 0) {
$data[] = $data_row; $data[] = $data_row;
} }
} }
$return['data'] = $data; $return["data"] = $data;
if ($config['metaconsole']) { if ($config['metaconsole']) {
metaconsole_restore_db(); metaconsole_restore_db();
} }
@ -2891,101 +2950,92 @@ function reporting_alert_report_module($report, $content) {
$return["date"] = reporting_get_date_text($report, $content); $return["date"] = reporting_get_date_text($report, $content);
$return['label'] = (isset($content['style']['label'])) ? $content['style']['label'] : ''; $return['label'] = (isset($content['style']['label'])) ? $content['style']['label'] : '';
switch ($config["dbtype"]) {
case "mysql": $data_row = array();
case "postgresql":
$alerts = db_get_all_rows_sql('
SELECT *, t1.id as id_alert_template_module $data_row['agent'] = io_safe_output(agents_get_name(
FROM talert_template_modules t1 agents_get_agent_id_by_module_id($content['id_agent_module'])));
INNER JOIN talert_templates t2 $data_row['module'] = db_get_value_filter('nombre', 'tagente_modulo',
ON t1.id_alert_template = t2.id array('id_agente_modulo' => $content['id_agent_module']));
WHERE id_agent_module = ' . $content['id_agent_module']);
break; // Alerts over $id_agent_module
case "oracle": $alerts = alerts_get_effective_alert_actions($content['id_agent_module']);
$alerts = db_get_all_rows_sql('
SELECT t1.*, t2.*, t1.id as id_alert_template_module if ($alerts === false){
FROM talert_template_modules t1 continue;
INNER JOIN talert_templates t2
ON t1.id_alert_template = t2.id
WHERE id_agent_module = ' . $content['id_agent_module']);
break;
} }
$ntemplates = 0;
foreach ($alerts as $template => $actions) {
if ($alerts === false) {
$alerts = array(); $data_action = array();
} $data_action['actions'] = array();
$data = array();
$actions = array();
foreach ($alerts as $alert) {
$data_row = array(); $naction = 0;
if (isset($actions["custom"])) {
$data_row['disabled'] = $alert['disabled']; foreach ($actions["custom"] as $action) {
$data_action[$naction]["name"] = $action["name"];
$data_row['template'] = db_get_value_filter('name', $fired = $action["fired"];
'talert_templates', array('id' => $alert['id_alert_template'])); if ($fired == 0){
$data_action[$naction]['fired'] = '----------------------------';
$actions = alerts_get_alert_agent_module_actions ($alert['id_alert_template_module']); }
else {
if (!empty($actions)) { $data_action[$naction]['fired'] = $fired;
$row = db_get_row_sql('SELECT id_alert_action }
FROM talert_templates $naction++;
WHERE id IN (SELECT id_alert_template
FROM talert_template_modules
WHERE id = ' . $alert['id_alert_template_module'] . ')');
$id_action = 0;
if (!empty($row))
$id_action = $row['id_alert_action'];
// Prevent from void action
if (empty($id_action))
$id_action = 0;
}
else {
if ($id_action != null) {
$actions = db_get_all_rows_sql('SELECT name
FROM talert_actions
WHERE id = ' . $id_action);
} }
} }
elseif (isset($actions["default"])) {
if (empty($actions)) { foreach ($actions["default"] as $action) {
$data_row['action'][] = __('No defined actions'); $data_action[$naction]["name"] = $action["name"];
$fired = $action["fired"];
if ($fired == 0){
$data_action[$naction]['fired'] = '----------------------------';
}
else {
$data_action[$naction]['fired'] = $fired;
}
$naction++;
}
} }
else { elseif(isset($actions["unavailable"])) {
$data_row['action'] = array(); foreach ($actions["unavailable"] as $action) {
foreach ($actions as $action) { $data_action[$naction]["name"] = $action["name"];
$data_row['action'][] = $action['name']; $fired = $action["fired"];
if ($fired == 0){
$data_action[$naction]['fired'] = '----------------------------';
}
else {
$data_action[$naction]['fired'] = $fired;
}
$naction++;
} }
} }
$data_row['fired'] = array(); $module_actions = array();
$firedTimes = get_module_alert_fired(
$content['id_agent_module'],
$alert['id_alert_template_module'],
(int) $content['period'],
(int) $report["datetime"]);
if (empty($firedTimes)) { $module_actions["template"] = $template;
$firedTimes = array(); $module_actions["template_fired"] = reporting_alert_get_fired(
$firedTimes[0]['timestamp'] = '----------------------------'; $content['id_agent_module'],
} $actions["id"],
(int) $content["period"],
(int) $report["datetime"]);
$module_actions["actions"] = $data_action;
foreach ($firedTimes as $fireTime) { $data_row['alerts'][$ntemplates] = $module_actions;
$data_row['fired'][] = $fireTime['timestamp']; $ntemplates++;
} }
if ($ntemplates > 0) {
$data[] = $data_row; $data[] = $data_row;
} }
$return['data'] = $data; $return["data"] = $data;
if ($config['metaconsole']) { if ($config['metaconsole']) {
metaconsole_restore_db(); metaconsole_restore_db();
} }
return reporting_check_structure_content($return); return reporting_check_structure_content($return);
@ -5208,7 +5258,7 @@ function reporting_availability_graph($report, $content, $date=false, $time=fals
1920, 1920,
50, 50,
$urlImage, $urlImage,
5, 1,
$raw_graph, $raw_graph,
false); false);
@ -6101,7 +6151,7 @@ function reporting_get_group_detailed_event ($id_group, $period = 0,
$filter_event_validated, $filter_event_critical, $filter_event_validated, $filter_event_critical,
$filter_event_warning, $filter_event_no_validated, $filter_event_warning, $filter_event_no_validated,
$filter_event_filter_search, false, $history, $filter_event_type); $filter_event_filter_search, false, $history, $filter_event_type);
if ($return_type === 'hash') { if ($return_type === 'hash') {
return $events; return $events;
} }

View File

@ -233,14 +233,10 @@ function reporting_html_print_report($report, $mini = false) {
case 'sql_graph_pie': case 'sql_graph_pie':
reporting_html_sql_graph($table, $item); reporting_html_sql_graph($table, $item);
break; break;
case 'alert_report_module':
reporting_html_alert_report_module($table, $item);
break;
case 'alert_report_agent':
reporting_html_alert_report_agent($table, $item);
break;
case 'alert_report_group': case 'alert_report_group':
reporting_html_alert_report_group($table, $item); case 'alert_report_module':
case 'alert_report_agent':
reporting_html_alert_report($table, $item);
break; break;
case 'network_interfaces_report': case 'network_interfaces_report':
reporting_html_network_interfaces_report($table, $item); reporting_html_network_interfaces_report($table, $item);
@ -1610,113 +1606,72 @@ function reporting_html_network_interfaces_report($table, $item) {
} }
} }
function reporting_html_alert_report_group($table, $item) { /**
* Unified alert report HTML
*/
function reporting_html_alert_report($table, $item) {
$table->colspan['alerts']['cell'] = 3; $table->colspan['alerts']['cell'] = 3;
$table->cellstyle['alerts']['cell'] = 'text-align: left;'; $table->cellstyle['alerts']['cell'] = 'text-align: left;';
$table1->width = '99%'; $table1->width = '99%';
$table1->head = array (); $table1->head = array ();
$table1->head['agent'] = __('Agent'); $table1->data = array ();
$table1->head['module'] = __('Module'); $table1->rowspan = array();
$table1->valign = array();
$table1->head['agent'] = __('Agent');
$table1->head['module'] = __('Module');
$table1->head['template'] = __('Template'); $table1->head['template'] = __('Template');
$table1->head['actions'] = __('Actions'); $table1->head['actions'] = __('Actions');
$table1->head['fired'] = __('Fired'); $table1->head['fired'] = __('Action') . " " . __('Fired');
$table1->data = array (); $table1->head['tfired'] = __('Template') . " " . __('Fired');
foreach ($item['data'] as $alert) { $table1->valign["agent"] = "top";
$row = array(); $table1->valign["module"] = "top";
$table1->valign["template"] = "top";
$row['agent'] = $alert['agent']; $table1->valign["actions"] = "top";
$row['module'] = $alert['module']; $table1->valign["fired"] = "top";
$row['template'] = $alert['template']; $table1->valign["tfired"] = "top";
$row['actions'] = $alert['template'];
$row['actions'] = '<ul class="action_list">' . "\n";
foreach ($alert['action'] as $action) {
$row['actions'] .= '<li>' . $action . '</li>' . "\n";
}
$row['actions'] .= '</ul>';
$row['fired'] = '<ul style="list-style-type: disc; margin-left: 10px;">' . "\n";
foreach ($alert['fired'] as $fired) {
$row['fired'] .= '<li>' . $fired . '</li>' . "\n";
}
$row['fired'] .= '</ul>';
$table1->data[] = $row;
}
$table->data['alerts']['cell'] = html_print_table($table1, true);
}
function reporting_html_alert_report_agent($table, $item) { $td = 0;
$table->colspan['alerts']['cell'] = 3; foreach ($item['data'] as $information) {
$table->cellstyle['alerts']['cell'] = 'text-align: left;';
$table1 = new stdClass();
$table1->width = '99%';
$table1->head = array ();
$table1->head['module'] = __('Module');
$table1->head['template'] = __('Template');
$table1->head['actions'] = __('Actions');
$table1->head['fired'] = __('Fired');
$table1->data = array ();
foreach ($item['data'] as $alert) {
$row = array(); $row = array();
$row['module'] = $alert['module']; $td = count($information["alerts"]);
$row['template'] = $alert['template'];
$row['actions'] = $alert['template'];
$row['actions'] = '<ul class="action_list">' . "\n"; $row['agent'] = $information['agent'];
foreach ($alert['action'] as $action) { $row['module'] = $information['module'];
$row['actions'] .= '<li>' . $action . '</li>' . "\n";
}
$row['actions'] .= '</ul>';
$row['fired'] = '<ul style="list-style-type: disc; margin-left: 10px;">' . "\n";
foreach ($alert['fired'] as $fired) {
$row['fired'] .= '<li>' . $fired . '</li>' . "\n";
}
$row['fired'] .= '</ul>';
$table1->data[] = $row;
}
$table->data['alerts']['cell'] = html_print_table($table1, true); foreach ($information["alerts"] as $alert) {
} $row['template'] = $alert["template"];
$row['actions'] = '<ul>' . "\n";
$row['fired'] = '<ul style="list-style-type: none;">' . "\n";
foreach ($alert['actions'] as $action) {
$row['actions'] .= '<li>' . $action['name'] . '</li>';
if (is_numeric($action['fired'])){
$row['fired'] .= '<li>' . date("Y-m-d H:i:s", $action['fired']) . '</li>';
}
else {
$row['fired'] .= '<li>' . $action['fired'] . '</li>';
}
}
$row['actions'] .= '</ul>';
$row['fired'] .= '</ul>';
function reporting_html_alert_report_module($table, $item) { $row['tfired'] = '<ul style="list-style-type: none;">' . "\n";
$table->colspan['alerts']['cell'] = 3; foreach ($alert['template_fired'] as $fired) {
$table->cellstyle['alerts']['cell'] = 'text-align: left;'; $row['tfired'] .= '<li>' . $fired . '</li>' . "\n";
}
$table1 = new stdClass(); $row['tfired'] .= '</ul>';
$table1->width = '99%';
$table1->head = array (); // Skip first td's to avoid repeat the agent and module names
$table1->head['template'] = __('Template'); $table1->data[] = $row;
$table1->head['actions'] = __('Actions'); if($td > 1){
$table1->head['fired'] = __('Fired'); for($i=0; $i<$td;$i++) {
$table1->data = array (); $row['agent'] = "";
foreach ($item['data'] as $alert) { $row['module'] = "";
$row = array(); }
}
$row['template'] = $alert['template'];
$row['actions'] = $alert['template'];
$row['actions'] = '<ul class="action_list">' . "\n";
foreach ($alert['action'] as $action) {
$row['actions'] .= '<li>' . $action . '</li>' . "\n";
} }
$row['actions'] .= '</ul>';
$row['fired'] = '<ul style="list-style-type: disc; margin-left: 10px;">' . "\n";
foreach ($alert['fired'] as $fired) {
$row['fired'] .= '<li>' . $fired . '</li>' . "\n";
}
$row['fired'] .= '</ul>';
$table1->data[] = $row;
} }
$table->data['alerts']['cell'] = html_print_table($table1, true); $table->data['alerts']['cell'] = html_print_table($table1, true);
} }