mirror of https://github.com/jumpserver/jumpserver
bugs
parent
78dc6e5154
commit
9e1dd270ae
|
@ -3,6 +3,7 @@
|
|||
import socket
|
||||
import sys
|
||||
import os
|
||||
import ast
|
||||
import select
|
||||
import time
|
||||
from datetime import datetime
|
||||
|
@ -103,6 +104,12 @@ def log_record(username, host):
|
|||
log_filename = '%s_%s_%s.log' % (username, host, time_now)
|
||||
log_file_path = os.path.join(today_connect_log_dir, log_filename)
|
||||
pid = os.getpid()
|
||||
ip_list = []
|
||||
remote_ip = os.popen("who |grep `ps aux |gawk '{if ($2==%s) print $1}'` |gawk '{print $5}'|tr -d '()'" % pid).readlines()
|
||||
for ip in remote_ip:
|
||||
ip_list.append(ip.strip('\n'))
|
||||
print ip_list
|
||||
ip_list = list(set(ip_list))
|
||||
|
||||
if not os.path.isdir(today_connect_log_dir):
|
||||
try:
|
||||
|
@ -116,7 +123,7 @@ def log_record(username, host):
|
|||
except IOError:
|
||||
raise ServerError('Create logfile failed, Please modify %s permission.' % today_connect_log_dir)
|
||||
|
||||
log = Log(user=username, host=host, log_path=log_file_path, start_time=datetime.now(), pid=pid)
|
||||
log = Log(user=username, host=host, remote_ip=ip_list, log_path=log_file_path, start_time=datetime.now(), pid=pid)
|
||||
log_file.write('Starttime is %s\n' % datetime.now())
|
||||
log.save()
|
||||
return log_file, log
|
||||
|
|
|
@ -37,7 +37,6 @@ def f_add_host(ip, port, idc, jtype, group, dept, active, comment, username='',
|
|||
comment=comment)
|
||||
a.save()
|
||||
|
||||
jasset_group_add(ip, ip, 'P')
|
||||
all_group = BisGroup.objects.get(name='ALL')
|
||||
private_group = BisGroup.objects.get(name=ip.strip())
|
||||
for g in group:
|
||||
|
@ -45,9 +44,7 @@ def f_add_host(ip, port, idc, jtype, group, dept, active, comment, username='',
|
|||
groups.append(c)
|
||||
groups.extend([all_group, private_group])
|
||||
|
||||
print dept
|
||||
for d in dept:
|
||||
print d
|
||||
p = DEPT.objects.get(name=d)
|
||||
depts.append(p)
|
||||
|
||||
|
@ -61,7 +58,7 @@ def add_host(request):
|
|||
header_title, path1, path2 = u'添加主机', u'资产管理', u'添加主机'
|
||||
eidc = IDC.objects.all()
|
||||
edept = DEPT.objects.all()
|
||||
egroup = BisGroup.objects.filter(type='A')
|
||||
egroup = BisGroup.objects.all()
|
||||
eusergroup = UserGroup.objects.all()
|
||||
|
||||
if request.method == 'POST':
|
||||
|
@ -197,7 +194,7 @@ def host_edit(request):
|
|||
header_title, path1, path2 = u'修改主机', u'资产管理', u'修改主机'
|
||||
groups, e_group, e_dept, depts = [], [], [], []
|
||||
eidc = IDC.objects.all()
|
||||
egroup = BisGroup.objects.filter(type='A')
|
||||
egroup = BisGroup.objects.all()
|
||||
edept = DEPT.objects.all()
|
||||
offset = request.GET.get('id')
|
||||
for g in Asset.objects.get(id=int(offset)).bis_group.all():
|
||||
|
|
|
@ -4,6 +4,7 @@ from django.db import models
|
|||
class Log(models.Model):
|
||||
user = models.CharField(max_length=20, null=True)
|
||||
host = models.CharField(max_length=20, null=True)
|
||||
remote_ip = models.CharField(max_length=100)
|
||||
log_path = models.CharField(max_length=100)
|
||||
start_time = models.DateTimeField(null=True)
|
||||
pid = models.IntegerField(max_length=10)
|
||||
|
|
|
@ -5,6 +5,7 @@ from datetime import datetime
|
|||
|
||||
from django.db.models import Q
|
||||
from django.http import HttpResponse
|
||||
from django.template import RequestContext
|
||||
from django.http import HttpResponseRedirect
|
||||
from django.shortcuts import render_to_response
|
||||
|
||||
|
@ -28,7 +29,7 @@ def log_list_online(request):
|
|||
posts = Log.objects.filter(is_finished=0).order_by('-start_time')
|
||||
contact_list, p, contacts, page_range, current_page, show_first, show_end = pages(posts, request)
|
||||
|
||||
return render_to_response('jlog/log_online.html', locals())
|
||||
return render_to_response('jlog/log_online.html', locals(), context_instance=RequestContext(request))
|
||||
|
||||
|
||||
def log_list_offline(request):
|
||||
|
@ -43,7 +44,7 @@ def log_list_offline(request):
|
|||
posts = Log.objects.filter(is_finished=1).order_by('-start_time')
|
||||
contact_list, p, contacts, page_range, current_page, show_first, show_end = pages(posts, request)
|
||||
|
||||
return render_to_response('jlog/log_offline.html', locals())
|
||||
return render_to_response('jlog/log_offline.html', locals(), context_instance=RequestContext(request))
|
||||
|
||||
|
||||
def log_kill(request, offset):
|
||||
|
@ -51,7 +52,7 @@ def log_kill(request, offset):
|
|||
if pid:
|
||||
os.kill(int(pid), 9)
|
||||
Log.objects.filter(pid=pid).update(is_finished=1, end_time=datetime.now())
|
||||
return HttpResponseRedirect('jlog/log_offline.html', locals())
|
||||
return HttpResponseRedirect('jlog/log_offline.html', locals(), context_instance=RequestContext(request))
|
||||
|
||||
|
||||
def log_history(request):
|
||||
|
@ -78,4 +79,4 @@ def log_search(request):
|
|||
.filter(is_finished=1).order_by('-start_time')
|
||||
contact_list, p, contacts, page_range, current_page, show_first, show_end = pages(posts, request)
|
||||
|
||||
return render_to_response('jlog/log_search.html', locals())
|
||||
return render_to_response('jlog/log_search.html', locals(), context_instance=RequestContext(request))
|
||||
|
|
|
@ -8,11 +8,11 @@ password = mysql234
|
|||
database = jumpserver
|
||||
|
||||
[ldap]
|
||||
ldap_enable = 0
|
||||
host_url = ldap://127.0.0.1:389
|
||||
base_dn = dc=jumpserver, dc=org
|
||||
root_dn = cn=admin,dc=jumpserver,dc=org
|
||||
root_pw = secret234
|
||||
ldap_enable = 1
|
||||
host_url = ldap://192.168.8.230:389
|
||||
base_dn = dc=fengxing, dc=com
|
||||
root_dn = cn=admin,dc=fengxing,dc=com
|
||||
root_pw = 123456
|
||||
|
||||
[websocket]
|
||||
web_socket_host = 127.0.0.1:3000
|
||||
|
|
|
@ -145,9 +145,9 @@
|
|||
var regx = /\x1B\[([0-9]{1,3}((;[0-9]{1,3})*)?)?[m|K]/g;
|
||||
// tag.append('<p>'+escapeString(obj.content.replace(regx,''))+'</p>');
|
||||
if (option == 'new') {
|
||||
tag.append('<p>' + escapeString(obj.content) + '</p>');
|
||||
tag.append('<p style="margin: 2px">' + escapeString(obj.content) + '</p>');
|
||||
} else if (option == 'exist') {
|
||||
tag.append('<p>' + exsit_message + '</p>');
|
||||
tag.append('<p style="margin: 0">' + exsit_message + '</p>');
|
||||
}
|
||||
tag.animate({ scrollTop: tag[0].scrollHeight}, 1);
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue