Operation Screen - Play Sound
Operation Screen - Play Sound
Is it possible to modify the php for the Operation Screen to play a sound file (.wav) when a down host is detected?
Re: Operation Screen - Play Sound
Should be doable, are you requesting any critical (host and service) or just if a host is down?
Re: Operation Screen - Play Sound
Well, I imagine the php/HTML code is extremely similar for both. My preference is just for critical hosts at the moment.
Re: Operation Screen - Play Sound
I can point you in the right direction but it will get reverted if/when you do an upgrade and it's not something that we support.
Edit /usr/local/nagiosxi/html/includes/components/opscreen/opscreen.php and add this under the <script type="text/javascript"> section:
Edit /usr/local/nagiosxi/html/includes/components/opscreen/merlin.php
Find this code:
Add this code right beneath it:
That should get you going in the right direction, works for me, you may modify it to your liking.
Edit /usr/local/nagiosxi/html/includes/components/opscreen/opscreen.php and add this under the <script type="text/javascript"> section:
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();
}Find this code:
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>';
}Re: Operation Screen - Play Sound
Awesome!
I'll give it a shot and report back with my results. Thank you very very much
I'll give it a shot and report back with my results. Thank you very very much
Re: Operation Screen - Play Sound
You could also just copy your mp3 file to /usr/local/nagiosxi/html/images
Then you could change the code to:
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();
}