diff --git a/pandora_console/godmode/setup/setup.php b/pandora_console/godmode/setup/setup.php index a4c072b173..4c7fda4ed3 100644 --- a/pandora_console/godmode/setup/setup.php +++ b/pandora_console/godmode/setup/setup.php @@ -108,6 +108,43 @@ $table->data[16][1] .= __('No').' '.print_radio_button ('activate_gis', 0, $table->data[19][0] = __('Timezone setup'); $table->data[19][1] = print_input_text ('timezone', $config["timezone"], '', 25, 25, true); +$sounds = get_sounds(); +$table->data[20][0] = __('Sound for Alert fired'); +$table->data[20][1] = print_select($sounds, 'sound_alert', $config['sound_alert'], 'replaySound(\'alert\');', '', '', true); +$table->data[20][1] .= ' '; +$table->data[20][1] .= '
'; + +$table->data[21][0] = __('Sound for Monitor critical'); +$table->data[21][1] = print_select($sounds, 'sound_critical', $config['sound_critical'], 'replaySound(\'critical\');', '', '', true); +$table->data[21][1] .= ' '; +$table->data[21][1] .= '
'; + +$table->data[22][0] = __('Sound for Monitor warning'); +$table->data[22][1] = print_select($sounds, 'sound_warning', $config['sound_warning'], 'replaySound(\'warning\');', '', '', true); +$table->data[22][1] .= ' '; +$table->data[22][1] .= '
'; +?> + +'; @@ -117,4 +154,20 @@ echo '
'; print_submit_button (__('Update'), 'update_button', false, 'class="sub upd"'); echo '
'; echo ''; + +function get_sounds() { + global $config; + + $return = array(); + + $files = scandir($config['homedir'] . '/include/sounds'); + + foreach ($files as $file) { + if (strstr($file, 'wav') !== false) { + $return['include/sounds/' . $file] = $file; + } + } + + return $return; +} ?> diff --git a/pandora_console/images/music_note.png b/pandora_console/images/music_note.png new file mode 100644 index 0000000000..e2133d0c92 Binary files /dev/null and b/pandora_console/images/music_note.png differ diff --git a/pandora_console/images/ok.button.png b/pandora_console/images/ok.button.png new file mode 100644 index 0000000000..9af240433c Binary files /dev/null and b/pandora_console/images/ok.button.png differ diff --git a/pandora_console/images/pause.button.png b/pandora_console/images/pause.button.png new file mode 100644 index 0000000000..1184db3f36 Binary files /dev/null and b/pandora_console/images/pause.button.png differ diff --git a/pandora_console/images/play.button.png b/pandora_console/images/play.button.png new file mode 100644 index 0000000000..272acab64b Binary files /dev/null and b/pandora_console/images/play.button.png differ diff --git a/pandora_console/include/functions_alerts.php b/pandora_console/include/functions_alerts.php index 73f944163a..04bdb8a857 100644 --- a/pandora_console/include/functions_alerts.php +++ b/pandora_console/include/functions_alerts.php @@ -19,6 +19,48 @@ * @subpackage Alerts */ +/** + * Get fired status from any alert of agent in group. + * + * @param integer $idGroup The ID of group. + * @param mixed $type The list of types to search or type. By default "alert_fired". + * + * @return mixed Return id if the group have any alert is fired or false is not. + */ +function get_event_status_group($idGroup, $type = "alert_fired", $query = 'AND 1=1') { + global $config; + + $return = false; + + $typeWhere = ''; + + if (!is_array($type)) { + $typeWhere = ' AND event_type = "' . $type . '" '; + } + else { + $temp = array(); + foreach ($type as $item) { + $temp[] = '"' . $item . '"'; + } + + $typeWhere = ' AND event_type IN (' . implode(',', $temp) . ')'; + } + + $agents = get_group_agents($idGroup, false, "lower", false); + + $idAgents = array_keys($agents); + + $result = get_db_all_rows_sql('SELECT id_evento + FROM tevento + WHERE estado = 0 AND id_agente IN (' . implode(',', $idAgents) . ') ' . $typeWhere . $query . ' ORDER BY id_evento DESC LIMIT 1'); + + if ($result === false) { + return false; + } + + return $result[0]['id_evento']; +} + /** * Insert in talert_commands a new command. * diff --git a/pandora_console/include/functions_config.php b/pandora_console/include/functions_config.php index bdec270e21..f9d06aa999 100644 --- a/pandora_console/include/functions_config.php +++ b/pandora_console/include/functions_config.php @@ -215,6 +215,10 @@ function update_config () { update_config_value ('rintegria_dbname', get_parameter ('rintegria_dbname', $config['rintegria_dbname'])); update_config_value ('rintegria_user', get_parameter ('rintegria_user', $config['rintegria_user'])); update_config_value ('rintegria_pass', get_parameter ('rintegria_pass', $config['rintegria_pass'])); + + update_config_value ('sound_alert', get_parameter('sound_alert', $config['sound_alert'])); + update_config_value ('sound_critical', get_parameter('sound_critical', $config['sound_critical'])); + update_config_value ('sound_warning', get_parameter('sound_warning', $config['sound_warning'])); } /** diff --git a/pandora_console/operation/events/events.php b/pandora_console/operation/events/events.php index bed087a712..3345fb65f6 100644 --- a/pandora_console/operation/events/events.php +++ b/pandora_console/operation/events/events.php @@ -32,6 +32,7 @@ if (is_ajax ()) { $get_event_tooltip = (bool) get_parameter ('get_event_tooltip'); $validate_event = (bool) get_parameter ('validate_event'); $delete_event = (bool) get_parameter ('delete_event'); + $get_events_fired = (bool) get_parameter('get_events_fired'); if ($get_event_tooltip) { $id = (int) get_parameter ('id'); @@ -87,6 +88,44 @@ if (is_ajax ()) { return; } + if ($get_events_fired) { + require("include/functions_alerts.php"); + + $id = get_parameter('id_row'); + $idGroup = get_parameter('id_group'); + + $query = ' AND id_evento > ' . $id; + + $type = array(); + $alert = get_parameter('alert_fired'); + if ($alert == 'true') { + $resultAlert = get_event_status_group($idGroup, 'alert_fired', $query); + } + $critical = get_parameter('critical'); + if ($critical == 'true') { + $resultCritical = get_event_status_group($idGroup, 'going_up_critical', $query); + } + $warning = get_parameter('warning'); + if ($warning == 'true') { + $resultWarning = get_event_status_group($idGroup, 'going_up_warning', $query); + } + + if ($resultAlert) { + $return = array('fired' => $resultAlert, 'sound' => $config['sound_alert']); + } + else if ($resultCritical) { + $return = array('fired' => $resultCritical, 'sound' => $config['sound_critical']); + } + else if ($resultWarning) { + $return = array('fired' => $resultWarning, 'sound' => $config['sound_warning']); + } + else { + $return = array('fired' => 0); + } + + echo json_encode($return); + } + return; } @@ -163,24 +202,27 @@ if (!give_acl ($config["id_user"], 0, "PM")) { if ($status == 1) { $sql_post .= " AND estado = 1"; -} elseif ($status == 0) { +} +elseif ($status == 0) { $sql_post .= " AND estado = 0"; } -if ($search != "") +if ($search != "") { $sql_post .= " AND evento LIKE '%".$search."%'"; +} -if ($event_type != ""){ +if ($event_type != "") { // If normal, warning, could be several (going_up_warning, going_down_warning... too complex // for the user so for him is presented only "warning, critical and normal" - if ($event_type == "warning" || $event_type == "critical" || $event_type == "normal"){ + if ($event_type == "warning" || $event_type == "critical" || $event_type == "normal") { $sql_post .= " AND event_type LIKE '%$event_type%' "; } - elseif ($event_type == "not_normal"){ + elseif ($event_type == "not_normal") { $sql_post .= " AND event_type LIKE '%warning%' OR event_type LIKE '%critical%' OR event_type LIKE '%unknown%' "; } - else + else { $sql_post .= " AND event_type = '".$event_type."'"; + } } if ($severity != -1) @@ -210,21 +252,33 @@ $url = "index.php?sec=eventos&sec2=operation/events/events&search=" . // Header if ($config["pure"] == 0) { $buttons = array( - 'fullscreen' => array('active' => false, - 'text' => '' . - print_image("images/fullscreen.png", true, array ("title" => __('Full screen'))) .''), - 'rss' => array('active' => false, - 'text' => '' . - print_image("images/rss.png", true, array ("title" => __('RSS Events'))) .''), - 'marquee' => array('active' => false, - 'text' => '' . - print_image("images/heart.png", true, array ("title" => __('Marquee display'))) .''), - 'csv' => array('active' => false, - 'text' => '' . - print_image("images/disk.png", true, array ("title" => __('Export to CSV file'))) .'') - ); + 'fullscreen' => array('active' => false, + 'text' => '' . + print_image("images/fullscreen.png", true, array ("title" => __('Full screen'))) .''), + 'rss' => array('active' => false, + 'text' => '' . + print_image("images/rss.png", true, array ("title" => __('RSS Events'))) .''), + 'marquee' => array('active' => false, + 'text' => '' . + print_image("images/heart.png", true, array ("title" => __('Marquee display'))) .''), + 'csv' => array('active' => false, + 'text' => '' . + print_image("images/disk.png", true, array ("title" => __('Export to CSV file'))) .''), + 'sound_event' => array('active' => false, + 'text' => '' . print_image('images/music_note.png', true, array('title' => __('Sound events'))) . '') + ); - print_page_header (__("Events"), "images/lightning_go.png", false, "eventview", false,$buttons); + print_page_header (__("Events"), "images/lightning_go.png", false, "eventview", false, $buttons); + + ?> + + "; +echo "" . __("Sound Alerts") . ""; +echo ""; +echo ""; + +echo "

" . __("Sound Events") . "

"; + +$table = null; +$table->width = '100%'; + +$table->size[0] = '10%'; +$table->size[1] = '90%'; +$table->style[0] = 'font-weight: bold; vertical-align: top;'; + +$table->data[0][0] = __('Group'); +$table->data[0][1] = print_select_groups(false, "AR", true, 'group', '', 'changeGroup();', '', 0, true); +$table->data[1][0] = __('Type'); +$table->data[1][1] = print_checkbox('alert_fired', 'alert_fired', true, true, false, 'changeType();') . __('Alert fired') . '
' . + print_checkbox('critical', 'critical', true, true, false, 'changeType();') . __('Monitor critical') . '
' . + print_checkbox('warning', 'warning', true, true, false, 'changeType();') . __('Monitor warning') . '
' . +$table->data[2][0] = ''; +$table->data[2][1] = ''; +$table->data[2][1] .= ''; + +print_table($table); +?> + + +"; +echo ""; +?> \ No newline at end of file diff --git a/pandora_console/pandoradb_data.sql b/pandora_console/pandoradb_data.sql index d258896852..c94523b8b5 100644 --- a/pandora_console/pandoradb_data.sql +++ b/pandora_console/pandoradb_data.sql @@ -71,7 +71,10 @@ INSERT INTO `tconfig` (`token`, `value`) VALUES ('audit_purge', 15), ('trap_purge', 7), ('event_purge', 15), -('gis_purge', 15); +('gis_purge', 15), +('sound_alert', 'include/sounds/air_shock_alarm.wav'), +('sound_critical', 'include/sounds/Star_Trek_emergency_simulation.wav'), +('sound_warning', 'include/sounds/negativebeep.wav')); UNLOCK TABLES;