wip reports alert actions
This commit is contained in:
parent
9b62aa11da
commit
780d2bf87d
|
@ -752,17 +752,24 @@ switch ($action) {
|
|||
hd('1');
|
||||
$description = $item['description'];
|
||||
$es = json_decode($item['external_source'], true);
|
||||
$id_agents = $es['id_agents'];
|
||||
|
||||
hd($es);
|
||||
|
||||
hd(base64_decode($es['id_agents']));
|
||||
|
||||
// Decode agents and modules.
|
||||
$id_agents = json_decode(
|
||||
io_safe_output(base64_decode($es['id_agents'])),
|
||||
true
|
||||
);
|
||||
$module = json_decode(
|
||||
io_safe_output(base64_decode($es['module'])),
|
||||
true
|
||||
);
|
||||
|
||||
$selection_a_m = get_parameter('selection');
|
||||
$recursion = $item['recursion'];
|
||||
|
||||
if ((count($es['module']) == 1) && ($es['module'][0] == 0)) {
|
||||
$module = '';
|
||||
} else {
|
||||
$module = $es['module'];
|
||||
}
|
||||
|
||||
$group = $item['id_group'];
|
||||
$modulegroup = $item['id_module_group'];
|
||||
$idAgentModule = $module;
|
||||
|
@ -1725,6 +1732,11 @@ $class = 'databox filters';
|
|||
true,
|
||||
true
|
||||
);
|
||||
|
||||
html_print_input_hidden(
|
||||
'id_agents2-multiple-text',
|
||||
json_encode($agents_select)
|
||||
);
|
||||
?>
|
||||
</td>
|
||||
</tr>
|
||||
|
@ -1814,6 +1826,11 @@ $class = 'databox filters';
|
|||
true,
|
||||
true
|
||||
);
|
||||
|
||||
html_print_input_hidden(
|
||||
'module-multiple-text',
|
||||
json_encode($agents_select)
|
||||
);
|
||||
?>
|
||||
</td>
|
||||
</tr>
|
||||
|
@ -4712,6 +4729,14 @@ $(document).ready (function () {
|
|||
}
|
||||
|
||||
switch (type){
|
||||
case 'alert_report_actions':
|
||||
var agents_multiple = $('#id_agents2').val();
|
||||
var modules_multiple = $('#module').val();
|
||||
$('#hidden-id_agents2-multiple-text').val(JSON.stringify(agents_multiple));
|
||||
$('#hidden-module-multiple-text').val(JSON.stringify(modules_multiple));
|
||||
$('#id_agents2').val('');
|
||||
$('#module').val('');
|
||||
break;
|
||||
case 'alert_report_module':
|
||||
case 'alert_report_agent':
|
||||
case 'event_report_agent':
|
||||
|
@ -4850,6 +4875,16 @@ $(document).ready (function () {
|
|||
return false;
|
||||
}
|
||||
switch (type){
|
||||
case 'alert_report_actions':
|
||||
var agents_multiple = $('#id_agents2').val();
|
||||
var modules_multiple = $('#module').val();
|
||||
console.log(agents_multiple);
|
||||
console.log(modules_multiple);
|
||||
$('#hidden-id_agents2-multiple-text').val(JSON.stringify(agents_multiple));
|
||||
$('#hidden-module-multiple-text').val(JSON.stringify(modules_multiple));
|
||||
$('#id_agents2').val('');
|
||||
$('#module').val('');
|
||||
break;
|
||||
case 'alert_report_module':
|
||||
case 'alert_report_agent':
|
||||
case 'event_report_agent':
|
||||
|
|
|
@ -1693,24 +1693,40 @@ switch ($action) {
|
|||
break;
|
||||
|
||||
case 'alert_report_actions':
|
||||
hd('3');
|
||||
$agents_to_report = get_parameter('id_agents2');
|
||||
$modules_to_report = get_parameter('module', '');
|
||||
$alert_templates_to_report = get_parameter('alert_templates');
|
||||
$alert_actions_to_report = get_parameter('alert_actions');
|
||||
$show_summary = get_parameter('show_summary', 0);
|
||||
$group_by = get_parameter('group_by');
|
||||
hd('3');
|
||||
$agents_to_report_text = get_parameter('id_agents2-multiple-text');
|
||||
$modules_to_report_text = get_parameter('module-multiple-text', '');
|
||||
|
||||
// Decode json check modules.
|
||||
$agents_to_report = json_decode(
|
||||
io_safe_output($agents_to_report_text),
|
||||
true
|
||||
);
|
||||
$modules_to_report = json_decode(
|
||||
io_safe_output($modules_to_report_text),
|
||||
true
|
||||
);
|
||||
|
||||
$es['module'] = get_same_modules(
|
||||
$agents_to_report,
|
||||
$modules_to_report
|
||||
);
|
||||
$es['id_agents'] = $agents_to_report;
|
||||
|
||||
// Encode json modules and agents.
|
||||
$es['module'] = base64_encode(json_encode($es['module']));
|
||||
$es['id_agents'] = base64_encode(json_encode($agents_to_report));
|
||||
|
||||
$es['templates'] = $alert_templates_to_report;
|
||||
$es['actions'] = $alert_actions_to_report;
|
||||
$es['show_summary'] = $show_summary;
|
||||
$es['group_by'] = $group_by;
|
||||
|
||||
hd($es);
|
||||
|
||||
$values['external_source'] = json_encode($es);
|
||||
|
||||
$values['period'] = get_parameter('period');
|
||||
|
@ -2470,23 +2486,41 @@ switch ($action) {
|
|||
|
||||
case 'alert_report_actions':
|
||||
hd('2');
|
||||
$agents_to_report = get_parameter('id_agents2');
|
||||
$modules_to_report = get_parameter('module', '');
|
||||
$alert_templates_to_report = get_parameter('alert_templates');
|
||||
$alert_actions_to_report = get_parameter('alert_actions');
|
||||
$show_summary = get_parameter('show_summary', 0);
|
||||
$group_by = get_parameter('group_by');
|
||||
|
||||
$agents_to_report_text = get_parameter('id_agents2-multiple-text');
|
||||
$modules_to_report_text = get_parameter('module-multiple-text', '');
|
||||
|
||||
// Decode json check modules.
|
||||
$agents_to_report = json_decode(
|
||||
io_safe_output($agents_to_report_text),
|
||||
true
|
||||
);
|
||||
$modules_to_report = json_decode(
|
||||
io_safe_output($modules_to_report_text),
|
||||
true
|
||||
);
|
||||
|
||||
$es['module'] = get_same_modules(
|
||||
$agents_to_report,
|
||||
$modules_to_report
|
||||
);
|
||||
$es['id_agents'] = $agents_to_report;
|
||||
|
||||
// Encode json modules and agents.
|
||||
$es['module'] = base64_encode(json_encode($es['module']));
|
||||
$es['id_agents'] = base64_encode(json_encode($agents_to_report));
|
||||
|
||||
$es['templates'] = $alert_templates_to_report;
|
||||
$es['actions'] = $alert_actions_to_report;
|
||||
$es['show_summary'] = $show_summary;
|
||||
$es['group_by'] = $group_by;
|
||||
|
||||
|
||||
hd($es);
|
||||
|
||||
$values['external_source'] = json_encode($es);
|
||||
|
||||
$values['period'] = get_parameter('period');
|
||||
|
|
|
@ -2888,17 +2888,23 @@ function alerts_get_alert_fired($filters=[], $groupsBy=[])
|
|||
global $config;
|
||||
|
||||
$filter_date = '';
|
||||
if (isset($filters['period']) === true && empty($filters['period']) === false) {
|
||||
if (isset($filters['period']) === true
|
||||
&& empty($filters['period']) === false
|
||||
) {
|
||||
$filter_date = sprintf('AND utimestamp > %d', (time() - $filters['period']));
|
||||
}
|
||||
|
||||
$filter_group = '';
|
||||
if (isset($filters['group']) === true && empty($filters['group']) === false) {
|
||||
if (isset($filters['group']) === true
|
||||
&& empty($filters['group']) === false
|
||||
) {
|
||||
$filter_group = sprintf('AND id_grupo = %d', $filters['group']);
|
||||
}
|
||||
|
||||
$filter_agents = '';
|
||||
if (isset($filters['agents']) === true) {
|
||||
if (isset($filters['agents']) === true
|
||||
&& empty($filters['agents']) === false
|
||||
) {
|
||||
$filter_agents = sprintf(
|
||||
'AND id_agente IN (%s)',
|
||||
implode(',', $filters['agents'])
|
||||
|
@ -2906,15 +2912,21 @@ function alerts_get_alert_fired($filters=[], $groupsBy=[])
|
|||
}
|
||||
|
||||
$filter_modules = '';
|
||||
if (isset($filters['modules']) === true) {
|
||||
if (isset($filters['modules']) === true
|
||||
&& empty($filters['modules']) === false
|
||||
) {
|
||||
$filter_modules = sprintf(
|
||||
'AND id_agentmodule IN (%s)',
|
||||
implode(',', $filters['modules'])
|
||||
);
|
||||
}
|
||||
|
||||
hd($filters['templates']);
|
||||
|
||||
$filter_templates = '';
|
||||
if (isset($filters['templates']) === true) {
|
||||
if (isset($filters['templates']) === true
|
||||
&& empty($filters['templates']) === false
|
||||
) {
|
||||
$filter_templates = sprintf(
|
||||
'AND id_alert_am IN (%s)',
|
||||
implode(',', $filters['templates'])
|
||||
|
@ -2923,7 +2935,9 @@ function alerts_get_alert_fired($filters=[], $groupsBy=[])
|
|||
|
||||
$filter_actions = '';
|
||||
$fields_actions = [];
|
||||
if (isset($filters['actions']) === true) {
|
||||
if (isset($filters['actions']) === true
|
||||
&& empty($filters['actions']) === false
|
||||
) {
|
||||
$actions_names = alerts_get_actions_names($filters['actions'], true);
|
||||
$filter_actions .= 'AND ( ';
|
||||
$first = true;
|
||||
|
@ -2951,7 +2965,9 @@ function alerts_get_alert_fired($filters=[], $groupsBy=[])
|
|||
|
||||
$group_array = [];
|
||||
$fields = ['COUNT(tevento.id_evento) as fired'];
|
||||
if (isset($groupsBy['group_by']) === true) {
|
||||
if (isset($groupsBy['group_by']) === true
|
||||
&& empty($filters['group_by']) === false
|
||||
) {
|
||||
foreach ($groupsBy['group_by'] as $groupBy) {
|
||||
switch ($groupBy) {
|
||||
case 'module':
|
||||
|
@ -2992,7 +3008,9 @@ function alerts_get_alert_fired($filters=[], $groupsBy=[])
|
|||
}
|
||||
}
|
||||
|
||||
if (isset($groupsBy['lapse']) === true) {
|
||||
if (isset($groupsBy['lapse']) === true
|
||||
&& empty($filters['lapse']) === false
|
||||
) {
|
||||
$fields[] = sprintf(
|
||||
'ROUND((CEILING(UNIX_TIMESTAMP(`timestamp`) / %d) * %d)) AS period',
|
||||
(int) $groupsBy['lapse'],
|
||||
|
@ -3037,6 +3055,8 @@ function alerts_get_alert_fired($filters=[], $groupsBy=[])
|
|||
hd($data);
|
||||
|
||||
foreach ($data as $key => $value) {
|
||||
if (isset($value['period']) === true) {
|
||||
hd(date('y-m-d h:i:s', $value['period']));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue