示例#1
0
文件: bfsum.py 项目: mealy/splunk
def searchFactory(maxjobs, params, time_list, uuid):
    spawned = 1
    completed = 0
    time_len = len(time_list)
    if maxjobs == 1:
        try:
            while time_list:
                st = time_list.pop()
                logger.info("uuid=%s Dispatching job %s for time %s (%s)" % (uuid, spawned, st, time.ctime(int(st))))
                job = search.dispatchSavedSearch(
                    params["ss_name"],
                    sessionKey=params["sessionKey"],
                    namespace=params["namespace"],
                    owner=params["owner"],
                    triggerActions=True,
                    now=st,
                    ttl="120",
                )
                spawned = spawned + 1
                while not job.isDone:
                    time.sleep(0.5)
                completed = completed + 1
                logger.info("uuid=%s Job %d of %d completed" % (uuid, completed, time_len))
            logger.info("uuid=%s All jobs completed" % uuid)
            return
        except Exception, ex:
            logger.exception(ex)
            raise
示例#2
0
def searchFactory(maxjobs, params, time_list, uuid):
    spawned = 1
    completed = 0
    time_len = len(time_list)
    if maxjobs == 1:
        try:
            while time_list:
                    st = time_list.pop()
                    logger.info('uuid=%s Dispatching job %s for time %s (%s)' \
                                 % (uuid, spawned, st, time.ctime(int(st))))
                    job = search.dispatchSavedSearch(params['ss_name'], 
                                                 sessionKey=params['sessionKey'], 
                                                 namespace=params['namespace'],
                                                 owner=params['owner'], 
                                                 triggerActions=True, 
                                                 now=st,
						 ttl='120') 
                    spawned = spawned + 1
                    while not job.isDone:
                        time.sleep(.5)
                    completed = completed + 1
                    logger.info('uuid=%s Job %d of %d completed' \
                                 % (uuid, completed, time_len))
            logger.info('uuid=%s All jobs completed' % uuid)
            return
        except Exception, ex:
            logger.exception(ex)
            raise
示例#3
0
文件: bfsum.py 项目: mealy/splunk
 curjobs = []
 compjobs = []
 while 1:
     try:
         while len(curjobs) >= maxjobs:
             (curjobs, compjobs) = updateJobList(curjobs)
             for j in compjobs:
                 logger.info("uuid=%s Job %d of %d completed (id: %s)" % (uuid, completed, time_len, j.id))
                 completed = completed + 1
         st = time_list.pop()
         logger.info("uuid=%s Dispatching job %s for time %s (%s)" % (uuid, spawned, st, time.ctime(int(st))))
         job = search.dispatchSavedSearch(
             params["ss_name"],
             sessionKey=params["sessionKey"],
             namespace=params["namespace"],
             owner=params["owner"],
             triggerActions=True,
             now=st,
             ttl="120",
         )
         spawned = spawned + 1
         curjobs.append(job)
         (curjobs, compjobs) = updateJobList(curjobs)
         for j in compjobs:
             logger.info("uuid=%s Job %d of %d completed (id: %s)" % (uuid, completed, time_len, j.id))
             completed = completed + 1
         for j in curjobs:
             logger.info("uuid=%s Job %s still running" % (uuid, j.id))
         if not time_list:
             logger.info("uuid=%s Encountered empty time list" % uuid)
             break
示例#4
0
        compjobs = []
        while 1:
            try:
                while (len(curjobs) >= maxjobs):
                    (curjobs, compjobs) = updateJobList(curjobs)
                    for j in compjobs:
                        logger.info('uuid=%s Job %d of %d completed (id: %s)' \
                                     %(uuid, completed, time_len, j.id))
                        completed = completed + 1
                st = time_list.pop()
                logger.info('uuid=%s Dispatching job %s for time %s (%s)' \
                             % (uuid, spawned, st, time.ctime(int(st))))
                job = search.dispatchSavedSearch(params['ss_name'], 
                                                 sessionKey=params['sessionKey'], 
                                                 namespace=params['namespace'],
                                                 owner=params['owner'], 
                                                 triggerActions=True, 
                                                 now=st,
						 ttl='120') 
                spawned = spawned + 1
                curjobs.append(job)
                (curjobs, compjobs) = updateJobList(curjobs)
                for j in compjobs:
                    logger.info('uuid=%s Job %d of %d completed (id: %s)' \
                                 %(uuid, completed, time_len, j.id))
                    completed = completed + 1
                for j in curjobs:
                    logger.info('uuid=%s Job %s still running' % (uuid, j.id))
                if not time_list:
                    logger.info('uuid=%s Encountered empty time list' % uuid)
                    break