2015-01-25 14:20:07 +00:00
|
|
|
# coding:utf-8
|
|
|
|
import os
|
|
|
|
import ConfigParser
|
|
|
|
from datetime import datetime
|
|
|
|
from django.http import HttpResponseRedirect
|
|
|
|
from django.template import RequestContext
|
|
|
|
from django.shortcuts import render_to_response
|
|
|
|
from django.core.paginator import Paginator, EmptyPage
|
2014-12-26 13:57:10 +00:00
|
|
|
|
2015-01-25 14:20:07 +00:00
|
|
|
from connect import BASE_DIR
|
|
|
|
from jlog.models import Log
|
|
|
|
|
|
|
|
CONF = ConfigParser.ConfigParser()
|
|
|
|
CONF.read('%s/jumpserver.conf' % BASE_DIR)
|
|
|
|
|
2015-02-01 15:00:23 +00:00
|
|
|
|
|
|
|
def jlog_list(request, offset='online'):
|
2015-01-25 14:20:07 +00:00
|
|
|
header_title, path1, path2 = u'查看日志 | Log List.', u'查看日志', u'日志列表'
|
2015-02-01 15:00:23 +00:00
|
|
|
web_socket_host = CONF.get('websocket', 'web_socket_host')
|
2015-01-25 14:20:07 +00:00
|
|
|
online = Log.objects.filter(is_finished=0)
|
|
|
|
offline = Log.objects.filter(is_finished=1)
|
2015-02-01 15:00:23 +00:00
|
|
|
|
|
|
|
return render_to_response('jlog/log_list.html', locals())
|
2015-01-25 14:20:07 +00:00
|
|
|
|
|
|
|
|
|
|
|
def jlog_kill(request, offset):
|
|
|
|
pid = offset
|
|
|
|
if pid:
|
|
|
|
os.kill(int(pid), 9)
|
|
|
|
Log.objects.filter(pid=pid).update(is_finished=1, end_time=datetime.now())
|
2015-02-01 15:00:23 +00:00
|
|
|
return HttpResponseRedirect('jlog/log_list.html', locals())
|