Esempio n. 1
0
def rm_queue(queue_name):
   REG  = registry.FinishedJobRegistry(queue_name, connection=CON)

   if REG.count > 0:
      JOBS = REG.get_job_ids()
      for job_num in JOBS:
         job = Job.fetch(job_num, connection=CON)
         job.delete()
Esempio n. 2
0
def mets():
    REG = registry.FinishedJobRegistry('default', connection=CON)
    JOBS = REG.get_job_ids()

    for job_num in JOBS:

        job = Job.fetch(job_num, connection=CON)
        start = job.started_at
        finish = job.ended_at
        duration = finish - start
        #print "job number: ", job_num
        #print "job function name: ", job.func_name
        #print "job duration: ", duration.seconds
        #print "job status: ", job.status
        #print "job result: ", job.result
        REQUEST_LATENCY.labels('web_api',
                               job.func_name).observe(duration.seconds)
        print REQUEST_LATENCY
    return REQUEST_LATENCY
Esempio n. 3
0
def show_stats(write_fn):
    """Print some metrics to stdout"""
    queue = django_rq.get_queue()
    conn = django_rq.get_connection()

    write_fn("Queued:")
    for job in queue.jobs:
        _print(write_fn, job)

    write_fn("Started:")
    for job_id in registry.StartedJobRegistry(connection=conn).get_job_ids():
        _print(write_fn, queue.fetch_job(job_id))

    write_fn("Finished:")
    for job_id in registry.FinishedJobRegistry(connection=conn).get_job_ids():
        _print(write_fn, queue.fetch_job(job_id))

    write_fn("Failed:")
    for job in FailedQueue(connection=conn).jobs:
        _print(write_fn, job)
        for line in job.exc_info.split('\n'):
            write_fn("\t\t" + line)
Esempio n. 4
0
def mets(queue_name):
   REG  = registry.FinishedJobRegistry(queue_name, connection=CON)
   JOBS = REG.get_job_ids()

   for job_num in JOBS:
      job = Job.fetch(job_num, connection=CON)
      start    = job.started_at
      finish   = job.ended_at
      duration = finish - start
      #print "job number: ", job_num
      #print "job function name: ", job.func_name
      #print "job duration: ", duration.
      #print "job status: ", job.status
      #print "job result: ", job.result
      if job.func_name.split(".")[1] == "check_svc":
        CHECKSVC_LATENCY.labels('/cs', job.func_name).observe(duration.total_seconds())
      elif job.func_name.split(".")[1] == "build_system":
        BUILDVM_LATENCY.labels('/cs', job.func_name).observe(duration.total_seconds())
      #REQUEST_SUMMARY.labels('/cs', job.func_name).observe(duration.total_seconds())
 
   rm_queue(queue_name)
   #return REQUEST_LATENCY, REQUEST_SUMMARY
   return CHECKSVC_LATENCY, BUILDVM_LATENCY
Esempio n. 5
0
#!/usr/bin/python
import rq
from rq.job import Job
from rq import registry
from redis import StrictRedis

REDIS_HOST = '172.17.0.1'
REDIS_PORT = '6379'

CON = StrictRedis(host=REDIS_HOST, port=REDIS_PORT)
REG = registry.FinishedJobRegistry('default', connection=CON)
JOBS = REG.get_job_ids()

for job_num in JOBS:

    job = Job.fetch(job_num, connection=CON)
    start = job.started_at
    finish = job.ended_at
    duration = finish - start
    print "job number: ", job_num
    print "job function name: ", job.func_name
    print "job duration: ", duration.total_seconds()
    print "job status: ", job.status
    print "job result: ", job.result