Beispiel #1
0
    def manage_brok(self, b):
        # We need to do some brok mod, so we copy it
        new_b = copy.deepcopy(b)

        # If we synchronize, must look for id change
        if self.synchronize_database_id != 0 and 'instance_id' in new_b.data:
            # If we use database sync, we have to synchronize database id
            # so we wait for the instance name
            brok_id = new_b.data['instance_id']
            converted_instance_id = self.convert_id(brok_id)
            if converted_instance_id is not None:
                new_b.data['instance_id'] = converted_instance_id
                queries = BaseModule.manage_brok(self, new_b)
                if queries is not None:
                    for q in queries:
                        self.db.execute_query(q)

            if converted_instance_id is None:
                if brok_id in self.todo:
                    self.todo[brok_id].append(new_b)
                else:
                    self.todo[brok_id] = [new_b]

            if converted_instance_id is None and 'instance_name' in new_b.data:
                converted_brok_id = self.get_instance_id(new_b.data['instance_name'])
                self.database_id_cache[brok_id] = converted_brok_id
                # We have to put the good instance ID to all brok waiting
                # in the list then execute the query
                for brok in self.todo[brok_id]:
                    brok.data['instance_id'] = converted_brok_id
                    queries = BaseModule.manage_brok(self, brok)
                    if queries is not None:
                        for q in queries:
                            self.db.execute_query(q)
                # We've finished to manage the todo, so we empty it
                self.todo[brok_id] = []

            return

        # Executed if we don't synchronize or there is no instance_id
        queries = BaseModule.manage_brok(self, new_b)

        if queries is not None:
            for q in queries:
                self.db.execute_query(q)
            return
Beispiel #2
0
 def manage_brok(self, b):
     # We've got problem with instance_id == 0 so we add 1 every where
     if "instance_id" in b.data:
         b.data["instance_id"] = b.data["instance_id"] + 1
     # print "(Ndo) I search manager:", manager
     queries = BaseModule.manage_brok(self, b)
     if queries is not None:
         for q in queries:
             self.db.execute_query(q)
         return
 def manage_brok(self, b):
     #We've got problem with instance_id == 0 so we add 1 every where
     if 'instance_id' in b.data:
         b.data['instance_id'] = b.data['instance_id'] + 1
     #print "(Ndo) I search manager:", manager
     queries = BaseModule.manage_brok(self, b)
     if queries is not None:
         for q in queries:
             self.db.execute_query(q)
         return
    def manage_brok(self, b):
        # We need to do some brok mod, so we copy it
        new_b = copy.deepcopy(b)

        # If we synchronize, must look for id change
        if self.synchronize_database_id != '0' and 'instance_id' in new_b.data:
            # If we use database sync, we have to synchronize database id
            # so we wait for the instance name
            if 'instance_name' not in new_b.data:
                self.todo.append(new_b)
                return

            # We convert the id to write properly in the base using the
            # instance_name to reuse the instance_id in the base.
            else:
                new_b.data['instance_id'] = self.convert_id(
                    new_b.data['instance_id'], new_b.data['instance_name']
                    )

                self.todo.append(new_b)
                for brok in self.todo:
                    # We have to put the good instance ID to all brok waiting
                    # in the list then execute the query
                    brok.data['instance_id'] = new_b.data['instance_id']
                    queries = BaseModule.manage_brok(self, brok)
                    if queries is not None:
                        for q in queries:
                            self.db.execute_query(q)
                # We've finished to manage the todo, so we empty it
                self.todo = []
                return

        # Executed if we don't synchronize or there is no instance_id
        queries = BaseModule.manage_brok(self, new_b)

        if queries is not None:
            for q in queries:
                self.db.execute_query(q)
            return
Beispiel #5
0
    def manage_brok(self, b):
        # We need to do some brok mod, so we copy it
        new_b = copy.deepcopy(b)

        # If we synchronize, must look for id change
        if self.synchronize_database_id != '0' and 'instance_id' in new_b.data:
            # If we use database sync, we have to synchronize database id
            # so we wait for the instance name
            if 'instance_name' not in new_b.data:
                self.todo.append(new_b)
                return

            # We convert the id to write properly in the base using the
            # instance_name to reuse the instance_id in the base.
            else:
                new_b.data['instance_id'] = self.convert_id(
                    new_b.data['instance_id'], new_b.data['instance_name']
                    )

                self.todo.append(new_b)
                for brok in self.todo:
                    # We have to put the good instance ID to all brok waiting
                    # in the list then execute the query
                    brok.data['instance_id'] = new_b.data['instance_id']
                    queries = BaseModule.manage_brok(self, brok)
                    if queries is not None:
                        for q in queries:
                            self.db.execute_query(q)
                # We've finished to manage the todo, so we empty it
                self.todo = []
                return

        # Executed if we don't synchronize or there is no instance_id
        queries = BaseModule.manage_brok(self, new_b)

        if queries is not None:
            for q in queries:
                self.db.execute_query(q)
            return
Beispiel #6
0
    def manage_brok(self, b):
        # We need to do some brok mod, so we copy it
        new_b = copy.deepcopy(b)

        # We've got problem with instance_id == 0 so we add 1 every where
        if "instance_id" in new_b.data:
            # For nagios mix install, move more than 1
            if self.nagios_mix_offset != 0:
                new_b.data["instance_id"] = new_b.data["instance_id"] + self.nagios_mix_offset
            else:
                new_b.data["instance_id"] = new_b.data["instance_id"] + 1

        queries = BaseModule.manage_brok(self, new_b)
        if queries is not None:
            for q in queries:
                self.db.execute_query(q)
            return
Beispiel #7
0
 def manage_brok(self, b):
     if self.process_performance_data or b.type in ('program_status', 'update_program_status'):
         BaseModule.manage_brok(self, b)
Beispiel #8
0
 def manage_brok(self, b):
     # We will transform data of b, so copy it
     return BaseModule.manage_brok(self, copy.deepcopy(b))
Beispiel #9
0
 def manage_brok(self, b):
     logger.info("[mongodb_broker] %s" % self.pp.pformat(b.type))
     return BaseModule.manage_brok(self, b)
Beispiel #10
0
 def manage_brok(self, b):
     # We will transform data of b, so copy it
     return BaseModule.manage_brok(self, copy.deepcopy(b))
Beispiel #11
0
 def manage_brok(self, b):
     if self.process_performance_data or b.type in (
             'program_status', 'update_program_status'):
         BaseModule.manage_brok(self, b)
Beispiel #12
0
 def manage_brok(self, b):
     if b.type in ('initial_host_status', 'initial_service_status', 'service_check_result', 'host_check_result'):
         BaseModule.manage_brok(self, b)
Beispiel #13
0
 def manage_brok(self, b):
     if b.type in ('initial_host_status', 'initial_service_status', 'service_check_result', 'host_check_result'):
         BaseModule.manage_brok(self, b)