good morning!!!!
Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
B
bor
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container registry
Harbor Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
open
bor
Commits
d6c6bcc9
Commit
d6c6bcc9
authored
Feb 11, 2016
by
Péter Szilágyi
Browse files
Options
Downloads
Patches
Plain Diff
cmd/geth: update monitor to new termui code
parent
b019f3ee
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
cmd/geth/monitorcmd.go
+22
-25
22 additions, 25 deletions
cmd/geth/monitorcmd.go
with
22 additions
and
25 deletions
cmd/geth/monitorcmd.go
+
22
−
25
View file @
d6c6bcc9
...
...
@@ -105,8 +105,6 @@ func monitor(ctx *cli.Context) {
}
defer
termui
.
Close
()
termui
.
UseTheme
(
"helloworld"
)
rows
:=
len
(
monitored
)
if
max
:=
ctx
.
Int
(
monitorCommandRowsFlag
.
Name
);
rows
>
max
{
rows
=
max
...
...
@@ -117,7 +115,7 @@ func monitor(ctx *cli.Context) {
}
// Create each individual data chart
footer
:=
termui
.
NewPar
(
""
)
footer
.
Has
Border
=
true
footer
.
Block
.
Border
=
true
footer
.
Height
=
3
charts
:=
make
([]
*
termui
.
LineChart
,
len
(
monitored
))
...
...
@@ -135,28 +133,27 @@ func monitor(ctx *cli.Context) {
termui
.
Render
(
termui
.
Body
)
// Watch for various system events, and periodically refresh the charts
refresh
:=
time
.
Tick
(
time
.
Duration
(
ctx
.
Int
(
monitorCommandRefreshFlag
.
Name
))
*
time
.
Second
)
for
{
select
{
case
event
:=
<-
termui
.
EventCh
()
:
if
event
.
Type
==
termui
.
EventKey
&&
event
.
Key
==
termui
.
KeyCtrlC
{
return
}
if
event
.
Type
==
termui
.
EventResize
{
termui
.
Handle
(
"/sys/kbd/C-c"
,
func
(
termui
.
Event
)
{
termui
.
StopLoop
()
})
termui
.
Handle
(
"/sys/wnd/resize"
,
func
(
termui
.
Event
)
{
termui
.
Body
.
Width
=
termui
.
TermWidth
()
for
_
,
chart
:=
range
charts
{
chart
.
Height
=
(
termui
.
TermHeight
()
-
footer
.
Height
)
/
rows
}
termui
.
Body
.
Align
()
termui
.
Render
(
termui
.
Body
)
}
case
<-
refresh
:
})
go
func
()
{
tick
:=
time
.
NewTicker
(
time
.
Duration
(
ctx
.
Int
(
monitorCommandRefreshFlag
.
Name
))
*
time
.
Second
)
for
range
tick
.
C
{
if
refreshCharts
(
client
,
monitored
,
data
,
units
,
charts
,
ctx
,
footer
)
{
termui
.
Body
.
Align
()
}
termui
.
Render
(
termui
.
Body
)
}
}
}()
termui
.
Loop
()
}
// retrieveMetrics contacts the attached geth node and retrieves the entire set
...
...
@@ -328,9 +325,9 @@ func updateChart(metric string, data []float64, base *int, chart *termui.LineCha
if
strings
.
Contains
(
metric
,
"/Percentiles/"
)
||
strings
.
Contains
(
metric
,
"/pauses/"
)
||
strings
.
Contains
(
metric
,
"/time/"
)
{
units
=
timeUnits
}
chart
.
Border
.
Label
=
metric
chart
.
BorderLabel
=
metric
if
len
(
units
[
unit
])
>
0
{
chart
.
Border
.
Label
+=
" ["
+
units
[
unit
]
+
"]"
chart
.
BorderLabel
+=
" ["
+
units
[
unit
]
+
"]"
}
chart
.
LineColor
=
colors
[
unit
]
|
termui
.
AttrBold
if
err
!=
nil
{
...
...
@@ -350,8 +347,8 @@ func createChart(height int) *termui.LineChart {
chart
.
AxesColor
=
termui
.
ColorWhite
chart
.
PaddingBottom
=
-
2
chart
.
Border
.
LabelFg
Color
=
chart
.
Border
.
Fg
Color
|
termui
.
AttrBold
chart
.
Border
.
Fg
Color
=
chart
.
Border
.
Bg
Color
chart
.
BorderLabelFg
=
chart
.
BorderFg
|
termui
.
AttrBold
chart
.
BorderFg
=
chart
.
BorderBg
return
chart
}
...
...
@@ -361,7 +358,7 @@ func updateFooter(ctx *cli.Context, err error, footer *termui.Par) {
// Generate the basic footer
refresh
:=
time
.
Duration
(
ctx
.
Int
(
monitorCommandRefreshFlag
.
Name
))
*
time
.
Second
footer
.
Text
=
fmt
.
Sprintf
(
"Press Ctrl+C to quit. Refresh interval: %v."
,
refresh
)
footer
.
TextFgColor
=
termui
.
Theme
()
.
ParTextFg
|
termui
.
AttrBold
footer
.
TextFgColor
=
termui
.
Theme
Attr
(
"par.fg"
)
|
termui
.
AttrBold
// Append any encountered errors
if
err
!=
nil
{
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment