Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
K
k3s
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
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Jacklull
k3s
Commits
a77c8a1e
Commit
a77c8a1e
authored
Oct 07, 2017
by
Di Xu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
sort top pod and top node output by namespace/name
parent
3f1a2e43
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
13 additions
and
0 deletions
+13
-0
metrics_printer.go
pkg/kubectl/metricsutil/metrics_printer.go
+13
-0
No files found.
pkg/kubectl/metricsutil/metrics_printer.go
View file @
a77c8a1e
...
@@ -19,6 +19,7 @@ package metricsutil
...
@@ -19,6 +19,7 @@ package metricsutil
import
(
import
(
"fmt"
"fmt"
"io"
"io"
"sort"
"k8s.io/apimachinery/pkg/api/resource"
"k8s.io/apimachinery/pkg/api/resource"
"k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/api"
...
@@ -58,6 +59,10 @@ func (printer *TopCmdPrinter) PrintNodeMetrics(metrics []metricsapi.NodeMetrics,
...
@@ -58,6 +59,10 @@ func (printer *TopCmdPrinter) PrintNodeMetrics(metrics []metricsapi.NodeMetrics,
w
:=
printers
.
GetNewTabWriter
(
printer
.
out
)
w
:=
printers
.
GetNewTabWriter
(
printer
.
out
)
defer
w
.
Flush
()
defer
w
.
Flush
()
sort
.
Slice
(
metrics
,
func
(
i
,
j
int
)
bool
{
return
metrics
[
i
]
.
Name
<
metrics
[
j
]
.
Name
})
printColumnNames
(
w
,
NodeColumns
)
printColumnNames
(
w
,
NodeColumns
)
var
usage
api
.
ResourceList
var
usage
api
.
ResourceList
for
_
,
m
:=
range
metrics
{
for
_
,
m
:=
range
metrics
{
...
@@ -87,6 +92,14 @@ func (printer *TopCmdPrinter) PrintPodMetrics(metrics []metricsapi.PodMetrics, p
...
@@ -87,6 +92,14 @@ func (printer *TopCmdPrinter) PrintPodMetrics(metrics []metricsapi.PodMetrics, p
if
printContainers
{
if
printContainers
{
printValue
(
w
,
PodColumn
)
printValue
(
w
,
PodColumn
)
}
}
sort
.
Slice
(
metrics
,
func
(
i
,
j
int
)
bool
{
if
withNamespace
&&
metrics
[
i
]
.
Namespace
!=
metrics
[
j
]
.
Namespace
{
return
metrics
[
i
]
.
Namespace
<
metrics
[
j
]
.
Namespace
}
return
metrics
[
i
]
.
Name
<
metrics
[
j
]
.
Name
})
printColumnNames
(
w
,
PodColumns
)
printColumnNames
(
w
,
PodColumns
)
for
_
,
m
:=
range
metrics
{
for
_
,
m
:=
range
metrics
{
err
:=
printSinglePodMetrics
(
w
,
&
m
,
printContainers
,
withNamespace
)
err
:=
printSinglePodMetrics
(
w
,
&
m
,
printContainers
,
withNamespace
)
...
...
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