Example #1
0
 def manage_program_status_brok(self, b):
     data = b.data
     c_id = data['instance_id']
     #print "Creating config:", c_id, data
     c = Config()
     for prop in data:
         setattr(c, prop, data[prop])
     #print "CFG:", c
     self.configs[c_id] = c
Example #2
0
    def __init__(self, config_files, is_daemon, do_replace, debug, debug_file):        
        super(Webui, self).__init__('webui', config_files[0], is_daemon, do_replace, debug, debug_file)
        
        self.config_files = config_files

        # Use to know if we must still be alive or not
        self.must_run = True
        
        self.conf = Config()

        self.plugins = []
Example #3
0
 def manage_program_status_brok(self, b):
     data = b.data
     c_id = data['instance_id']
     print "Creating config:", c_id, data
     c = Config()
     for prop in data:
         setattr(c, prop, data[prop])
     #print "CFG:", c
     self.configs[0] = c
     # And we save that we got data from this instance_id
     self.instance_ids.append(c_id)
Example #4
0
class Webui(Daemon):

    def __init__(self, config_files, is_daemon, do_replace, debug, debug_file):        
        super(Webui, self).__init__('webui', config_files[0], is_daemon, do_replace, debug, debug_file)
        
        self.config_files = config_files

        # Use to know if we must still be alive or not
        self.must_run = True
        
        self.conf = Config()

        self.plugins = []


    def load_config_file(self):
        print "Loading configuration"
        # REF: doc/shinken-conf-dispatching.png (1)
        buf = self.conf.read_config(self.config_files)
        raw_objects = self.conf.read_config_buf(buf)

        self.conf.create_objects_for_type(raw_objects, 'arbiter')
        self.conf.create_objects_for_type(raw_objects, 'module')
        
        self.conf.early_arbiter_linking()

        ### Resume standard operations ###
        self.conf.create_objects(raw_objects)
        
        # Maybe conf is already invalid
        if not self.conf.conf_is_correct:
            sys.exit("***> One or more problems was encountered while processing the config files...")

        # Change Nagios2 names to Nagios3 ones
        self.conf.old_properties_names_to_new()

        # Create Template links
        self.conf.linkify_templates()

        # All inheritances
        self.conf.apply_inheritance()

        # Explode between types
        self.conf.explode()

        # Create Name reversed list for searching list
        self.conf.create_reversed_list()

        # Cleaning Twins objects
        self.conf.remove_twins()

        # Implicit inheritance for services
        self.conf.apply_implicit_inheritance()

        # Fill default values
        self.conf.fill_default()
        
        # Remove templates from config
        self.conf.remove_templates()
        
        # Pythonize values
        self.conf.pythonize()

        # Linkify objects each others
        self.conf.linkify()

        # applying dependancies
        self.conf.apply_dependancies()

        # Hacking some global parameter inherited from Nagios to create
        # on the fly some Broker modules like for status.dat parameters
        # or nagios.log one if there are no already available
        self.conf.hack_old_nagios_parameters()

        # Exlode global conf parameters into Classes
        self.conf.explode_global_conf()

        # set ourown timezone and propagate it to other satellites
        self.conf.propagate_timezone_option()

        # Look for business rules, and create teh dep trees
        self.conf.create_business_rules()
        # And link them
        self.conf.create_business_rules_dependencies()
        
        # Correct conf?
        self.conf.is_correct()

        # The conf can be incorrect here if the cut into parts see errors like
        # a realm with hosts and not schedulers for it
        if not self.conf.conf_is_correct:
            self.conf.show_errors()
            sys.exit("Configuration is incorrect, sorry, I bail out")

        logger.log('Things look okay - No serious problems were detected during the pre-flight check')

        # Now clean objects of temporary/unecessary attributes for live work:
        self.conf.clean()

        # Ok, here we must check if we go on or not.
        # TODO : check OK or not
        self.pidfile = os.path.abspath(self.conf.webui_lock_file)
        self.idontcareaboutsecurity = self.conf.idontcareaboutsecurity
        self.user = self.conf.shinken_user
        self.group = self.conf.shinken_group
        
        self.workdir = os.path.abspath(os.path.dirname(self.pidfile))

        self.port = self.conf.webui_port
        self.host = self.conf.webui_host
        
        logger.log("Configuration Loaded")
        print ""


    # Main loop function
    def main(self):
        try:
            # Log will be broks
            for line in self.get_header():
                self.log.log(line)

            self.load_config_file()
            self.do_daemon_init_and_start(use_pyro=False)

            ## And go for the main loop
            self.do_mainloop()
        except SystemExit, exp:
            # With a 2.4 interpreter the sys.exit() in load_config_file
            # ends up here and must be handled.
            sys.exit(exp.code)
        except Exception, exp:
            logger.log("CRITICAL ERROR : I got an non recovarable error. I must exit")
            logger.log("You can log a bug ticket at https://sourceforge.net/apps/trac/shinken/newticket for geting help")
            logger.log("Back trace of it: %s" % (traceback.format_exc()))
            raise