Merge "Update log level classification info"
This commit is contained in:
commit
73e0072802
@ -35,7 +35,6 @@ CONFIG_ARG_KEYS = set(["url", "user", "password", "use_server_status_metrics"])
|
||||
|
||||
|
||||
class Apache(monasca_setup.detection.Plugin):
|
||||
|
||||
"""Detect Apache web server daemons and setup configuration to monitor apache.
|
||||
|
||||
This plugin will by default setup process check metrics for the apache process,
|
||||
@ -70,9 +69,9 @@ class Apache(monasca_setup.detection.Plugin):
|
||||
self.available = process_exists and has_args_or_config_file
|
||||
if not self.available:
|
||||
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:
|
||||
log.error(('Apache process exists but '
|
||||
log.warning(('Apache process exists but '
|
||||
'configuration file was not found and '
|
||||
'no arguments were given.'))
|
||||
|
||||
|
@ -67,7 +67,7 @@ class InfluxDBRelay(detection.Plugin):
|
||||
elif not dependencies_installed:
|
||||
err_chunks.append('\tinfluxdb-relay plugin requires "toml" '
|
||||
'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' %
|
||||
'\n'.join(err_chunks))
|
||||
else:
|
||||
|
@ -70,13 +70,13 @@ class Kibana(detection.Plugin):
|
||||
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)
|
||||
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.error('Kibana plugin cannot find configuration file %s. %s'
|
||||
LOG.warning('Kibana plugin cannot find configuration file %s. %s'
|
||||
% (cfg_file, err_str))
|
||||
|
||||
def build_config(self):
|
||||
|
@ -71,6 +71,7 @@ def _get_impl_lang(process):
|
||||
|
||||
class MonAgent(monasca_setup.detection.Plugin):
|
||||
"""Detect the Monsaca agent engine and setup some simple checks."""
|
||||
|
||||
def _detect(self):
|
||||
"""Run detection, set self.available True if the service is detected."""
|
||||
self.available = True
|
||||
@ -158,7 +159,7 @@ class MonAPI(monasca_setup.detection.Plugin):
|
||||
self.available = port_taken
|
||||
self._impl_helper = impl_helper
|
||||
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)
|
||||
|
||||
def build_config(self):
|
||||
@ -198,6 +199,7 @@ class MonAPI(monasca_setup.detection.Plugin):
|
||||
|
||||
class MonNotification(monasca_setup.detection.Plugin):
|
||||
"""Detect the Monsaca notification engine and setup some simple checks."""
|
||||
|
||||
def _detect(self):
|
||||
"""Run detection, set self.available True if the service is detected."""
|
||||
if find_process_cmdline('monasca-notification') is not None:
|
||||
@ -246,7 +248,7 @@ class MonPersister(monasca_setup.detection.Plugin):
|
||||
log.info('\tmonasca-persister implementation is %s', impl_lang)
|
||||
|
||||
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)
|
||||
|
||||
def build_config(self):
|
||||
@ -292,6 +294,7 @@ class MonPersister(monasca_setup.detection.Plugin):
|
||||
|
||||
class MonThresh(monasca_setup.detection.Plugin):
|
||||
"""Detect the running mon-thresh and monitor."""
|
||||
|
||||
def _detect(self):
|
||||
"""Run detection, set self.available True if the service is detected."""
|
||||
# The node will be running either nimbus or supervisor or both
|
||||
|
@ -28,7 +28,6 @@ SOCKET = '/var/run/mysqld/mysqld.sock'
|
||||
|
||||
|
||||
class MySQL(monasca_setup.detection.Plugin):
|
||||
|
||||
"""Detect MySQL daemons and setup configuration to monitor them.
|
||||
|
||||
This plugin needs user/password info for mysql setup.
|
||||
@ -58,9 +57,9 @@ class MySQL(monasca_setup.detection.Plugin):
|
||||
has_dependencies)
|
||||
if not self.available:
|
||||
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:
|
||||
log.error(('MySQL process exists but '
|
||||
log.warning(('MySQL process exists but '
|
||||
'configuration file was not found and '
|
||||
'no arguments were given.'))
|
||||
elif not has_dependencies:
|
||||
|
@ -82,10 +82,10 @@ class Ovs(detection.Plugin):
|
||||
|
||||
if not self.available:
|
||||
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)
|
||||
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 '
|
||||
'as a process parameter or was not '
|
||||
'passed via args.'))
|
||||
|
@ -69,7 +69,7 @@ class Postfix(plugin.Plugin):
|
||||
'\n Refer to postfix plugin documentation '
|
||||
'for more details.'
|
||||
% (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):
|
||||
"""Build the config as a Plugins object and return.
|
||||
|
@ -18,7 +18,6 @@ import os
|
||||
import monasca_setup.agent_config
|
||||
import monasca_setup.detection
|
||||
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
# Defaults
|
||||
@ -59,9 +58,9 @@ class Supervisord(monasca_setup.detection.Plugin):
|
||||
self.available = found_process is not None and has_args_or_conf_file
|
||||
if not self.available:
|
||||
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:
|
||||
log.error(('Supervisord process exists but '
|
||||
log.warning(('Supervisord process exists but '
|
||||
'configuration file was not found and '
|
||||
'no arguments were given.'))
|
||||
|
||||
|
@ -20,7 +20,6 @@ import monasca_setup.agent_config
|
||||
from monasca_setup.detection import Plugin
|
||||
from monasca_setup.detection.utils import find_process_name
|
||||
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
|
||||
@ -43,9 +42,9 @@ class VCenter(Plugin):
|
||||
self.available = process_exist and has_config_file_or_args
|
||||
if not self.available:
|
||||
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:
|
||||
log.error(('Nova-compute process exists but '
|
||||
log.warning(('Nova-compute process exists but '
|
||||
'the configuration file was not detected and no '
|
||||
'arguments were given.'))
|
||||
|
||||
|
@ -28,7 +28,6 @@ _ZOOKEEPER_DEFAULT_PORT = 2181
|
||||
|
||||
|
||||
class Zookeeper(monasca_setup.detection.Plugin):
|
||||
|
||||
"""Detect Zookeeper daemons and setup configuration to monitor them.
|
||||
|
||||
"""
|
||||
@ -46,9 +45,9 @@ class Zookeeper(monasca_setup.detection.Plugin):
|
||||
if not self.available:
|
||||
err_str = 'Plugin for Zookeeper will not be configured.'
|
||||
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:
|
||||
log.error('Zookeeper plugin cannot find configuration '
|
||||
log.warning('Zookeeper plugin cannot find configuration '
|
||||
'file: {0}. {1}'.format(self._cfg_file, err_str))
|
||||
|
||||
def build_config(self):
|
||||
|
@ -113,13 +113,13 @@ class KibanaDetectionTest(unittest.TestCase):
|
||||
self.assertEqual(kibana_user, instance['username'])
|
||||
|
||||
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 = []
|
||||
self._detect(self.kibana_plugin)
|
||||
self.assertFalse(self.kibana_plugin.available)
|
||||
|
||||
self.assertEqual(mock_log_error.call_count, 1)
|
||||
self.assertEqual(mock_log_error.call_args[0][0],
|
||||
self.assertEqual(mock_log_info.call_count, 1)
|
||||
self.assertEqual(mock_log_info.call_args[0][0],
|
||||
'Kibana process has not been found. '
|
||||
'Plugin for Kibana will not be configured.')
|
||||
|
||||
@ -135,12 +135,12 @@ class KibanaDetectionTest(unittest.TestCase):
|
||||
'Plugin for Kibana will not be configured.')
|
||||
|
||||
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.assertFalse(self.kibana_plugin.available)
|
||||
|
||||
self.assertEqual(mock_log_error.call_count, 1)
|
||||
self.assertEqual(mock_log_error.call_args[0][0],
|
||||
self.assertEqual(mock_log_warning.call_count, 1)
|
||||
self.assertEqual(mock_log_warning.call_args[0][0],
|
||||
'Kibana plugin cannot find configuration '
|
||||
'file /opt/kibana/config/kibana.yml. '
|
||||
'Plugin for Kibana will not be configured.')
|
||||
@ -148,16 +148,16 @@ class KibanaDetectionTest(unittest.TestCase):
|
||||
def test_no_detect_no_args_config_file(self):
|
||||
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._detect(self.kibana_plugin, config_is_file=False)
|
||||
self.assertFalse(self.kibana_plugin.available)
|
||||
|
||||
self.assertEqual(mock_log_error.call_count, 1)
|
||||
self.assertEqual(mock_log_error.call_args[0][0],
|
||||
self.assertEqual(mock_log_warning.call_count, 1)
|
||||
self.assertEqual(mock_log_warning.call_args[0][0],
|
||||
'Kibana plugin cannot find configuration '
|
||||
'file %s. '
|
||||
'Plugin for Kibana will not be configured.'
|
||||
|
@ -169,8 +169,8 @@ class TestOvs(unittest.TestCase):
|
||||
self.assertTrue(self.ovs_obj.available)
|
||||
self.assertEqual(self.ovs_obj.neutron_conf, '/opt/stack/neutron.conf')
|
||||
|
||||
def test_detect_warning(self):
|
||||
with patch.object(LOG, 'error') as mock_log_warn:
|
||||
def test_detect_info(self):
|
||||
with patch.object(LOG, 'info') as mock_log_warn:
|
||||
ps_util_get_proc.detect_warning = True
|
||||
self._detect(self.ovs_obj)
|
||||
self.assertFalse(self.ovs_obj.available)
|
||||
|
Loading…
Reference in New Issue
Block a user