예제 #1
0
 def re_load(self):
     conf = get_conf()
     self.node = conf['node']
     self.ip = conf['local_ip']
     self.app = conf['application']
     self.paths = conf['paths']
     self.etcd_interval_time = conf['etcd']['interval']
예제 #2
0
def start_chitu():
    # load all configs
    all_conf = get_conf('conf/conf.toml')

    # init log config
    setup_logging(all_conf['log_configuration'])

    thread_set = dict()
    queue = None
    workers = list()

    for redis_address in all_conf['redis']['address']:
        work = Transport(all_conf, redis_address)
        work.name = 'redis_' + str(redis_address['db'])
        thread = Thread(target=work.work, args=(), name='%s' % work.name)
        thread.setDaemon(True)
        thread.start()
        workers.append(work)
        thread_set[work.name] = thread

    # start communication instance
    communication = Communication(all_conf)
    thread = Thread(target=communication.work,
                    args=(),
                    name='%s' % communication.name)
    thread.setDaemon(True)
    thread.start()

    # start watch instance
    watch = WatchDog(all_conf)
    watch = Thread(target=watch.work,
                   name='watchdog',
                   args=(thread_set, queue, workers))
    watch.setDaemon(True)
    watch.start()
예제 #3
0
    def re_load(self):
        conf = get_conf()
        self.to_where = conf['send_to_where']
        self.data_original = None
        self.name = None

        if self.to_where == 'influxdb':
            self.db = InfluxdbWrapper(conf['influxdb'])
        return self
예제 #4
0
def start_ziyan():
    from plugins.your_plugin import MyCheck, MyHandler

    # init queues
    queue = {'data_queue': Queue(), 'sender': Queue()}

    # load all configs
    all_conf = get_conf('conf/conf.toml')

    # init log config
    setup_logging(all_conf['log_configuration'])

    # init instances
    checker = MyCheck(all_conf)
    handler = MyHandler(all_conf)
    sender = Sender(all_conf)
    communication = Communication(all_conf)

    # name instances
    checker.name = 'checker'
    handler.name = 'handler'
    sender.name = 'sender'

    # init work threads set
    workers = [checker, handler]

    thread_set = dict()

    # start workers instance
    for worker in workers:
        thread = Thread(target=worker.work,
                        args=(queue, ),
                        name='%s' % worker.name)
        thread.setDaemon(True)
        thread.start()
        thread_set[worker.name] = thread

    # init send set
    send_set = [communication, sender]
    for send in send_set:
        thread = Thread(target=send.work,
                        args=(queue, ),
                        name='%s' % send.name)
        thread.setDaemon(True)
        thread.start()

    # start watch instance
    watch = WatchDog(all_conf)
    watch = Thread(target=watch.work,
                   name='%s' % watch.name,
                   args=(thread_set, queue, workers))
    watch.setDaemon(True)
    watch.start()
예제 #5
0
    def re_load(self):
        conf = get_conf()
        self.to_where = conf['send_to_where']
        self.data_original = None
        self.name = None

        if self.to_where == 'influxdb':
            self.db = InfluxdbWrapper(conf['influxdb'])
        elif self.to_where == 'kafka':
            self.db = KafkaWrapper(conf['kafka'])
        elif self.to_where == 'mqtt':
            self.mqtt_conf = conf.get('mqtt', dict())
            self.mqtt = MqttWrapper(self.mqtt_conf)
            self.mqtt_put_queue = Queue()
        return self
예제 #6
0
 def re_load(self):
     self.conf = get_conf("conf/conf.toml")
     return self
예제 #7
0
 def re_load(self):
     self.conf = get_conf("conf/conf.toml")['user_conf']['handler']
     self.field_name_list = self.conf.get('field_name_list', [])
     self.table_name = self.conf.get('table_name', 'influxdb')
     self.unit = self.conf.get('unit', 's')
     return self
예제 #8
0
# -*- coding: utf-8 -*-

import requests
import argparse

from Doctopus.utils.util import get_conf

def chitu(command):
    url = "http://127.0.0.1:8001/" + command
    requests.get(url)

def ziyan(command):
    url = "http://127.0.0.1:8000/" + command
    requests.get(url)

if __name__ == "__main__":
    parse = argparse.ArgumentParser()
    parse.add_argument('action', action='store')
    command = parse.parse_args().action
    conf = get_conf("../conf/conf.toml")
    fn = {"ziyan": ziyan, "chitu": chitu}
    fn.get(conf["application"])(command)
예제 #9
0
def get_app(selection='client'):
    if selection == "client":
        return create_client(get_conf())
    elif selection == "server":
        return create_server(get_conf())
예제 #10
0
 def __init__(self):
     self.communication = Communication(get_conf())
     logging.Handler.__init__(self)
예제 #11
0
    将日志保存在 Communication 类中,传输至远端
    """
    def __init__(self):
        self.communication = Communication(get_conf())
        logging.Handler.__init__(self)

    def emit(self, record):
        msg = self.format(record)
        self.communication.enqueue_log(msg)


def test():
    log = logging.getLogger("Doctopus.test")
    log.warning("函数调用")


def test2():
    log = logging.getLogger("Doctopus")
    log.critical("同名调用")


if __name__ == '__main__':
    from Doctopus.utils.util import get_conf

    conf = get_conf('../conf/conf.toml')['log_configuration']
    log = setup_logging(conf)
    log.info("测试脚本")
    log.error("错误信息")
    test()
    test2()
예제 #12
0
 def re_load(self):
     conf = get_conf()
     self.app = conf['application']