mirror of
https://github.com/pandorafms/pandorafms.git
synced 2025-07-28 00:04:37 +02:00
Merge branch '1920_Informe_de_alertas_2' into 'develop'
Fixed module/agent/group alert report See merge request artica/pandorafms!1772
This commit is contained in:
commit
9f0271c0b8
@ -1638,23 +1638,13 @@ function get_agent_alert_fired ($id_agent, $id_alert, $period, $date = 0) {
|
|||||||
*
|
*
|
||||||
* @return array An array with all the events happened.
|
* @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)) {
|
$sql = sprintf ('SELECT *
|
||||||
$date = time_w_fixed_tz($date);
|
|
||||||
}
|
|
||||||
if (empty ($date)) {
|
|
||||||
$date = get_system_time();
|
|
||||||
}
|
|
||||||
|
|
||||||
$datelimit = $date - $period;
|
|
||||||
|
|
||||||
$sql = sprintf ('SELECT timestamp
|
|
||||||
FROM tevento
|
FROM tevento
|
||||||
WHERE id_agentmodule = %d AND utimestamp > %d
|
WHERE id_agentmodule = %d
|
||||||
AND utimestamp <= %d
|
|
||||||
AND id_alert_am = %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);
|
return db_get_all_rows_sql ($sql);
|
||||||
}
|
}
|
||||||
|
@ -2865,14 +2865,28 @@ function reporting_alert_get_fired($id_agent_module, $id_alert_template_module,
|
|||||||
$id_alert_template_module,
|
$id_alert_template_module,
|
||||||
$period,
|
$period,
|
||||||
$datetime);
|
$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)) {
|
if (empty($firedTimes)) {
|
||||||
$firedTimes = array();
|
$firedTimes = array();
|
||||||
$firedTimes[0]['timestamp'] = null;
|
$empty = _('There are no alerts defined');
|
||||||
|
$firedTimes[0]['timestamp'] = '';
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach ($firedTimes as $fireTime) {
|
foreach ($firedTimes as $fireTime) {
|
||||||
|
if($fireTime['utimestamp'] > $datelimit && $fireTime['utimestamp'] <= $datetime)
|
||||||
$fired[] = $fireTime['timestamp'];
|
$fired[] = $fireTime['timestamp'];
|
||||||
|
else
|
||||||
|
$fired[] = $empty;
|
||||||
}
|
}
|
||||||
|
|
||||||
return $fired;
|
return $fired;
|
||||||
@ -2955,6 +2969,16 @@ function reporting_alert_report_group($report, $content) {
|
|||||||
|
|
||||||
foreach ($alerts as $template => $actions) {
|
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 = array();
|
||||||
$data_action['actions'] = array();
|
$data_action['actions'] = array();
|
||||||
|
|
||||||
@ -2963,7 +2987,7 @@ function reporting_alert_report_group($report, $content) {
|
|||||||
foreach ($actions["custom"] as $action) {
|
foreach ($actions["custom"] as $action) {
|
||||||
$data_action[$naction]["name"] = $action["name"];
|
$data_action[$naction]["name"] = $action["name"];
|
||||||
$fired = $action["fired"];
|
$fired = $action["fired"];
|
||||||
if ($fired == 0){
|
if ($fired == 0 || ($fired <= $datelimit || $fired > $datetime)){
|
||||||
$data_action[$naction]['fired'] = '----------------------------';
|
$data_action[$naction]['fired'] = '----------------------------';
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@ -2976,7 +3000,7 @@ function reporting_alert_report_group($report, $content) {
|
|||||||
foreach ($actions["default"] as $action) {
|
foreach ($actions["default"] as $action) {
|
||||||
$data_action[$naction]["name"] = $action["name"];
|
$data_action[$naction]["name"] = $action["name"];
|
||||||
$fired = $action["fired"];
|
$fired = $action["fired"];
|
||||||
if ($fired == 0){
|
if ($fired == 0 || ($fired <= $datelimit || $fired > $datetime)){
|
||||||
$data_action[$naction]['fired'] = '----------------------------';
|
$data_action[$naction]['fired'] = '----------------------------';
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@ -2989,7 +3013,7 @@ function reporting_alert_report_group($report, $content) {
|
|||||||
foreach ($actions["unavailable"] as $action) {
|
foreach ($actions["unavailable"] as $action) {
|
||||||
$data_action[$naction]["name"] = $action["name"];
|
$data_action[$naction]["name"] = $action["name"];
|
||||||
$fired = $action["fired"];
|
$fired = $action["fired"];
|
||||||
if ($fired == 0){
|
if ($fired == 0 || ($fired <= $datelimit || $fired > $datetime)){
|
||||||
$data_action[$naction]['fired'] = '----------------------------';
|
$data_action[$naction]['fired'] = '----------------------------';
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@ -3009,10 +3033,7 @@ function reporting_alert_report_group($report, $content) {
|
|||||||
(int) $report["datetime"]);
|
(int) $report["datetime"]);
|
||||||
$module_actions["actions"] = $data_action;
|
$module_actions["actions"] = $data_action;
|
||||||
|
|
||||||
if ($module_actions["template_fired"][0] !== null)
|
|
||||||
$data_row['alerts'][$ntemplates] = $module_actions;
|
$data_row['alerts'][$ntemplates] = $module_actions;
|
||||||
else
|
|
||||||
$data_row = null;
|
|
||||||
$ntemplates++;
|
$ntemplates++;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3075,6 +3096,16 @@ function reporting_alert_report_agent($report, $content) {
|
|||||||
|
|
||||||
foreach ($alerts as $template => $actions) {
|
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 = array();
|
||||||
$data_action['actions'] = array();
|
$data_action['actions'] = array();
|
||||||
|
|
||||||
@ -3083,7 +3114,7 @@ function reporting_alert_report_agent($report, $content) {
|
|||||||
foreach ($actions["custom"] as $action) {
|
foreach ($actions["custom"] as $action) {
|
||||||
$data_action[$naction]["name"] = $action["name"];
|
$data_action[$naction]["name"] = $action["name"];
|
||||||
$fired = $action["fired"];
|
$fired = $action["fired"];
|
||||||
if ($fired == 0){
|
if ($fired == 0 || ($fired <= $datelimit || $fired > $datetime)){
|
||||||
$data_action[$naction]['fired'] = '----------------------------';
|
$data_action[$naction]['fired'] = '----------------------------';
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@ -3096,7 +3127,7 @@ function reporting_alert_report_agent($report, $content) {
|
|||||||
foreach ($actions["default"] as $action) {
|
foreach ($actions["default"] as $action) {
|
||||||
$data_action[$naction]["name"] = $action["name"];
|
$data_action[$naction]["name"] = $action["name"];
|
||||||
$fired = $action["fired"];
|
$fired = $action["fired"];
|
||||||
if ($fired == 0){
|
if ($fired == 0 || ($fired <= $datelimit || $fired > $datetime)){
|
||||||
$data_action[$naction]['fired'] = '----------------------------';
|
$data_action[$naction]['fired'] = '----------------------------';
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@ -3109,7 +3140,7 @@ function reporting_alert_report_agent($report, $content) {
|
|||||||
foreach ($actions["unavailable"] as $action) {
|
foreach ($actions["unavailable"] as $action) {
|
||||||
$data_action[$naction]["name"] = $action["name"];
|
$data_action[$naction]["name"] = $action["name"];
|
||||||
$fired = $action["fired"];
|
$fired = $action["fired"];
|
||||||
if ($fired == 0){
|
if ($fired == 0 || ($fired <= $datelimit || $fired > $datetime)){
|
||||||
$data_action[$naction]['fired'] = '----------------------------';
|
$data_action[$naction]['fired'] = '----------------------------';
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@ -3129,10 +3160,7 @@ function reporting_alert_report_agent($report, $content) {
|
|||||||
(int) $report["datetime"]);
|
(int) $report["datetime"]);
|
||||||
$module_actions["actions"] = $data_action;
|
$module_actions["actions"] = $data_action;
|
||||||
|
|
||||||
if ($module_actions["template_fired"][0] !== null)
|
|
||||||
$data_row['alerts'][$ntemplates] = $module_actions;
|
$data_row['alerts'][$ntemplates] = $module_actions;
|
||||||
else
|
|
||||||
$data_row = null;
|
|
||||||
$ntemplates++;
|
$ntemplates++;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3198,6 +3226,15 @@ function reporting_alert_report_module($report, $content) {
|
|||||||
$ntemplates = 0;
|
$ntemplates = 0;
|
||||||
|
|
||||||
foreach ($alerts as $template => $actions) {
|
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 = array();
|
||||||
$data_action['actions'] = array();
|
$data_action['actions'] = array();
|
||||||
@ -3207,7 +3244,7 @@ function reporting_alert_report_module($report, $content) {
|
|||||||
foreach ($actions["custom"] as $action) {
|
foreach ($actions["custom"] as $action) {
|
||||||
$data_action[$naction]["name"] = $action["name"];
|
$data_action[$naction]["name"] = $action["name"];
|
||||||
$fired = $action["fired"];
|
$fired = $action["fired"];
|
||||||
if ($fired == 0){
|
if ($fired == 0 || ($fired <= $datelimit || $fired > $datetime)){
|
||||||
$data_action[$naction]['fired'] = '----------------------------';
|
$data_action[$naction]['fired'] = '----------------------------';
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@ -3220,7 +3257,7 @@ function reporting_alert_report_module($report, $content) {
|
|||||||
foreach ($actions["default"] as $action) {
|
foreach ($actions["default"] as $action) {
|
||||||
$data_action[$naction]["name"] = $action["name"];
|
$data_action[$naction]["name"] = $action["name"];
|
||||||
$fired = $action["fired"];
|
$fired = $action["fired"];
|
||||||
if ($fired == 0){
|
if ($fired == 0 || ($fired <= $datelimit || $fired > $datetime)){
|
||||||
$data_action[$naction]['fired'] = '----------------------------';
|
$data_action[$naction]['fired'] = '----------------------------';
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@ -3233,7 +3270,7 @@ function reporting_alert_report_module($report, $content) {
|
|||||||
foreach ($actions["unavailable"] as $action) {
|
foreach ($actions["unavailable"] as $action) {
|
||||||
$data_action[$naction]["name"] = $action["name"];
|
$data_action[$naction]["name"] = $action["name"];
|
||||||
$fired = $action["fired"];
|
$fired = $action["fired"];
|
||||||
if ($fired == 0){
|
if ($fired == 0 || ($fired <= $datelimit || $fired > $datetime)){
|
||||||
$data_action[$naction]['fired'] = '----------------------------';
|
$data_action[$naction]['fired'] = '----------------------------';
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@ -3253,10 +3290,7 @@ function reporting_alert_report_module($report, $content) {
|
|||||||
(int) $report["datetime"]);
|
(int) $report["datetime"]);
|
||||||
$module_actions["actions"] = $data_action;
|
$module_actions["actions"] = $data_action;
|
||||||
|
|
||||||
if ($module_actions["template_fired"][0] !== null)
|
|
||||||
$data_row['alerts'][$ntemplates] = $module_actions;
|
$data_row['alerts'][$ntemplates] = $module_actions;
|
||||||
else
|
|
||||||
$data_row = null;
|
|
||||||
$ntemplates++;
|
$ntemplates++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1960,6 +1960,12 @@ function reporting_html_alert_report($table, $item, $pdf = 0) {
|
|||||||
$table1->data = array ();
|
$table1->data = array ();
|
||||||
$table1->rowspan = array();
|
$table1->rowspan = array();
|
||||||
$table1->valign = 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['agent'] = __('Agent');
|
||||||
$table1->head['module'] = __('Module');
|
$table1->head['module'] = __('Module');
|
||||||
$table1->head['template'] = __('Template');
|
$table1->head['template'] = __('Template');
|
||||||
|
Loading…
x
Reference in New Issue
Block a user