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

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


The following commit has been merged in the debian/master branch:
commit 91bac27943f652c2dfa06d0a2ae037a9dc32d6d9
Author: Naparuba <naparuba at gmail.com>
Date:   Wed Dec 14 12:47:12 2011 +0100

    Add (reported by : sprudhomme): long_output in ndo if it's teh centreon version.

diff --git a/THANKS b/THANKS
index af3de53..36871ff 100644
--- a/THANKS
+++ b/THANKS
@@ -48,4 +48,4 @@ To Stéphane Duchesneau for his work on the setup.py file and log/run driectorie
 To grim for his bug report about disabling flapping options
 To peter woodman for his bug report about timezone override crash
 To Laurent Ollagnier for his bug report and patch about notification commands
-
+To sprudhomme for his feature request about long_output in Centreon/Ndo
diff --git a/shinken/modules/ndodb_mysql_broker/ndodb_mysql_broker.py b/shinken/modules/ndodb_mysql_broker/ndodb_mysql_broker.py
index 0112926..612f601 100644
--- a/shinken/modules/ndodb_mysql_broker/ndodb_mysql_broker.py
+++ b/shinken/modules/ndodb_mysql_broker/ndodb_mysql_broker.py
@@ -64,6 +64,8 @@ class Ndodb_Mysql_broker(BaseModule):
         self.character_set = conf.character_set
         self.nagios_mix_offset = int(conf.nagios_mix_offset)
         self.port = int(getattr(conf, 'port', '3306'))
+        # Centreon ndo add some fields like long_output that are not in the vanilla ndo
+        self.centreon_version = False
 
 
     #Called by Broker so we can do init stuff
@@ -74,12 +76,22 @@ class Ndodb_Mysql_broker(BaseModule):
         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
-        #will be flushed when we got a net instance id
-        #or something like that
+        # Cache for hosts and services
+        # will be flushed when we got a net instance id
+        # or something like that
         self.services_cache = {}
         self.hosts_cache = {}
 
+        # We need to search for centreon_specific fields, like long_output
+        query = u"select TABLE_NAME from information_schema.columns where TABLE_SCHEMA='ndo' and TABLE_NAME='nagios_servicestatus' and COLUMN_NAME='long_output';"
+        self.db.execute_query(query)
+        row = self.db.fetchone ()
+        if row is None or len(row) < 1:
+            self.centreon_version = False
+        else:
+            self.centreon_version = True
+            print "NDO/Mysql : using the centreon version"
+
 
     #Get a brok, parse it, and put in in database
     #We call functions like manage_ TYPEOFBROK _brok that return us queries
@@ -103,8 +115,8 @@ class Ndodb_Mysql_broker(BaseModule):
         #print "(ndodb)I don't manage this brok type", b
 
 
-    #Create the database connection
-    #TODO : finish (begin :) ) error catch and conf parameters...
+    # Create the database connection
+    # TODO : finish (begin :) ) error catch and conf parameters...
     def connect_database(self):
         self.db.connect_database()
 
@@ -329,6 +341,10 @@ class Ndodb_Mysql_broker(BaseModule):
                            'has_been_checked' : 1, 'percent_state_change' : data['percent_state_change'], 'is_flapping' : data['is_flapping'],
                            'flap_detection_enabled' : data['flap_detection_enabled'],
                            }
+        # Centreon add some fields
+        if self.centreon_version:
+            hoststatus_data['long_output'] = data['long_output']
+
         hoststatus_query = self.db.create_insert_query('hoststatus' , hoststatus_data)
 
         return [query, hoststatus_query]
@@ -391,6 +407,10 @@ class Ndodb_Mysql_broker(BaseModule):
                               'has_been_checked' : 1, 'percent_state_change' : data['percent_state_change'], 'is_flapping' : data['is_flapping'],
                               'flap_detection_enabled' : data['flap_detection_enabled'],
                               }
