Ejemplo n.º 1
0
def setup_logging():
    """
    Set logging levels based on configuration.
    """
    cfg = AgentConfig()
    for name, level in cfg.logging:
        if not level:
            continue
        try:
            logger = logging.getLogger(name)
            level = getattr(logging, level.upper())
            logger.setLevel(level)
        except Exception, e:
            log.error(utf8(e))
Ejemplo n.º 2
0
def setup_logging():
    """
    Set logging levels based on configuration.
    The special name of 'root' is used to specify the root logger.
    """
    cfg = AgentConfig()
    for name, level in cfg.logging:
        if not level:
            continue
        if name.lower() == 'root':
            name = None
        try:
            logger = logging.getLogger(name)
            level = getattr(logging, level.upper())
            logger.setLevel(level)
        except Exception as e:
            log.error(str(e))
Ejemplo n.º 3
0
 def start(self, block=True):
     """
     Start the agent.
     """
     cfg = AgentConfig()
     for plugin in Plugin.all():
         plugin.start()
     if get_bool(cfg.manager.enabled):
         host = cfg.manager.host
         port = int(cfg.manager.port)
         manager = Manager(host, port)
         manager.start()
     actions = ActionThread()
     actions.start()
     log.info('agent started.')
     if block:
         actions.join(self.WAIT)
Ejemplo n.º 4
0
 def __init__(self):
     cfg = AgentConfig()
Ejemplo n.º 5
0
 def test_init(self, cfg):
     path = str(uuid4())
     agent = AgentConfig(path)
     cfg.assert_called_once_with(AGENT_DEFAULTS, path)
     cfg.return_value.validate.assert_called_once_with(AGENT_SCHEMA)
     self.assertTrue(isinstance(agent, Graph))
Ejemplo n.º 6
0
 def __init__(self):
     cfg = AgentConfig()
     pam.SERVICE = cfg.pam.service