2010-09-06 Miguel de Dios <miguel.dedios@artica.es>
* pandoradb_data.sql: added default value for "sound_alert", "sound_critical" and "sound_warning" into table "tconfig". * include/functions_config.php: in function "update_config" added to update sounds. * include/functions_alerts.php: added function "get_event_status_group" for scan the events. * operation/events/sound_events.php: added first version of event sound window. * operation/events/events.php: added the request for ajax of sound event window. * images/pause.button.png, images/ok.button.png,images/music_note.png, images/play.button.png: added images for sound event window and button in the head of events. * godmode/setup/setup.php: added source code for to config the sounds of events. git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@3219 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
parent
392f24e174
commit
bdbd632606
|
@ -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] .= ' <a href="javascript: toggleButton(\'alert\');"><img id="button_sound_alert" style="vertical-align: middle;" src="images/play.button.png" width="20" /></a>';
|
||||
$table->data[20][1] .= '<div id="layer_sound_alert"></div>';
|
||||
|
||||
$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] .= ' <a href="javascript: toggleButton(\'critical\');"><img id="button_sound_critical" style="vertical-align: middle;" src="images/play.button.png" width="20" /></a>';
|
||||
$table->data[21][1] .= '<div id="layer_sound_critical"></div>';
|
||||
|
||||
$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] .= ' <a href="javascript: toggleButton(\'warning\');"><img id="button_sound_warning" style="vertical-align: middle;" src="images/play.button.png" width="20" /></a>';
|
||||
$table->data[22][1] .= '<div id="layer_sound_warning"></div>';
|
||||
?>
|
||||
<script type="text/javascript">
|
||||
function toggleButton(type) {
|
||||
if ($("#button_sound_" + type).attr('src') == 'images/pause.button.png') {
|
||||
$("#button_sound_" + type).attr('src', 'images/play.button.png');
|
||||
$('#layer_sound_' + type).html("");
|
||||
}
|
||||
else {
|
||||
$("#button_sound_" + type).attr('src', 'images/pause.button.png');
|
||||
$('#layer_sound_' + type).html("<embed src='" + $("#sound_" + type).val() + "' autostart='true' hidden='true' loop='true'>");
|
||||
}
|
||||
}
|
||||
|
||||
function replaySound(type) {
|
||||
if ($("#button_sound_" + type).attr('src') == 'images/pause.button.png') {
|
||||
$('#layer_sound_' + type).html("");
|
||||
$('#layer_sound_' + type).html("<embed src='" + $("#sound_" + type).val() + "' autostart='true' hidden='true' loop='true'>");
|
||||
}
|
||||
}
|
||||
</script>
|
||||
<?php
|
||||
|
||||
enterprise_hook ('setup');
|
||||
|
||||
echo '<form id="form_setup" method="post">';
|
||||
|
@ -117,4 +154,20 @@ echo '<div class="action-buttons" style="width: '.$table->width.'">';
|
|||
print_submit_button (__('Update'), 'update_button', false, 'class="sub upd"');
|
||||
echo '</div>';
|
||||
echo '</form>';
|
||||
|
||||
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;
|
||||
}
|
||||
?>
|
||||
|
|
Binary file not shown.
After Width: | Height: | Size: 862 B |
Binary file not shown.
After Width: | Height: | Size: 5.3 KiB |
Binary file not shown.
After Width: | Height: | Size: 2.3 KiB |
Binary file not shown.
After Width: | Height: | Size: 3.9 KiB |
|
@ -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.
|
||||
*
|
||||
|
|
|
@ -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']));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -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' => '<a href="'.$url.'&pure=1">' .
|
||||
print_image("images/fullscreen.png", true, array ("title" => __('Full screen'))) .'</a>'),
|
||||
'rss' => array('active' => false,
|
||||
'text' => '<a href="operation/events/events_rss.php?ev_group='.$ev_group.'&event_type='.$event_type.'&search='.rawurlencode ($search).'&severity='.$severity.'&status='.$status.'&event_view_hr='.$event_view_hr.'&id_agent='.$id_agent.'">' .
|
||||
print_image("images/rss.png", true, array ("title" => __('RSS Events'))) .'</a>'),
|
||||
'marquee' => array('active' => false,
|
||||
'text' => '<a href="operation/events/events_marquee.php">' .
|
||||
print_image("images/heart.png", true, array ("title" => __('Marquee display'))) .'</a>'),
|
||||
'csv' => array('active' => false,
|
||||
'text' => '<a href="operation/events/export_csv.php?ev_group='.$ev_group.'&event_type='.$event_type.'&search='.rawurlencode ($search).'&severity='.$severity.'&status='.$status.'&event_view_hr='.$event_view_hr.'&id_agent='.$id_agent.'">' .
|
||||
print_image("images/disk.png", true, array ("title" => __('Export to CSV file'))) .'</a>')
|
||||
);
|
||||
'fullscreen' => array('active' => false,
|
||||
'text' => '<a href="'.$url.'&pure=1">' .
|
||||
print_image("images/fullscreen.png", true, array ("title" => __('Full screen'))) .'</a>'),
|
||||
'rss' => array('active' => false,
|
||||
'text' => '<a href="operation/events/events_rss.php?ev_group='.$ev_group.'&event_type='.$event_type.'&search='.rawurlencode ($search).'&severity='.$severity.'&status='.$status.'&event_view_hr='.$event_view_hr.'&id_agent='.$id_agent.'">' .
|
||||
print_image("images/rss.png", true, array ("title" => __('RSS Events'))) .'</a>'),
|
||||
'marquee' => array('active' => false,
|
||||
'text' => '<a href="operation/events/events_marquee.php">' .
|
||||
print_image("images/heart.png", true, array ("title" => __('Marquee display'))) .'</a>'),
|
||||
'csv' => array('active' => false,
|
||||
'text' => '<a href="operation/events/export_csv.php?ev_group='.$ev_group.'&event_type='.$event_type.'&search='.rawurlencode ($search).'&severity='.$severity.'&status='.$status.'&event_view_hr='.$event_view_hr.'&id_agent='.$id_agent.'">' .
|
||||
print_image("images/disk.png", true, array ("title" => __('Export to CSV file'))) .'</a>'),
|
||||
'sound_event' => array('active' => false,
|
||||
'text' => '<a href="javascript: openSoundEventWindow();">' . print_image('images/music_note.png', true, array('title' => __('Sound events'))) . '</a>')
|
||||
);
|
||||
|
||||
print_page_header (__("Events"), "images/lightning_go.png", false, "eventview", false,$buttons);
|
||||
print_page_header (__("Events"), "images/lightning_go.png", false, "eventview", false, $buttons);
|
||||
|
||||
?>
|
||||
<script type="text/javascript">
|
||||
function openSoundEventWindow() {
|
||||
url = '<?php echo 'http://' . $_SERVER['SERVER_NAME'] . $config['homeurl'] . '/operation/events/sound_events.php'; ?>';
|
||||
|
||||
window.open(url, '<?php __('Sound Alerts'); ?>','width=300, height=300, toolbar=no, location=no, directories=no, status=no, menubar=no');
|
||||
}
|
||||
</script>
|
||||
<?php
|
||||
}
|
||||
else {
|
||||
// Fullscreen
|
||||
|
|
|
@ -0,0 +1,213 @@
|
|||
<?php
|
||||
|
||||
// Pandora FMS - http://pandorafms.com
|
||||
// ==================================================
|
||||
// Copyright (c) 2005-2010 Artica Soluciones Tecnologicas
|
||||
// Please see http://pandorafms.org for full contribution list
|
||||
|
||||
// This program is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU General Public License
|
||||
// as published by the Free Software Foundation for version 2.
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
|
||||
// Load global vars
|
||||
|
||||
if ((! file_exists("../../include/config.php")) || (! is_readable("../../include/config.php"))) {
|
||||
exit;
|
||||
}
|
||||
|
||||
require_once ('../../include/config.php');
|
||||
require_once ('../../include/functions.php');
|
||||
require_once ('../../include/functions_db.php');
|
||||
require_once ('../../include/auth/mysql.php');
|
||||
|
||||
global $config;
|
||||
|
||||
// Real start
|
||||
session_start ();
|
||||
|
||||
// Check user
|
||||
check_login ();
|
||||
$config["id_user"] = $_SESSION["id_usuario"];
|
||||
|
||||
|
||||
if (! give_acl ($config['id_user'], 0, "AR")) {
|
||||
audit_db ($config['id_user'],$_SERVER['REMOTE_ADDR'], "ACL Violation","Trying to access event viewer");
|
||||
require ("general/noaccess.php");
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
echo "<html>";
|
||||
echo "<title>" . __("Sound Alerts") . "</title>";
|
||||
echo "<style type='text/css'>";
|
||||
?>
|
||||
*
|
||||
{
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
img {
|
||||
border: 0;
|
||||
}
|
||||
<?php
|
||||
echo "</style>";
|
||||
echo "<body>";
|
||||
|
||||
echo "<h1 style='background: #66AA44; color: #fff;'><img src='images/pandora_header_logo.png'/>" . __("Sound Events") . "</h1>";
|
||||
|
||||
$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') . '<br />' .
|
||||
print_checkbox('critical', 'critical', true, true, false, 'changeType();') . __('Monitor critical') . '<br />' .
|
||||
print_checkbox('warning', 'warning', true, true, false, 'changeType();') . __('Monitor warning') . '<br />' .
|
||||
$table->data[2][0] = '';
|
||||
$table->data[2][1] = '<a href="javascript: toggleButton();"><img id="button" src="../../images/play.button.png" /></a>';
|
||||
$table->data[2][1] .= '<a href="javascript: ok();"><img style="margin-left: 10px;" src="../../images/ok.button.png" /></a>';
|
||||
|
||||
print_table($table);
|
||||
?>
|
||||
<script src="../../include/javascript/jquery.js" type="text/javascript"></script>
|
||||
<script type="text/javascript">
|
||||
var group = 0;
|
||||
var alert_fired = true;
|
||||
var critical = true;
|
||||
var warning = true;
|
||||
|
||||
var running = false;
|
||||
var fired = false;
|
||||
|
||||
var id_row = 0;
|
||||
|
||||
var redBackground = false;
|
||||
|
||||
function changeGroup() {
|
||||
group = $("#group").val();
|
||||
}
|
||||
|
||||
function changeType() {
|
||||
alert_fired = $("input[name=alert_fired]").attr('checked');
|
||||
critical = $("input[name=critical]").attr('checked');
|
||||
warning = $("input[name=warning]").attr('checked');
|
||||
}
|
||||
|
||||
function toggleButton() {
|
||||
//alert($("#button").attr('src'));
|
||||
if ($("#button").attr('src') == '../../images/pause.button.png') {
|
||||
$("#button").attr('src', '../../images/play.button.png');
|
||||
stopSound();
|
||||
}
|
||||
else {
|
||||
$("#button").attr('src', '../../images/pause.button.png');
|
||||
forgetPreviousEvents();
|
||||
startSound();
|
||||
}
|
||||
}
|
||||
|
||||
function ok() {
|
||||
fired = false;
|
||||
$('body').css('background', 'white');
|
||||
$('embed').remove();
|
||||
}
|
||||
|
||||
function stopSound() {
|
||||
$('embed').remove();
|
||||
|
||||
$('body').css('background', 'white');
|
||||
redBackground = false;
|
||||
|
||||
running = false;
|
||||
fired = false;
|
||||
}
|
||||
|
||||
function startSound() {
|
||||
$('embed').remove();
|
||||
|
||||
//running = true;
|
||||
}
|
||||
|
||||
function forgetPreviousEvents() {
|
||||
jQuery.post ("../../ajax.php",
|
||||
{"page" : "operation/events/events",
|
||||
"get_events_fired": 1,
|
||||
"id_group": group,
|
||||
"alert_fired": alert_fired,
|
||||
"critical": critical,
|
||||
"warning": warning,
|
||||
"id_row": id_row
|
||||
},
|
||||
function (data) {
|
||||
firedId = parseInt(data['fired']);
|
||||
if (firedId != 0) {
|
||||
id_row = firedId;
|
||||
running = true;
|
||||
}
|
||||
},
|
||||
"json"
|
||||
);
|
||||
}
|
||||
|
||||
function check_event() {
|
||||
if (running) {
|
||||
if (!fired) {
|
||||
jQuery.post ("../../ajax.php",
|
||||
{"page" : "operation/events/events",
|
||||
"get_events_fired": 1,
|
||||
"id_group": group,
|
||||
"alert_fired": alert_fired,
|
||||
"critical": critical,
|
||||
"warning": warning,
|
||||
"id_row": id_row
|
||||
},
|
||||
function (data) {
|
||||
firedId = parseInt(data['fired']);
|
||||
if (firedId != 0) {
|
||||
id_row = firedId;
|
||||
fired = true;
|
||||
$('embed').remove();
|
||||
$('body').append("<embed src='../../" + data['sound'] + "' autostart='true' hidden='true' loop='true'>");
|
||||
}
|
||||
},
|
||||
"json"
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function animation() {
|
||||
if (fired) {
|
||||
window.focus();
|
||||
if (redBackground) {
|
||||
redBackground = false;
|
||||
$('body').css('background', 'white');
|
||||
window.moveBy(5, 0);
|
||||
}
|
||||
else {
|
||||
redBackground = true;
|
||||
$('body').css('background-color', 'red');
|
||||
window.moveBy(-5, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$(document).ready (function () {
|
||||
setInterval("check_event()", (10 * 1000)); //10 seconds between ajax request
|
||||
setInterval("animation()", (0.1 * 1000));
|
||||
});
|
||||
</script>
|
||||
<?php
|
||||
echo "</body>";
|
||||
echo "</html>";
|
||||
?>
|
|
@ -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;
|
||||
|
|
Loading…
Reference in New Issue