Esempio n. 1
0
def performs():
    _app_key = request.headers.get('app_key', '')
    _app_secret = request.headers.get('app_secret', '')
    if _app_key != gconf.APP_KEY and _app_secret != gconf.APP_SECRET:
        return json.dumps({'code': 400, 'text': 'error'})
    Performs.add(request.json)
    return json.dumps({'code': 200, 'text': 'success'})
Esempio n. 2
0
def performs():
    _app_key = request.headers.get('app_key', '')
    _app_secret = request.headers.get('app_secret', '')
    # _app_key = request.args.get('app_key', '')
    # _app_secret = request.args.get('app_secret', '')
    if _app_key != gconf.APP_KEY or _app_secret != gconf.APP_SECRET:
        return json.dumps({'code': 400, 'text': 'secret error'})
    #获取json数据
    Performs.add(request.json)
    #0.10 request.get_json()
    return json.dumps({'code': 200, 'text': 'success'})
Esempio n. 3
0
def performs():
    #header方式请求
    _app_key = request.headers.get('app_key', '')
    _app_secret = request.headers.get('app_secret', '')
    #get 方式请求
    #_app_key = request.args.get('app_key','')
    #_app_secret = request.args.get('app_secret','')
    if _app_key != gconf.APP_KEY or _app_secret != gconf.APP_SECRET:
        return json.dumps({"code": 400, "text": "secret error"})
    # Flask > 0.10 request.get_json() else request.json()
    # 获取json数据
    Performs.add(request.get_json())
    return json.dumps({"code": 200, "text": "success"})
Esempio n. 4
0
def performs():
    # msg = {u'ip': u'192.168.0.3', u'ram': 31.810766721044047, u'cpu': 2.9000000000000057, u'time': u'2018-02-10 18:30:11'}
    # app_key = request.args.get('app_key')
    # app_secret = request.args.get('app_secret')

    app_key = request.headers.get('app_key', '')
    app_secret = request.headers.get('app_secret', '')
    if app_key != gconf.app_key or app_secret != gconf.app_secret:
        return json.dumps({'code': 400, 'text': '认证失败'})

    msg = request.get_json()
    Performs.add(msg)
    return json.dumps({'is_ok': True})
Esempio n. 5
0
def asset_performs():
    _ip = request.args.get('ip', '')
    datetime_list, cpu_list, ram_list = Performs.get_list(_ip)
    return render_template('asset_perfrom.html',
                           datetime_list=datetime_list,
                           cpu_list=cpu_list,
                           ram_list=ram_list)
Esempio n. 6
0
def perform_asset():
    asset_id = request.form.get("asset_id")
    _ip = Asset.get_list(asset_id)[0]['ip']
    datetime_list, cpu_list, ram_list = Performs.get_list(_ip)
    return render_template('asset_perform.html',
                           datetime_list=json.dumps(datetime_list),
                           cpu_list=json.dumps(cpu_list),
                           ram_list=json.dumps(ram_list))
Esempio n. 7
0
def rate_asset_ajx():
    _id = request.args.get('id', '')
    _asset = Asset.get_by_key(_id)
    cpu_list, ram_list = Performs.get_rate_list(_asset['ip'])
    if len(cpu_list) == 0 or len(ram_list) == 0:
        cpu_list = [0]
        ram_list = [0]
    return json.dumps({'cpu': cpu_list[-1], 'ram': ram_list[-1]})
Esempio n. 8
0
def perform_asset():
    _id = request.args.get('id', '')
    _count, _asset = asset.get_by_id(_id)
    _asset = _asset[0]
    datetime_list, cpu_list, ram_list = Performs.get_list(_asset['ip'])
    return render_template('asset_perform.html',
                           datetime_list=json.dumps(datetime_list),
                           cpu_list=json.dumps(cpu_list),
                           ram_list=json.dumps(ram_list))
Esempio n. 9
0
def perform_asset():
    _id = request.args.get('id', '')
    _asset = Asset.get_by_key(_id)
    datetime_list, cpu_list, ram_list = Performs.get_list(_asset['ip'])
    print datetime_list, cpu_list, ram_list
    return render_template('asset_perform.html',
                           datetime_list=json.dumps(datetime_list),
                           cpu_list=json.dumps(cpu_list),
                           ram_list=json.dumps(ram_list))
Esempio n. 10
0
def asset_perform():
    asset_ip = request.args.get('ip')
    # cpu_list = [43934, 52503, 57177, 69658, 97031, 119931, 137133, 154175]
    # ram_list = [24916, 24064, 29742, 29851, 32490, 30282, 38121, 40434]
    # time_list = ['09:00:00', '09:10:40', '09:20:20', '09:30:10', '09:40:11', '09:50:20', '10:00:10', '10:10:10']
    time_list, cpu_list, ram_list = Performs.get_list(ip=asset_ip)
    return render_template('/asset/asset_perform.html',
                           time_list=time_list,
                           cpu_list=cpu_list,
                           ram_list=ram_list)
Esempio n. 11
0
def perform_asset():
    _id = request.args.get('id', '')
    _asset = Asset.get_by_key(_id)
    datetime_list, cpu_list, ram_list = Performs.get_list(_asset['ip'])
    # datetime_list = ['2016-7-10 19:16:50', '2016-7-10 19:16:50', '2016-7-10 19:16:50', '2016-7-10 19:16:50', '2016-7-10 19:16:50', '2016-7-10 19:16:50', '2016-7-10 19:16:50', '2016-7-10 19:16:50','2016-7-10 19:16:50', '2016-7-10 19:16:50', '2016-7-10 19:16:50']
    # cpu_list = [-0.9, 0.6, 3.5, 8.4, 13.5, 17.0, 18.6, 17.9, 14.3, 9.0, 3.9, 1.0]
    # ram_list = [3.9, 4.2, 5.7, 8.5, 11.9, 15.2, 17.0, 16.6, 14.2, 10.3, 6.6, 4.8]
    return render_template('asset_perform.html',
                           datetime_list=json.dumps(datetime_list),
                           cpu_list=json.dumps(cpu_list),
                           ram_list=json.dumps(ram_list))
Esempio n. 12
0
def rate_asset():
    _id = request.args.get('id', '')
    _asset = Asset.get_by_key(_id)
    cpu_list, ram_list = Performs.get_rate_list(_asset['ip'])
    if len(cpu_list) == 0 or len(ram_list) == 0:
        cpu_list = [0]
        ram_list = [0]
    return render_template('asset_rate.html',
                           id=_id,
                           cpu_list=json.dumps([cpu_list[-1]]),
                           ram_list=json.dumps([ram_list[-1]]))
Esempio n. 13
0
def performs():
    # 获取json数据
    Performs.add(request.get_json())
    # print request.get_json()
    return json.dumps({'code': 200, 'text': 'success'})
Esempio n. 14
0
def performs():

    Performs.add(request.json)

    #print type(request.json)
    return json.dumps({'code': 200, 'text': 'success'})