示例#1
0
def get_torque_data():
    TS.getData()
    dct = dict()
    Hosts = TS.Hosts
    #The column headers for torque 'Host' attribute='State,Slots,SlotsUsed,AvailMem(MB),TotalMem(MB)or Swap,Time_Last_Rec,LoadAve,NetLoad(MB)'
    Job_State_Dict = {
        "down": 0,
        "free": 1,
        'job-exclusive': 2,
        'job-sharing': 3,
        'offline': 4,
        'reserve': 5,
        'time-shared': 6,
        'unknown': 7
    }
    for h in Hosts.values():
        #data is cleaned ,clean JOB list(not Required)
        if h.RecTime is None:
            continue  #Handling error generated by RecTime
        t = round(time.time() - int(h.RecTime), 2)
        # We scale down the attributes to minimize distortion of data by higher value

        tmp_list = (str(Job_State_Dict[h.State[0]]) + "," + str(h.Slots) +
                    "," + str(h.SlotsUsed) + "," +
                    str(round(float(h.AvailMem[0:-2]) / 1024, 2)) + "," +
                    str(round(float(h.TotalMem[0:-2]) / 1024, 2)) + ',' +
                    str(t) + "," + str(h.LoadAve) + "," +
                    str(round(float(h.NetLoad) / (1024 * 1024), 2)))
        dct[h.Name] = tmp_list

    return jsonify(dct)  # Return Results in JSON Format
示例#2
0
def get_torque_data():
    TS.getData()
    lst = []
    dct = dict()
    Hosts = TS.Hosts
    dct['Host'] = 'State,Slots,SlotsUsed,AvailMem(MB),TotalMem(MB)or Swap,Time_Last_Rec,LoadAve,NetLoad(MB)'
    Job_State_Dict = {
        "free": 1,
        'job-exclusive': 2,
        'job-sharing': 3,
        'offline': 4,
        'reserve': 5,
        'time-shared': 6,
        'unknown': 7
    }
    for h in Hosts.values():
        #data is cleaned ,clean JOB list(not Required)
        t = round(time.time() - int(h.RecTime), 2)
        l1 = (str(Job_State_Dict[h.State[0]]) + "," + str(h.Slots) + "," +
              str(h.SlotsUsed) + "," +
              str(round(float(h.AvailMem[0:-2]) / 1024, 2)) + "," +
              str(round(float(h.TotalMem[0:-2]) / 1024, 2)) + ',' + str(t) +
              "," + str(h.LoadAve) + "," +
              str(round(float(h.NetLoad) / (1024 * 1024), 2)))
        dct[h.Name] = l1
    #lst.append(dict)
    #print dct
    return jsonify(dct)
示例#3
0
def get_torque_data():
    TS.getData()
    lst=[]
    dct=dict()
    Hosts=TS.Hosts
    dct['Host']='State,Slots,SlotsUsed,AvailMem(MB),TotalMem(MB)or Swap,Time_Last_Rec,LoadAve,NetLoad(MB)'
    Job_State_Dict={"free":1,'job-exclusive':2,'job-sharing':3,'offline':4,'reserve':5,'time-shared':6,'unknown':7}
    for h in Hosts.values():
	#data is cleaned ,clean JOB list(not Required)
	t=round(time.time()-int(h.RecTime),2)
	l1=(str(Job_State_Dict[h.State[0]])+","+str(h.Slots)+","+str(h.SlotsUsed)+","+str(round(float(h.AvailMem[0:-2])/1024,2))+","+str(round(float(h.TotalMem[0:-2])/1024,2))+','+str(t)+","+str(h.LoadAve)+","+str(round(float(h.NetLoad)/(1024*1024),2)))
	dct[h.Name]=l1
                #lst.append(dict)    
    #print dct
    return jsonify(dct)
示例#4
0
def get_torque_data():
    TS.getData()
    dct=dict()
    Hosts=TS.Hosts
    #The column headers for torque 'Host' attribute='State,Slots,SlotsUsed,AvailMem(MB),TotalMem(MB)or Swap,Time_Last_Rec,LoadAve,NetLoad(MB)'
    Job_State_Dict={"down":0,"free":1,'job-exclusive':2,'job-sharing':3,'offline':4,'reserve':5,'time-shared':6,'unknown':7}
    for h in Hosts.values():
	#data is cleaned ,clean JOB list(not Required)
	if h.RecTime is None:
        	continue     #Handling error generated by RecTime
	t=round(time.time()-int(h.RecTime),2)
	# We scale down the attributes to minimize distortion of data by higher value

	tmp_list=(str(Job_State_Dict[h.State[0]])+","+str(h.Slots)+","+str(h.SlotsUsed)+","+str(round(float(h.AvailMem[0:-2])/1024,2))+","+str(round(float(h.TotalMem[0:-2])/1024,2))+','+str(t)+","+str(h.LoadAve)+","+str(round(float(h.NetLoad)/(1024*1024),2)))
	dct[h.Name]=tmp_list
    
    return jsonify(dct) # Return Results in JSON Format
示例#5
0
import TorqueStatus as TS
import time

TS.getData()
lst = []
dct = dict()
Job_State_Dict = {
    "down": 0,
    "free": 1,
    "job-exclusive": 2,
    "job-sharing": 3,
    "offline": 4,
    "reserve": 5,
    "time-shared": 6,
    "unknown": 7,
}
Hosts = TS.Hosts
for h in Hosts.values():
    #    l1=(str(h.State)+","+str(h.Slots)+","+str(h.SlotsUsed)+","+str(h.Jobs)+","+str(h.AvailMem)+","+str(h.TotalMem))# last is memory used
    # if type(h.RecTime)!=int:
    #    t=time.time()
    # else:
    if h.RecTime is None:
        continue
    t = time.time() - int(h.RecTime)
    # t=0
    # t=time.strftime('%Y-%m-%d %H:%M:%S',time.localtime(h.RecTime))
    l1 = (
        str(Job_State_Dict[h.State[0]])
        + ","
        + str(h.Slots)
示例#6
0
import TorqueStatus as TS
import time
TS.getData()
lst=[]
dct=dict()
Job_State_Dict={"down":0,"free":1,'job-exclusive':2,'job-sharing':3,'offline':4,'reserve':5,'time-shared':6,'unknown':7} 
Hosts=TS.Hosts
for h in Hosts.values():
#    l1=(str(h.State)+","+str(h.Slots)+","+str(h.SlotsUsed)+","+str(h.Jobs)+","+str(h.AvailMem)+","+str(h.TotalMem))# last is memory used
    #if type(h.RecTime)!=int:
    #    t=time.time()
    #else:
    if h.RecTime is None:
	continue
    t=time.time()-int(h.RecTime)
    #t=0
    #t=time.strftime('%Y-%m-%d %H:%M:%S',time.localtime(h.RecTime))
    l1=(str(Job_State_Dict[h.State[0]])+","+str(h.Slots)+","+str(h.SlotsUsed)+","+str(round(int(h.AvailMem[0:-2])/1024,2))+","+str(round(int(h.TotalMem[0:-2])/1024,2))+","+str((int(h.TotalMem[0:-2])-int(h.AvailMem[0:-2])))+','+str(t)+","+str(h.LoadAve)+","+str(round(int(h.NetLoad)/(1024*1024),2)))
    dct[h.Name]=l1
            #lst.append(dict)    
print dct