Added a bunch of swift diagnostic commands. Added postfix checking back in but warned when root access is not granted. Ported over ntp check from the datadog agent and added detection. Moved detection plugin list out of the main of monasca-setup just so it looks tidy. Change-Id: I9a76d0cc009545d30df60c17f65a1db6e8329b63
42 lines
1.4 KiB
Python
42 lines
1.4 KiB
Python
import logging
|
|
import os
|
|
import yaml
|
|
|
|
import monasca_setup.agent_config
|
|
import monasca_setup.detection
|
|
|
|
log = logging.getLogger(__name__)
|
|
|
|
|
|
class Postfix(monasca_setup.detection.Plugin):
|
|
"""If postfix is running install the default config.
|
|
"""
|
|
def _detect(self):
|
|
"""Run detection, set self.available True if the service is detected.
|
|
|
|
"""
|
|
if monasca_setup.detection.find_process_cmdline('postfix') is not None:
|
|
# Test for sudo access
|
|
test_sudo = os.system('sudo -l -U monasca-agent find /var/spool/postfix/incoming -type f > /dev/null')
|
|
if test_sudo != 0:
|
|
log.info("Postfix found but the required sudo access is not configured.\n\t" +
|
|
"Refer to plugin documentation for more detail")
|
|
return False
|
|
|
|
self.available = True
|
|
|
|
def build_config(self):
|
|
"""Build the config as a Plugins object and return.
|
|
|
|
"""
|
|
# A bit silly to parse the yaml only for it to be converted back but this
|
|
# plugin is the exception not the rule
|
|
with open(os.path.join(self.template_dir, 'conf.d/postfix.yaml.example'), 'r') as postfix_template:
|
|
default_net_config = yaml.load(postfix_template.read())
|
|
config = monasca_setup.agent_config.Plugins()
|
|
config['postfix'] = default_net_config
|
|
return config
|
|
|
|
def dependencies_installed(self):
|
|
return True
|