[Pkg-nagios-changes] [SCM] UNNAMED PROJECT branch, debian/master, updated. 810edbdd3feedbfe37f4a65bee50b57b2f60fa2a

Naparuba naparuba at gmail.com
Tue Feb 28 22:08:30 UTC 2012


The following commit has been merged in the debian/master branch:
commit 91a875f9f2e4e1b8853ce2fbe34024417c03a6fa
Author: Naparuba <naparuba at gmail.com>
Date:   Tue Dec 13 14:48:08 2011 +0100

    *Add : port option for the mysql connexion with NDO
    *Add : impact page for mobile.

diff --git a/etc/shinken-specific.cfg b/etc/shinken-specific.cfg
index 33c3405..976b9c6 100644
--- a/etc/shinken-specific.cfg
+++ b/etc/shinken-specific.cfg
@@ -247,7 +247,8 @@ define module{
        user		root      ; user of the database
        password		root      ; must be changed
        host		localhost ; host to connect to
-       character_set	utf8      ;optionnal, UTF8 is the default
+       character_set	utf8      ; optionnal, UTF8 is the default
+       port		3306	  ; mysql port
 
        # If you want to mix Shinken AND Nagios/icinga in the same db
        # you need to offset shinken instance id so they will not
diff --git a/shinken/db_mysql.py b/shinken/db_mysql.py
index 08a4f82..012ad51 100644
--- a/shinken/db_mysql.py
+++ b/shinken/db_mysql.py
@@ -30,13 +30,14 @@ from MySQLdb import ProgrammingError
 
 
 class DBMysql(DB):
-    def __init__(self, host, user, password, database, character_set, table_prefix = ''):
+    def __init__(self, host, user, password, database, character_set, table_prefix = '', port=3306):
         self.host = host
         self.user = user
         self.password = password
         self.database = database
         self.character_set = character_set
         self.table_prefix = table_prefix
+        self.port = port
 
 
     #Create the database connection
@@ -44,7 +45,8 @@ class DBMysql(DB):
     def connect_database(self):
         #self.db = MySQLdb.connect (host = "localhost", user = "root", passwd = "root", db = "merlin")
         self.db = MySQLdb.connect (host = self.host, user = self.user, \
-                                       passwd = self.password, db = self.database)
+                                       passwd = self.password, db = self.database,
+                                   port = self.port)
         self.db.set_character_set(self.character_set)
         self.db_cursor = self.db.cursor ()
         self.db_cursor.execute('SET NAMES %s;' % self.character_set)
diff --git a/shinken/modules/ndodb_mysql_broker/ndodb_mysql_broker.py b/shinken/modules/ndodb_mysql_broker/ndodb_mysql_broker.py
index 16509b7..0112926 100644
--- a/shinken/modules/ndodb_mysql_broker/ndodb_mysql_broker.py
+++ b/shinken/modules/ndodb_mysql_broker/ndodb_mysql_broker.py
@@ -63,6 +63,7 @@ class Ndodb_Mysql_broker(BaseModule):
         self.database = conf.database
         self.character_set = conf.character_set
         self.nagios_mix_offset = int(conf.nagios_mix_offset)
+        self.port = int(getattr(conf, 'port', '3306'))
 
 
     #Called by Broker so we can do init stuff
@@ -70,7 +71,7 @@ class Ndodb_Mysql_broker(BaseModule):
     #Conf from arbiter!
     def init(self):
         print "I connect to NDO database"
-        self.db = DBMysql(self.host, self.user, self.password, self.database, self.character_set, table_prefix='nagios_')
+        self.db = DBMysql(self.host, self.user, self.password, self.database, self.character_set, table_prefix='nagios_', port=self.port)
         self.connect_database()
 
         #Cache for hosts and services
