Updated the plugin code to handle the dimensions from the agent config, the plugin config and dimensions defined in the code correctly. Also removed the old-style plugin configuration code from several of the plugins and added a command-line option to monasca-setup to pass the log_level if desired instead of hard-coding it in the config. This will make it easier to test in debug mode. Fixed an issue with the Swift detection plugin. Change-Id: I679457e5e1f302b0cdc87b0f0f799a42a9fa0ba4
55 lines
2.6 KiB
Python
55 lines
2.6 KiB
Python
import os
|
|
|
|
import monasca_setup.detection
|
|
|
|
|
|
class Swift(monasca_setup.detection.ServicePlugin):
|
|
|
|
"""Detect Swift daemons and setup configuration to monitor them.
|
|
|
|
"""
|
|
|
|
def __init__(self, template_dir, overwrite=True):
|
|
service_params = {
|
|
'template_dir': template_dir,
|
|
'overwrite': overwrite,
|
|
'service_name': 'object-storage',
|
|
'process_names': ['swift-container-updater', 'swift-account-auditor',
|
|
'swift-object-replicator', 'swift-container-replicator',
|
|
'swift-object-auditor', 'swift-container-auditor',
|
|
'swift-account-reaper', 'swift-container-sync',
|
|
'swift-account-replicator', 'swift-object-updater',
|
|
'swift-object-server', 'swift-account-server',
|
|
'swift-container-server', 'swift-proxy-server'],
|
|
'service_api_url': 'http://localhost:8080/healthcheck',
|
|
'search_pattern': '.*OK.*'
|
|
}
|
|
|
|
super(Swift, self).__init__(service_params)
|
|
|
|
def build_config(self):
|
|
config = super(Swift, self).build_config()
|
|
|
|
# This is a bit of an abuse of the nagios_wrapper but the commands will return failed error code properly
|
|
swift_health = "/bin/sh -c '" + \
|
|
"/usr/local/bin/diagnostics --check_mounts && " + \
|
|
"/usr/local/bin/diagnostics --disk_monitoring && " + \
|
|
"/usr/local/bin/diagnostics --file_ownership && " + \
|
|
"/usr/local/bin/diagnostics --network_interface && " + \
|
|
"/usr/local/bin/diagnostics --ping_hosts && " + \
|
|
"/usr/local/bin/diagnostics --swift_services && " + \
|
|
"/usr/local/bin/swift-checker --diskusage && " + \
|
|
"/usr/local/bin/swift-checker --healthcheck && " + \
|
|
"/usr/local/bin/swift-checker --replication'"
|
|
|
|
if os.path.exists('/usr/local/bin/diagnostics') and os.path.exists('/usr/local/bin/swift-checker'):
|
|
config['nagios_wrapper'] = {'init_config': None,
|
|
'instances': [
|
|
{'name': 'Swift.health',
|
|
'check_command': swift_health,
|
|
'check_interval': 60,
|
|
'dimensions': {'service': 'swift'}}
|
|
]}
|
|
|
|
return config
|