def _detect(self): # check process and port process_found = utils.find_process_cmdline('kibana') is not None has_deps = self.dependencies_installed() has_args = self.args is not None cfg_file = self._get_config_file() if has_args else _KIBANA_CFG_FILE has_config_file = os.path.isfile(cfg_file) available = process_found and has_deps and has_config_file self.available = available if not self.available: err_str = 'Plugin for Kibana will not be configured.' if not process_found: LOG.error('Kibana process has not been found. %s' % err_str) elif not has_deps: LOG.error('Kibana plugin dependencies are not satisfied. ' 'Module "pyaml" not found. %s' % err_str) elif not has_config_file: LOG.error( 'Kibana plugin cannot find configuration file %s. %s' % (cfg_file, err_str))
def _detect(self): """Run detection, set self.available True if the service is detected. """ try: has_process = (utils.find_process_cmdline(_POSTFIX_PROC_NAME) is not None) agent_user = utils.get_agent_username() if has_process else None has_user = agent_user is not None has_sudoers = (self._has_sudoers(agent_user) if agent_user else False) except Exception: self.available = False detailed_msg = ('Unexpected exception while ' 'running postfix detection.') log.exception('%s\n%s' % (detailed_msg, self.ERROR_MSG)) else: self.available = has_process and has_sudoers if not self.available: if not has_process: detailed_msg = ('%s process was not found.' % _POSTFIX_PROC_NAME) log.info('%s\n%s' % (detailed_msg, self.ERROR_MSG)) elif not has_user: detailed_msg = 'Did not locate agent\'s username.' log.error('%s\n%s' % (detailed_msg, self.ERROR_MSG)) elif not has_sudoers: detailed_msg = ('%s cannot access %s directory. ' '\n Refer to postfix plugin documentation ' 'for more details.' % (agent_user, _POSTFIX_DIRECTORY)) log.error('%s\n%s' % (detailed_msg, self.ERROR_MSG))
def _detect(self): """Run detection, set self.available True if the service is detected. """ try: has_process = (utils.find_process_cmdline(_POSTFIX_PROC_NAME) is not None) agent_user = utils.get_agent_username() if has_process else None has_user = agent_user is not None has_sudoers = (self._has_sudoers(agent_user) if agent_user else False) except Exception: self.available = False detailed_msg = ('Unexpected exception while ' 'running postfix detection.') log.exception('%s\n%s' % (detailed_msg, self.ERROR_MSG)) else: self.available = has_process and has_sudoers if not self.available: if not has_process: detailed_msg = ('%s process was not found.' % _POSTFIX_PROC_NAME) log.info('%s\n%s' % (detailed_msg, self.ERROR_MSG)) elif not has_user: detailed_msg = 'Did not locate agent\'s username.' log.error('%s\n%s' % (detailed_msg, self.ERROR_MSG)) elif not has_sudoers: detailed_msg = ('%s cannot access %s directory. ' '\n Refer to postfix plugin documentation ' 'for more details.' % (agent_user, _POSTFIX_DIRECTORY)) log.warning('%s\n%s' % (detailed_msg, self.ERROR_MSG))
def _detect(self): # check process and port process_found = utils.find_process_cmdline('kibana') is not None has_deps = self.dependencies_installed() has_args = self.args is not None cfg_file = self._get_config_file() if has_args else _KIBANA_CFG_FILE has_config_file = os.path.isfile(cfg_file) available = process_found and has_deps and has_config_file self.available = available if not self.available: err_str = 'Plugin for Kibana will not be configured.' if not process_found: LOG.info('Kibana process has not been found. %s' % err_str) elif not has_deps: LOG.error('Kibana plugin dependencies are not satisfied. ' 'Module "pyaml" not found. %s' % err_str) elif not has_config_file: LOG.warning('Kibana plugin cannot find configuration file %s. %s' % (cfg_file, err_str))
def _detect(self): """Run detection. """ self.found_processes = [] for process in self.process_names: if find_process_cmdline(process) is not None: self.found_processes.append(process) if len(self.found_processes) > 0: self.available = True
def _detect(self): """Run detection. """ self.found_processes = [] if self.process_names: for process in self.process_names: if find_process_cmdline(process) is not None: self.found_processes.append(process) if len(self.found_processes) > 0: self.available = True if self.process_username and self.component_name: self.available = True if self.file_dirs_names: self.available = True if self.directory_names: self.available = True
def _detect(self): """Run detection, set self.available True if the service is detected. """ self._get_config() for process_item in self.process_config: if 'dimensions' not in process_item: process_item['dimensions'] = {} if 'process_names' in process_item: found_process_names = [] not_found_process_names = [] for process_name in process_item['process_names']: if find_process_cmdline(process_name) is not None: found_process_names.append(process_name) else: not_found_process_names.append(process_name) # monitoring by process_names if not_found_process_names: log.info("\tDid not discover process_name(s): {0}.".format( ",".join(not_found_process_names))) if found_process_names: process_item['found_process_names'] = found_process_names if 'exact_match' in process_item: if isinstance(process_item['exact_match'], basestring): process_item['exact_match'] = ( process_item['exact_match'].lower() == 'true') else: process_item['exact_match'] = False self.valid_process_names.append(process_item) if 'process_username' in process_item: if 'component' in process_item['dimensions']: self.valid_usernames.append(process_item) else: log.error( "\tMissing required component dimension, when monitoring by " "process_username: {}".format( process_item['process_username'])) if self.valid_process_names or self.valid_usernames: self.available = True
def _detect(self): """Run detection, set self.available True if the service is detected. """ self._get_config() for process_item in self.process_config: if 'dimensions' not in process_item: process_item['dimensions'] = {} if 'process_names' in process_item: found_process_names = [] not_found_process_names = [] for process_name in process_item['process_names']: if find_process_cmdline(process_name) is not None: found_process_names.append(process_name) else: not_found_process_names.append(process_name) # monitoring by process_names if not_found_process_names: log.info( "\tDid not discover process_name(s): {0}.".format( ",".join(not_found_process_names))) if found_process_names: process_item['found_process_names'] = found_process_names if 'exact_match' in process_item: if isinstance(process_item['exact_match'], six.string_types): process_item['exact_match'] = ( process_item['exact_match'].lower() == 'true') else: process_item['exact_match'] = False self.valid_process_names.append(process_item) if 'process_username' in process_item: if 'component' in process_item['dimensions']: self.valid_usernames.append(process_item) else: log.error("\tMissing required component dimension, when monitoring by " "process_username: {}".format(process_item['process_username'])) if self.valid_process_names or self.valid_usernames: self.available = True
def _detect(self): process_exist = utils.find_process_cmdline(Ovs.PROC_NAME) has_dependencies = self.dependencies_installed() neutron_conf = self._get_ovs_config_file() if process_exist else '' neutron_conf_exists = os.path.isfile(neutron_conf) neutron_conf_valid = (neutron_conf_exists and self._is_neutron_conf_valid(neutron_conf)) self.available = (process_exist is not None and neutron_conf_valid and has_dependencies) if not self.available: if not process_exist: log.error('OVS daemon process [%s] does not exist.', Ovs.PROC_NAME) elif not neutron_conf_exists: log.error(('OVS daemon process exists but configuration ' 'file was not found. Path to file does not exist ' 'as a process parameter or was not ' 'passed via args.')) elif not neutron_conf_valid: log.error(('OVS daemon process exists, configuration file was ' 'found but it looks like it does not contain ' 'one of following sections=%s. ' 'Check if neutron was not configured to load ' 'configuration from /etc/neutron/neutron.conf.d/.'), Ovs.REQUIRED_CONF_SECTIONS) # NOTE(trebskit) the problem with that approach is that # each setting that Ovs plugin require might be scattered # through multiple files located inside # /etc/neutron/neutron.conf.d/ # not to mention that it is still possible to have # yet another configuration file passed as neutron CLI # argument elif not has_dependencies: log.error(('OVS daemon process exists but required ' 'dependence python-neutronclient is ' 'not installed.')) else: log.info("\tUsing neutron configuration file {0}".format( neutron_conf)) self.neutron_conf = neutron_conf
def _detect(self): """Run detection, set self.available True if the service is detected. """ self._get_config() for process_item in self.process_config: if "dimensions" not in process_item: process_item["dimensions"] = {} if "process_names" in process_item: found_process_names = [] not_found_process_names = [] for process_name in process_item["process_names"]: if find_process_cmdline(process_name) is not None: found_process_names.append(process_name) else: not_found_process_names.append(process_name) # monitoring by process_names if not_found_process_names: log.info("\tDid not discover process_name(s): {0}.".format(",".join(not_found_process_names))) if found_process_names: process_item["found_process_names"] = found_process_names if "exact_match" in process_item: if isinstance(process_item["exact_match"], basestring): process_item["exact_match"] = process_item["exact_match"].lower() == "true" else: process_item["exact_match"] = False self.valid_process_names.append(process_item) if "process_username" in process_item: if "component" in process_item["dimensions"]: self.valid_usernames.append(process_item) else: log.error( "\tMissing required component dimension, when monitoring by " "process_username: {}".format(process_item["process_username"]) ) if self.valid_process_names or self.valid_usernames: self.available = True
def _detect(self): process_exist = utils.find_process_cmdline(Ovs.PROC_NAME) has_dependencies = self.dependencies_installed() neutron_conf = self._get_ovs_config_file() if process_exist else '' neutron_conf_exists = os.path.isfile(neutron_conf) neutron_conf_valid = (neutron_conf_exists and self._is_neutron_conf_valid(neutron_conf)) self.available = (process_exist is not None and neutron_conf_valid and has_dependencies) self.cmd = '' if process_exist: self.cmd = process_exist.as_dict(attrs=['cmdline'])['cmdline'] if not self.available: if not process_exist: log.error('OVS daemon process [%s] does not exist.', Ovs.PROC_NAME) elif not neutron_conf_exists: log.error(('OVS daemon process exists but configuration ' 'file was not found. Path to file does not exist ' 'as a process parameter or was not ' 'passed via args.')) elif not neutron_conf_valid: log.error(('OVS daemon process exists, configuration file was ' 'found but it looks like it does not contain ' 'one of following sections=%s. ' 'Check if neutron was not configured to load ' 'configuration from /etc/neutron/neutron.conf.d/.'), Ovs.REQUIRED_CONF_SECTIONS) # NOTE(trebskit) the problem with that approach is that # each setting that Ovs plugin require might be scattered # through multiple files located inside # /etc/neutron/neutron.conf.d/ # not to mention that it is still possible to have # yet another configuration file passed as neutron CLI # argument elif not has_dependencies: log.error(('OVS daemon process exists but required ' 'dependencies were not found.\n' 'Run pip install monasca-agent[ovs] ' 'to install all dependencies.')) else: for_opts = [{ 'opt': cfg.StrOpt('region', default='RegionOne'), 'group': 'service_auth' }, { 'opt': cfg.StrOpt('region_name'), 'group': 'nova' }, { 'opt': cfg.StrOpt('nova_region_name'), 'group': 'DEFAULT' }, { 'opt': cfg.StrOpt('username'), 'group': 'keystone_authtoken' }, { 'opt': cfg.StrOpt('password'), 'group': 'keystone_authtoken' }, { 'opt': cfg.StrOpt('project_name'), 'group': 'keystone_authtoken' }, { 'opt': cfg.StrOpt('auth_url'), 'group': 'keystone_authtoken' }, { 'opt': cfg.StrOpt('identity_uri'), 'group': 'keystone_authtoken' }] self.conf = utils.load_oslo_configuration(from_cmd=self.cmd, in_project='neutron', for_opts=for_opts) log.info( "\tUsing neutron configuration file {0} for detection".format( neutron_conf)) self.neutron_conf = neutron_conf
def _detect(self): process_exist = utils.find_process_cmdline(Ovs.PROC_NAME) has_dependencies = self.dependencies_installed() neutron_conf = self._get_ovs_config_file() if process_exist else '' neutron_conf_exists = os.path.isfile(neutron_conf) neutron_conf_valid = (neutron_conf_exists and self._is_neutron_conf_valid(neutron_conf)) self.available = (process_exist is not None and neutron_conf_valid and has_dependencies) self.cmd = '' if process_exist: self.cmd = process_exist.as_dict(attrs=['cmdline'])['cmdline'] if not self.available: if not process_exist: log.info('OVS daemon process [%s] does not exist.', Ovs.PROC_NAME) elif not neutron_conf_exists: log.warning(('OVS daemon process exists but configuration ' 'file was not found. Path to file does not exist ' 'as a process parameter or was not ' 'passed via args.')) elif not neutron_conf_valid: log.error(('OVS daemon process exists, configuration file was ' 'found but it looks like it does not contain ' 'one of following sections=%s. ' 'Check if neutron was not configured to load ' 'configuration from /etc/neutron/neutron.conf.d/.'), Ovs.REQUIRED_CONF_SECTIONS) # NOTE(trebskit) the problem with that approach is that # each setting that Ovs plugin require might be scattered # through multiple files located inside # /etc/neutron/neutron.conf.d/ # not to mention that it is still possible to have # yet another configuration file passed as neutron CLI # argument elif not has_dependencies: log.error(('OVS daemon process exists but required ' 'dependencies were not found.\n' 'Run pip install monasca-agent[ovs] ' 'to install all dependencies.')) else: for_opts = [{'opt': cfg.StrOpt('region', default='RegionOne'), 'group': 'service_auth'}, {'opt': cfg.StrOpt('region_name'), 'group': 'nova'}, {'opt': cfg.StrOpt('nova_region_name'), 'group': 'DEFAULT'}, {'opt': cfg.StrOpt('username'), 'group': 'keystone_authtoken'}, {'opt': cfg.StrOpt('password'), 'group': 'keystone_authtoken'}, {'opt': cfg.StrOpt('project_name'), 'group': 'keystone_authtoken'}, {'opt': cfg.StrOpt('user_domain_name'), 'group': 'keystone_authtoken'}, {'opt': cfg.StrOpt('user_domain_id'), 'group': 'keystone_authtoken'}, {'opt': cfg.StrOpt('project_domain_name'), 'group': 'keystone_authtoken'}, {'opt': cfg.StrOpt('project_domain_id'), 'group': 'keystone_authtoken'}, {'opt': cfg.StrOpt('auth_url'), 'group': 'keystone_authtoken'}, {'opt': cfg.StrOpt('identity_uri'), 'group': 'keystone_authtoken'}] self.conf = utils.load_oslo_configuration(from_cmd=self.cmd, in_project='neutron', for_opts=for_opts ) log.info("\tUsing neutron configuration file {0} for detection".format(neutron_conf)) self.neutron_conf = neutron_conf