Merge "Update log level classification info"

This commit is contained in:
Zuul 2019-02-15 10:06:32 +00:00 committed by Gerrit Code Review
commit 73e0072802
12 changed files with 80 additions and 82 deletions

View File

@ -35,7 +35,6 @@ CONFIG_ARG_KEYS = set(["url", "user", "password", "use_server_status_metrics"])
class Apache(monasca_setup.detection.Plugin): class Apache(monasca_setup.detection.Plugin):
"""Detect Apache web server daemons and setup configuration to monitor apache. """Detect Apache web server daemons and setup configuration to monitor apache.
This plugin will by default setup process check metrics for the apache process, This plugin will by default setup process check metrics for the apache process,
@ -70,11 +69,11 @@ class Apache(monasca_setup.detection.Plugin):
self.available = process_exists and has_args_or_config_file self.available = process_exists and has_args_or_config_file
if not self.available: if not self.available:
if not process_exists: if not process_exists:
log.error('Apache process does not exist.') log.info('Apache process does not exist.')
elif not has_args_or_config_file: elif not has_args_or_config_file:
log.error(('Apache process exists but ' log.warning(('Apache process exists but '
'configuration file was not found and ' 'configuration file was not found and '
'no arguments were given.')) 'no arguments were given.'))
def _read_apache_config(self, config_location): def _read_apache_config(self, config_location):
# Read the apache config file to extract the needed variables. # Read the apache config file to extract the needed variables.

View File

@ -67,9 +67,9 @@ class InfluxDBRelay(detection.Plugin):
elif not dependencies_installed: elif not dependencies_installed:
err_chunks.append('\tinfluxdb-relay plugin requires "toml" ' err_chunks.append('\tinfluxdb-relay plugin requires "toml" '
'to be installed') 'to be installed')
LOG.error('Plugin for influxdb-relay will not be configured.\n' LOG.warning('Plugin for influxdb-relay will not be configured.\n'
'Following issue have to be resolved: %s' % 'Following issue have to be resolved: %s' %
'\n'.join(err_chunks)) '\n'.join(err_chunks))
else: else:
self._config = self._load_config(config_file) self._config = self._load_config(config_file)

View File

@ -70,14 +70,14 @@ class Kibana(detection.Plugin):
if not self.available: if not self.available:
err_str = 'Plugin for Kibana will not be configured.' err_str = 'Plugin for Kibana will not be configured.'
if not process_found: if not process_found:
LOG.error('Kibana process has not been found. %s' % err_str) LOG.info('Kibana process has not been found. %s' % err_str)
elif not has_deps: elif not has_deps:
LOG.error('Kibana plugin dependencies are not satisfied. ' LOG.error('Kibana plugin dependencies are not satisfied. '
'Module "pyaml" not found. %s' 'Module "pyaml" not found. %s'
% err_str) % err_str)
elif not has_config_file: elif not has_config_file:
LOG.error('Kibana plugin cannot find configuration file %s. %s' LOG.warning('Kibana plugin cannot find configuration file %s. %s'
% (cfg_file, err_str)) % (cfg_file, err_str))
def build_config(self): def build_config(self):
kibana_config = self._get_config_file() kibana_config = self._get_config_file()

View File

