mirror of https://github.com/jumpserver/jumpserver
日志回放OK
parent
a1862d912a
commit
8e8d8c9d6a
|
@ -1,8 +1,7 @@
|
|||
# coding:utf-8
|
||||
from django.db.models import Q
|
||||
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 jperm.perm_api import user_have_perm
|
||||
from django.http import HttpResponseNotFound
|
||||
|
@ -114,20 +113,36 @@ def log_history(request):
|
|||
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')
|
||||
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)
|
||||
"""
|
||||
Author: liuzheng712@gmail.com
|
||||
"""
|
||||
if request.method == "GET":
|
||||
return render(request, 'jlog/record.html')
|
||||
elif request.method == "POST":
|
||||
log_id = request.REQUEST.get('id', None)
|
||||
if log_id:
|
||||
logs = TermLogRecorder(request.user)
|
||||
log = TermLog.objects.get(id=int(log_id))
|
||||
return HttpResponse(logs.load_full_log(log.filename))
|
||||
else:
|
||||
return HttpResponse('无日志记录!')
|
||||
|
||||
return HttpResponse("ERROR")
|
||||
else:
|
||||
return HttpResponse("ERROR METHOD!")
|
||||
|
||||
@require_role('admin')
|
||||
def log_detail(request, offset):
|
||||
|
|
|
@ -99,23 +99,23 @@ WSGI_APPLICATION = 'jumpserver.wsgi.application'
|
|||
# Database
|
||||
# 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 = {
|
||||
'default': {
|
||||
'ENGINE': 'django.db.backends.sqlite3',
|
||||
'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
|
||||
'ENGINE': 'django.db.backends.mysql',
|
||||
'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 = (
|
||||
'django.contrib.auth.context_processors.auth',
|
||||
'django.core.context_processors.debug',
|
||||
|
|
|
@ -22,7 +22,7 @@ import tornado.httpclient
|
|||
from tornado.websocket import WebSocketClosedError
|
||||
|
||||
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
|
||||
|
||||
from connect import Tty, User, Asset, PermRole, logger, get_object, gen_resource
|
||||
|
@ -101,12 +101,12 @@ class MyThread(threading.Thread):
|
|||
pass
|
||||
|
||||
|
||||
# class EventHandler(ProcessEvent):
|
||||
# def __init__(self, client=None):
|
||||
# self.client = client
|
||||
#
|
||||
# def process_IN_MODIFY(self, event):
|
||||
# self.client.write_message(f.read())
|
||||
class EventHandler(ProcessEvent):
|
||||
def __init__(self, client=None):
|
||||
self.client = client
|
||||
|
||||
def process_IN_MODIFY(self, event):
|
||||
self.client.write_message(f.read())
|
||||
|
||||
|
||||
def file_monitor(path='.', client=None):
|
||||
|
|
Loading…
Reference in New Issue