Operation Screen - Play Sound
Posted: Thu Jun 11, 2015 2:06 pm
Is it possible to modify the php for the Operation Screen to play a sound file (.wav) when a down host is detected?
Support for Nagios products and services
https://support.nagios.com/forum/
Code: Select all
function play_sound() {
var audioElement = document.createElement('audio');
audioElement.setAttribute('src', 'http://www.stephaniequinn.com/Music/Allegro%20from%20Duet%20in%20C%20Major.mp3');
audioElement.setAttribute('autoplay', 'autoplay');
audioElement.load();
audioElement.play();
}Code: Select all
$hosts_down = $row[0];Code: Select all
$file = '/tmp/hosts_down_temp.txt';
// Add host count to file
// Open the file to get existing content
$old_hosts_down = file_get_contents($file);
// Write the new host down count to the file
file_put_contents($file, $hosts_down);
if ($old_hosts_down < $hosts_down) {
echo '<script type="text/javascript">play_sound();</script>';
}Code: Select all
chmod 640 /usr/local/nagiosxi/html/images/alarm.mp3
chown nagios.nagios /usr/local/nagiosxi/html/images/alarm.mp3Code: Select all
function play_sound() {
var audioElement = document.createElement('audio');
audioElement.setAttribute('src', '/nagiosxi/images/alarm.mp3');
audioElement.setAttribute('autoplay', 'autoplay');
audioElement.load();
audioElement.play();
}