SE Stuff and the like…


Centreon add audioble alert to tacktical overview.

browse to your centreon install location web dir default;

~>cd /usr/local/centreon/www/

browse to the tacticalOverview dir.

~>cd /include/home/tackticalOverview

Open the file tacticalOverview.php

~>vi /tacticalOverview.php

Add the following code in the bottom of the file.


/*
                         * Audiable allert on Warning, Critical, Unknown states.
                         * Values are recalculated because we dont accept NULL as an answer
                         */
                        if(!isset($_SESSION['amis_alert'])){
                                $_SESSION['amis_alert'] = false;
                        }
                        foreach($SvcStat as $key => $val){
                                if(($key == 1) || ($key == 2) || ($key == 3)){
                                        $sum = $val - $svcAck[$key];
                                        if($sum >= 1){
                                                if(!$_SESSION['amis_alert']){
                                                        print('<script>window.open(\'./include/home/tacticalOverview/alert.ihtml\', \'alert\',\'width=180,height=20,scrollbars=no,toolbar=no,location=no\');</script>');
                                                        $_SESSION['amis_alert'] = true;
                                                        break;
                                                }
                                                break;
                                        }else{
                                                print('<script>window.open(\'./include/home/tacticalOverview/closeme.ihtml\', \'alert\',\'width=180,height=20,scrollbars=no,toolbar=no,location=no\');</script>');
                                                $_SESSION['amis_alert'] = false;
                                        }

                                }
                        }

If you want this tidy add additional template entries. I was to lazy for that ;-)

Save the file and add the alert.ihtml

~>vim ./alert.ihtml

Add the following code

<html>
<head></head>
<body>
<div>
<object type="application/x-shockwave-flash" data="../../../mp3player.swf" height="20" width="180"><param name="FlashVars" value="mp3=../../../error.mp3&autoplay=1&loop=1&showslider=0"/></object></div>
</body>

Save the file and add the closeme.ihtml

~>vim closeme.ihtml

Add the following code

<html>
<head></head>
<body>
<script>window.close();</script>
</body>

Go back to the www dir

~>cd /usr/local/centreon/www

download the a nice error.mp3 (yeah you need to rename it ;)

wget http://www.freeinfosociety.com/media/sounds/142.mp3
~>cp ./142.mp3 ./error.mp3

Download the flash player (yeah i renamed this one too :-)

~>wget http://flash-mp3-player.net/medias/player_mp3_maxi.swf
cp ./player_mp3_maxi.swf ./mp3player.swf

This should be all

Hope this helps, and sure do edit the scripts with nicer methods but please do me a favour by keeping us up-to-date with nice addons :D


1 Comment so far
Leave a comment

Ow, Using this manual is at your own risk!! Always make a backup of the original files!!!

Functionality

#Code opperates between refreshes. This is significant because it will “NOT” update a manual closed popup when there is no state change in centreon.

#Code will compare service problem (#) against acked problems. If the outcome is higher then 1, (there are unacked services) it will spawn the popup containing the alert.ihtml, else it will spawn the closeme.ihtml

#usage might get confusing when manualy closing any popup or when a popup killer is active! this is because the code requires a statechange and a refresh the restore a stable state.

#any refresh in a stable state (all problems acked or no service problems known) will generate a popup that closes itself instantly atm. This is to stop the alert from being played. window.focus might hide this behaviour. I will update the code with a state entry so we can limit this to once after a alert.

#Why a popup? this is because we want the alert to continue even after ‘a’ engineer changes any settings on the monitoring host. So our alert will survive pagechanges, it also allows us to use mp3 files that are longer then the refresh rate of centreon, which is a nice feature if you ask me ;)

Any bugs or unexpected funct loss next to the above described points? please feel free to update this post ;-)

Rgrds, and thx Chris

Comment by chrisgralike




Leave a comment
Line and paragraph breaks automatic, e-mail address never displayed, HTML allowed: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <pre> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>