def getDSStatInTimeWindow(request, MView=''):
    stop = datetime.now()
    start = datetime.now() - timedelta(days=7)
    par = Popularityparams()
    try:
        par.setTStart(request.GET.get('tstart', start.strftime("%Y-%m-%d")))
        par.setTStop(request.GET.get('tstop', stop.strftime("%Y-%m-%d")))

        par.setOrder(request.GET.get('orderby', 'totcpu'))
        par.setSiteName(request.GET.get('sitename', 'summary'))
        par.setIncludeWMAgent(request.GET.get('includewmagent', 'n'))

        jdata = _getDSStatInTimeWindowJSON(par, MView)

    except Paramvalidationexception as e:
        #return HttpResponseBadRequest("Given %s not valid (%s)" % (e.param, e.cause))
        return HttpResponseBadRequest(e.getmessage())
    except popDB.PopularityDBException as dbe:
        #return HttpResponseBadRequest("Given %s not valid (%s)" % (e.param, e.cause))
        return HttpResponseServerError(dbe.getmessage())
    except Exception as ex:
        return HttpResponseServerError(ex)

    #jdata = _getDSStatInTimeWindowJSON(par,MView)
    return HttpResponse(jdata)
def getProcessedDataSetStat(request):
    stop = datetime.now()
    start = datetime.now() - timedelta(days=7)
    par = Popularityparams()
    try:
        par.setTStart(request.GET.get('tstart', start.strftime("%Y-%m-%d")))
        par.setTStop(request.GET.get('tstop', stop.strftime("%Y-%m-%d")))
        par.setAggregation(request.GET.get('aggr', 'day'))
        par.setProcessedDataSet(request.GET.get('name'))
        par.setN('1')
        par.setOrder(request.GET.get('orderby', 'totcpu'))
        par.setSiteName(request.GET.get('sitename', 'summary'))
        par.setIncludeWMAgent(request.GET.get('includewmagent', 'n'))
        """ 
        data indexing start from 0
        """
        data = _getSingleElementStat(par, 'DSName')

    except Paramvalidationexception as e:
        #return HttpResponseBadRequest("Given %s not valid (%s)" % (pEx.param, pEx.cause))
        return HttpResponseBadRequest(e.getmessage())
    except popDB.PopularityDBException as dbe:
        #return HttpResponseBadRequest("Given %s not valid (%s)" % (e.param, e.cause))
        return HttpResponseServerError(dbe.getmessage())
    except Exception as ex:
        return HttpResponseServerError(ex)

    return HttpResponse(data)
Exemple #3
0
def getDSStatInTimeWindow(request,MView=''):
    stop = datetime.now()
    start = datetime.now() - timedelta(days = 7)
    par = Popularityparams()
    try:
        par.setTStart(request.GET.get('tstart', start.strftime("%Y-%m-%d")))
        par.setTStop(request.GET.get('tstop', stop.strftime("%Y-%m-%d")))

        par.setOrder(request.GET.get('orderby', 'totcpu'))
        par.setSiteName(request.GET.get('sitename', 'summary'))
        par.setIncludeWMAgent(request.GET.get('includewmagent', 'n'))

        jdata = _getDSStatInTimeWindowJSON(par, MView)

    except Paramvalidationexception as e:           
        #return HttpResponseBadRequest("Given %s not valid (%s)" % (e.param, e.cause))
        return HttpResponseBadRequest(e.getmessage())
    except popDB.PopularityDBException as dbe:
        #return HttpResponseBadRequest("Given %s not valid (%s)" % (e.param, e.cause))
        return HttpResponseServerError(dbe.getmessage())
    except Exception as ex:
        return HttpResponseServerError(ex) 
    

    #jdata = _getDSStatInTimeWindowJSON(par,MView)
    return HttpResponse(jdata)
Exemple #4
0
def getProcessedDataSetStat(request):
    stop = datetime.now()
    start = datetime.now() - timedelta(days=7)
    par = Popularityparams()
    try:
        par.setTStart(request.GET.get('tstart', start.strftime("%Y-%m-%d")))
        par.setTStop(request.GET.get('tstop', stop.strftime("%Y-%m-%d")))
        par.setAggregation(request.GET.get('aggr', 'day'))
        par.setProcessedDataSet(request.GET.get('name'))
        par.setN('1')
        par.setOrder(request.GET.get('orderby', 'totcpu'))
        par.setSiteName(request.GET.get('sitename', 'summary'))
        par.setIncludeWMAgent(request.GET.get('includewmagent', 'n'))
        """ 
        data indexing start from 0
        """
        data = _getSingleElementStat(par, 'DSName')
        
    except Paramvalidationexception as e:
        #return HttpResponseBadRequest("Given %s not valid (%s)" % (pEx.param, pEx.cause))
        return HttpResponseBadRequest(e.getmessage())
    except popDB.PopularityDBException as dbe:
        #return HttpResponseBadRequest("Given %s not valid (%s)" % (e.param, e.cause))
        return HttpResponseServerError(dbe.getmessage())
    except Exception as ex:
        return HttpResponseServerError(ex)

    return HttpResponse(data)