+        # Centreon add some fields
+        if self.centreon_version:
+            servicestatus_data['long_output'] = data['long_output']
+
         servicestatus_query = self.db.create_insert_query('servicestatus' , servicestatus_data)
 
         return [query, servicestatus_query]
@@ -481,6 +501,10 @@ class Ndodb_Mysql_broker(BaseModule):
                            'return_code' : data['return_code'], 'output' : data['output'],
                            'perfdata' : data['perf_data']
         }
+        # Centreon add some fields
+        if self.centreon_version:
+            host_check_data['long_output'] = data['long_output']
+
         query = self.db.create_update_query('hostchecks', host_check_data, where_clause)
 
         #Now servicestatus
@@ -491,6 +515,10 @@ class Ndodb_Mysql_broker(BaseModule):
                            'output' : data['output'], 'perfdata' : data['perf_data'], 'last_check' : de_unixify(data['last_chk']),
                            'percent_state_change' : data['percent_state_change'],
         }
+        # Centreon add some fields
+        if self.centreon_version:
+            hoststatus_data['long_output'] = data['long_output']
+
         hoststatus_query = self.db.create_update_query('hoststatus' , hoststatus_data, where_clause)
 
         return [query, hoststatus_query]
@@ -526,6 +554,10 @@ class Ndodb_Mysql_broker(BaseModule):
                            'return_code' : data['return_code'], 'output' : data['output'],
                            'perfdata' : data['perf_data']
         }
+        # Centreon add some fields
+        if self.centreon_version:
+            service_check_data['long_output'] = data['long_output']
+
         query = self.db.create_update_query('servicechecks', service_check_data, where_clause)
 
         #Now servicestatus
@@ -536,6 +568,9 @@ class Ndodb_Mysql_broker(BaseModule):
                               'output' : data['output'], 'perfdata' : data['perf_data'], 'last_check' : de_unixify(data['last_chk']),
                               'percent_state_change' : data['percent_state_change'],
         }
+        # Centreon add some fields
+        if self.centreon_version:
+            servicestatus_data['long_output'] = data['long_output']
 
         servicestatus_query = self.db.create_update_query('servicestatus' , servicestatus_data, where_clause)
 
@@ -602,6 +637,10 @@ class Ndodb_Mysql_broker(BaseModule):
                            'has_been_checked' : 1, 'is_flapping' : data['is_flapping'], 'percent_state_change' : data['percent_state_change'], 
                            'flap_detection_enabled' : data['flap_detection_enabled'],
                            }
+        # Centreon add some fields
+        if self.centreon_version:
+            hoststatus_data['long_output'] = data['long_output']
+
         hoststatus_query = self.db.create_update_query('hoststatus' , hoststatus_data, where_clause)
 
         return [query, hoststatus_query]
@@ -655,6 +694,9 @@ class Ndodb_Mysql_broker(BaseModule):
                               'has_been_checked' : 1, 'is_flapping' : data['is_flapping'], 'percent_state_change' : data['percent_state_change'],
                               'flap_detection_enabled' : data['flap_detection_enabled'],
                               }
+        # Centreon add some fields
+        if self.centreon_version:
+            servicestatus_data['long_output'] = data['long_output']
 
         where_clause = {'service_object_id' : service_id}
         servicestatus_query = self.db.create_update_query('servicestatus' , servicestatus_data, where_clause)
diff --git a/shinken/webui/plugins/mobile/htdocs/js/mobile_impacts.js b/shinken/webui/plugins/mobile/htdocs/js/mobile_impacts.js
index 0044805..172c2b5 100644
--- a/shinken/webui/plugins/mobile/htdocs/js/mobile_impacts.js
+++ b/shinken/webui/plugins/mobile/htdocs/js/mobile_impacts.js
@@ -27,6 +27,7 @@ var offset = 100;
 var nb_impacts = 0;
 var current_idx = 0;
 
+
 function focus_on(idx){
     
 

-- 
UNNAMED PROJECT



More information about the Pkg-nagios-changes mailing list