Example #1
0
 def build_config(self):
     """Build the config as a Plugins object and return."""
     log.info("\tEnabling the Monasca Notification healthcheck")
     notification_process = find_process_cmdline('monasca-notification')
     notification_user = notification_process.as_dict(['username'])['username']
     return watch_process_by_username(notification_user, 'monasca-notification',
                                      'monitoring', 'monasca-notification')
Example #2
0
 def build_config(self):
     """Build the config as a Plugins object and return."""
     log.info("\tEnabling the Monasca Notification healthcheck")
     notification_process = find_process_cmdline('monasca-notification')
     notification_user = notification_process.as_dict(['username'])['username']
     return watch_process_by_username(notification_user, 'monasca-notification',
                                      'monitoring', 'monasca-notification')
Example #3
0
    def build_config(self):
        """Build the config as a Plugins object and return.

        """
        config = monasca_setup.agent_config.Plugins()
        try:
            self._get_config()
            config.merge(watch_process_by_username('dbadmin', 'vertica', self.service, 'vertica'))
            log.info("\tWatching the vertica processes.")
            if self._connection_test():
                log.info("\tBuilding vertica config.")
                instance_config = {'name': 'localhost',
                                   'user': self.user,
                                   'password': self.password,
                                   'service': self.service,
                                   'node_name': self.node_name,
                                   'timeout': self.timeout}
                config['vertica'] = {'init_config': None, 'instances': [instance_config]}
            else:
                exception_msg = 'Unable to connect to the Vertica DB. ' \
                                'The Vertica plugin is not configured. ' \
                                'Please correct and re-run monasca-setup.'
                log.error(exception_msg)
                raise Exception(exception_msg)
        except Exception as e:
            exception_msg = 'Error configuring the Vertica check plugin - {0}'.format(e)
            log.error(exception_msg)
            raise Exception(exception_msg)

        return config
Example #4
0
 def build_config(self):
     """Build the config as a Plugins object and return."""
     log.info("\tWatching the mon-thresh process.")
     config = monasca_setup.agent_config.Plugins()
     for process in ['storm.daemon.nimbus', 'storm.daemon.supervisor', 'storm.daemon.worker']:
         if find_process_cmdline(process) is not None:
             config.merge(watch_process([process], 'monitoring', 'apache-storm', exact_match=False, detailed=False))
     config.merge(watch_process_by_username('storm', 'monasca-thresh', 'monitoring', 'apache-storm'))
     return config
Example #5
0
 def build_config(self):
     """Build the config as a Plugins object and return."""
     log.info("\tWatching the mon-thresh process.")
     config = monasca_setup.agent_config.Plugins()
     for process in ['storm.daemon.nimbus', 'storm.daemon.supervisor', 'storm.daemon.worker']:
         if find_process_cmdline(process) is not None:
             config.merge(watch_process([process], 'monitoring', 'apache-storm', exact_match=False, detailed=False))
     config.merge(watch_process_by_username('storm', 'monasca-thresh', 'monitoring', 'apache-storm'))
     return config
Example #6
0
    def build_config(self):
        """Build the config as a Plugins object and return.

        """
        config = agent_config.Plugins()
        if self.found_processes:
            log.info("\tMonitoring by process_name(s): {0} "
                     "for service: {1}.".format(",".join(self.found_processes),
                                                self.service_name))
            for process in self.found_processes:
                # Watch the service processes
                component_name = self.component_name if self.component_name else process
                config.merge(
                    watch_process(search_strings=[process],
                                  service=self.service_name,
                                  component=component_name,
                                  exact_match=False))

        if self.process_username:
            log.info("\tMonitoring by process_username: {0} for "
                     "service: {1}.".format(self.process_username,
                                            self.service_name))
            config.merge(
                watch_process_by_username(username=self.process_username,
                                          process_name=self.component_name,
                                          service=self.service_name,
                                          component=self.component_name))
        if self.file_dirs_names:
            for file_dir_name in self.file_dirs_names:
                # Watch file size
                file_dir = file_dir_name[0]
                file_names = file_dir_name[1]
                if len(file_dir_name) == 3:
                    file_recursive = file_dir_name[2]
                else:
                    file_recursive = False
                if file_names == ['*']:
                    log.info("\tMonitoring the size of all the files in the "
                             "directory {0}.".format(file_dir))
                else:
                    log.info("\tMonitoring the size of files {0} in the "
                             "directory {1}.".format(
                                 ", ".join(str(name) for name in file_names),
                                 file_dir))
                config.merge(
                    watch_file_size(directory_name=file_dir,
                                    file_names=file_names,
                                    file_recursive=file_recursive,
                                    service=self.service_name,
                                    component=self.component_name))

        if self.directory_names:
            for dir_name in self.directory_names:
                log.info(
                    "\tMonitoring the size of directory {0}.".format(dir_name))
                config.merge(
                    watch_directory(directory_name=dir_name,
                                    service=self.service_name,
                                    component=self.component_name))

        # Skip the http_check if disable_http_check is set
        if self.args is not None and self.args.get('disable_http_check',
                                                   False):
            self.service_api_url = None
            self.search_pattern = None

        if self.service_api_url and self.search_pattern:
            # Check if there is something listening on the host/port
            parsed = urllib.parse.urlparse(self.service_api_url)
            host, port = parsed.netloc.split(':')
            listening = find_addrs_listening_on_port(port)

            if len(listening) > 0:
                # If not listening on localhost or ips then use another local ip
                if host == 'localhost' and len(
                        set(['127.0.0.1', '0.0.0.0', '::', '::1'])
                        & set(listening)) == 0:
                    new_url = list(parsed)
                    new_url[1] = listening[0] + ':' + port
                    api_url = urllib.parse.urlunparse(new_url)
                else:
                    api_url = self.service_api_url

                # Setup an active http_status check on the API
                log.info("\tConfiguring an http_check for the {0} API.".format(
                    self.service_name))
                config.merge(
                    service_api_check(name=self.service_name + '-api',
                                      url=api_url,
                                      pattern=self.search_pattern,
                                      use_keystone=True,
                                      service=self.service_name,
                                      component=self.component_name))
            else:
                log.info("\tNo process found listening on {0} ".format(port) +
                         "skipping setup of http_check for the {0} API.".
                         format(self.service_name))

        return config
