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
d134b227
Commit
d134b227
authored
Nov 06, 2014
by
guanghongwei
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修改 monitor
parent
f3efa9b9
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
19 additions
and
17 deletions
+19
-17
jumpserver.py
jumpserver.py
+10
-14
log_handler.py
webroot/AutoSa/log_handler.py
+2
-1
addUser.html
webroot/AutoSa/templates/addUser.html
+6
-0
logView.html
webroot/AutoSa/templates/logView.html
+1
-1
showUser.html
webroot/AutoSa/templates/showUser.html
+0
-1
No files found.
jumpserver.py
View file @
d134b227
...
...
@@ -24,6 +24,8 @@ if not cur_dir:
sys
.
path
.
append
(
'
%
s/webroot/AutoSa/'
%
cur_dir
)
os
.
environ
[
'DJANGO_SETTINGS_MODULE'
]
=
'AutoSa.settings'
import
django
django
.
setup
()
from
UserManage.models
import
User
,
Logs
,
Pid
from
Assets.models
import
Assets
...
...
@@ -88,18 +90,6 @@ def getwinsize():
return
struct
.
unpack
(
'HHHH'
,
x
)[
0
:
2
]
# def connect_db(user, passwd, db, host='127.0.0.1', port=3306):
# """This function connect db and return db and cursor"""
# db = MySQLdb.connect(host=host,
# port=port,
# user=user,
# passwd=passwd,
# db=db,
# charset='utf8')
# cursor = db.cursor()
# return db, cursor
def
run_cmd
(
cmd
):
"""run command and return stdout"""
pipe
=
subprocess
.
Popen
(
cmd
,
...
...
@@ -120,8 +110,7 @@ def connect(host, port, user, password):
"""Use pexpect module to connect other server."""
log_date_dir
=
'
%
s/
%
s'
%
(
log_dir
,
time
.
strftime
(
'
%
Y
%
m
%
d'
))
if
not
os
.
path
.
isdir
(
log_date_dir
):
os
.
mkdir
(
log_date_dir
)
os
.
chmod
(
log_date_dir
,
0777
)
os
.
mkdir
(
log_date_dir
,
0777
)
structtime_start
=
time
.
localtime
()
datetime_start
=
time
.
strftime
(
'
%
Y
%
m
%
d
%
H
%
M
%
S'
,
structtime_start
)
logtime_start
=
time
.
strftime
(
'
%
Y/
%
m/
%
d
%
H:
%
M:
%
S'
,
structtime_start
)
...
...
@@ -259,6 +248,13 @@ def exec_cmd_servers(username):
cmd
=
raw_input
(
'
\033
[1;32mCmd(s):
\033
[0m'
)
if
cmd
in
[
'q'
,
'Q'
]:
break
if
not
os
.
path
.
isdir
():
exec_log_dir
=
os
.
path
.
join
(
log_dir
,
'exec_cmds'
)
os
.
mkdir
(
exec_log_dir
,
0777
)
filename
=
"
%
s/
%
s.log"
%
(
exec_log_dir
,
time
.
strftime
(
'
%
Y
%
m
%
d'
))
f
=
open
(
filename
,
'a'
)
f
.
write
(
"DateTime:
%
s User:
%
s Host:
%
s Cmds:
%
s"
%
(
time
.
strftime
(
'
%
Y/
%
m/
%
d
%
H:
%
M:
%
S'
),
username
,
hosts
,
cmd
))
for
host
in
hosts
:
remote_exec_cmd
(
host
,
username
,
cmd
)
...
...
webroot/AutoSa/log_handler.py
View file @
d134b227
...
...
@@ -9,6 +9,8 @@ cur_dir = os.path.dirname(__file__)
sys
.
path
.
append
(
'
%
s/webroot/AutoSa/'
%
cur_dir
)
os
.
environ
[
'DJANGO_SETTINGS_MODULE'
]
=
'AutoSa.settings'
import
django
django
.
setup
()
from
UserManage.models
import
Logs
,
Pid
...
...
@@ -24,7 +26,6 @@ def log_hanler(logid):
print
'Handler
%
ok.'
%
filename
def
set_finish
(
id
):
logs
=
Logs
.
objects
.
filter
(
id
=
id
,
finish
=
0
)
if
logs
:
...
...
webroot/AutoSa/templates/addUser.html
View file @
d134b227
...
...
@@ -68,6 +68,12 @@
<div
class=
"col-sm-4"
>
{{ form.group }}
</div>
<div
class=
"col-sm-4"
>
<a
href=
"/addGroup/"
>
添加属组
</a>
</div>
<div
class=
"col-sm-4"
>
<a
href=
"/showGroup/"
>
删除属组
</a>
</div>
</div>
<div
class=
"form-group"
>
{{ form.is_admin.errors }}
...
...
webroot/AutoSa/templates/logView.html
View file @
d134b227
...
...
@@ -27,7 +27,7 @@
<td><a
href=
"/logHistory/?id={{ log.id }}"
class=
"log_command"
>
命令统计
</a></td>
<td>
阻断
</td>
{% else %}
<td><
a
href=
"#"
>
监控
</a
></td>
<td><
span
class=
'monitor'
filename=
"{{ log_name }}"
>
监控
</span
></td>
<td>
命令统计
</td>
<td><a
href=
"/killSession/?id={{ log.id }}"
>
阻断
</a>
</td>
{% endif %}
...
...
webroot/AutoSa/templates/showUser.html
View file @
d134b227
...
...
@@ -30,7 +30,6 @@
<td>
{{ user.id }}
</td>
<td>
{{ user.username }}
</td>
<td>
{{ user.name }}
</td>
<!--<td>{{ user.group }}</td>-->
<td>
{% for group in user.group.all %}
{{ group.name }}
...
...
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