mirror of https://github.com/jumpserver/jumpserver
日志回放OK
parent
a1862d912a
commit
8e8d8c9d6a
|
@ -1,8 +1,7 @@
|
||||||
# coding:utf-8
|
# coding:utf-8
|
||||||
from django.db.models import Q
|
from django.db.models import Q
|
||||||
from django.template import RequestContext
|
from django.template import RequestContext
|
||||||
from django.shortcuts import render_to_response
|
from django.shortcuts import render_to_response, render
|
||||||
|
|
||||||
from jumpserver.api import *
|
from jumpserver.api import *
|
||||||
from jperm.perm_api import user_have_perm
|
from jperm.perm_api import user_have_perm
|
||||||
from django.http import HttpResponseNotFound
|
from django.http import HttpResponseNotFound
|
||||||
|
@ -114,20 +113,36 @@ def log_history(request):
|
||||||
return HttpResponse('无日志记录!')
|
return HttpResponse('无日志记录!')
|
||||||
|
|
||||||
|
|
||||||
|
# @require_role('admin')
|
||||||
|
# def log_record(request):
|
||||||
|
# log_id = request.GET.get('id', 0)
|
||||||
|
# log = Log.objects.filter(id=int(log_id))
|
||||||
|
# if log:
|
||||||
|
# log = log[0]
|
||||||
|
# log_file = log.log_path + '.log'
|
||||||
|
# log_time = log.log_path + '.time'
|
||||||
|
# if os.path.isfile(log_file) and os.path.isfile(log_time):
|
||||||
|
# content = renderTemplate(log_file, log_time)
|
||||||
|
# return HttpResponse(content)
|
||||||
|
# else:
|
||||||
|
# return HttpResponse('无日志记录!')
|
||||||
@require_role('admin')
|
@require_role('admin')
|
||||||
def log_record(request):
|
def log_record(request):
|
||||||
log_id = request.GET.get('id', 0)
|
"""
|
||||||
log = Log.objects.filter(id=int(log_id))
|
Author: liuzheng712@gmail.com
|
||||||
if log:
|
"""
|
||||||
log = log[0]
|
if request.method == "GET":
|
||||||
log_file = log.log_path + '.log'
|
return render(request, 'jlog/record.html')
|
||||||
log_time = log.log_path + '.time'
|
elif request.method == "POST":
|
||||||
if os.path.isfile(log_file) and os.path.isfile(log_time):
|
log_id = request.REQUEST.get('id', None)
|
||||||
content = renderTemplate(log_file, log_time)
|
if log_id:
|
||||||
return HttpResponse(content)
|
logs = TermLogRecorder(request.user)
|
||||||
|
log = TermLog.objects.get(id=int(log_id))
|
||||||
|
return HttpResponse(logs.load_full_log(log.filename))
|
||||||
else:
|
else:
|
||||||
return HttpResponse('无日志记录!')
|
return HttpResponse("ERROR")
|
||||||
|
else:
|
||||||
|
return HttpResponse("ERROR METHOD!")
|
||||||
|
|
||||||
@require_role('admin')
|
@require_role('admin')
|
||||||
def log_detail(request, offset):
|
def log_detail(request, offset):
|
||||||
|
|
|
@ -99,23 +99,23 @@ WSGI_APPLICATION = 'jumpserver.wsgi.application'
|
||||||
# Database
|
# Database
|
||||||
# https://docs.djangoproject.com/en/1.7/ref/settings/#databases
|
# https://docs.djangoproject.com/en/1.7/ref/settings/#databases
|
||||||
|
|
||||||
# DATABASES = {
|
|
||||||
# 'default': {
|
|
||||||
# 'ENGINE': 'django.db.backends.mysql',
|
|
||||||
# 'NAME': DB_DATABASE,
|
|
||||||
# 'USER': DB_USER,
|
|
||||||
# 'PASSWORD': DB_PASSWORD,
|
|
||||||
# 'HOST': DB_HOST,
|
|
||||||
# 'PORT': DB_PORT,
|
|
||||||
# }
|
|
||||||
# }
|
|
||||||
|
|
||||||
DATABASES = {
|
DATABASES = {
|
||||||
'default': {
|
'default': {
|
||||||
'ENGINE': 'django.db.backends.sqlite3',
|
'ENGINE': 'django.db.backends.mysql',
|
||||||
'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
|
'NAME': DB_DATABASE,
|
||||||
|
'USER': DB_USER,
|
||||||
|
'PASSWORD': DB_PASSWORD,
|
||||||
|
'HOST': DB_HOST,
|
||||||
|
'PORT': DB_PORT,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# DATABASES = {
|
||||||
|
# 'default': {
|
||||||
|
# 'ENGINE': 'django.db.backends.sqlite3',
|
||||||
|
# 'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
|
||||||
|
# }
|
||||||
|
# }
|
||||||
TEMPLATE_CONTEXT_PROCESSORS = (
|
TEMPLATE_CONTEXT_PROCESSORS = (
|
||||||
'django.contrib.auth.context_processors.auth',
|
'django.contrib.auth.context_processors.auth',
|
||||||
'django.core.context_processors.debug',
|
'django.core.context_processors.debug',
|
||||||
|
|
|
@ -22,7 +22,7 @@ import tornado.httpclient
|
||||||
from tornado.websocket import WebSocketClosedError
|
from tornado.websocket import WebSocketClosedError
|
||||||
|
|
||||||
from tornado.options import define, options
|
from tornado.options import define, options
|
||||||
# from pyinotify import WatchManager, ProcessEvent, IN_DELETE, IN_CREATE, IN_MODIFY, AsyncNotifier
|
from pyinotify import WatchManager, ProcessEvent, IN_DELETE, IN_CREATE, IN_MODIFY, AsyncNotifier
|
||||||
import select
|
import select
|
||||||
|
|
||||||
from connect import Tty, User, Asset, PermRole, logger, get_object, gen_resource
|
from connect import Tty, User, Asset, PermRole, logger, get_object, gen_resource
|
||||||
|
@ -101,12 +101,12 @@ class MyThread(threading.Thread):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
# class EventHandler(ProcessEvent):
|
class EventHandler(ProcessEvent):
|
||||||
# def __init__(self, client=None):
|
def __init__(self, client=None):
|
||||||
# self.client = client
|
self.client = client
|
||||||
#
|
|
||||||
# def process_IN_MODIFY(self, event):
|
def process_IN_MODIFY(self, event):
|
||||||
# self.client.write_message(f.read())
|
self.client.write_message(f.read())
|
||||||
|
|
||||||
|
|
||||||
def file_monitor(path='.', client=None):
|
def file_monitor(path='.', client=None):
|
||||||
|
|
Loading…
Reference in New Issue