コード例 #1
0
ファイル: app.py プロジェクト: sumantmurke/Cloud99
def timelinedata(filename):
    timelinefile = "/tmp/ha_infra/"+filename
    archivefile = "/tmp/ha_infra/a"+filename
    dr = data_retriever()
    dr.getTimeLineData(timelinefile)
    dr1 = data_retriever()
    dr1.caculateServiceStatePercent(timelinefile,archivefile)
    gDataDict = dr.getDataDict()
    gDataDict = dr.getDataDict()
    gData = []
    endTime = map(int,dr.getETime().split(' ')[1].split(':'))
    
    #print endTime
    for k in gDataDict.keys():
        temp = []
        # timemap ={}
        timemap=[]
        for item in gDataDict.get(k):
            temp_item =[]
            timemap.append(map(int,item.getTS().split(' ')[1].split(':')))
            temp_item.append(item.getHostName() + ' - ' + item.getServiceName())
            temp_item.append(item.getStatus())
            # temp.append('TS')
            temp_item.append(map(int,item.getTS().split(' ')[1].split(':')))
            temp.append(temp_item)
        count = 1
        #print timemap
        for i in temp:
            
            # print len(temp)
            # print 'count ',count
            if len(temp) == count:
                i.append(endTime)
            else:
                i.append(timemap[count])
                count = count + 1    
        # print temp
        gData.extend(temp)
    #print gData    


    #gData = [['NS','OK',[14,0,0],[14,15,0]],['NS','CRITICAL',[14,15,0],[14,20,0]]]
    """
    TestStartDate:2015-05-05 15:00:00
    Service-1##Host-1,2015-05-05 15:01:01,WARNING,Nova Failure
    Service-1##Host-1,2015-05-05 15:02:01,OK,Nova Works
    Service-2##Host-1,2015-05-05 15:01:01,WARNING,Neutron Failure
    Service-2##Host-1,2015-05-05 15:03:01,OK,Neutron Failure
    TestEndDate:2015-05-05 16:00:00
    """
    #gData = [['Service-1##Host-1','WARNING',[15,1,1],[15,02,01]],['NS','OK',[15,02,01],[16,0,0]],
    #          ['Service-2##Host-1','WARNING',[15,1,1],[15,3,1]],['NS','OK',[15,3,1],[16,0,0]],
    #		]
    return str(gData)
コード例 #2
0
ファイル: app.py プロジェクト: sumantmurke/Cloud99
def archivedata(filename):
    archivefile = "/tmp/ha_infra/"+filename
    #print "Time line"
    # return render_template('archive.html')
    gData = [['Services', 'OK', 'CRITICAL']]
    dr = data_retriever()
    dr.getArchiveData(archivefile)
    gDataDict = dr.getDataDict()
    #print gDataDict
    # gdata = []
    for k in gDataDict.keys():
        servicename = k.split('##')[1]
        for item in gDataDict.get(k):
            temp = []
            #print item.getServiceName()
            #print item.getData()
            temp.append(item.getServiceName()+"-"+item.getHostName())
            temp.extend(item.getData())
            #print temp
        gData.append(temp)
    #print gData

    # gdata = [['Services', 'OK', 'CRITICAL'],['Service-1', 60, 40],['Service-2', 80, 20,],['Service-3', 70, 30]]
    return str(gData)