Beispiel #1
0
def updateNodeStats(node, daytime):
    url = node.hostname + "/stats/get?date=" + str(daytime)
    data = getNodeStats(url)
    if (not data):
        node.checked = False
    else: 
        node.checked = True
        node.timestamp = datetime.now()
        
        
        
        
        for items in data:
            if (items.has_key("date")):
                for key,val in items.items():
                    if (key != "date"):
                        datestats = NodeStats.objects.filter(node=node, date=daytime, datakey=key)
                        updatestats = False
                        if (datestats.count() == 0):
                            nodestats = NodeStats(node = node, date=daytime, datakey=key)
                        else:
                            nodestats = datestats[0]
                            updatestats = True
                    
                        nodestats.dataval = int(val)
                        nodestats.save(force_update=updatestats)        
    node.save(force_update=True)
    return 
Beispiel #2
0
def updateNodeStats(node, daytime):
    url = node.hostname + "/stats/get?date=" + str(daytime)
    data = getNodeStats(url)
    if (not data):
        node.checked = False
    else: 
        node.checked = True
        node.timestamp = datetime.now()
        
        for items in data:
            if (items.has_key("date")):
                for key,val in items.items():
                    if (key != "date" and (isinstance(val, int) or isinstance(val, float))):
                        datestats = NodeStats.objects.filter(node=node, date=daytime, datakey=key)
                        updatestats = False
                        if (datestats.count() == 0):
                            nodestats = NodeStats(node = node, date=daytime, datakey=key)
                        else:
                            nodestats = datestats[0]
                            updatestats = True
                        nodestats.dataval = int(val)
                        nodestats.save(force_update=updatestats)        
    node.save(force_update=True)
    return 
Beispiel #3
0
def updateNodeStats(node, daytime):
    url = node.hostname + "/stats/get?date=" + str(daytime)
    data = getNodeStats(url)
    if (not data):
        node.checked = False
    else: 
        node.checked = True
        node.timestamp = datetime.now()
        
        datestats = NodeStats.objects.filter(hostname=node.hostname, date=daytime)
        updatestats = False
        if (datestats.count() == 0):
            nodestats = NodeStats(hostname = node.hostname, date=daytime)
        else:
            nodestats = datestats[0]
            updatestats = True
        
        for item in data:
            if (item.has_key("date")):
                nodestats.date = item["date"]
            if (item.has_key("user")):
                nodestats.user = int(item["user"])
            if (item.has_key("lrupdate")):
                nodestats.lrupdate = int(item["lrupdate"])
            if (item.has_key("lrdown")):
                nodestats.lrdown = int(item["lrdown"])
            if (item.has_key("lrview")):
                nodestats.lrview = int(item["lrview"])
            if (item.has_key("queries")):
                nodestats.queries = int(item["queries"])
            if (item.has_key("qexec_time_avg")):
                nodestats.qexec_time_avg = int(item["qexec_time_avg"])         
            if (item.has_key("qlt_avg")):
                nodestats.qlt_avg = int(item["qlt_avg"])         
 
        nodestats.save(force_update=updatestats)
        
    node.save(force_update=True)
    return