def __init__(self): self.log = logger( '{}.{}'.format( __name__, self.__class__.__name__, ) )
import django sys.path.append('.') sys.path.append('..') os.environ['DJANGO_SETTINGS_MODULE'] = 'alfmonitor.settings' django.setup() from alfmonitor.settings import AGENT_RUN_FREQUENCY from agents.messages import (SVC_START_MSG, ACTVE_AGENTS_MSG, INACTIVE_MAIL_MSG, START_AGENT_MSG, ENGINE_SLEEP_MSG, SCRIPT_CALL_MSG) from agents.models import Agent from alfmonitor.lib.alflogger import logger LOGGER = logger(__name__) def get_mod_and_class(script): return ('.'.join(script.split('.')[:-1]), script.split('.')[-1]) class AlfMonitorService(object): def run(self): """ Runs the Alfmonitor engine.""" LOGGER.info(SVC_START_MSG.format(datetime.datetime.now())) LOGGER.info('Running active agents.') while True: active_agent_list = Agent.objects.filter(is_active=True)