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,11 +69,11 @@ 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 '
|
||||
'configuration file was not found and '
|
||||
'no arguments were given.'))
|
||||
log.warning(('Apache process exists but '
|
||||
'configuration file was not found and '
|
||||
'no arguments were given.'))
|
||||
|
||||
def _read_apache_config(self, config_location):
|
||||
# Read the apache config file to extract the needed variables.
|
||||
|
|
|
@ -67,9 +67,9 @@ 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'
|
||||
'Following issue have to be resolved: %s' %
|
||||
'\n'.join(err_chunks))
|
||||
LOG.warning('Plugin for influxdb-relay will not be configured.\n'
|
||||
'Following issue have to be resolved: %s' %
|
||||
'\n'.join(err_chunks))
|
||||
else:
|
||||
self._config = self._load_config(config_file)
|
||||
|
||||
|
|
|
@ -70,14 +70,14 @@ 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'
|
||||
% (cfg_file, err_str))
|
||||
LOG.warning('Kibana plugin cannot find configuration file %s. %s'
|
||||
% (cfg_file, err_str))
|
||||
|
||||
def build_config(self):
|
||||
kibana_config = self._get_config_file()
|
||||
|
|
|
@ -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,8 +159,8 @@ 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'
|
||||
% self.PARTIAL_ERR_MSG)
|
||||
log.warning('monasca-api process has not been found. %s'
|
||||
% self.PARTIAL_ERR_MSG)
|
||||
|
||||
def build_config(self):
|
||||
"""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):
|
||||
"""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,8 +248,8 @@ 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'
|
||||
% self.PARTIAL_ERR_MSG)
|
||||
log.info('monasca-persister process has not been found. %s'
|
||||
% self.PARTIAL_ERR_MSG)
|
||||
|
||||
def build_config(self):
|
||||
"""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):
|
||||
"""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
|
||||
|
@ -511,30 +514,30 @@ class _MonPersisterJavaHelper(_DropwizardJavaHelper):
|
|||
"path": "meters/monasca.persister.repository.vertica.VerticaMetricRepo."
|
||||
"definition-cache-miss-meter/count",
|
||||
"type": "rate"},
|
||||
{"name": "monasca.persister.repository.vertica.VerticaMetricRepo."
|
||||
"definition-dimension-cache-hit-meter",
|
||||
"path": "meters/monasca.persister.repository.vertica.VerticaMetricRepo."
|
||||
"definition-dimension-cache-hit-meter/count",
|
||||
"type": "rate"},
|
||||
{"name": "monasca.persister.repository.vertica.VerticaMetricRepo."
|
||||
"definition-dimension-cache-miss-meter",
|
||||
"path": "meters/monasca.persister.repository.vertica.VerticaMetricRepo."
|
||||
"definition-dimension-cache-miss-meter/count",
|
||||
"type": "rate"},
|
||||
{"name": "monasca.persister.repository.vertica.VerticaMetricRepo."
|
||||
"dimension-cache-hit-meter",
|
||||
"path": "meters/monasca.persister.repository.vertica.VerticaMetricRepo."
|
||||
"dimension-cache-hit-meter/count",
|
||||
"type": "rate"},
|
||||
{"name": "monasca.persister.repository.vertica.VerticaMetricRepo."
|
||||
"dimension-cache-miss-meter",
|
||||
"path": "meters/monasca.persister.repository.vertica.VerticaMetricRepo."
|
||||
"dimension-cache-miss-meter/count",
|
||||
"type": "rate"},
|
||||
{"name": "monasca.persister.repository.vertica.VerticaMetricRepo.measurement-meter",
|
||||
"path": "meters/monasca.persister.repository.vertica.VerticaMetricRepo."
|
||||
"measurement-meter/count",
|
||||
"type": "rate"}])
|
||||
{"name": "monasca.persister.repository.vertica.VerticaMetricRepo."
|
||||
"definition-dimension-cache-hit-meter",
|
||||
"path": "meters/monasca.persister.repository.vertica.VerticaMetricRepo."
|
||||
"definition-dimension-cache-hit-meter/count",
|
||||
"type": "rate"},
|
||||
{"name": "monasca.persister.repository.vertica.VerticaMetricRepo."
|
||||
"definition-dimension-cache-miss-meter",
|
||||
"path": "meters/monasca.persister.repository.vertica.VerticaMetricRepo."
|
||||
"definition-dimension-cache-miss-meter/count",
|
||||
"type": "rate"},
|
||||
{"name": "monasca.persister.repository.vertica.VerticaMetricRepo."
|
||||
"dimension-cache-hit-meter",
|
||||
"path": "meters/monasca.persister.repository.vertica.VerticaMetricRepo."
|
||||
"dimension-cache-hit-meter/count",
|
||||
"type": "rate"},
|
||||
{"name": "monasca.persister.repository.vertica.VerticaMetricRepo."
|
||||
"dimension-cache-miss-meter",
|
||||
"path": "meters/monasca.persister.repository.vertica.VerticaMetricRepo."
|
||||
"dimension-cache-miss-meter/count",
|
||||
"type": "rate"},
|
||||
{"name": "monasca.persister.repository.vertica.VerticaMetricRepo.measurement-meter",
|
||||
"path": "meters/monasca.persister.repository.vertica.VerticaMetricRepo."
|
||||
"measurement-meter/count",
|
||||
"type": "rate"}])
|
||||
|
||||
def _monitor_endpoints(self, config, metrics):
|
||||
admin_connector = self._cfg['server']['adminConnectors'][0]
|
||||
|
|
|
@ -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,11 +57,11 @@ 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 '
|
||||
'configuration file was not found and '
|
||||
'no arguments were given.'))
|
||||
log.warning(('MySQL process exists but '
|
||||
'configuration file was not found and '
|
||||
'no arguments were given.'))
|
||||
elif not has_dependencies:
|
||||
log.error(('MySQL process exists but required dependence '
|
||||
'PyMySQL is not installed.'))
|
||||
|
@ -138,10 +137,10 @@ class MySQL(monasca_setup.detection.Plugin):
|
|||
log.info("\tConnection test success.")
|
||||
config['mysql'] = {
|
||||
'init_config': None, 'instances':
|
||||
[{'name': self.host, 'server': self.host, 'port': self.port,
|
||||
'user': self.user, 'pass': self.password,
|
||||
'sock': self.socket, 'ssl_ca': self.ssl_ca,
|
||||
'ssl_key': self.ssl_key, 'ssl_cert': self.ssl_cert}]}
|
||||
[{'name': self.host, 'server': self.host, 'port': self.port,
|
||||
'user': self.user, 'pass': self.password,
|
||||
'sock': self.socket, 'ssl_ca': self.ssl_ca,
|
||||
'ssl_key': self.ssl_key, 'ssl_cert': self.ssl_cert}]}
|
||||
except ImportError as e:
|
||||
exception_msg = ('The mysql dependency PyMySQL is not '
|
||||
'installed. {}'.format(e))
|
||||
|
|
|
@ -82,13 +82,13 @@ class Ovs(detection.Plugin):
|
|||
|
||||
if not self.available:
|
||||
if not process_exist:
|
||||
log.error('OVS daemon process [%s] does not exist.',
|
||||
Ovs.PROC_NAME)
|
||||
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 '
|
||||
'file was not found. Path to file does not exist '
|
||||
'as a process parameter or was not '
|
||||
'passed via args.'))
|
||||
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 '
|
||||
|
|
|
@ -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,11 +58,11 @@ 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 '
|
||||
'configuration file was not found and '
|
||||
'no arguments were given.'))
|
||||
log.warning(('Supervisord process exists but '
|
||||
'configuration file was not found and '
|
||||
'no arguments were given.'))
|
||||
|
||||
def _get_config(self):
|
||||
"""Set the configuration to be used for connecting to supervisord
|
||||
|
|
|
@ -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,11 +42,11 @@ 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 '
|
||||
'the configuration file was not detected and no '
|
||||
'arguments were given.'))
|
||||
log.warning(('Nova-compute process exists but '
|
||||
'the configuration file was not detected and no '
|
||||
'arguments were given.'))
|
||||
|
||||
def get_nova_config_file(self):
|
||||
nova_conf = None
|
||||
|
|
|
@ -28,7 +28,6 @@ _ZOOKEEPER_DEFAULT_PORT = 2181
|
|||
|
||||
|
||||
class Zookeeper(monasca_setup.detection.Plugin):
|
||||
|
||||
"""Detect Zookeeper daemons and setup configuration to monitor them.
|
||||
|
||||
"""
|
||||
|
@ -46,10 +45,10 @@ 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 '
|
||||
'file: {0}. {1}'.format(self._cfg_file, err_str))
|
||||
log.warning('Zookeeper plugin cannot find configuration '
|
||||
'file: {0}. {1}'.format(self._cfg_file, err_str))
|
||||
|
||||
def build_config(self):
|
||||
"""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")
|
||||
config['zk'] = {
|
||||
'init_config': None, 'instances':
|
||||
[{'name': host, 'host': host, 'port': port, 'timeout': 3}]
|
||||
[{'name': host, 'host': host, 'port': port, 'timeout': 3}]
|
||||
}
|
||||
|
||||
return config
|
||||
|
|
|
@ -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