Example #7
0
 def build_config(self):
     """Build the config as a Plugins object and return."""
     log.info("\tEnabling the Monasca Agent process check")
     return watch_process_by_username('mon-agent', 'monasca-agent',
                                      'monitoring', 'monasca-agent')
Example #8
0
 def build_config(self):
     """Build the config as a Plugins object and return."""
     log.info("\tEnabling the Monasca Notification healthcheck")
     return watch_process_by_username('mon-notification',
                                      'monasca-notification', 'monitoring',
                                      'monasca-notification')
Example #9
0
    def build_config(self):
        """Build the config as a Plugins object and return.

        """
        config = agent_config.Plugins()
        if self.found_processes:
            log.info("\tMonitoring by process_name(s): {0} "
                     "for service: {1}.".format(",".join(self.found_processes), self.service_name))
            for process in self.found_processes:
                # Watch the service processes
                component_name = self.component_name if self.component_name else process
                config.merge(watch_process(search_strings=[process], service=self.service_name,
                                           component=component_name, exact_match=False))

        if self.process_username:
            log.info("\tMonitoring by process_username: {0} for "
                     "service: {1}.".format(self.process_username, self.service_name))
            config.merge(watch_process_by_username(username=self.process_username,
                                                   process_name=self.component_name,
                                                   service=self.service_name,
                                                   component=self.component_name))
        if self.file_dirs_names:
            for file_dir_name in self.file_dirs_names:
                # Watch file size
                file_dir = file_dir_name[0]
                file_names = file_dir_name[1]
                if len(file_dir_name) == 3:
                    file_recursive = file_dir_name[2]
                else:
                    file_recursive = False
                if file_names == ['*']:
                    log.info("\tMonitoring the size of all the files in the "
                             "directory {0}.".format(file_dir))
                else:
                    log.info("\tMonitoring the size of files {0} in the "
                             "directory {1}.".format(", ".join(str(name) for name in file_names), file_dir))
                config.merge(watch_file_size(directory_name=file_dir, file_names=file_names,
                                             file_recursive=file_recursive, service=self.service_name,
                                             component=self.component_name))

        if self.directory_names:
            for dir_name in self.directory_names:
                log.info("\tMonitoring the size of directory {0}.".format(
                    dir_name))
                config.merge(watch_directory(directory_name=dir_name, service=self.service_name, component=self.component_name))

        # Skip the http_check if disable_http_check is set
        if self.args is not None and self.args.get('disable_http_check', False):
            self.service_api_url = None
            self.search_pattern = None

        if self.service_api_url and self.search_pattern:
            # Check if there is something listening on the host/port
            parsed = urlparse.urlparse(self.service_api_url)
            host, port = parsed.netloc.split(':')
            listening = find_addrs_listening_on_port(port)

            if len(listening) > 0:
                # If not listening on localhost or ips then use another local ip
                if host == 'localhost' and len(set(['127.0.0.1', '0.0.0.0', '::', '::1']) & set(listening)) == 0:
                    new_url = list(parsed)
                    new_url[1] = listening[0] + ':' + port
                    api_url = urlparse.urlunparse(new_url)
                else:
                    api_url = self.service_api_url

                # Setup an active http_status check on the API
                log.info("\tConfiguring an http_check for the {0} API.".format(self.service_name))
                config.merge(service_api_check(name=self.service_name + '-api',
                                               url=api_url,
                                               pattern=self.search_pattern,
                                               use_keystone=True,
                                               service=self.service_name,
                                               component=self.component_name))
            else:
                log.info("\tNo process found listening on {0} ".format(port) +
                         "skipping setup of http_check for the {0} API." .format(self.service_name))

        return config
Example #10
0
 def build_config(self):
     """Build the config as a Plugins object and return."""
     log.info("\tEnabling the Monasca Agent process check")
     return watch_process_by_username(get_agent_username(), 'monasca-agent',
                                      'monitoring', 'monasca-agent')
Example #11
0
 def build_config(self):
     """Build the config as a Plugins object and return."""
     log.info("\tEnabling the Monasca Notification healthcheck")
     return watch_process_by_username('mon-notification', 'monasca-notification', 'monitoring',
                                      'monasca-notification')