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
e5121fe7
Commit
e5121fe7
authored
Nov 02, 2014
by
ibuler
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
记录 子pid
parent
ac926b5f
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
15 additions
and
11 deletions
+15
-11
jumpserver.py
jumpserver.py
+9
-8
models.py
webroot/AutoSa/UserManage/models.py
+6
-3
No files found.
jumpserver.py
View file @
e5121fe7
...
@@ -124,19 +124,22 @@ def connect(host, port, user, password):
...
@@ -124,19 +124,22 @@ def connect(host, port, user, password):
logtime_start
=
time
.
strftime
(
'
%
Y/
%
m/
%
d
%
H:
%
M:
%
S'
,
structtime_start
)
logtime_start
=
time
.
strftime
(
'
%
Y/
%
m/
%
d
%
H:
%
M:
%
S'
,
structtime_start
)
timestamp_start
=
int
(
time
.
mktime
(
structtime_start
))
timestamp_start
=
int
(
time
.
mktime
(
structtime_start
))
logfile_name
=
"
%
s/
%
s_
%
s_
%
s"
%
(
log_date_dir
,
host
,
user
,
datetime_start
)
logfile_name
=
"
%
s/
%
s_
%
s_
%
s"
%
(
log_date_dir
,
host
,
user
,
datetime_start
)
logfile
=
open
(
logfile_name
,
'a'
)
log
=
Logs
(
user
=
user
,
host
=
host
,
logfile
=
logfile_name
,
start_time
=
timestamp_start
)
log
.
save
()
logfile
.
write
(
'
\n
%
s
\n
'
%
logtime_start
)
try
:
try
:
global
foo
global
foo
foo
=
pxssh
.
pxssh
()
foo
=
pxssh
.
pxssh
()
foo
.
login
(
host
,
user
,
password
,
port
=
port
,
auto_prompt_reset
=
False
)
foo
.
login
(
host
,
user
,
password
,
port
=
port
,
auto_prompt_reset
=
False
)
log
=
Logs
(
user
=
user
,
host
=
host
,
logfile
=
logfile_name
,
start_time
=
timestamp_start
)
# 日志信息记录到数据库
log
.
save
()
pid
=
Pid
(
ppid
=
os
.
getpid
(),
cpid
=
foo
.
pid
)
pid
.
save
()
logfile
=
open
(
logfile_name
,
'a'
)
# 记录日志文件
logfile
.
write
(
'
\n
%
s
\n
'
%
logtime_start
)
foo
.
logfile
=
logfile
foo
.
logfile
=
logfile
foo
.
sendline
(
''
)
foo
.
sendline
(
''
)
signal
.
signal
(
signal
.
SIGWINCH
,
sigwinch_passthrough
)
signal
.
signal
(
signal
.
SIGWINCH
,
sigwinch_passthrough
)
pid
=
Pid
(
pid
=
os
.
getpid
())
pid
.
save
()
foo
.
interact
(
escape_character
=
chr
(
28
))
foo
.
interact
(
escape_character
=
chr
(
28
))
logfile
.
write
(
'
\n
%
s'
%
time
.
strftime
(
'
%
Y/
%
m/
%
d
%
H:
%
M:
%
S'
))
logfile
.
write
(
'
\n
%
s'
%
time
.
strftime
(
'
%
Y/
%
m/
%
d
%
H:
%
M:
%
S'
))
log
.
finish
=
1
log
.
finish
=
1
...
@@ -144,8 +147,6 @@ def connect(host, port, user, password):
...
@@ -144,8 +147,6 @@ def connect(host, port, user, password):
log
.
save
()
log
.
save
()
except
pxssh
.
ExceptionPxssh
as
e
:
except
pxssh
.
ExceptionPxssh
as
e
:
print
(
'登录失败:
%
s'
%
e
)
print
(
'登录失败:
%
s'
%
e
)
log
.
finish
=
2
log
.
save
()
except
KeyboardInterrupt
:
except
KeyboardInterrupt
:
foo
.
logout
()
foo
.
logout
()
log
.
finish
=
1
log
.
finish
=
1
...
...
webroot/AutoSa/UserManage/models.py
View file @
e5121fe7
...
@@ -36,7 +36,10 @@ class Logs(models.Model):
...
@@ -36,7 +36,10 @@ class Logs(models.Model):
class
Pid
(
models
.
Model
):
class
Pid
(
models
.
Model
):
pid
=
models
.
IntegerField
()
"""
ppid : parent pid
cpid: child pid
"""
ppid
=
models
.
IntegerField
()
cpid
=
models
.
IntegerField
()
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