Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
G
Geth-Modification
Project
Project
Details
Activity
Releases
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
张蕾
Geth-Modification
Commits
302187ae
Commit
302187ae
authored
Jun 24, 2015
by
Péter Szilágyi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
cmd/geth: allow branching metric patterns
parent
bf99d5b3
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
25 additions
and
18 deletions
+25
-18
monitorcmd.go
cmd/geth/monitorcmd.go
+25
-18
No files found.
cmd/geth/monitorcmd.go
View file @
302187ae
...
...
@@ -149,30 +149,37 @@ func resolveMetrics(metrics map[string]interface{}, patterns []string) []string
// resolveMetrics takes a single of input metric pattern, and resolves it to one
// or more canonical metric names.
func
resolveMetric
(
metrics
map
[
string
]
interface
{},
pattern
string
,
path
string
)
[]
string
{
var
ok
bool
// Build up the canonical metric path
parts
:=
strings
.
Split
(
pattern
,
"/"
)
for
len
(
parts
)
>
1
{
if
metrics
,
ok
=
metrics
[
parts
[
0
]]
.
(
map
[
string
]
interface
{});
!
ok
{
utils
.
Fatalf
(
"Failed to retrieve system metrics: %s"
,
path
+
parts
[
0
])
results
:=
[]
string
{}
// If a nested metric was requested, recurse optionally branching (via comma)
parts
:=
strings
.
SplitN
(
pattern
,
"/"
,
2
)
if
len
(
parts
)
>
1
{
for
_
,
variation
:=
range
strings
.
Split
(
parts
[
0
],
","
)
{
if
submetrics
,
ok
:=
metrics
[
variation
]
.
(
map
[
string
]
interface
{});
!
ok
{
utils
.
Fatalf
(
"Failed to retrieve system metrics: %s"
,
path
+
variation
)
return
nil
}
else
{
results
=
append
(
results
,
resolveMetric
(
submetrics
,
parts
[
1
],
path
+
variation
+
"/"
)
...
)
}
path
+=
parts
[
0
]
+
"/"
parts
=
parts
[
1
:
]
}
return
results
}
// Depending what the last link is, return or expand
switch
metric
:=
metrics
[
parts
[
0
]]
.
(
type
)
{
for
_
,
variation
:=
range
strings
.
Split
(
pattern
,
","
)
{
switch
metric
:=
metrics
[
variation
]
.
(
type
)
{
case
float64
:
// Final metric value found, return as singleton
return
[]
string
{
path
+
parts
[
0
]}
results
=
append
(
results
,
path
+
variation
)
case
map
[
string
]
interface
{}
:
return
expandMetrics
(
metric
,
path
+
parts
[
0
]
+
"/"
)
results
=
append
(
results
,
expandMetrics
(
metric
,
path
+
variation
+
"/"
)
...
)
default
:
utils
.
Fatalf
(
"Metric pattern resolved to unexpected type: %v"
,
reflect
.
TypeOf
(
metric
))
return
nil
}
}
return
results
}
// expandMetrics expands the entire tree of metrics into a flat list of paths.
...
...
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