diff --git a/shinken/webui/plugins/mobile/htdocs/css/impacts.css b/shinken/webui/plugins/mobile/htdocs/css/impacts.css
new file mode 100644
index 0000000..512452b
--- /dev/null
+++ b/shinken/webui/plugins/mobile/htdocs/css/impacts.css
@@ -0,0 +1,9 @@
+.impacts{
+    positon : absolute;
+}
+
+.impact{
+    width: 250px; 
+    height: 150px;
+    position : absolute;
+}
\ No newline at end of file
diff --git a/shinken/webui/plugins/mobile/htdocs/css/main.css b/shinken/webui/plugins/mobile/htdocs/css/main.css
new file mode 100644
index 0000000..c0bdba1
--- /dev/null
+++ b/shinken/webui/plugins/mobile/htdocs/css/main.css
@@ -0,0 +1,3 @@
+#all{
+position : absolute;
+}
\ No newline at end of file
diff --git a/shinken/webui/htdocs/js/reload.js b/shinken/webui/plugins/mobile/htdocs/js/mobile_main.js
similarity index 59%
copy from shinken/webui/htdocs/js/reload.js
copy to shinken/webui/plugins/mobile/htdocs/js/mobile_main.js
index 6a9ed83..19564c5 100644
--- a/shinken/webui/htdocs/js/reload.js
+++ b/shinken/webui/plugins/mobile/htdocs/js/mobile_main.js
@@ -21,27 +21,24 @@
  along with Shinken.  If not, see <http://www.gnu.org/licenses/>.
 */
 
