[Pkg-nagios-changes] [SCM] UNNAMED PROJECT branch, master, updated. 016db4e7560fc8ef5ccdb6357745ef691650d94a

Naparuba naparuba at gmail.com
Wed Nov 16 10:03:27 UTC 2011


The following commit has been merged in the master branch:
commit 0732e6cdfde9e7d3821ecf651512f519c8f328a4
Author: Naparuba <naparuba at gmail.com>
Date:   Tue Nov 15 16:57:22 2011 +0100

    Add : last 10min it problems, and make them 'slide' in the wall page.

diff --git a/shinken/webui/plugins/wall/htdocs/css/wall.css b/shinken/webui/plugins/wall/htdocs/css/wall.css
index 800f87d..c1fa942 100644
--- a/shinken/webui/plugins/wall/htdocs/css/wall.css
+++ b/shinken/webui/plugins/wall/htdocs/css/wall.css
@@ -74,3 +74,29 @@
     left: 20px;
     top : 10px;
 }
+
+
+
+
+.last_errors{
+    border-color : black;
+    border : 1px;
+    top : 450px;
+    position: relative;
+}
+
+
+.wall-aroundpulse{
+    margin : 0;
+    width: 32px;
+    height: 32px;
+
+}
+
+.wall-problems-text{
+    position: relative;
+    top : -25px;
+    left: 40px;
+}
+
+.sliding{}
\ No newline at end of file
diff --git a/shinken/webui/plugins/wall/htdocs/js/wall.js b/shinken/webui/plugins/wall/htdocs/js/wall.js
index 9754b8b..b3fa8db 100644
--- a/shinken/webui/plugins/wall/htdocs/js/wall.js
+++ b/shinken/webui/plugins/wall/htdocs/js/wall.js
@@ -22,8 +22,43 @@
 */
 
 
-
+/* We will initialize the WALL panel with our data*/
 window.addEvent('domready', function(){
     options = {'autoslide' : true};
     snowstack_init(images, options);
 });
+
+
+function translate_problem(){
+    var to_slide = $$('.sliding');
+    to_slide.each(function(el){
+	var pos = el.getPosition();
+	var new_pos = pos.x - 400;
+	
+	var myeffect  = new Fx.Elements(el);//$$('a'));
+
+	myeffect.start({
+	    '0': {
+		'left': [pos.x,new_pos]
+	    }
+	});
+	
+    });
+
+}
+
+/* And we will initialise the slide of our problems too*/
+window.addEvent('domready', function(){
+    var nb_elements = $$('.sliding').length;
+    // If there is not enough elements, don't even slide
+    // So we print in each page 12 elements. No need to slide if lower
+    if(nb_elements > 12){
+	var nb_slides = nb_elements / 4;
+	var slide_interval = 60/nb_slides;
+	//alert('interval'+slide_interval);
+
+	slide_interval = Math.max(slide_interval, 10000);
+	setInterval( translate_problem, slide_interval);//10000);
+    }
+
+});
diff --git a/shinken/webui/plugins/wall/views/wall.tpl b/shinken/webui/plugins/wall/views/wall.tpl
index 4aaef4e..d0312d3 100644
--- a/shinken/webui/plugins/wall/views/wall.tpl
+++ b/shinken/webui/plugins/wall/views/wall.tpl
@@ -1,3 +1,4 @@
+%helper = app.helper
 
 %rebase layout css=['wall/css/snowstack.css', 'wall/css/wall.css'], title='Wall view', js=['wall/js/snowstack.js', 'wall/js/wall.js'], refresh=True, user=user, print_menu=False, print_header=True
 
@@ -11,7 +12,36 @@
 
 
 <script type="text/javascript">
-
 var images = {{!impacts}};
-
 </script>
+
+
+<div class="last_errors">
+%if len(problems) == 0:
+<h2>No new IT problems in the last 10minutes</h2>
+%else:
+<h3>There are {{len(problems)}} new IT problems in the last 10 minutes :</h3>
+%end
+
+%ind = -1
+%for pb in problems:
+   %ind += 1
+   %x,y = divmod(ind, 4)
+       <div class="divstate{{pb.state_id}} sliding" style="left:{{x * 400}}px; position: absolute; top:{{ y * 50 + 50}}px; i:{{ind}} {{x}} {{y}}">
+	 <div class="wall-aroundpulse aroundpulse">
+	 %if pb.business_impact > 2:
+	   <span class="pulse" title=""></span>
+	 %end
+	   <img style="width : 32px; height:32px" src="{{helper.get_icon_state(pb)}}">
+	 </div>
+	 <div class="wall-problems-text">
+	 %for i in range(0, pb.business_impact-2):
+	 <img style="width : 16px; height:16px" src='/static/images/star.png'>
+	 %end
+
+	   <span style="font-size:110%">{{!helper.get_link(pb, short=False)}}</span> is <span style="font-size:110%">{{pb.state}}</span> since {{helper.print_duration(pb.last_state_change, just_duration=True, x_elts=2)}}
+	 </div>
+       </div>
+
+%end
+</div>
diff --git a/shinken/webui/plugins/wall/wall.py b/shinken/webui/plugins/wall/wall.py
index ad509e0..1f39786 100644
--- a/shinken/webui/plugins/wall/wall.py
+++ b/shinken/webui/plugins/wall/wall.py
@@ -1,6 +1,8 @@
 ### Will be populated by the UI with it's own value
 app = None
 
+import time
+
 from shinken.webui.bottle import redirect
 from shinken.modules.webui_broker.helper import hst_srv_sort
 from shinken.util import safe_print
@@ -15,6 +17,16 @@ except ImportError:
         print "Error : you need the json or simplejson module"
         raise
 
+
+
+# Sort hosts and services by impact, states and co
+def sort_by_last_state_change(s1, s2):
+    if s1.last_state_change > s2.last_state_change:
+        return -1
+    else:
+        return 1
+
+
 # Get the div for each element
 def get_div(elt):
     icon = app.helper.get_icon_state(elt)
@@ -74,8 +86,14 @@ def get_page():
     # Got in json format
     #j_impacts = json.dumps(impacts)
 #    print "Return impact in json", j_impacts
+    all_pbs = app.datamgr.get_all_problems()
+    now = time.time()
+    # Get only the last 10min errors
+    all_pbs = [pb for pb in all_pbs if pb.last_state_change > now - 600]
+    # And sort it
+    all_pbs.sort(hst_srv_sort)#sort_by_last_state_change)
 
-    return {'app' : app, 'user' : user, 'impacts' : impacts}
+    return {'app' : app, 'user' : user, 'impacts' : impacts, 'problems' : all_pbs}
 
 
 pages = {get_page : { 'routes' : ['/wall/'], 'view' : 'wall', 'static' : True}}

-- 
UNNAMED PROJECT



More information about the Pkg-nagios-changes mailing list