예제 #1
0
#!/usr/bin/env python
# !-*- coding:utf-8 -*-

import tornado.web

from bin.service import Outer_services
from bin.logic.Service_Mail import *
from bin.until import Logger
from bin.until import PR
import json

L = Logger.getInstance()
operator = \
    {
        "sendMail": Outer_services().send_msg
    }


class Service(tornado.web.RequestHandler):
    def get(self):
        _PR = PR.getInstance()
        try:
            method = self.get_argument('method', '__error__')
            if method == "__error__":
                _PR.setCode(PR.Code_METHODERROR)
                _PR.setMsg("method ERROR , not give the method or get the method is __error__")
                return self.write(_PR.getPRBytes())
            data = json.loads(self.get_argument('data', None))
            L.debug("the service request method : " + str(method))
            L.debug("the service request parameter : " + str(data))
            self.write(operator.get(method)(data))
import threading
import queue
from bin.until import Mongo
from bin.until import Logger
from bin.until import DBCODE
from bin import logic
from bin.until import Filter
from bin.until import Time
from bin import init
from bin.logic.BO import statistic_res_BO
from bin.logic import BO
from bin.logic.BO import statistical_item_BO
import time
from bin.init import RabbitMQ_mongo_log

L = Logger.getInstance("times-task.log")


class Statistical_compute_init(threading.Thread):
    def __init__(self):
        threading.Thread.__init__(self)
        self.step_type_count = 3
        self.queue = queue.Queue(self.step_type_count)
        self.thread_stop = False

    # 添加统计任务
    def add_item_compute_task(self):
        # 开启一个线程处理这个频率段的数据
        pass

    # 统计任务处理
예제 #3
0
# add zhushi
sys.path.append(sys.path[0].replace("/bin", ""))  # 初始化项目路径

import tornado
from bin.service.Html_service import index
from bin.service import Service
from bin.service import Open_falcon_query as Qfq
from tornado.options import define, options
from bin.init import Init
from bin.until import Path
from bin.until import Logger
from bin import init

P = Path.getInstance()
L = Logger.getInstance()

if __name__ == "__main__":
    Init.Init().init()  # 系统初始化
    port = init.CONF_INFO["server"]["port"]
    context = init.CONF_INFO["server"]["context"]
    define("port", default=port, help="run on the given port", type=int)
    tornado.options.parse_command_line()
    app = tornado.web.Application(
        handlers=[(r"/" + context + "/service", Service),
                  (r"/" + context + "/open-falcon/mail/query", Qfq),
                  (r"/" + context + "/index.html", index)
                  ],
        template_path=P.htmlPath,
        static_path=P.webPath,
        debug=False
예제 #4
0
#!/usr/bin/env python
# !-*- coding:utf-8 -*-

from bin.init import RabbitMQ_mongo_log
from bin.until import Mongo
from bin.until import Path
from bin.until import Logger
from bin.until import Time
from bin import init
import time
import json
import threading

MQ = RabbitMQ_mongo_log.getInstance()
P = Path.getInstance()
L = Logger.getInstance("init.log")
global insert_interval_time_stamp
insert_interval_time_stamp = Time.getNowTimeStamp()


class MongoDB_log(object):
    def __init__(self):
        self.delivery_tags = []
        self.insert_datas = []
        self.time_interval = 0
        pass

    def insert_log(self, ch, method, properties, body):
        self.insert_datas.append(json.loads(str(body, encoding="utf-8")))
        self.delivery_tags.append(method.delivery_tag)
        is_ack = False