Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
B
beego
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
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
go
beego
Commits
d314d12c
Commit
d314d12c
authored
Aug 14, 2014
by
Lei Cao
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added the UI for Admin monitor page
parent
14cd9e51
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
17 additions
and
10 deletions
+17
-10
admin.go
admin.go
+0
-0
adminui.go
adminui.go
+0
-0
statistics.go
toolbox/statistics.go
+17
-10
No files found.
admin.go
View file @
d314d12c
This diff is collapsed.
Click to expand it.
adminui.go
0 → 100644
View file @
d314d12c
This diff is collapsed.
Click to expand it.
toolbox/statistics.go
View file @
d314d12c
// Beego (http://beego.me/)
//
// @description beego is an open-source, high-performance web framework for the Go programming language.
//
// @link http://github.com/astaxie/beego for the canonical source repository
//
// @license http://github.com/astaxie/beego/blob/master/LICENSE
//
// @authors astaxie
package
toolbox
import
(
"fmt"
"io"
"sync"
"time"
)
...
...
@@ -79,17 +74,29 @@ func (m *UrlMap) AddStatistics(requestMethod, requestUrl, requestController stri
}
// put url statistics result in io.Writer
func
(
m
*
UrlMap
)
GetMap
(
rw
io
.
Writer
)
{
func
(
m
*
UrlMap
)
GetMap
(
)
[][]
string
{
m
.
lock
.
RLock
()
defer
m
.
lock
.
RUnlock
()
fmt
.
Fprintf
(
rw
,
"| % -50s| % -10s | % -16s | % -16s | % -16s | % -16s | % -16s |
\n
"
,
"requestUrl"
,
"method"
,
"times"
,
"used"
,
"max used"
,
"min used"
,
"avg used"
)
resultLists
:=
make
([][]
string
,
0
)
var
result
=
[]
string
{
"requestUrl"
,
"method"
,
"times"
,
"used"
,
"max used"
,
"min used"
,
"avg used"
}
resultLists
=
append
(
resultLists
,
result
)
for
k
,
v
:=
range
m
.
urlmap
{
for
kk
,
vv
:=
range
v
{
fmt
.
Fprintf
(
rw
,
"| % -50s| % -10s | % -16d | % -16s | % -16s | % -16s | % -16s |
\n
"
,
k
,
kk
,
vv
.
RequestNum
,
toS
(
vv
.
TotalTime
),
toS
(
vv
.
MaxTime
),
toS
(
vv
.
MinTime
),
toS
(
time
.
Duration
(
int64
(
vv
.
TotalTime
)
/
vv
.
RequestNum
)),
)
result
:=
[]
string
{
fmt
.
Sprintf
(
"% -50s"
,
k
),
fmt
.
Sprintf
(
"% -10s"
,
kk
),
fmt
.
Sprintf
(
"% -16d"
,
vv
.
RequestNum
),
fmt
.
Sprintf
(
"% -16s"
,
toS
(
vv
.
TotalTime
)),
fmt
.
Sprintf
(
"% -16s"
,
toS
(
vv
.
MaxTime
)),
fmt
.
Sprintf
(
"% -16s"
,
toS
(
vv
.
MinTime
)),
fmt
.
Sprintf
(
"% -16s"
,
toS
(
time
.
Duration
(
int64
(
vv
.
TotalTime
)
/
vv
.
RequestNum
))),
}
resultLists
=
append
(
resultLists
,
result
)
}
}
fmt
.
Println
(
resultLists
)
return
resultLists
}
// global statistics data map
...
...
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