@ -71,6 +71,7 @@ def _get_impl_lang(process):
class MonAgent(monasca_setup.detection.Plugin): class MonAgent(monasca_setup.detection.Plugin):
"""Detect the Monsaca agent engine and setup some simple checks.""" """Detect the Monsaca agent engine and setup some simple checks."""
def _detect(self): def _detect(self):
"""Run detection, set self.available True if the service is detected.""" """Run detection, set self.available True if the service is detected."""
self.available = True self.available = True
@ -158,8 +159,8 @@ class MonAPI(monasca_setup.detection.Plugin):
self.available = port_taken self.available = port_taken
self._impl_helper = impl_helper self._impl_helper = impl_helper
else: else:
log.error('monasca-api process has not been found. %s' log.warning('monasca-api process has not been found. %s'
% self.PARTIAL_ERR_MSG) % self.PARTIAL_ERR_MSG)
def build_config(self): def build_config(self):
"""Build the config as a Plugins object and return.""" """Build the config as a Plugins object and return."""
@ -198,6 +199,7 @@ class MonAPI(monasca_setup.detection.Plugin):
class MonNotification(monasca_setup.detection.Plugin): class MonNotification(monasca_setup.detection.Plugin):
"""Detect the Monsaca notification engine and setup some simple checks.""" """Detect the Monsaca notification engine and setup some simple checks."""
def _detect(self): def _detect(self):
"""Run detection, set self.available True if the service is detected.""" """Run detection, set self.available True if the service is detected."""
if find_process_cmdline('monasca-notification') is not None: if find_process_cmdline('monasca-notification') is not None:
@ -246,8 +248,8 @@ class MonPersister(monasca_setup.detection.Plugin):
log.info('\tmonasca-persister implementation is %s', impl_lang) log.info('\tmonasca-persister implementation is %s', impl_lang)
else: else:
log.error('monasca-persister process has not been found. %s' log.info('monasca-persister process has not been found. %s'
% self.PARTIAL_ERR_MSG) % self.PARTIAL_ERR_MSG)
def build_config(self): def build_config(self):
"""Build the config as a Plugins object and return.""" """Build the config as a Plugins object and return."""
@ -292,6 +294,7 @@ class MonPersister(monasca_setup.detection.Plugin):
class MonThresh(monasca_setup.detection.Plugin): class MonThresh(monasca_setup.detection.Plugin):
"""Detect the running mon-thresh and monitor.""" """Detect the running mon-thresh and monitor."""
def _detect(self): def _detect(self):
"""Run detection, set self.available True if the service is detected.""" """Run detection, set self.available True if the service is detected."""
# The node will be running either nimbus or supervisor or both # The node will be running either nimbus or supervisor or both
@ -511,30 +514,30 @@ class _MonPersisterJavaHelper(_DropwizardJavaHelper):
"path": "meters/monasca.persister.repository.vertica.VerticaMetricRepo." "path": "meters/monasca.persister.repository.vertica.VerticaMetricRepo."
"definition-cache-miss-meter/count", "definition-cache-miss-meter/count",
"type": "rate"}, "type": "rate"},
{"name": "monasca.persister.repository.vertica.VerticaMetricRepo." {"name": "monasca.persister.repository.vertica.VerticaMetricRepo."
"definition-dimension-cache-hit-meter", "definition-dimension-cache-hit-meter",
"path": "meters/monasca.persister.repository.vertica.VerticaMetricRepo." "path": "meters/monasca.persister.repository.vertica.VerticaMetricRepo."
"definition-dimension-cache-hit-meter/count", "definition-dimension-cache-hit-meter/count",
"type": "rate"}, "type": "rate"},
{"name": "monasca.persister.repository.vertica.VerticaMetricRepo." {"name": "monasca.persister.repository.vertica.VerticaMetricRepo."
"definition-dimension-cache-miss-meter", "definition-dimension-cache-miss-meter",
"path": "meters/monasca.persister.repository.vertica.VerticaMetricRepo." "path": "meters/monasca.persister.repository.vertica.VerticaMetricRepo."
"definition-dimension-cache-miss-meter/count", "definition-dimension-cache-miss-meter/count",
"type": "rate"}, "type": "rate"},
{"name": "monasca.persister.repository.vertica.VerticaMetricRepo." {"name": "monasca.persister.repository.vertica.VerticaMetricRepo."
"dimension-cache-hit-meter", "dimension-cache-hit-meter",
"path": "meters/monasca.persister.repository.vertica.VerticaMetricRepo." "path": "meters/monasca.persister.repository.vertica.VerticaMetricRepo."
"dimension-cache-hit-meter/count", "dimension-cache-hit-meter/count",
"type": "rate"}, "type": "rate"},
{"name": "monasca.persister.repository.vertica.VerticaMetricRepo." {"name": "monasca.persister.repository.vertica.VerticaMetricRepo."
"dimension-cache-miss-meter", "dimension-cache-miss-meter",
"path": "meters/monasca.persister.repository.vertica.VerticaMetricRepo." "path": "meters/monasca.persister.repository.vertica.VerticaMetricRepo."
"dimension-cache-miss-meter/count", "dimension-cache-miss-meter/count",
"type": "rate"}, "type": "rate"},
{"name": "monasca.persister.repository.vertica.VerticaMetricRepo.measurement-meter", {"name": "monasca.persister.repository.vertica.VerticaMetricRepo.measurement-meter",
"path": "meters/monasca.persister.repository.vertica.VerticaMetricRepo." "path": "meters/monasca.persister.repository.vertica.VerticaMetricRepo."
"measurement-meter/count", "measurement-meter/count",
"type": "rate"}]) "type": "rate"}])
def _monitor_endpoints(self, config, metrics): def _monitor_endpoints(self, config, metrics):
admin_connector = self._cfg['server']['adminConnectors'][0] admin_connector = self._cfg['server']['adminConnectors'][0]

