Ejemplo n.º 1
0
def load(webApp, dbClient, mqClient, env):
    for ename in getPackageFiles('web/endpoints'):
        logger.info('loading endpoint %s', ename)
        try:
            module = importlib.import_module('endpoints.' + ename)
            mlog.configLoggers([module.name], env.logs_folder, env.debug_mode)
            Endpoint(webApp, dbClient, mqClient, logger, module)
        except Exception as e:
            logger.error('error loading: %s', str(e))
Ejemplo n.º 2
0
def load(mqc, dbc, env):
    pluginNames = os.listdir('thirdparty/plugins')
    logger.debug(pluginNames)
    for pluginName in pluginNames:
        if pluginName == '__init__.py' or \
            pluginName == '__init__.pyc': 
            continue
        try:
            logger.info('Loading plugin %s', pluginName)
            mdl = import_module('plugins.' + pluginName)
            mlog.configLoggers([mdl.name], env.logs_folder, env.debug_mode)
            Plugin(mdl, mqc, dbc)
        except Exception as e:
            logger.error('Failed to load plugin: %s', str(e))
Ejemplo n.º 3
0
import env
import sys
import time
sys.path.append(env.infra_path)

from mq import MQClient
from db import DBClient
import keepalive
import mlog
import logging
import threading
mlog.configLoggers(['main', 'mq'], env.logs_folder, env.debug_mode)

logger = logging.getLogger('main')

try:
    mqc = MQClient(env)
    dbc = DBClient(env)

    def handleKeepAlive(kadata):
        comp = kadata['component']
        upd = {'name': comp, 'lts': time.time()}
        dbc.db.monitor.update_one({'name': comp}, {'$set': upd}, upsert=True)

    def pingDB():
        while True:
            if dbc.ping():
                keepalive.beat(mqc, 'DB')
            time.sleep(10)

    mqc.on_topic('keepalive', handleKeepAlive)
Ejemplo n.º 4
0
import env
import time
import threading
from uuid import getnode as get_mac
from recorder import Recorder
from sender import Sender
from filequeue import FileQueue

import mlog
import logging
mlog.configLoggers(['agent'],
                   logs_folder=env.logs_folder,
                   debug_mode=env.debug_mode)
logger = logging.getLogger('agent')
env.uuid = '%s.%s' % (env.iface, str(get_mac()))

queue = FileQueue(env)

sender = Sender(env, queue)
sender.start()

if env.mode == "live":
    recorder = Recorder(env, queue)
    recorder.start()
logger.info('Agent %s is up in %s mode', env.uuid, env.mode)

while True:
    time.sleep(1)
Ejemplo n.º 5
0
import sys
sys.path.append(env.infra_path)
sys.path.append('models')
sys.path.append('entities')

from importlib import import_module
import logging
import signal
import keepalive
import network_lock
from mq import MQClient
from db import DBClient

import mlog
import os
import processor

mlog.configLoggers(['main', 'network', 'proc', 'mq', 'db', 'model'], env.logs_folder, env.debug_mode)
logger = logging.getLogger('main')

try:
    mqc = MQClient(env)
    dbc = DBClient(env)
    network_lock.init(dbc)
    processor.load(mqc, dbc, network_lock.lock)
    logger.info('Networker is up')
    keepalive.start(mqc, 'networker')
except KeyboardInterrupt:
    pass
except Exception as e:
    logger.fatal(str(e))
Ejemplo n.º 6
0
import env
import sys
sys.path.append(env.infra_path)
import mlog
import logging
import time
from mq import MQClient 
from api_server import APIServer
from db import DBClient

mlog.configLoggers(['main', 'mq', 'api', 'db', 'endpoint'], env.logs_folder, env.debug_mode)

logger = logging.getLogger('main')

try:
    mqc = MQClient(env)
    dbc = DBClient(env)
    api = APIServer(env, mqc, dbc)
    logger.info('WEB Server up and running')

    api.start()
except KeyboardInterrupt:
    pass
except Exception as e:
    logger.fatal(str(e))