fixed events sound

This commit is contained in:
Daniel Barbero Martin 2019-07-15 15:31:01 +02:00
parent 5498e1df3c
commit 45e1c32473
2 changed files with 118 additions and 2 deletions

View File

@ -83,6 +83,7 @@ $validate_event = get_parameter('validate_event', 0);
$delete_event = get_parameter('delete_event', 0);
$get_event_filters = get_parameter('get_event_filters', 0);
$get_comments = get_parameter('get_comments', 0);
$get_events_fired = (bool) get_parameter('get_events_fired');
if ($get_comments) {
$event = get_parameter('event', false);
@ -1695,3 +1696,118 @@ if ($get_table_response_command) {
return;
}
if ($get_events_fired) {
$id = get_parameter('id_row');
$idGroup = get_parameter('id_group');
$agents = get_parameter('agents', null);
$query = ' AND id_evento > '.$id;
$type = [];
$alert = get_parameter('alert_fired');
if ($alert == 'true') {
$resultAlert = alerts_get_event_status_group(
$idGroup,
[
'alert_fired',
'alert_ceased',
],
$query,
$agents
);
}
$critical = get_parameter('critical');
if ($critical == 'true') {
$resultCritical = alerts_get_event_status_group(
$idGroup,
'going_up_critical',
$query,
$agents
);
}
$warning = get_parameter('warning');
if ($warning == 'true') {
$resultWarning = alerts_get_event_status_group(
$idGroup,
'going_up_warning',
$query,
$agents
);
}
$unknown = get_parameter('unknown');
if ($unknown == 'true') {
$resultUnknown = alerts_get_event_status_group(
$idGroup,
'going_unknown',
$query,
$agents
);
}
if ($resultAlert) {
$return = [
'fired' => $resultAlert,
'sound' => $config['sound_alert'],
];
$event = events_get_event($resultAlert);
$module_name = modules_get_agentmodule_name($event['id_agentmodule']);
$agent_name = agents_get_alias($event['id_agente']);
$return['message'] = io_safe_output($agent_name).' - ';
$return['message'] .= __('Alert fired in module ');
$return['message'] .= io_safe_output($module_name).' - ';
$return['message'] .= $event['timestamp'];
} else if ($resultCritical) {
$return = [
'fired' => $resultCritical,
'sound' => $config['sound_critical'],
];
$event = events_get_event($resultCritical);
$module_name = modules_get_agentmodule_name($event['id_agentmodule']);
$agent_name = agents_get_alias($event['id_agente']);
$return['message'] = io_safe_output($agent_name).' - ';
$return['message'] .= __('Module ').io_safe_output($module_name);
$return['message'] .= __(' is going to critical').' - ';
$return['message'] .= $event['timestamp'];
} else if ($resultWarning) {
$return = [
'fired' => $resultWarning,
'sound' => $config['sound_warning'],
];
$event = events_get_event($resultWarning);
$module_name = modules_get_agentmodule_name($event['id_agentmodule']);
$agent_name = agents_get_alias($event['id_agente']);
$return['message'] = io_safe_output($agent_name).' - ';
$return['message'] .= __('Module ').io_safe_output($module_name);
$return['message'] .= __(' is going to warning').' - ';
$return['message'] .= $event['timestamp'];
} else if ($resultUnknown) {
$return = [
'fired' => $resultUnknown,
'sound' => $config['sound_alert'],
];
$event = events_get_event($resultUnknown);
$module_name = modules_get_agentmodule_name($event['id_agentmodule']);
$agent_name = agents_get_alias($event['id_agente']);
$return['message'] = io_safe_output($agent_name).' - ';
$return['message'] .= __('Module ').io_safe_output($module_name);
$return['message'] .= __(' is going to unknown').' - ';
$return['message'] .= $event['timestamp'];
} else {
$return = ['fired' => 0];
}
echo io_json_mb_encode($return);
}

View File

@ -196,7 +196,7 @@ function forgetPreviousEvents() {
var agents = $("#id_agents").val();
jQuery.post ("../../ajax.php",
{"page" : "operation/events/events",
{"page" : "include/ajax/events",
"get_events_fired": 1,
"id_group": group,
"agents[]" : agents,
@ -222,7 +222,7 @@ function check_event() {
if (running) {
jQuery.post ("../../ajax.php",
{"page" : "operation/events/events",
{"page" : "include/ajax/events",
"get_events_fired": 1,
"id_group": group,
"agents[]" : agents,