View File

@ -28,7 +28,6 @@ SOCKET = '/var/run/mysqld/mysqld.sock'
class MySQL(monasca_setup.detection.Plugin): class MySQL(monasca_setup.detection.Plugin):
"""Detect MySQL daemons and setup configuration to monitor them. """Detect MySQL daemons and setup configuration to monitor them.
This plugin needs user/password info for mysql setup. This plugin needs user/password info for mysql setup.
@ -58,11 +57,11 @@ class MySQL(monasca_setup.detection.Plugin):
has_dependencies) has_dependencies)
if not self.available: if not self.available:
if not process_exist: if not process_exist:
log.error('MySQL process does not exist.') log.info('MySQL process does not exist.')
elif not has_args_or_config_file: elif not has_args_or_config_file:
log.error(('MySQL process exists but ' log.warning(('MySQL process exists but '
'configuration file was not found and ' 'configuration file was not found and '
'no arguments were given.')) 'no arguments were given.'))
elif not has_dependencies: elif not has_dependencies:
log.error(('MySQL process exists but required dependence ' log.error(('MySQL process exists but required dependence '
'PyMySQL is not installed.')) 'PyMySQL is not installed.'))
@ -138,10 +137,10 @@ class MySQL(monasca_setup.detection.Plugin):
log.info("\tConnection test success.") log.info("\tConnection test success.")
config['mysql'] = { config['mysql'] = {
'init_config': None, 'instances': 'init_config': None, 'instances':
[{'name': self.host, 'server': self.host, 'port': self.port, [{'name': self.host, 'server': self.host, 'port': self.port,
'user': self.user, 'pass': self.password, 'user': self.user, 'pass': self.password,
'sock': self.socket, 'ssl_ca': self.ssl_ca, 'sock': self.socket, 'ssl_ca': self.ssl_ca,
'ssl_key': self.ssl_key, 'ssl_cert': self.ssl_cert}]} 'ssl_key': self.ssl_key, 'ssl_cert': self.ssl_cert}]}
except ImportError as e: except ImportError as e:
exception_msg = ('The mysql dependency PyMySQL is not ' exception_msg = ('The mysql dependency PyMySQL is not '
'installed. {}'.format(e)) 'installed. {}'.format(e))

View File

