예제 #1
0
def get_cpu_softirq(request):
    server = request['server']
    tag = request['tag']
    datatype = request['type']
    print("datatype"+datatype)
    socketio = cpu_blueprint.get_io()
    if (tag == 0):
        print("tag" + str(tag))
        interval = request['interval']
        global cpu_softirq_timer,cpu_softirq_count
        tableinfo = {'datatype':datatype}
        socketio.emit("cpu.softirq.res",CPUProfiler(server).get_softirq(tableinfo))
        tableinfo = {'list5':1,'datatype':datatype}
        cpu_softirq_count = request["flag"]
        set_value("cpusoftirq",str(cpu_softirq_count))
        # if cpu_softirq_timer is None:
        cpu_softirq_timer = Timer(interval, background_timer_stuff_cpusoftirq, [socketio, interval, "cpu.softirq.res", CPUProfiler(server).get_softirq,tableinfo])
        cpu_softirq_timer.start()
        # emit("cpu.softirq.res", CPUProfiler(server).get_softirq())
    elif (tag == 1):
        print("tag"+str(tag))
        clock = request['min']
        print('time-1-'+ clock)
        tableinfo = {'list4':clock,'datatype':datatype}
        socketio.emit("cpu.softirq.res",CPUProfiler(server).get_softirq(tableinfo))
예제 #2
0
def get_avg_load(request):
    server = request['server']
    tag = request['tag']
    socketio = cpu_blueprint.get_io()
    if (tag == 0):
        print("tag" + str(tag))
        interval = request['interval']
        global cpu_avg_timer,cpu_avg_count
        tableinfo = {}
        socketio.emit("cpu.avgload.res", CPUProfiler(server).get_avg_load(tableinfo))
        tableinfo = {'list5': 1}
        cpu_avg_count = request["flag"]
        set_value("cpuavg",str(cpu_avg_count))
        # if cpu_avg_timer is None:
        #       print("cpu.avgload.res-2-", str(CPUProfiler(server).get_average_load()))
        cpu_avg_timer = Timer(interval, background_timer_stuff_cpuavg, [socketio, interval, "cpu.avgload.res", CPUProfiler(server).get_avg_load,tableinfo])
        cpu_avg_timer.start()
        #    print("cpu.avgload.res-1-", str(CPUProfiler(server).get_average_load()))
        #     emit("cpu.avgload.res", CPUProfiler(server).get_average_load())
    elif (tag == 1):
        print("tag" + str(tag))
        clock = request['min']
        print('time-1-' + clock)
        tableinfo = {'list4': clock}
        socketio.emit("cpu.avgload.res",CPUProfiler(server).get_avg_load(tableinfo))
예제 #3
0
def get_ms_data(request):
    server = request['server']
    tag = request['tag']
    socketio = cpu_blueprint.get_io()

    if (tag == 0):
        print("tag" + str(tag))
        interval = request['interval']
        global cpu_mysql_timer,cpu_mysql_count
        # tableinfo = {'tablename': 'history', 'list1': 'clock', 'list2': 'value', 'list3': '25462'}//wh
        tableinfo = {'tablename': 'history', 'list1': 'clock', 'list2': 'value', 'list3': '23296'}
        # if cpu_mysql_timer is None:
        #       print("cpu.avgload.res-2-", str(CPUProfiler(server).get_average_load()))
        # cpu_mysql_count = request["flag"]
        # set_value("cpumysql",str(cpu_mysql_count))
        # cpu_mysql_timer = Timer(interval, background_timer_stuff_cpumysql, [socketio, interval, "cpu.mysql.res", CPUProfiler(server).get_mysql_data, tableinfo])
        # cpu_mysql_timer.start()
        get_mysql_data = CPUProfiler(server).get_mysql_data(tableinfo)
        socketio.emit("cpu.mysql.res", get_mysql_data)
        socketio.sleep(0)
        tableinfo = {'tablename': 'history', 'list1': 'clock', 'list2': 'value', 'list3': '23296', 'list5': '1'}
        cpu_mysql_count = request["flag"]
        set_value("cpumysql",str(cpu_mysql_count))
        cpu_mysql_timer = Timer(interval, background_timer_stuff_cpumysql, [socketio, interval, "cpu.mysql.res", CPUProfiler(server).get_mysql_data, tableinfo])
        cpu_mysql_timer.start()

    elif (tag == 1):
        print("tag" + str(tag))
        clock = request['min']
        print('time-1-'+ clock)
        tableinfo = {'tablename': 'history', 'list1': 'clock', 'list2': 'value', 'list3': '23296', 'list4': clock}
        get_mysql_data = CPUProfiler(server).get_mysql_data(tableinfo)
        socketio.emit("cpu.mysql.res", get_mysql_data)
        socketio.sleep(0)
