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
67c1f120
Commit
67c1f120
authored
Feb 26, 2015
by
root
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
dashboard
parent
a746cab2
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
53 additions
and
21 deletions
+53
-21
jumpserver.conf
jumpserver.conf
+5
-5
views.py
jumpserver/views.py
+27
-1
index.html
templates/index.html
+20
-14
log_offline.html
templates/jlog/log_offline.html
+1
-1
No files found.
jumpserver.conf
View file @
67c1f120
...
...
@@ -8,11 +8,11 @@ password = mysql234
database
=
jumpserver
[
ldap
]
ldap_enable
=
1
host_url
=
ldap
://
1
27
.
0
.
0
.
1
:
389
base_dn
=
dc
=
jumpserver
,
dc
=
org
root_dn
=
cn
=
admin
,
dc
=
jumpserver
,
dc
=
org
root_pw
=
secret234
ldap_enable
=
0
host_url
=
ldap
://
1
92
.
168
.
8
.
60
:
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
...
...
jumpserver/views.py
View file @
67c1f120
#coding: utf-8
import
hashlib
import
datetime
from
django.db.models
import
Q
from
django.db.models
import
Count
from
django.shortcuts
import
render_to_response
from
django.http
import
HttpResponseRedirect
from
django.core.paginator
import
Paginator
,
EmptyPage
,
InvalidPage
...
...
@@ -15,11 +18,34 @@ def md5_crypt(string):
return
hashlib
.
new
(
"md5"
,
string
)
.
hexdigest
()
def
getDaysByNum
(
num
):
today
=
datetime
.
date
.
today
()
oneday
=
datetime
.
timedelta
(
days
=
1
)
li
=
[]
for
i
in
range
(
0
,
num
):
today
=
today
-
oneday
li
.
append
(
str
(
today
)[
0
:
10
])
li
.
reverse
()
return
li
def
index
(
request
):
path1
,
path2
=
u'仪表盘'
,
'Dashboard'
dic
=
{}
today
=
datetime
.
datetime
.
now
()
.
day
from_week
=
datetime
.
datetime
.
now
()
-
datetime
.
timedelta
(
days
=
7
)
week_data
=
Log
.
objects
.
filter
(
start_time__range
=
[
from_week
,
datetime
.
datetime
.
now
()])
top_ten
=
week_data
.
values
(
'user'
)
.
annotate
(
times
=
Count
(
'user'
))
.
order_by
(
'-times'
)[:
10
]
for
user
in
top_ten
:
username
=
user
[
'user'
]
li
=
[]
for
t
in
getDaysByNum
(
7
):
times
=
week_data
.
filter
(
user
=
user
)
.
filter
(
start_time__gt
=
t
)
.
count
()
li
.
append
(
times
)
dic
[
username
]
=
li
print
dic
users
=
User
.
objects
.
all
()
hosts
=
Asset
.
objects
.
all
()
user
=
'wangyong'
online_host
=
Log
.
objects
.
filter
(
is_finished
=
0
)
online_user
=
online_host
.
distinct
()
return
render_to_response
(
'index.html'
,
locals
())
...
...
templates/index.html
View file @
67c1f120
...
...
@@ -78,7 +78,7 @@ $(function () {
},
yAxis
:
{
title
:
{
text
:
'登
陆
次数'
text
:
'登
录
次数'
},
plotLines
:
[{
value
:
0
,
...
...
@@ -95,19 +95,25 @@ $(function () {
verticalAlign
:
'middle'
,
borderWidth
:
0
},
series
:
[{
name
:
'{{ user }}'
,
data
:
[
5
,
10
,
20
,
10
,
8
,
1
,
0
]
},
{
name
:
'广宏伟'
,
data
:
[
10
,
11
,
13
,
12
,
18
,
11
,
6
]
},
{
name
:
'刘德华'
,
data
:
[
2
,
2
,
5
,
6
,
4
,
7
,
3
]
},
{
name
:
'梁朝伟'
,
data
:
[
3
,
4
,
5
,
8
,
11
,
15
,
8
]
}]
{
#
series
:
[{
#
}
{
#
name
:
'{{ user }}'
,
#
}
{
#
data
:
[
5
,
10
,
20
,
10
,
8
,
1
,
0
]
#
}
{
#
},
{
#
}
{
#
name
:
'广宏伟'
,
#
}
{
#
data
:
[
10
,
11
,
13
,
12
,
18
,
11
,
6
]
#
}
{
#
},
{
#
}
{
#
name
:
'刘德华'
,
#
}
{
#
data
:
[
2
,
2
,
5
,
6
,
4
,
7
,
3
]
#
}
{
#
},
{
#
}
{
#
name
:
'梁朝伟'
,
#
}
{
#
data
:
[
3
,
4
,
5
,
8
,
11
,
15
,
8
]
#
}
{
#
}]
#
}
series
:
[
{
%
for
k
,
v
in
dic
.
items
%
}
{
name
:
'{{ k }}'
,
data
:
{{
v
}}},
{
%
endfor
%
}
]
});
});
</script>
...
...
templates/jlog/log_offline.html
View file @
67c1f120
...
...
@@ -127,7 +127,7 @@
</div>
<script
src=
"http://{{ web_socket_host }}/socket.io/socket.io.js"
></script>
{#
<script
src=
"http://{{ web_socket_host }}/socket.io/socket.io.js"
></script>
#}
<script>
$
(
'.log_command'
).
on
(
'click'
,
function
(){
var
url
=
$
(
this
).
attr
(
'href'
);
...
...
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