-
-/* By default, we set the page to reload each 60s*/
-var refresh_timeout = 60;
-
-/* Each second, we check for timeout and restart page */
-function check_refresh(){
-    if(refresh_timeout < 0){
-	location.assign(location.href);
-    }
-    refresh_timeout = refresh_timeout - 1;    
-}
-
-
-/* Someone ask us to reinit the refresh so the user will have time to
-   do some thigns like ask actions or something like that */
-function reinit_refresh(){
-    refresh_timeout = 60;
+function go_to(url){
+    window.location = url;
 }
 
-/* We will check timeout each 1s*/
-window.addEvent('domready', function(){
-	setInterval("check_refresh();", 1000); 
+/* We want to slide all elements (in fact the div that got all elements
+   , make it opacity in 0.5 s and then go to the new page.
+*/
+function slide_and_go(url){
+    /* We must avoid $$() call for IE, so call a standad way*/
+    var a = $(document.body).getElement('#all');
+    
+    var toggleEffect = new Fx.Tween(a, {
+	property : 'opacity',
+	duration : 500/*'short'*/
     });
 
+    toggleEffect.start(1, 0); // go show by in opacity
+    var move = new Fx.Tween(a, {property: 'left', duration : 500});
+    move.start(0, 200); // and by moving right
+    setTimeout("go_to('"+url+"')", 500);
+}    
diff --git a/shinken/webui/plugins/mobile/mobile.py b/shinken/webui/plugins/mobile/mobile.py
index ef07999..225c583 100644
--- a/shinken/webui/plugins/mobile/mobile.py
+++ b/shinken/webui/plugins/mobile/mobile.py
@@ -44,5 +44,22 @@ def main():
     return {'app' : app, 'user' : user, 'impacts' : all_imp_impacts, 'problems' : all_pbs}
 
 
-pages = {main : { 'routes' : ['/mobile/main'], 'view' : 'mobile_main', 'static' : True}}
+def impacts():
+    # First we look for the user sid
+    # so we bail out if it's a false one
+    user = app.get_user_auth()
+
+    if not user:
+        redirect("/mobile/")
+        return
+
+
+    all_imp_impacts = app.datamgr.get_important_elements()
+    
+    return {'app' : app, 'user' : user, 'impacts' : all_imp_impacts}
+
+
+pages = {main : { 'routes' : ['/mobile/main'], 'view' : 'mobile_main', 'static' : True},
+         impacts : { 'routes' : ['/mobile/impacts'], 'view' : 'mobile_impacts', 'static' : True},
+         }
 
diff --git a/shinken/webui/plugins/mobile/views/mobile_impacts.tpl b/shinken/webui/plugins/mobile/views/mobile_impacts.tpl
new file mode 100644
index 0000000..30199c5
--- /dev/null
+++ b/shinken/webui/plugins/mobile/views/mobile_impacts.tpl
@@ -0,0 +1,25 @@
+
+%rebase layout globals(), title="Tactical view", js=['mobile/js/mobile_main.js'], css=['mobile/css/main.css', 'mobile/css/impacts.css']
+
+<div id="all">
+<div> <h1> Shinken business apps</h1> </div>
+
+<h2>End users apps</h2>
+
+
+
+<img src="/static/images/state_critical.png" >
+<a href="#" onclick="slide_and_go('/mobile/impacts');"><img src="/static/images/next.png"/></a>
+%i = 0
+<div class="impacts">
+  %for imp in impacts:
+    <div class="impact" style="left:{{i*250}}px">
+      <p class="{{imp.state.lower()}}">{{imp.get_full_name()}} is {{imp.state}}</p>
+    </div>
+    %i += 1
+  %end
+</div>
+
+
+
+</div>
diff --git a/shinken/webui/plugins/mobile/views/mobile_main.tpl b/shinken/webui/plugins/mobile/views/mobile_main.tpl
index 4706ad9..be53f9b 100644
--- a/shinken/webui/plugins/mobile/views/mobile_main.tpl
+++ b/shinken/webui/plugins/mobile/views/mobile_main.tpl
@@ -1,5 +1,7 @@
 
-%rebase layout globals()
+%rebase layout globals(), title="Tactical view", js=['mobile/js/mobile_main.js'], css=['mobile/css/main.css']
+
+<div id="all">
 <div> <h1> Shinken </h1> </div>
 
 <h2>End users apps</h2>
@@ -7,14 +9,14 @@
 %bad_business = [i for i in impacts if i.state_id != 0]
 
 
-%""" All business apps are OK """
+%# """ All business apps are OK """
 %if len(bad_business) == 0:
-    <img src="/static/images/state_ok.png" >
-    <img src="/static/images/next.png"/>
- """ Are, some business apps are bad!"""
+    <img src="/static/images/state_ok.png">
+    <a href="#" onclick="slide_and_go('/mobile/impacts');"><img src="/static/images/next.png"/></a>
+%# """ Are, some business apps are bad!"""
 %else:
     <img src="/static/images/state_critical.png" >
-    <img src="/static/images/next.png"/>
+    <a href="#" onclick="slide_and_go('/mobile/impacts');"><img src="/static/images/next.png"/></a>
     <ul>
     %for imp in bad_business:
          <li class="{{imp.state.lower()}}">{{imp.get_full_name()}} is {{imp.state}}</li>
@@ -23,4 +25,20 @@
 %end
 
 
-<h2>Pure IT problems</h2>
\ No newline at end of file
+<h2>Pure IT problems</h2>
+%if len(problems) == 0:
+    <img src="/static/images/state_ok.png" >
+    <a href="#" onclick="slide_and_go('/mobile/problems');"><img src="/static/images/next.png"/></a>
+%else:
+    <img src="/static/images/state_warning.png" >
+    <a href="#" onclick="slide_and_go('/mobile/problems');"><img src="/static/images/next.png"/></a>
+    %nb_high_critical = len([pb for pb in problems if pb.business_impact > 2 and pb.state in ['DOWN', 'CRITICAL'] ])
+    %nb_high_warn = len([pb for pb in problems if pb.business_impact > 2 and pb.state in ['WARNING']])
+    %nb_low_critical = len([pb for pb in problems if pb.business_impact <= 2 and pb.state in ['DOWN', 'CRITICAL'] ])
+    %nb_low_warn = len([pb for pb in problems if pb.business_impact <= 2 and pb.state in ['WARNING']])
+    <br/>
+    <p>Production : {{nb_high_critical}} Criticals, {{nb_high_warn}} Warnings.</p>
+    <p>Lower      : {{nb_low_critical}} Criticals, {{nb_low_warn}} Warnings.</p>
+%end
+
+</div>

-- 
UNNAMED PROJECT



More information about the Pkg-nagios-changes mailing list