예제 #4
0
def get_cpu_idle(request):
    server = request['server']
    tag = request['tag']
    socketio = cpu_blueprint.get_io()

    # cpu_statidle_timer = Timer(interval, background_timer_stuff_cpustatidle, [socketio, interval, "cpu.statidle.res", CPUProfiler(server).idle])
    # cpu_statidle_timer.start()
    # emit("cpu.statidle.res", CPUProfiler(server).get_irq())
    if (tag == 0):
        print("tag" + str(tag))
        interval = request['interval']
        global cpu_statidle_timer, cpu_statidle_count
        tableinfo = {}
        socketio.emit("cpu.statidle.res", CPUProfiler(server).get_cpu_idle(tableinfo))
        tableinfo = { 'list5': '1'}

        cpu_statidle_count = request["flag"]
        set_value("cpustatidle", str(cpu_statidle_count))
        print("cpu_statidle_count"+ str(cpu_statidle_count))
        cpu_statidle_timer = Timer(interval, background_timer_stuff_cpustatidle, [socketio, interval, "cpu.statidle.res", CPUProfiler(server).get_cpu_idle, tableinfo])
        cpu_statidle_timer.start()

    elif (tag == 1):
        print("tag" + str(tag))
        clock = request['min']
        print('time-1-'+ clock)
        tableinfo = {'list4': clock}
        socketio.emit("cpu.statidle.res", CPUProfiler(server).get_cpu_idle(tableinfo))
예제 #5
0
def getCpuTop(server):

    profiler = CPUProfiler(server)
    data = profiler.getTopOutput()

    if 'request_id' in request.args:
        data['response_id'] = request.args['request_id']
    return jsonify(data)
예제 #6
0
def getCpuStatus(server):

    profiler = CPUProfiler(server)

    data = profiler.get_status()

    if 'request_id' in request.args:
        data['response_id'] = request.args['request_id']
    return jsonify(data)
예제 #7
0
def get_avg_load(request):
    server = request['server']
    interval = request['interval']
    socketio = cpu_blueprint.get_io()
    global cpu_avg_timer
    if cpu_avg_timer is None:
        cpu_avg_timer = Timer(interval, background_timer_stuff, [
            socketio, interval, "cpu.avgload.res",
            CPUProfiler(server).get_average_load
        ])
        cpu_avg_timer.start()
    emit("cpu.avgload.res", CPUProfiler(server).get_average_load())
예제 #8
0
def get_top(request):
    server = request['server']
    interval = request['interval']
    socketio = cpu_blueprint.get_io()
    global cpu_top_timer
    if cpu_top_timer is None:
        cpu_top_timer = Timer(interval, background_timer_stuff, [
            socketio, interval, "cpu.top.res",
            CPUProfiler(server).getTopOutput
        ])
        cpu_top_timer.start()
    emit("cpu.top.res", CPUProfiler(server).getTopOutput())
예제 #9
0
def get_cpu_softirq(request):
    server = request['server']
    interval = request['interval']
    socketio = cpu_blueprint.get_io()
    global cpu_softirq_timer
    if cpu_softirq_timer is None:
        cpu_softirq_timer = Timer(interval, background_timer_stuff, [
            socketio, interval, "cpu.softirq.res",
            CPUProfiler(server).get_softirq
        ])
        cpu_softirq_timer.start()
    emit("cpu.softirq.res", CPUProfiler(server).get_softirq())
예제 #10
0
def get_average_load(server):
    # options = {
    #     'is_debug': False,
    # }
    # if not request.args['debug']:
    #     options['is_debug'] = request.args['debug']

    profiler = CPUProfiler(server)
    data = profiler.get_average_load()

    if 'request_id' in request.args:
        data['response_id'] = request.args['request_id']
    return jsonify(data)
예제 #11
0
def get_mysql_data(server):
    # options = {
    #     'is_debug': False,
    # }
    # if not request.args['debug']:
    #     options['is_debug'] = request.args['debug']
    tableinfo = {
        'tablename': 'history',
        'list1': 'clock',
        'list2': 'value',
        'list3': '25462'
    }
    profiler = CPUProfiler(server)
    data = profiler.get_mysql_data(tableinfo)

    if 'request_id' in request.args:
        data['response_id'] = request.args['request_id']
    return jsonify(data)
