mirror of https://github.com/jumpserver/jumpserver
日志汇总查看
parent
654c27490d
commit
08c30e462c
|
@ -19,6 +19,8 @@ import pxssh
|
|||
import pexpect
|
||||
|
||||
cur_dir = os.path.dirname(__file__)
|
||||
if not cur_dir:
|
||||
cur_dir = "./"
|
||||
sys.path.append('%s/webroot/AutoSa/' % cur_dir)
|
||||
os.environ['DJANGO_SETTINGS_MODULE'] = 'AutoSa.settings'
|
||||
|
||||
|
|
|
@ -32,4 +32,5 @@ urlpatterns = patterns('',
|
|||
(r'^upFile/$', views.upFile),
|
||||
(r'^downFile/$', views.downFile),
|
||||
(r'^logView/$', views.logView),
|
||||
(r'^logHistory/$', views.logHistory),
|
||||
)
|
||||
|
|
|
@ -976,6 +976,23 @@ def logView(request):
|
|||
context_instance=RequestContext(request))
|
||||
|
||||
|
||||
@admin_required
|
||||
def logHistory(request):
|
||||
if request.method == 'GET':
|
||||
logid = request.GET.get('id', 0)
|
||||
log = Logs.objects.filter(id=int(logid))
|
||||
if log:
|
||||
log = log[0]
|
||||
log_his = "%s.his" % log.filename
|
||||
if os.path.isfile(log_his):
|
||||
f = open(log_his)
|
||||
content = f.read()
|
||||
return render_to_response(content)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -17,9 +17,12 @@ def log_hanler(logid):
|
|||
if log:
|
||||
log = log[0]
|
||||
filename = log.logfile
|
||||
os.system('cat %s | grep "DateTime" > %s.his' % (filename, filename))
|
||||
os.system('cat %s | grep "\[.*@.*\][\$\#]" >> %s.his' % (filename, filename))
|
||||
os.system('cat %s | grep "EndTime" >> %s.his' % (filename, filename))
|
||||
ret1 = os.system('cat %s | grep "DateTime" > %s.his' % (filename, filename))
|
||||
ret2 = os.system('cat %s | grep "\[.*@.*\][\$\#]" >> %s.his' % (filename, filename))
|
||||
ret3 = os.system('cat %s | grep "EndTime" >> %s.his' % (filename, filename))
|
||||
if (ret1 + ret2 + ret3) == 0:
|
||||
print 'Handler % ok.' % filename
|
||||
|
||||
|
||||
|
||||
def set_finish(id):
|
||||
|
|
|
@ -0,0 +1,18 @@
|
|||
{% extends 'base.html' %}
|
||||
{% block content %}
|
||||
|
||||
<div id="myModal" class="modal hide fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
|
||||
<div class="modal-header">
|
||||
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
|
||||
<h3 id="myModalLabel">日志汇总</h3>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<p>弹出层…</p>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button class="btn" data-dismiss="modal" aria-hidden="true">Close</button>
|
||||
<button class="btn btn-primary">Save changes</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{% end block %}
|
|
@ -23,7 +23,7 @@
|
|||
<td>{{ log.user }}</td>
|
||||
<td>{{ log.host }}</td>
|
||||
<td><a href="#">监控</a></td>
|
||||
<td><a href="#">命令统计</a></td>
|
||||
<td><a href="/logHistory/?id={{ log.id }}">命令统计</a></td>
|
||||
<td><a href="#">阻断</a> </td>
|
||||
<td>{{ log.start_time|stamp2str }}</td>
|
||||
<td>{{ log.end_time|stamp2str }}</td>
|
||||
|
|
Loading…
Reference in New Issue