Fixed module/agent/group alert report
This commit is contained in:
parent
7a6c3c16ec
commit
8daca7d220
|
@ -1633,23 +1633,13 @@ function get_agent_alert_fired ($id_agent, $id_alert, $period, $date = 0) {
|
|||
*
|
||||
* @return array An array with all the events happened.
|
||||
*/
|
||||
function get_module_alert_fired ($id_agent_module, $id_alert, $period, $date = 0) {
|
||||
function get_module_alert_fired ($id_agent_module, $id_alert) {
|
||||
|
||||
if (!is_numeric ($date)) {
|
||||
$date = time_w_fixed_tz($date);
|
||||
}
|
||||
if (empty ($date)) {
|
||||
$date = get_system_time();
|
||||
}
|
||||
|
||||
$datelimit = $date - $period;
|
||||
|
||||
$sql = sprintf ('SELECT timestamp
|
||||
$sql = sprintf ('SELECT *
|
||||
FROM tevento
|
||||
WHERE id_agentmodule = %d AND utimestamp > %d
|
||||
AND utimestamp <= %d
|
||||
WHERE id_agentmodule = %d
|
||||
AND id_alert_am = %d
|
||||
ORDER BY timestamp DESC', $id_agent_module, $datelimit, $date, $id_alert);
|
||||
ORDER BY timestamp DESC', $id_agent_module, $id_alert);
|
||||
|
||||
return db_get_all_rows_sql ($sql);
|
||||
}
|
||||
|
|
|
@ -2867,13 +2867,27 @@ function reporting_alert_get_fired($id_agent_module, $id_alert_template_module,
|
|||
$period,
|
||||
$datetime);
|
||||
|
||||
if (!is_numeric ($datetime)) {
|
||||
$datetime = time_w_fixed_tz($datetime);
|
||||
}
|
||||
if (empty ($datetime)) {
|
||||
$datetime = get_system_time();
|
||||
}
|
||||
|
||||
$datelimit = $datetime - $period;
|
||||
|
||||
$empty = '----------------------------';
|
||||
if (empty($firedTimes)) {
|
||||
$firedTimes = array();
|
||||
$firedTimes[0]['timestamp'] = null;
|
||||
$empty = _('There are no alerts defined');
|
||||
$firedTimes[0]['timestamp'] = '';
|
||||
}
|
||||
|
||||
foreach ($firedTimes as $fireTime) {
|
||||
if($fireTime['utimestamp'] > $datelimit && $fireTime['utimestamp'] <= $datetime)
|
||||
$fired[] = $fireTime['timestamp'];
|
||||
else
|
||||
$fired[] = $empty;
|
||||
}
|
||||
|
||||
return $fired;
|
||||
|
@ -2956,6 +2970,16 @@ function reporting_alert_report_group($report, $content) {
|
|||
|
||||
foreach ($alerts as $template => $actions) {
|
||||
|
||||
$datetime = (int) $report["datetime"];
|
||||
if (!is_numeric ($datetime)) {
|
||||
$datetime = time_w_fixed_tz($datetime);
|
||||
}
|
||||
if (empty ($datetime)) {
|
||||
$datetime = get_system_time();
|
||||
}
|
||||
$period = (int) $content["period"];
|
||||
$datelimit = $datetime - $period;
|
||||
|
||||
$data_action = array();
|
||||
$data_action['actions'] = array();
|
||||
|
||||
|
@ -2964,7 +2988,7 @@ function reporting_alert_report_group($report, $content) {
|
|||
foreach ($actions["custom"] as $action) {
|
||||
$data_action[$naction]["name"] = $action["name"];
|
||||
$fired = $action["fired"];
|
||||
if ($fired == 0){
|
||||
if ($fired == 0 || ($fired <= $datelimit || $fired > $datetime)){
|
||||
$data_action[$naction]['fired'] = '----------------------------';
|
||||
}
|
||||
else {
|
||||
|
@ -2977,7 +3001,7 @@ function reporting_alert_report_group($report, $content) {
|
|||
foreach ($actions["default"] as $action) {
|
||||
$data_action[$naction]["name"] = $action["name"];
|
||||
$fired = $action["fired"];
|
||||
if ($fired == 0){
|
||||
if ($fired == 0 || ($fired <= $datelimit || $fired > $datetime)){
|
||||
$data_action[$naction]['fired'] = '----------------------------';
|
||||
}
|
||||
else {
|
||||
|
@ -2990,7 +3014,7 @@ function reporting_alert_report_group($report, $content) {
|
|||
foreach ($actions["unavailable"] as $action) {
|
||||
$data_action[$naction]["name"] = $action["name"];
|
||||
$fired = $action["fired"];
|
||||
if ($fired == 0){
|
||||
if ($fired == 0 || ($fired <= $datelimit || $fired > $datetime)){
|
||||
$data_action[$naction]['fired'] = '----------------------------';
|
||||
}
|
||||
else {
|
||||
|
@ -3010,10 +3034,7 @@ function reporting_alert_report_group($report, $content) {
|
|||
(int) $report["datetime"]);
|
||||
$module_actions["actions"] = $data_action;
|
||||
|
||||
if ($module_actions["template_fired"][0] !== null)
|
||||
$data_row['alerts'][$ntemplates] = $module_actions;
|
||||
else
|
||||
$data_row = null;
|
||||
$ntemplates++;
|
||||
}
|
||||
|
||||
|
@ -3076,6 +3097,16 @@ function reporting_alert_report_agent($report, $content) {
|
|||
|
||||
foreach ($alerts as $template => $actions) {
|
||||
|
||||
$datetime = (int) $report["datetime"];
|
||||
if (!is_numeric ($datetime)) {
|
||||
$datetime = time_w_fixed_tz($datetime);
|
||||
}
|
||||
if (empty ($datetime)) {
|
||||
$datetime = get_system_time();
|
||||
}
|
||||
$period = (int) $content["period"];
|
||||
$datelimit = $datetime - $period;
|
||||
|
||||
$data_action = array();
|
||||
$data_action['actions'] = array();
|
||||
|
||||
|
@ -3084,7 +3115,7 @@ function reporting_alert_report_agent($report, $content) {
|
|||
foreach ($actions["custom"] as $action) {
|
||||
$data_action[$naction]["name"] = $action["name"];
|
||||
$fired = $action["fired"];
|
||||
if ($fired == 0){
|
||||
if ($fired == 0 || ($fired <= $datelimit || $fired > $datetime)){
|
||||
$data_action[$naction]['fired'] = '----------------------------';
|
||||
}
|
||||
else {
|
||||
|
@ -3097,7 +3128,7 @@ function reporting_alert_report_agent($report, $content) {
|
|||
foreach ($actions["default"] as $action) {
|
||||
$data_action[$naction]["name"] = $action["name"];
|
||||
$fired = $action["fired"];
|
||||
if ($fired == 0){
|
||||
if ($fired == 0 || ($fired <= $datelimit || $fired > $datetime)){
|
||||
$data_action[$naction]['fired'] = '----------------------------';
|
||||
}
|
||||
else {
|
||||
|
@ -3110,7 +3141,7 @@ function reporting_alert_report_agent($report, $content) {
|
|||
foreach ($actions["unavailable"] as $action) {
|
||||
$data_action[$naction]["name"] = $action["name"];
|
||||
$fired = $action["fired"];
|
||||
if ($fired == 0){
|
||||
if ($fired == 0 || ($fired <= $datelimit || $fired > $datetime)){
|
||||
$data_action[$naction]['fired'] = '----------------------------';
|
||||
}
|
||||
else {
|
||||
|
@ -3130,10 +3161,7 @@ function reporting_alert_report_agent($report, $content) {
|
|||
(int) $report["datetime"]);
|
||||
$module_actions["actions"] = $data_action;
|
||||
|
||||
if ($module_actions["template_fired"][0] !== null)
|
||||
$data_row['alerts'][$ntemplates] = $module_actions;
|
||||
else
|
||||
$data_row = null;
|
||||
$ntemplates++;
|
||||
}
|
||||
|
||||
|
@ -3199,6 +3227,15 @@ function reporting_alert_report_module($report, $content) {
|
|||
$ntemplates = 0;
|
||||
|
||||
foreach ($alerts as $template => $actions) {
|
||||
$datetime = (int) $report["datetime"];
|
||||
if (!is_numeric ($datetime)) {
|
||||
$datetime = time_w_fixed_tz($datetime);
|
||||
}
|
||||
if (empty ($datetime)) {
|
||||
$datetime = get_system_time();
|
||||
}
|
||||
$period = (int) $content["period"];
|
||||
$datelimit = $datetime - $period;
|
||||
|
||||
$data_action = array();
|
||||
$data_action['actions'] = array();
|
||||
|
@ -3208,7 +3245,7 @@ function reporting_alert_report_module($report, $content) {
|
|||
foreach ($actions["custom"] as $action) {
|
||||
$data_action[$naction]["name"] = $action["name"];
|
||||
$fired = $action["fired"];
|
||||
if ($fired == 0){
|
||||
if ($fired == 0 || ($fired <= $datelimit || $fired > $datetime)){
|
||||
$data_action[$naction]['fired'] = '----------------------------';
|
||||
}
|
||||
else {
|
||||
|
@ -3221,7 +3258,7 @@ function reporting_alert_report_module($report, $content) {
|
|||
foreach ($actions["default"] as $action) {
|
||||
$data_action[$naction]["name"] = $action["name"];
|
||||
$fired = $action["fired"];
|
||||
if ($fired == 0){
|
||||
if ($fired == 0 || ($fired <= $datelimit || $fired > $datetime)){
|
||||
$data_action[$naction]['fired'] = '----------------------------';
|
||||
}
|
||||
else {
|
||||
|
@ -3234,7 +3271,7 @@ function reporting_alert_report_module($report, $content) {
|
|||
foreach ($actions["unavailable"] as $action) {
|
||||
$data_action[$naction]["name"] = $action["name"];
|
||||
$fired = $action["fired"];
|
||||
if ($fired == 0){
|
||||
if ($fired == 0 || ($fired <= $datelimit || $fired > $datetime)){
|
||||
$data_action[$naction]['fired'] = '----------------------------';
|
||||
}
|
||||
else {
|
||||
|
@ -3254,10 +3291,7 @@ function reporting_alert_report_module($report, $content) {
|
|||
(int) $report["datetime"]);
|
||||
$module_actions["actions"] = $data_action;
|
||||
|
||||
if ($module_actions["template_fired"][0] !== null)
|
||||
$data_row['alerts'][$ntemplates] = $module_actions;
|
||||
else
|
||||
$data_row = null;
|
||||
$ntemplates++;
|
||||
}
|
||||
|
||||
|
|
|
@ -1960,6 +1960,12 @@ function reporting_html_alert_report($table, $item, $pdf = 0) {
|
|||
$table1->data = array ();
|
||||
$table1->rowspan = array();
|
||||
$table1->valign = array();
|
||||
|
||||
if ($item['data'] == null) {
|
||||
$table->data['alerts']['cell'] = ui_print_empty_data ( __('No alerts defined') , '', true) ;
|
||||
return true;
|
||||
}
|
||||
|
||||
$table1->head['agent'] = __('Agent');
|
||||
$table1->head['module'] = __('Module');
|
||||
$table1->head['template'] = __('Template');
|
||||
|
|
Loading…
Reference in New Issue