예제 #12
0
def get_cpu_stat(request):
    server = request['server']
    tag = request['tag']
    socketio = cpu_blueprint.get_io()

    # global cpu_statoverall_timer,cpu_statoverall_count
    # cpu_statoverall_count = request["flag"]
    # set_value("cpustatoverall",str(cpu_statoverall_count))
    # if cpu_statoverall_timer is None:
    # cpu_statoverall_timer = Timer(interval, background_timer_stuff_cpustatoverall, [socketio, interval, "cpu.statoverall.res", CPUProfiler(server).get_cpu_stat])
    # cpu_statoverall_timer.start()
    # emit("cpu.statoverall.res", {'data':[{'softirq': 0.0502, 'idle': 99.1556, 'time': 1542252266, 'iowait': 0.1589, 'irq': 0.0, 'steal': 0.0, 'user': 0.1421, 'nice': 0.0, 'system': 0.5142}]})

    if (tag == 0):
        print("tag" + str(tag))
        interval = request['interval']
        # global cpu_mysql_timer,cpu_mysql_count
        global cpu_statoverall_timer, cpu_statoverall_count
        tableinfo = {}
        # get_mysql_data = CPUProfiler(server).get_mysql_data(tableinfo)
        socketio.emit("cpu.statoverall.res", CPUProfiler(server).get_cpu_stat(tableinfo))
        # socketio.emit("cpu.statoverall.res", "222")
        socketio.sleep(0)
        tableinfo = { 'list5': '1'}
        # cpu_mysql_count = request["flag"]
        # set_value("cpumysql",str(cpu_mysql_count))
        cpu_statoverall_count = request["flag"]
        set_value("cpustatoverall", str(cpu_statoverall_count))
        cpu_statoverall_timer = Timer(interval, background_timer_stuff_cpustatoverall, [socketio, interval, "cpu.statoverall.res", CPUProfiler(server).get_cpu_stat, tableinfo])
        cpu_statoverall_timer.start()
        # cpu_mysql_timer = Timer(interval, background_timer_stuff_cpumysql, [socketio, interval, "cpu.mysql.res", CPUProfiler(server).get_mysql_data, tableinfo])
        # cpu_mysql_timer.start()

    elif (tag == 1):
        print("tag" + str(tag))
        clock = request['min']
        print('time-1-'+ clock)
        tableinfo = {'list4': clock}
        socketio.emit("cpu.statoverall.res", CPUProfiler(server).get_cpu_stat(tableinfo))
        socketio.sleep(0)
예제 #13
0
def get_ms_data2(request):
    server = request['server']
    interval = request['interval']
    socketio = cpu_blueprint.get_io()
    global cpu_mysql_timer2,cpu_mysql_count2
    tableinfo = {'tablename': 'history', 'list1': 'clock', 'list2': 'value', 'list3': '25940'}
    cpu_mysql_count2 = request["flag"]
    set_value("cpumysql2", str(cpu_mysql_count2))
    # if cpu_mysql_timer2 is None:
#       print("cpu.avgload.res-2-", str(CPUProfiler(server).get_average_load()))
    cpu_mysql_timer2 = Timer(interval, background_timer_stuff_cpumysql2, [socketio, interval, "cpu.mysql2.res", CPUProfiler(server).get_mysql_data, tableinfo])
    cpu_mysql_timer2.start()
예제 #14
0
 def setUp(self):
     self.functor = CPUProfiler('').getTopOutput
예제 #15
0
 def test_stability(self):
     profiler = CPUProfiler('www.rmlink.cn')
     self.repeated_test(profiler.get_average_load)
예제 #16
0
 def setUp(self):
     self.functor = CPUProfiler('').get_irq
예제 #17
0
 def setUp(self):
     self.functor = CPUProfiler('').get_processor_count
예제 #18
0
 def test_stability(self):
     profiler = CPUProfiler('www.rmlink.cn')
     self.repeated_test(profiler.getTopOutput)
 def test_stability(self):
     profiler = CPUProfiler('www.rmlink.cn')
     self.repeated_test(profiler.get_proc_cpu_info)
예제 #20
0
def get_top(request):
    server = request['server']
    interval = request['interval']
    socketio = cpu_blueprint.get_io()
    global cpu_top_timer,cpu_top_count
    cpu_top_count = request["flag"]
    set_value("cputop",str(cpu_top_count))
    # if cpu_top_timer is None:
    # cpu_top_timer = Timer(interval, background_timer_stuff_cputop, [socketio, interval, "cpu.top.res", CPUProfiler(server).getTopOut])
    cpu_top_timer = Timer(interval, background_timer_stuff_cputop, [socketio, interval, "cpu.top.res", CPUProfiler(server).get_cpu_top])
    cpu_top_timer.start()
예제 #21
0
def getCpuCapacity(server):

    profiler = CPUProfiler(server)
    data = profiler.get_capacity()

    return jsonify(data)
예제 #22
0
 def setUp(self):
     self.functor = CPUProfiler('').get_average_load
예제 #23
0
def getCpuCount(server):

    profiler = CPUProfiler(server)
    data = profiler.get_processor_count()

    return jsonify(data)
예제 #24
0
 def setUp(self):
     self.functor = CPUProfiler('').get_proc_cpu_info
예제 #25
0
 def test_stability(self):
     profiler = CPUProfiler('www.rmlink.cn')
     self.repeated_test(profiler.get_capacity)