Exemple #5
0
def getTimeEvolutionPlotData(request,MView=''):
    stop = datetime.now()
    start = datetime.now() - timedelta(days=7)
    par = Popularityparams()
    try:
        par.setTStart(request.GET.get('tstart', start.strftime("%Y-%m-%d")))
        par.setTStop(request.GET.get('tstop', stop.strftime("%Y-%m-%d")))
        par.setAggregation(request.GET.get('aggr', 'day'))
        par.setN(request.GET.get('n', '1'))


        par.setOrder(request.GET.get('orderby', 'totcpu'))
        par.setSiteName(request.GET.get('sitename', 'summary'))
        if (par.FirstN == 0):
            return HttpResponseBadRequest("Given n not valid (param must be > 0)")
        par.setIncludeWMAgent(request.GET.get('includewmagent', 'n'))

        """
        data indexing start from 0
        """
        idx = (par.FirstN)-1
        logger.info(MView)
        data = _getMostPopStatDict(par, MView)

    except Paramvalidationexception as e:
        #return HttpResponseBadRequest("Given %s not valid (%s)" % (pEx.param, pEx.cause))
        return HttpResponseBadRequest(e.getmessage())
    except popDB.PopularityDBException as dbe:
        #return HttpResponseBadRequest("Given %s not valid (%s)" % (e.param, e.cause))
        return HttpResponseServerError(dbe.getmessage())
    except Exception as ex:
        return HttpResponseServerError(ex)

    jsonRes = {}
    listRes = []
    for i in data:
        series1 = []
        series2 = []
        for entry in data[i]['DATA']:
            millisecondSinceEpoch=1000*calendar.timegm(time.strptime(entry['TDAY'], '%Y/%m/%d'))
            if (par.orderVar == "totcpu"):
                series1.append( [  millisecondSinceEpoch, entry['TOTCPU'] ] )
            elif (par.orderVar == "naccess"):
                series1.append( [  millisecondSinceEpoch, entry['NACC'  ] ] )
            elif (par.orderVar == "nusers"):
                series1.append( [  millisecondSinceEpoch, entry['NUSERS'  ] ] )

        listRes.append({'name' : data[i]['COLLNAME'], 'data' : series1})
            #,
            #            {'label' : 'NACC', 'yaxis' : 1 , 'data' : series2}
            #             ]

    jsonRes = {'tstart': par.TStart, 'tstop': par.TStop, 'aggr': par.AggrFlag, 'data': listRes}
    jdata = json.dumps(jsonRes)

    return HttpResponse(jdata)
def getTimeEvolutionPlotData(request, MView=''):
    stop = datetime.now()
    start = datetime.now() - timedelta(days=7)
    par = Popularityparams()
    try:
        par.setTStart(request.GET.get('tstart', start.strftime("%Y-%m-%d")))
        par.setTStop(request.GET.get('tstop', stop.strftime("%Y-%m-%d")))
        par.setAggregation(request.GET.get('aggr', 'day'))
        par.setN(request.GET.get('n', '1'))

        par.setOrder(request.GET.get('orderby', 'totcpu'))
        par.setSiteName(request.GET.get('sitename', 'summary'))
        if (par.FirstN == 0):
            return HttpResponseBadRequest(
                "Given n not valid (param must be > 0)")
        par.setIncludeWMAgent(request.GET.get('includewmagent', 'n'))
        """
        data indexing start from 0
        """
        idx = (par.FirstN) - 1
        logger.info(MView)
        data = _getMostPopStatDict(par, MView)

    except Paramvalidationexception as e:
        #return HttpResponseBadRequest("Given %s not valid (%s)" % (pEx.param, pEx.cause))
        return HttpResponseBadRequest(e.getmessage())
    except popDB.PopularityDBException as dbe:
        #return HttpResponseBadRequest("Given %s not valid (%s)" % (e.param, e.cause))
        return HttpResponseServerError(dbe.getmessage())
    except Exception as ex:
        return HttpResponseServerError(ex)

    jsonRes = {}
    listRes = []
    for i in data:
        series1 = []
        series2 = []
        for entry in data[i]['DATA']:
            millisecondSinceEpoch = 1000 * calendar.timegm(
                time.strptime(entry['TDAY'], '%Y/%m/%d'))
            if (par.orderVar == "totcpu"):
                series1.append([millisecondSinceEpoch, entry['TOTCPU']])
            elif (par.orderVar == "naccess"):
                series1.append([millisecondSinceEpoch, entry['NACC']])
            elif (par.orderVar == "nusers"):
                series1.append([millisecondSinceEpoch, entry['NUSERS']])

        listRes.append({'name': data[i]['COLLNAME'], 'data': series1})
        #,
        #            {'label' : 'NACC', 'yaxis' : 1 , 'data' : series2}
        #             ]

    jsonRes = {
        'tstart': par.TStart,
        'tstop': par.TStop,
        'aggr': par.AggrFlag,
        'data': listRes
    }
    jdata = json.dumps(jsonRes)

    return HttpResponse(jdata)