Ticket integria:4063 fixed report alert for module, group, agent
(cherry picked from commit d2617df147
)
This commit is contained in:
parent
ebc78153cd
commit
5e2706efd1
|
@ -2593,19 +2593,14 @@ function reporting_alert_report_group($report, $content) {
|
|||
$data_row['template'] = db_get_value_filter('name', 'talert_templates',
|
||||
array('id' => $alert['id_alert_template']));
|
||||
|
||||
|
||||
$actions = db_get_all_rows_sql('SELECT name
|
||||
FROM talert_actions
|
||||
WHERE id IN (SELECT id_alert_action
|
||||
FROM talert_template_module_actions
|
||||
WHERE id_alert_template_module = ' . $alert['id_alert_template'] . ')');
|
||||
$actions = alerts_get_alert_agent_module_actions ($alert['id']);
|
||||
|
||||
if (!empty($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'] . ')');
|
||||
WHERE id = ' . $alert['id'] . ')');
|
||||
|
||||
$id_action = 0;
|
||||
if (!empty($row))
|
||||
|
@ -2614,16 +2609,13 @@ function reporting_alert_report_group($report, $content) {
|
|||
// Prevent from void action
|
||||
if (empty($id_action))
|
||||
$id_action = 0;
|
||||
|
||||
}
|
||||
else {
|
||||
$actions = db_get_all_rows_sql('SELECT name
|
||||
FROM talert_actions
|
||||
WHERE id = ' . $id_action);
|
||||
|
||||
if (empty($actions)) {
|
||||
$actions = array();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$data_row['action'] = array();
|
||||
foreach ($actions as $action) {
|
||||
$data_row['action'][] = $action['name'];
|
||||
|
@ -2635,9 +2627,12 @@ function reporting_alert_report_group($report, $content) {
|
|||
$alert['id_alert_template'],
|
||||
(int) $content['period'],
|
||||
(int) $report["datetime"]);
|
||||
|
||||
if (empty($firedTimes)) {
|
||||
$firedTimes = array();
|
||||
$firedTimes[0]['timestamp'] = '----------------------------';
|
||||
}
|
||||
|
||||
foreach ($firedTimes as $fireTime) {
|
||||
$data_row['fired'][] = $fireTime['timestamp'];
|
||||
}
|
||||
|
@ -2667,8 +2662,6 @@ function reporting_alert_report_agent($report, $content) {
|
|||
if ($config['metaconsole']) {
|
||||
$id_meta = metaconsole_get_id_server($content["server_name"]);
|
||||
|
||||
|
||||
|
||||
$server = metaconsole_get_connection_by_id ($id_meta);
|
||||
metaconsole_connect($server);
|
||||
}
|
||||
|
@ -2692,87 +2685,69 @@ function reporting_alert_report_agent($report, $content) {
|
|||
|
||||
$data = array();
|
||||
|
||||
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']));
|
||||
|
||||
|
||||
|
||||
switch ($config["dbtype"]) {
|
||||
case "mysql":
|
||||
case "postgresql":
|
||||
$actions = db_get_all_rows_sql('SELECT name
|
||||
FROM talert_actions
|
||||
WHERE id IN (SELECT id_alert_action
|
||||
FROM talert_template_module_actions
|
||||
WHERE id_alert_template_module = ' . $alert['id_alert_template'] . ');');
|
||||
break;
|
||||
case "oracle":
|
||||
$actions = db_get_all_rows_sql('SELECT name
|
||||
FROM talert_actions
|
||||
WHERE id IN (SELECT id_alert_action
|
||||
FROM talert_template_module_actions
|
||||
WHERE id_alert_template_module = ' . $alert['id_alert_template'] . ')');
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
if (!empty($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'] . ')');
|
||||
if (is_array($alerts) || is_object($alerts)) {
|
||||
foreach ($alerts as $alert) {
|
||||
$data_row = array();
|
||||
|
||||
$id_action = 0;
|
||||
if (!empty($row))
|
||||
$id_action = $row['id_alert_action'];
|
||||
$data_row['disabled'] = $alert['disabled'];
|
||||
|
||||
// Prevent from void action
|
||||
if (empty($id_action))
|
||||
$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)) {
|
||||
$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;
|
||||
|
||||
$actions = db_get_all_rows_sql('SELECT name
|
||||
FROM talert_actions
|
||||
WHERE id = ' . $id_action);
|
||||
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
|
||||
FROM talert_actions
|
||||
WHERE id = ' . $id_action);
|
||||
}
|
||||
|
||||
if (empty($actions)) {
|
||||
$actions = array();
|
||||
}
|
||||
|
||||
$data_row['action'] = array();
|
||||
foreach ($actions as $action) {
|
||||
$data_row['action'][] = $action['name'];
|
||||
}
|
||||
|
||||
$data_row['fired'] = array();
|
||||
$firedTimes = get_module_alert_fired(
|
||||
$alert['id_agent_module'],
|
||||
$alert['id_alert_template'],
|
||||
(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;
|
||||
}
|
||||
|
||||
$data_row['action'] = array();
|
||||
foreach ($actions as $action) {
|
||||
$data_row['action'][] = $action['name'];
|
||||
}
|
||||
|
||||
$data_row['fired'] = array();
|
||||
$firedTimes = get_module_alert_fired(
|
||||
$alert['id_agent_module'],
|
||||
$alert['id_alert_template'],
|
||||
(int) $content['period'],
|
||||
(int) $report["datetime"]);
|
||||
|
||||
|
||||
|
||||
if (empty($firedTimes)) {
|
||||
$firedTimes = array();
|
||||
}
|
||||
foreach ($firedTimes as $fireTime) {
|
||||
$data_row['fired'][] = $fireTime['timestamp'];
|
||||
}
|
||||
|
||||
$data[] = $data_row;
|
||||
}
|
||||
|
||||
|
||||
$return['data'] = $data;
|
||||
|
||||
if ($config['metaconsole']) {
|
||||
|
@ -2837,7 +2812,9 @@ function reporting_alert_report_module($report, $content) {
|
|||
}
|
||||
|
||||
$data = array();
|
||||
|
||||
foreach ($alerts as $alert) {
|
||||
|
||||
$data_row = array();
|
||||
|
||||
$data_row['disabled'] = $alert['disabled'];
|
||||
|
@ -2845,25 +2822,7 @@ function reporting_alert_report_module($report, $content) {
|
|||
$data_row['template'] = db_get_value_filter('name',
|
||||
'talert_templates', array('id' => $alert['id_alert_template']));
|
||||
|
||||
switch ($config["dbtype"]) {
|
||||
case "mysql":
|
||||
case "postgresql":
|
||||
$actions = db_get_all_rows_sql('SELECT name
|
||||
FROM talert_actions
|
||||
WHERE id IN (SELECT id_alert_action
|
||||
FROM talert_template_module_actions
|
||||
WHERE id_alert_template_module = ' . $alert['id_alert_template_module'] . ');');
|
||||
break;
|
||||
case "oracle":
|
||||
$actions = db_get_all_rows_sql('SELECT name
|
||||
FROM talert_actions
|
||||
WHERE id IN (SELECT id_alert_action
|
||||
FROM talert_template_module_actions
|
||||
WHERE id_alert_template_module = ' . $alert['id_alert_template_module'] . ')');
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
$actions = alerts_get_alert_agent_module_actions ($alert['id_alert_template_module']);
|
||||
|
||||
if (!empty($actions)) {
|
||||
$row = db_get_row_sql('SELECT id_alert_action
|
||||
|
@ -2873,43 +2832,41 @@ function reporting_alert_report_module($report, $content) {
|
|||
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 {
|
||||
$actions = db_get_all_rows_sql('SELECT name
|
||||
FROM talert_actions
|
||||
WHERE id = ' . $id_action);
|
||||
|
||||
if (empty($actions)) {
|
||||
$actions = array();
|
||||
}
|
||||
}
|
||||
|
||||
$data_row['action'] = array();
|
||||
foreach ($actions as $action) {
|
||||
$data_row['action'][] = $action['name'];
|
||||
}
|
||||
|
||||
|
||||
$data_row['fired'] = array();
|
||||
$firedTimes = get_module_alert_fired(
|
||||
$content['id_agent_module'],
|
||||
$alert['id_alert_template_module'],
|
||||
(int) $content['period'],
|
||||
(int) $report["datetime"]);
|
||||
|
||||
|
||||
(int) $report["datetime"]);
|
||||
|
||||
if (empty($firedTimes)) {
|
||||
$firedTimes = array();
|
||||
$firedTimes[0]['timestamp'] = '----------------------------';
|
||||
}
|
||||
|
||||
foreach ($firedTimes as $fireTime) {
|
||||
$data_row['fired'][] = $fireTime['timestamp'];
|
||||
}
|
||||
|
||||
|
||||
$data[] = $data_row;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue