예제 #1
0
파일: views.py 프로젝트: antineutron/baruwa
def index(request):
    "displays the status"
    addrs = []
    act = 3

    if not request.user.is_superuser:
        addrs = request.session["user_filter"]["addresses"]
        act = request.session["user_filter"]["account_type"]

    data = MessageStats.objects.get(request.user, addrs, act)

    val1, val2, val3 = os.getloadavg()
    load = "%.2f %.2f %.2f" % (val1, val2, val3)

    scanners = get_processes("MailScanner")
    mas = get_config_option("MTA")
    mta = get_processes(mas)
    clamd = get_processes("clamd")

    pipe1 = subprocess.Popen("uptime", shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
    upt = pipe1.stdout.read().split()
    uptime = upt[2] + " " + upt[3].rstrip(",")

    return render_to_response(
        "status/index.html",
        {"data": data, "load": load, "scanners": scanners, "mta": mta, "av": clamd, "uptime": uptime},
        context_instance=RequestContext(request),
    )
예제 #2
0
def index(request):
    "displays the status"
    addrs = []
    act = 3

    inq = MailQueueItem.objects.filter(direction=1)
    outq = MailQueueItem.objects.filter(direction=2)

    if not request.user.is_superuser:
        addrs = request.session['user_filter']['addresses']
        act = request.session['user_filter']['account_type']
        if act == 2:
            query = Q()
            for addr in addrs:
                atdomain = "@%s" % addr
                query = query | Q(
                    Q(**{'from_address__iendswith': atdomain})
                    | Q(**{'to_address__iendswith': atdomain}))
            inq = inq.filter(query)
            outq = outq.filter(query)
        if act == 3:
            inq = inq.filter(
                Q(from_address__in=addrs) | Q(to_address__in=addrs))
            outq = outq.filter(
                Q(from_address__in=addrs) | Q(to_address__in=addrs))

    data = MessageStats.objects.get(request.user, addrs, act)
    inq = inq.aggregate(count=Count('messageid'))
    outq = outq.aggregate(count=Count('messageid'))

    val1, val2, val3 = os.getloadavg()
    load = "%.2f %.2f %.2f" % (val1, val2, val3)

    scanners = get_processes('MailScanner')
    mas = get_config_option('MTA')
    mta = get_processes(mas)
    clamd = get_processes('clamd')

    pipe1 = subprocess.Popen(['uptime'],
                             stdout=subprocess.PIPE,
                             stderr=subprocess.PIPE)
    upt = pipe1.communicate()[0].split()
    uptime = upt[2] + ' ' + upt[3].rstrip(',')

    return render_to_response('mail/status/index.html', {
        'data': data,
        'load': load,
        'scanners': scanners,
        'mta': mta,
        'av': clamd,
        'uptime': uptime,
        'outq': outq['count'],
        'inq': inq['count']
    },
                              context_instance=RequestContext(request))
예제 #3
0
파일: views.py 프로젝트: sandroden/baruwa
def index(request):
    "displays the status"
    addrs = []
    act = 3

    inq = MailQueueItem.objects.filter(direction=1)
    outq = MailQueueItem.objects.filter(direction=2)

    if not request.user.is_superuser:
        addrs = request.session['user_filter']['addresses']
        act = request.session['user_filter']['account_type']
        if act == 2:
            query = Q()
            for addr in addrs:
                atdomain = "@%s" % addr
                query = query | Q(Q(**{'from_address__iendswith': atdomain}) | 
                                Q(**{'to_address__iendswith': atdomain}))
            inq = inq.filter(query)
            outq = outq.filter(query)
        if act == 3:
            inq = inq.filter(Q(from_address__in=addrs) | 
                                Q(to_address__in=addrs))
            outq = outq.filter(Q(from_address__in=addrs) | 
                                Q(to_address__in=addrs))

    data = MessageStats.objects.get(request.user, addrs, act)
    inq = inq.aggregate(count=Count('messageid'))
    outq = outq.aggregate(count=Count('messageid'))

    val1, val2, val3 = os.getloadavg()
    load = "%.2f %.2f %.2f" % (val1, val2, val3)

    scanners = get_processes('MailScanner')
    mas = get_config_option('MTA')
    mta = get_processes(mas)
    clamd = get_processes('clamd')

    pipe1 = subprocess.Popen(
        'uptime', shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE
        )
    upt = pipe1.stdout.read().split()
    uptime = upt[2] + ' ' + upt[3].rstrip(',')

    return render_to_response('status/index.html', {'data': data, 'load': load,
        'scanners': scanners, 'mta': mta, 'av': clamd, 'uptime': uptime, 
        'outq': outq['count'], 'inq': inq['count']}, 
        context_instance=RequestContext(request))