def __queryForPlot(self):
   retVal = self.__parseFormParams()
   if not retVal['OK']:
     return retVal
   params = retVal['Value']
   repClient = ReportsClient(rpcClient=RPCClient("Accounting/ReportGenerator"))
   retVal = repClient.generateDelayedPlot(*params)
   return retVal
Exemple #2
0
 def __queryForPlot( self ):
   retVal = self.__parseFormParams()
   if not retVal[ 'OK' ]:
     return retVal
   params = retVal[ 'Value' ]
   repClient = ReportsClient( rpcClient = getRPCClient( "Accounting/ReportGenerator" ) )
   retVal = repClient.generateDelayedPlot( *params )
   return retVal
    def generateAccountingPlot(self):
        try:
            site = str(request.params['site'])
            plotName = str(request.params['plotName'])
            plotTime = str(request.params['plotTime'])
            height = int(request.params['height'])
            width = int(request.params['width'])
        except:
            S_ERROR("Oops, Invalid parameters!")

        extraParams = {'height': height, 'width': width}
        if plotName == 'CPU Used':
            typeName = "Job"
            reportName = "CPUUsed"
            grouping = "FinalMajorStatus"
            condDict = {'Site': [site]}
            extraParams['plotTitle'] = "CPU used for site %s" % site
        elif plotName == "Running jobs":
            typeName = "WMSHistory"
            reportName = "NumberOfJobs"
            grouping = "JobGroup"
            condDict = {'Site': [site], 'Status': ['Running']}
            extraParams['plotTitle'] = "Jobs running for site %s" % site
        else:
            return S_ERROR("Oops, invalid plot name!")

        if plotTime == "Last day":
            extraParams['lastSeconds'] = 86400
        elif plotTime == "Last week":
            extraParams['lastSeconds'] = 604800
        elif plotTime == "Last month":
            extraParams['lastSeconds'] = 2592000
        else:
            return S_ERROR("Oops, invalid time!")

        end = datetime.datetime.utcnow()
        start = end - datetime.timedelta(seconds=extraParams['lastSeconds'])
        repClient = ReportsClient(
            rpcClient=getRPCClient("Accounting/ReportGenerator"))
        result = repClient.generateDelayedPlot(typeName, reportName, start,
                                               end, condDict, grouping,
                                               extraParams)
        if not result['OK']:
            return S_ERROR(result['Message'])
        return S_OK(result['Value']['plot'])
    def web_generatePlot(self):
        callback = {}
        retVal = self.__parseFormParams()
        if not retVal[ 'OK' ]:
            callback = {"success":"false", "error":retVal[ 'Message' ]}
            self.finish( callback )

        params = retVal[ 'Value' ]
        repClient = ReportsClient( rpcClient = RPCClient( "Accounting/ReportGenerator" ) )
        retVal = repClient.generateDelayedPlot( *params )
        if not retVal[ 'OK' ]:
            callback = {"success":"false", "error":retVal[ 'Message' ]}
            self.finish( callback )
        rawData = retVal[ 'Value' ]
        '''groupKeys = rawData[ 'data' ].keys()'''
        self.log.always("11111111111111111111111111111111111111111111111111111111111")
        self.log.always(retVal[ 'Value' ][ 'plot' ])
        self.log.always("22222222222222222222222222222222222222222222222222222222222")
        self.finish({'success' : 'true', 'result' : rawData['plot']})
Exemple #5
0
  def generateAccountingPlot( self ):
    try:
      site = str( request.params[ 'site' ] )
      plotName = str( request.params[ 'plotName' ] )
      plotTime = str( request.params[ 'plotTime' ] )
      height = int( request.params[ 'height' ] )
      width = int( request.params[ 'width' ] )
    except:
      S_ERROR( "Oops, Invalid parameters!" )

    extraParams = { 'height' : height, 'width' : width }
    if plotName == 'CPU Used':
      typeName = "Job"
      reportName = "CPUUsed"
      grouping = "FinalMajorStatus"
      condDict = { 'Site' : [ site ] }
      extraParams[ 'plotTitle' ] = "CPU used for site %s" % site
    elif plotName == "Running jobs":
      typeName = "WMSHistory"
      reportName = "NumberOfJobs"
      grouping = "JobGroup"
      condDict = { 'Site' : [ site ], 'Status' : [ 'Running' ] }
      extraParams[ 'plotTitle' ] = "Jobs running for site %s" % site
    else:
      return S_ERROR( "Oops, invalid plot name!" )

    if plotTime == "Last day":
      extraParams[ 'lastSeconds' ] = 86400
    elif plotTime == "Last week":
      extraParams[ 'lastSeconds' ] = 604800
    elif plotTime == "Last month":
      extraParams[ 'lastSeconds' ] = 2592000
    else:
      return S_ERROR( "Oops, invalid time!" )

    end = datetime.datetime.utcnow()
    start = end - datetime.timedelta( seconds = extraParams[ 'lastSeconds' ] )
    repClient = ReportsClient( rpcClient = getRPCClient( "Accounting/ReportGenerator" ) )
    result = repClient.generateDelayedPlot( typeName, reportName, start, end, condDict, grouping, extraParams )
    if not result[ 'OK' ]:
      return S_ERROR( result[ 'Message' ] )
    return S_OK( result[ 'Value' ][ 'plot' ] )