Exemple #1
0
def main():
    daemonize()
    LOG = timed_logger()
    sys.argv = [
        'manage.py',
        '--start-driver',
        '--start-executor',
        '--executor-worker',
        '1',
        '--start-notifier',
        '--notifier-worker',
        '1',
    ]

    try:
        manage.main()
    except Exception as e:
        LOG.error(e, exc_info=True)
Exemple #2
0
"""
from functools import wraps
from time import time
import asyncio
import json
from ast import literal_eval
from abc import ABCMeta, abstractmethod, abstractproperty

import requests
from redis import Redis, ConnectionPool
from pymongo import MongoClient
from bson.objectid import ObjectId

from argus_alert.core.utils.log import timed_logger

LOG = timed_logger()
HandlerDict = {}


def run_alert_task(ctx):
    """根据告警类型type,选择相应的对象进行处理"""
    alert_type = ctx['strategy'].get('type', 'basic')
    try:
        Handler = HandlerDict.get(alert_type.upper())
    except KeyError:
        LOG.error(f'No handler found for alert, type: {alert_type}')
    else:
        Handler(ctx).run()


def register_handler(cls):