mirror of
https://github.com/pandorafms/pandorafms.git
synced 2025-07-31 01:35:36 +02:00
fixed errors in reports alerts
This commit is contained in:
parent
790b8bab6e
commit
85dddf0b56
@ -1273,6 +1273,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.
|
||||||
*
|
*
|
||||||
|
@ -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']);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1287,7 +1287,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);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -1451,7 +1451,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']) {
|
||||||
@ -2654,6 +2654,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;
|
||||||
@ -2680,8 +2706,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 (
|
||||||
@ -2689,8 +2715,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 (
|
||||||
@ -2708,66 +2734,90 @@ 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']));
|
|
||||||
|
|
||||||
$actions = alerts_get_alert_agent_module_actions ($alert['id']);
|
// Alerts over $id_agent_module
|
||||||
|
$alerts = alerts_get_effective_alert_actions($agent_module['id_agent_module']);
|
||||||
|
|
||||||
if (!empty($actions)) {
|
if ($alerts === false){
|
||||||
$row = db_get_row_sql('SELECT id_alert_action
|
continue;
|
||||||
FROM talert_templates
|
}
|
||||||
WHERE id IN (SELECT id_alert_template
|
|
||||||
FROM talert_template_modules
|
|
||||||
WHERE id = ' . $alert['id'] . ')');
|
|
||||||
|
|
||||||
$id_action = 0;
|
$ntemplates = 0;
|
||||||
if (!empty($row))
|
|
||||||
$id_action = $row['id_alert_action'];
|
|
||||||
|
|
||||||
// Prevent from void action
|
foreach ($alerts as $template => $actions) {
|
||||||
if (empty($id_action))
|
|
||||||
$id_action = 0;
|
$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 {
|
else {
|
||||||
$actions = db_get_all_rows_sql('SELECT name
|
$data_action[$naction]['fired'] = $fired;
|
||||||
FROM talert_actions
|
}
|
||||||
WHERE id = ' . $id_action);
|
$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'],
|
$agent_module['id_agent_module'],
|
||||||
$alert['id'],
|
$actions["id"],
|
||||||
(int) $content['period'],
|
(int) $content["period"],
|
||||||
(int) $report["datetime"]);
|
(int) $report["datetime"]);
|
||||||
|
$module_actions["actions"] = $data_action;
|
||||||
|
|
||||||
if (empty($firedTimes)) {
|
$data_row['alerts'][$ntemplates] = $module_actions;
|
||||||
$firedTimes = array();
|
$ntemplates++;
|
||||||
$firedTimes[0]['timestamp'] = '----------------------------';
|
|
||||||
}
|
|
||||||
|
|
||||||
foreach ($firedTimes as $fireTime) {
|
|
||||||
$data_row['fired'][] = $fireTime['timestamp'];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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();
|
||||||
@ -2801,81 +2851,90 @@ function reporting_alert_report_agent($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'] : '';
|
||||||
|
|
||||||
$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 = array();
|
||||||
|
$data_row['agent'] = $agent_name;
|
||||||
|
$data_row['module'] = $module_name;
|
||||||
|
|
||||||
$data_row['disabled'] = $alert['disabled'];
|
// Alerts over $id_agent_module
|
||||||
|
$alerts = alerts_get_effective_alert_actions($id);
|
||||||
|
|
||||||
$data_row['module'] = db_get_value_filter('nombre', 'tagente_modulo',
|
if ($alerts === false){
|
||||||
array('id_agente_modulo' => $alert['id_agent_module']));
|
continue;
|
||||||
$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']);
|
$ntemplates = 0;
|
||||||
|
|
||||||
if (!empty($actions)) {
|
foreach ($alerts as $template => $actions) {
|
||||||
$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_alert_template'] . ')');
|
|
||||||
|
|
||||||
$id_action = 0;
|
$data_action = array();
|
||||||
if (!empty($row))
|
$data_action['actions'] = array();
|
||||||
$id_action = $row['id_alert_action'];
|
|
||||||
|
|
||||||
// Prevent from void action
|
$naction = 0;
|
||||||
if (empty($id_action))
|
if (isset($actions["custom"])) {
|
||||||
$id_action = 0;
|
foreach ($actions["custom"] as $action) {
|
||||||
|
$data_action[$naction]["name"] = $action["name"];
|
||||||
|
$fired = $action["fired"];
|
||||||
|
if ($fired == 0){
|
||||||
|
$data_action[$naction]['fired'] = '----------------------------';
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$actions = db_get_all_rows_sql('SELECT name
|
$data_action[$naction]['fired'] = $fired;
|
||||||
FROM talert_actions
|
}
|
||||||
WHERE id = ' . $id_action);
|
$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++;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (empty($actions)) {
|
$module_actions = array();
|
||||||
$actions = array();
|
|
||||||
}
|
|
||||||
|
|
||||||
$data_row['action'] = array();
|
$module_actions["template"] = $template;
|
||||||
foreach ($actions as $action) {
|
$module_actions["template_fired"] = reporting_alert_get_fired(
|
||||||
$data_row['action'][] = $action['name'];
|
$id,
|
||||||
}
|
$actions["id"],
|
||||||
|
(int) $content["period"],
|
||||||
$data_row['fired'] = array();
|
|
||||||
$firedTimes = get_module_alert_fired(
|
|
||||||
$alert['id_agent_module'],
|
|
||||||
$alert['id'],
|
|
||||||
(int) $content['period'],
|
|
||||||
(int) $report["datetime"]);
|
(int) $report["datetime"]);
|
||||||
|
$module_actions["actions"] = $data_action;
|
||||||
|
|
||||||
if (empty($firedTimes)) {
|
$data_row['alerts'][$ntemplates] = $module_actions;
|
||||||
$firedTimes = array();
|
$ntemplates++;
|
||||||
$firedTimes[0]['timestamp'] = '----------------------------';
|
|
||||||
}
|
|
||||||
|
|
||||||
foreach ($firedTimes as $fireTime) {
|
|
||||||
$data_row['fired'][] = $fireTime['timestamp'];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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();
|
||||||
@ -2913,98 +2972,89 @@ 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":
|
|
||||||
case "postgresql":
|
|
||||||
$alerts = db_get_all_rows_sql('
|
|
||||||
SELECT *, t1.id as id_alert_template_module
|
|
||||||
FROM talert_template_modules t1
|
|
||||||
INNER JOIN talert_templates t2
|
|
||||||
ON t1.id_alert_template = t2.id
|
|
||||||
WHERE id_agent_module = ' . $content['id_agent_module']);
|
|
||||||
break;
|
|
||||||
case "oracle":
|
|
||||||
$alerts = db_get_all_rows_sql('
|
|
||||||
SELECT t1.*, t2.*, t1.id as id_alert_template_module
|
|
||||||
FROM talert_template_modules t1
|
|
||||||
INNER JOIN talert_templates t2
|
|
||||||
ON t1.id_alert_template = t2.id
|
|
||||||
WHERE id_agent_module = ' . $content['id_agent_module']);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
if ($alerts === false) {
|
|
||||||
$alerts = array();
|
|
||||||
}
|
|
||||||
|
|
||||||
$data = array();
|
|
||||||
$actions = array();
|
|
||||||
foreach ($alerts as $alert) {
|
|
||||||
|
|
||||||
$data_row = array();
|
$data_row = array();
|
||||||
|
|
||||||
$data_row['disabled'] = $alert['disabled'];
|
|
||||||
|
|
||||||
$data_row['template'] = db_get_value_filter('name',
|
$data_row['agent'] = io_safe_output(agents_get_name(
|
||||||
'talert_templates', array('id' => $alert['id_alert_template']));
|
agents_get_agent_id_by_module_id($content['id_agent_module'])));
|
||||||
|
$data_row['module'] = db_get_value_filter('nombre', 'tagente_modulo',
|
||||||
|
array('id_agente_modulo' => $content['id_agent_module']));
|
||||||
|
|
||||||
$actions = alerts_get_alert_agent_module_actions ($alert['id_alert_template_module']);
|
// Alerts over $id_agent_module
|
||||||
|
$alerts = alerts_get_effective_alert_actions($content['id_agent_module']);
|
||||||
|
|
||||||
if (!empty($actions)) {
|
if ($alerts === false){
|
||||||
$row = db_get_row_sql('SELECT id_alert_action
|
continue;
|
||||||
FROM talert_templates
|
}
|
||||||
WHERE id IN (SELECT id_alert_template
|
|
||||||
FROM talert_template_modules
|
|
||||||
WHERE id = ' . $alert['id_alert_template_module'] . ')');
|
|
||||||
|
|
||||||
$id_action = 0;
|
$ntemplates = 0;
|
||||||
|
|
||||||
if (!empty($row))
|
foreach ($alerts as $template => $actions) {
|
||||||
$id_action = $row['id_alert_action'];
|
|
||||||
|
|
||||||
// Prevent from void action
|
$data_action = array();
|
||||||
if (empty($id_action))
|
$data_action['actions'] = array();
|
||||||
$id_action = 0;
|
|
||||||
|
$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 {
|
else {
|
||||||
if ($id_action != null) {
|
$data_action[$naction]['fired'] = $fired;
|
||||||
$actions = db_get_all_rows_sql('SELECT name
|
}
|
||||||
FROM talert_actions
|
$naction++;
|
||||||
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 {
|
else {
|
||||||
$data_row['action'] = array();
|
$data_action[$naction]['fired'] = $fired;
|
||||||
foreach ($actions as $action) {
|
}
|
||||||
$data_row['action'][] = $action['name'];
|
$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['fired'] = array();
|
$module_actions = array();
|
||||||
$firedTimes = get_module_alert_fired(
|
|
||||||
|
$module_actions["template"] = $template;
|
||||||
|
$module_actions["template_fired"] = reporting_alert_get_fired(
|
||||||
$content['id_agent_module'],
|
$content['id_agent_module'],
|
||||||
$alert['id_alert_template_module'],
|
$actions["id"],
|
||||||
(int) $content['period'],
|
(int) $content["period"],
|
||||||
(int) $report["datetime"]);
|
(int) $report["datetime"]);
|
||||||
|
$module_actions["actions"] = $data_action;
|
||||||
|
|
||||||
if (empty($firedTimes)) {
|
$data_row['alerts'][$ntemplates] = $module_actions;
|
||||||
$firedTimes = array();
|
$ntemplates++;
|
||||||
$firedTimes[0]['timestamp'] = '----------------------------';
|
|
||||||
}
|
|
||||||
|
|
||||||
foreach ($firedTimes as $fireTime) {
|
|
||||||
$data_row['fired'][] = $fireTime['timestamp'];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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();
|
||||||
@ -5237,7 +5287,7 @@ function reporting_availability_graph($report, $content, $date=false, $time=fals
|
|||||||
$width_graph,
|
$width_graph,
|
||||||
$height_graph,
|
$height_graph,
|
||||||
$urlImage,
|
$urlImage,
|
||||||
5,
|
1,
|
||||||
$raw_graph,
|
$raw_graph,
|
||||||
false);
|
false);
|
||||||
|
|
||||||
|
@ -234,14 +234,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);
|
||||||
@ -1611,113 +1607,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->data = array ();
|
||||||
|
$table1->rowspan = array();
|
||||||
|
$table1->valign = array();
|
||||||
$table1->head['agent'] = __('Agent');
|
$table1->head['agent'] = __('Agent');
|
||||||
$table1->head['module'] = __('Module');
|
$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";
|
||||||
|
$table1->valign["module"] = "top";
|
||||||
|
$table1->valign["template"] = "top";
|
||||||
|
$table1->valign["actions"] = "top";
|
||||||
|
$table1->valign["fired"] = "top";
|
||||||
|
$table1->valign["tfired"] = "top";
|
||||||
|
|
||||||
|
$td = 0;
|
||||||
|
foreach ($item['data'] as $information) {
|
||||||
$row = array();
|
$row = array();
|
||||||
|
|
||||||
$row['agent'] = $alert['agent'];
|
$td = count($information["alerts"]);
|
||||||
$row['module'] = $alert['module'];
|
|
||||||
$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";
|
|
||||||
|
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['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>';
|
$row['fired'] .= '</ul>';
|
||||||
|
|
||||||
|
$row['tfired'] = '<ul style="list-style-type: none;">' . "\n";
|
||||||
|
foreach ($alert['template_fired'] as $fired) {
|
||||||
|
$row['tfired'] .= '<li>' . $fired . '</li>' . "\n";
|
||||||
|
}
|
||||||
|
$row['tfired'] .= '</ul>';
|
||||||
|
|
||||||
|
// Skip first td's to avoid repeat the agent and module names
|
||||||
$table1->data[] = $row;
|
$table1->data[] = $row;
|
||||||
|
if($td > 1){
|
||||||
|
for($i=0; $i<$td;$i++) {
|
||||||
|
$row['agent'] = "";
|
||||||
|
$row['module'] = "";
|
||||||
}
|
}
|
||||||
|
|
||||||
$table->data['alerts']['cell'] = html_print_table($table1, true);
|
|
||||||
}
|
|
||||||
|
|
||||||
function reporting_html_alert_report_agent($table, $item) {
|
|
||||||
$table->colspan['alerts']['cell'] = 3;
|
|
||||||
$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['module'] = $alert['module'];
|
|
||||||
$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);
|
|
||||||
}
|
|
||||||
|
|
||||||
function reporting_html_alert_report_module($table, $item) {
|
|
||||||
$table->colspan['alerts']['cell'] = 3;
|
|
||||||
$table->cellstyle['alerts']['cell'] = 'text-align: left;';
|
|
||||||
|
|
||||||
$table1 = new stdClass();
|
|
||||||
$table1->width = '99%';
|
|
||||||
$table1->head = array ();
|
|
||||||
$table1->head['template'] = __('Template');
|
|
||||||
$table1->head['actions'] = __('Actions');
|
|
||||||
$table1->head['fired'] = __('Fired');
|
|
||||||
$table1->data = array ();
|
|
||||||
foreach ($item['data'] as $alert) {
|
|
||||||
$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);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user