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

nap naparuba at gmail.com
Tue Feb 28 22:15:10 UTC 2012


The following commit has been merged in the debian/master branch:
commit e8223f8f00d416ceca26e1339237dec76793f45f
Author: nap <naparuba at gmail.com>
Date:   Sat Jan 21 14:45:28 2012 +0100

    Enh : make datamanager, the regenerator front class, a common one so it can be reused by LS.

diff --git a/shinken/basemodule.py b/shinken/basemodule.py
index fd32723..cc441f8 100644
--- a/shinken/basemodule.py
+++ b/shinken/basemodule.py
@@ -1,4 +1,3 @@
-#!/usr/bin/env python
 # -*- coding: utf-8 -*-
 
 # Copyright (C) 2009-2011 :
@@ -92,7 +91,8 @@ class BaseModule(object):
         self.modules = getattr(mod_conf, 'modules', [])
         self.props = mod_conf.properties.copy()
         # TODO: choose between 'props' or 'properties'..
-        self.interrupted = Falseself.properties = self.props 
+        self.interrupted = False
+        self.properties = self.props 
         self.is_external = self.props.get('external', False)
         # though a module defined with no phase is quite useless .
         self.phases = self.props.get('phases', []) 
diff --git a/shinken/modules/webui_broker/datamanager.py b/shinken/misc/datamanager.py
similarity index 99%
rename from shinken/modules/webui_broker/datamanager.py
rename to shinken/misc/datamanager.py
index b530980..71814c8 100644
--- a/shinken/modules/webui_broker/datamanager.py
+++ b/shinken/misc/datamanager.py
@@ -1,5 +1,5 @@
 #!/usr/bin/env python
-# Copyright (C) 2009-2010 :
+# Copyright (C) 2009-2012 :
 #    Gabes Jean, naparuba at gmail.com
 #    Gerhard Lausser, Gerhard.Lausser at consol.de
 #    Gregory Starck, g.starck at gmail.com
@@ -21,7 +21,7 @@
 # along with Shinken.  If not, see <http://www.gnu.org/licenses/>.
 
 from shinken.util import safe_print
-from helper import hst_srv_sort
+from shinken.misc.sorter import hst_srv_sort
 
 
 class DataManager(object):
diff --git a/shinken/misc/sorter.py b/shinken/misc/sorter.py
new file mode 100644
index 0000000..81718d6
--- /dev/null
+++ b/shinken/misc/sorter.py
@@ -0,0 +1,53 @@
+#!/usr/bin/env python
+# Copyright (C) 2009-2010 :
+#    Gabes Jean, naparuba at gmail.com
+#    Gerhard Lausser, Gerhard.Lausser at consol.de
+#    Gregory Starck, g.starck at gmail.com
+#    Hartmut Goebel, h.goebel at goebel-consult.de
+#
+# This file is part of Shinken.
+#
+# Shinken is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# Shinken is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public License
+# along with Shinken.  If not, see <http://www.gnu.org/licenses/>.
+
+
+"""
+Helper functions for some sortings
+"""
+
+# Sort hosts and services by impact, states and co
+def hst_srv_sort(s1, s2):
+    if s1.business_impact > s2.business_impact:
+        return -1
+    if s2.business_impact > s1.business_impact:
+        return 1
+
+    # Ok, we compute a importance value so
+    # For host, the order is UP, UNREACH, DOWN
+    # For service : OK, UNKNOWN, WARNING, CRIT
+    # And DOWN is before CRITICAL (potential more impact)
+    tab = {'host' : { 0 : 0, 1: 4, 2 : 1},
+           'service' : {0 : 0, 1 : 2, 2 : 3, 3 : 1}
+           }
+    state1 = tab[s1.__class__.my_type].get(s1.state_id ,0)
+    state2 = tab[s2.__class__.my_type].get(s2.state_id ,0)
+    # ok, here, same business_impact
+    # Compare warn and crit state
+    if state1 > state2:
+        return -1
+    if state2 > state1:
+        return 1
+    
+    # Ok, so by name...
+    return s1.get_full_name() > s2.get_full_name()
+
diff --git a/shinken/modules/webui_broker/helper.py b/shinken/modules/webui_broker/helper.py
index 84a843d..8bbc5bb 100644
--- a/shinken/modules/webui_broker/helper.py
+++ b/shinken/modules/webui_broker/helper.py
@@ -38,38 +38,11 @@ except ImportError:
 
 from shinken.util import safe_print
 from shinken.misc.perfdata import PerfDatas
+from shinken.misc.sorter import hst_srv_sort
 # TODO : manage it in a clean way.
 from shinken.modules.webui_broker.perfdata_guess import get_perfometer_table_values
 
 
-# Sort hosts and services by impact, states and co
-def hst_srv_sort(s1, s2):
-    if s1.business_impact > s2.business_impact:
-        return -1
-    if s2.business_impact > s1.business_impact:
-        return 1
-
-    # Ok, we compute a importance value so
-    # For host, the order is UP, UNREACH, DOWN
-    # For service : OK, UNKNOWN, WARNING, CRIT
-    # And DOWN is before CRITICAL (potential more impact)
-    tab = {'host' : { 0 : 0, 1: 4, 2 : 1},
-           'service' : {0 : 0, 1 : 2, 2 : 3, 3 : 1}
-           }
-    state1 = tab[s1.__class__.my_type].get(s1.state_id ,0)
-    state2 = tab[s2.__class__.my_type].get(s2.state_id ,0)
-    # ok, here, same business_impact
-    # Compare warn and crit state
-    if state1 > state2:
-        return -1
-    if state2 > state1:
-        return 1
-    
-    # Ok, so by name...
-    return s1.get_full_name() > s2.get_full_name()
-
-
-
 class Helper(object):
     def __init__(self):
         pass
diff --git a/shinken/modules/webui_broker/webui_broker.py b/shinken/modules/webui_broker/webui_broker.py
index 52cc756..b10d4df 100644
--- a/shinken/modules/webui_broker/webui_broker.py
+++ b/shinken/modules/webui_broker/webui_broker.py
@@ -46,7 +46,7 @@ from shinken.daemon import Daemon
 from shinken.util import safe_print, to_bool
 
 #Local import
-from datamanager import datamgr
+from shinken.misc.datamanager import datamgr
 from helper import helper
 
 # Debug

-- 
UNNAMED PROJECT



More information about the Pkg-nagios-changes mailing list