@ -82,13 +82,13 @@ class Ovs(detection.Plugin):
if not self.available: if not self.available:
if not process_exist: if not process_exist:
log.error('OVS daemon process [%s] does not exist.', log.info('OVS daemon process [%s] does not exist.',
Ovs.PROC_NAME) Ovs.PROC_NAME)
elif not neutron_conf_exists: elif not neutron_conf_exists:
log.error(('OVS daemon process exists but configuration ' log.warning(('OVS daemon process exists but configuration '
'file was not found. Path to file does not exist ' 'file was not found. Path to file does not exist '
'as a process parameter or was not ' 'as a process parameter or was not '
'passed via args.')) 'passed via args.'))
elif not neutron_conf_valid: elif not neutron_conf_valid:
log.error(('OVS daemon process exists, configuration file was ' log.error(('OVS daemon process exists, configuration file was '
'found but it looks like it does not contain ' 'found but it looks like it does not contain '

View File

@ -69,7 +69,7 @@ class Postfix(plugin.Plugin):
'\n Refer to postfix plugin documentation ' '\n Refer to postfix plugin documentation '
'for more details.' 'for more details.'
% (agent_user, _POSTFIX_DIRECTORY)) % (agent_user, _POSTFIX_DIRECTORY))
log.error('%s\n%s' % (detailed_msg, self.ERROR_MSG)) log.warning('%s\n%s' % (detailed_msg, self.ERROR_MSG))
def build_config(self): def build_config(self):
"""Build the config as a Plugins object and return. """Build the config as a Plugins object and return.

View File

@ -18,7 +18,6 @@ import os
import monasca_setup.agent_config import monasca_setup.agent_config
import monasca_setup.detection import monasca_setup.detection
log = logging.getLogger(__name__) log = logging.getLogger(__name__)
# Defaults # Defaults
@ -59,11 +58,11 @@ class Supervisord(monasca_setup.detection.Plugin):
self.available = found_process is not None and has_args_or_conf_file self.available = found_process is not None and has_args_or_conf_file
if not self.available: if not self.available:
if not found_process: if not found_process:
log.error('Supervisord process does not exist.') log.info('Supervisord process does not exist.')
elif not has_args_or_conf_file: elif not has_args_or_conf_file:
log.error(('Supervisord process exists but ' log.warning(('Supervisord process exists but '
'configuration file was not found and ' 'configuration file was not found and '
'no arguments were given.')) 'no arguments were given.'))
def _get_config(self): def _get_config(self):
"""Set the configuration to be used for connecting to supervisord """Set the configuration to be used for connecting to supervisord

View File

@ -20,7 +20,6 @@ import monasca_setup.agent_config
from monasca_setup.detection import Plugin from monasca_setup.detection import Plugin
from monasca_setup.detection.utils import find_process_name from monasca_setup.detection.utils import find_process_name
log = logging.getLogger(__name__) log = logging.getLogger(__name__)
@ -43,11 +42,11 @@ class VCenter(Plugin):
self.available = process_exist and has_config_file_or_args self.available = process_exist and has_config_file_or_args
if not self.available: if not self.available:
if not process_exist: if not process_exist:
log.error('Nova-compute process does not exist.') log.info('Nova-compute process does not exist.')
elif not has_config_file_or_args: elif not has_config_file_or_args:
log.error(('Nova-compute process exists but ' log.warning(('Nova-compute process exists but '
'the configuration file was not detected and no ' 'the configuration file was not detected and no '
'arguments were given.')) 'arguments were given.'))
def get_nova_config_file(self): def get_nova_config_file(self):
nova_conf = None nova_conf = None

View File

@ -28,7 +28,6 @@ _ZOOKEEPER_DEFAULT_PORT = 2181
class Zookeeper(monasca_setup.detection.Plugin): class Zookeeper(monasca_setup.detection.Plugin):
"""Detect Zookeeper daemons and setup configuration to monitor them. """Detect Zookeeper daemons and setup configuration to monitor them.
""" """
@ -46,10 +45,10 @@ class Zookeeper(monasca_setup.detection.Plugin):
if not self.available: if not self.available:
err_str = 'Plugin for Zookeeper will not be configured.' err_str = 'Plugin for Zookeeper will not be configured.'
if not process_found: if not process_found:
log.error('Zookeeper process has not been found: {0}'.format(err_str)) log.info('Zookeeper process has not been found: {0}'.format(err_str))
elif not has_config_file: elif not has_config_file:
log.error('Zookeeper plugin cannot find configuration ' log.warning('Zookeeper plugin cannot find configuration '
'file: {0}. {1}'.format(self._cfg_file, err_str)) 'file: {0}. {1}'.format(self._cfg_file, err_str))
def build_config(self): def build_config(self):
"""Build the config as a Plugins object and return. """Build the config as a Plugins object and return.
@ -68,7 +67,7 @@ class Zookeeper(monasca_setup.detection.Plugin):
log.info("\tEnabling the zookeeper plugin") log.info("\tEnabling the zookeeper plugin")
config['zk'] = { config['zk'] = {
'init_config': None, 'instances': 'init_config': None, 'instances':
[{'name': host, 'host': host, 'port': port, 'timeout': 3}] [{'name': host, 'host': host, 'port': port, 'timeout': 3}]
} }
return config return config

View File

@ -113,13 +113,13 @@ class KibanaDetectionTest(unittest.TestCase):
self.assertEqual(kibana_user, instance['username']) self.assertEqual(kibana_user, instance['username'])
def test_no_detect_no_process(self): def test_no_detect_no_process(self):
with mock.patch.object(LOG, 'error') as mock_log_error: with mock.patch.object(LOG, 'info') as mock_log_info:
PSUtilGetProc.cmdLine = [] PSUtilGetProc.cmdLine = []
self._detect(self.kibana_plugin) self._detect(self.kibana_plugin)
self.assertFalse(self.kibana_plugin.available) self.assertFalse(self.kibana_plugin.available)
self.assertEqual(mock_log_error.call_count, 1) self.assertEqual(mock_log_info.call_count, 1)
self.assertEqual(mock_log_error.call_args[0][0], self.assertEqual(mock_log_info.call_args[0][0],
'Kibana process has not been found. ' 'Kibana process has not been found. '
'Plugin for Kibana will not be configured.') 'Plugin for Kibana will not be configured.')
@ -135,12 +135,12 @@ class KibanaDetectionTest(unittest.TestCase):
'Plugin for Kibana will not be configured.') 'Plugin for Kibana will not be configured.')
def test_no_detect_no_default_config_file(self): def test_no_detect_no_default_config_file(self):
with mock.patch.object(LOG, 'error') as mock_log_error: with mock.patch.object(LOG, 'warning') as mock_log_warning:
self._detect(self.kibana_plugin, config_is_file=False) self._detect(self.kibana_plugin, config_is_file=False)
self.assertFalse(self.kibana_plugin.available) self.assertFalse(self.kibana_plugin.available)
self.assertEqual(mock_log_error.call_count, 1) self.assertEqual(mock_log_warning.call_count, 1)
self.assertEqual(mock_log_error.call_args[0][0], self.assertEqual(mock_log_warning.call_args[0][0],
'Kibana plugin cannot find configuration ' 'Kibana plugin cannot find configuration '
'file /opt/kibana/config/kibana.yml. ' 'file /opt/kibana/config/kibana.yml. '
'Plugin for Kibana will not be configured.') 'Plugin for Kibana will not be configured.')
@ -148,16 +148,16 @@ class KibanaDetectionTest(unittest.TestCase):
def test_no_detect_no_args_config_file(self): def test_no_detect_no_args_config_file(self):
config_file = '/fake/config' config_file = '/fake/config'
patch_log_error = mock.patch.object(LOG, 'error') patch_log_warning = mock.patch.object(LOG, 'warning')
with patch_log_error as mock_log_error: with patch_log_warning as mock_log_warning:
self.kibana_plugin.args = {'kibana-config': config_file} self.kibana_plugin.args = {'kibana-config': config_file}
self._detect(self.kibana_plugin, config_is_file=False) self._detect(self.kibana_plugin, config_is_file=False)
self.assertFalse(self.kibana_plugin.available) self.assertFalse(self.kibana_plugin.available)
self.assertEqual(mock_log_error.call_count, 1) self.assertEqual(mock_log_warning.call_count, 1)
self.assertEqual(mock_log_error.call_args[0][0], self.assertEqual(mock_log_warning.call_args[0][0],
'Kibana plugin cannot find configuration ' 'Kibana plugin cannot find configuration '
'file %s. ' 'file %s. '
'Plugin for Kibana will not be configured.' 'Plugin for Kibana will not be configured.'

View File

@ -169,8 +169,8 @@ class TestOvs(unittest.TestCase):
self.assertTrue(self.ovs_obj.available) self.assertTrue(self.ovs_obj.available)
self.assertEqual(self.ovs_obj.neutron_conf, '/opt/stack/neutron.conf') self.assertEqual(self.ovs_obj.neutron_conf, '/opt/stack/neutron.conf')
def test_detect_warning(self): def test_detect_info(self):
with patch.object(LOG, 'error') as mock_log_warn: with patch.object(LOG, 'info') as mock_log_warn:
ps_util_get_proc.detect_warning = True ps_util_get_proc.detect_warning = True
self._detect(self.ovs_obj) self._detect(self.ovs_obj)
self.assertFalse(self.ovs_obj.available) self.assertFalse(self.ovs_obj.available)