Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
J
jumpserver
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
ops
jumpserver
Commits
8e8d8c9d
Commit
8e8d8c9d
authored
Mar 25, 2016
by
liuzheng712
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
日志回放OK
parent
a1862d91
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
48 additions
and
33 deletions
+48
-33
views.py
jlog/views.py
+28
-13
settings.py
jumpserver/settings.py
+13
-13
run_server.py
run_server.py
+7
-7
No files found.
jlog/views.py
View file @
8e8d8c9d
# 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
):
...
...
jumpserver/settings.py
View file @
8e8d8c9d
...
...
@@ -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'
,
...
...
run_server.py
View file @
8e8d8c9d
...
...
@@ -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
):
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment