Exemple #1
0
def drop_sys_info():
    """
    :drop sys_info db
    """
    db = GetSysData.connect_db()
    db.drop_database(get_dir("mongodb_collection"))
    return HttpResponse("ok")
Exemple #2
0
def del_monitor_data(request, timing):
    timing = int(timing)
    if timing == 4:
        db = GetSysData.connect_db()
        db.drop_database("sys_info")
    else:
        host_list = Host.objects.all()
        client = GetSysData.connect_db()
        db = client.sys_info
        for host in host_list:
            try:
                collection = db[host]
            except:
                continue
            now_time = int(time.time())
            del_time = now_time-TIME_SECTOR[int(timing)]
            collection.remove({'timestamp': {'$lte': del_time}}, {"timestamp": 1})
    return HttpResponse("ok")