Exemplo n.º 1
0
def mem_report(request, machine_category_id=settings.DEFAULT_MC):

    machine_category = get_object_or_404(MachineCategory, pk=machine_category_id)
    
    start, end = get_date_range(request)

    job_list = CPUJob.objects.filter(date__gte=start, date__lte=end, machine__category=machine_category)
    mem_0_4 = job_list.filter(mem__lte=4 * 1024 * 1024).count()
    mem_4_8 = job_list.filter(mem__gt=4 * 1024 * 1024, mem__lte=8 * 1024 * 1024).count()
    mem_8_16 = job_list.filter(mem__gt=8 * 1024 * 1024, mem__lte=16 * 1024 * 1024).count()
    mem_16_32 = job_list.filter(mem__gt=16 * 1024 * 1024, mem__lte=32 * 1024 * 1024).count()
    mem_32_64 = job_list.filter(mem__gt=32 * 1024 * 1024, mem__lte=64 * 1024 * 1024).count()
    mem_64_128 = job_list.filter(mem__gt=64 * 1024 * 1024, mem__lte=128 * 1024 * 1024).count()
    mem_128 = job_list.filter(mem__gt=128 * 1024 * 1024).count()

    data = [mem_0_4, mem_4_8, mem_8_16, mem_16_32, mem_32_64, mem_64_128, mem_128]
    total = sum(data)
    x_labels = ['0-4', '4-8', '8-16', '16-32', '32-64', '64-128', '128+']
    labels = []
    max_y = max(data)
    data = {'Total jobs': data}
    g = GraphGenerator()
    graph = g.bar_chart(data, x_labels, max_y, bar_width=50).get_url()

    return render_to_response('usage/mem_report.html', locals(), context_instance=RequestContext(request))
Exemplo n.º 2
0
def core_report(request, machine_category_id=settings.DEFAULT_MC):

    machine_category = get_object_or_404(MachineCategory, pk=machine_category_id)
    
    start, end = get_date_range(request)

    job_list = CPUJob.objects.filter(date__gte=start, date__lte=end, machine__category=machine_category)
    core_1 = job_list.filter(cores=1).count()
    core_2_4 = job_list.filter(cores__gte=2, cores__lte=4).count()
    core_5_8 = job_list.filter(cores__gte=5, cores__lte=8).count()
    core_9_16 = job_list.filter(cores__gte=9, cores__lte=16).count()
    core_17_32 = job_list.filter(cores__gte=17, cores__lte=32).count()
    core_33_64 = job_list.filter(cores__gte=33, cores__lte=64).count()
    core_65_128 = job_list.filter(cores__gte=65, cores__lte=128).count()
    core_128 = job_list.filter(cores__gte=128).count()
    data = [core_1, core_2_4, core_5_8, core_9_16, core_17_32, core_33_64, core_65_128, core_128]
    total = sum(data)

    x_labels = ['1', '2-4', '5-8', '9-16', '17-32', '33-64', '65-128', '128+']
    max_y = max(data)
    data = {'Total jobs': data}
    g = GraphGenerator()
    graph = g.bar_chart(data, x_labels, max_y, bar_width=50).get_url()

    return render_to_response('usage/core_report.html', locals(), context_instance=RequestContext(request))