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
65394fe1
Commit
65394fe1
authored
Feb 20, 2018
by
David Ashpole
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update cadvisor godeps and ignore per-cpu metrics
parent
a4222bd8
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
24 additions
and
8 deletions
+24
-8
Godeps.json
Godeps/Godeps.json
+0
-0
cadvisor_linux.go
pkg/kubelet/cadvisor/cadvisor_linux.go
+5
-1
factory.go
vendor/github.com/google/cadvisor/container/factory.go
+1
-0
helpers.go
...hub.com/google/cadvisor/container/libcontainer/helpers.go
+9
-6
prometheus.go
vendor/github.com/google/cadvisor/metrics/prometheus.go
+9
-1
No files found.
Godeps/Godeps.json
View file @
65394fe1
This diff is collapsed.
Click to expand it.
pkg/kubelet/cadvisor/cadvisor_linux.go
View file @
65394fe1
...
...
@@ -108,7 +108,11 @@ func containerLabels(c *cadvisorapi.ContainerInfo) map[string]string {
func
New
(
address
string
,
port
uint
,
imageFsInfoProvider
ImageFsInfoProvider
,
rootPath
string
,
usingLegacyStats
bool
)
(
Interface
,
error
)
{
sysFs
:=
sysfs
.
NewRealSysFs
()
ignoreMetrics
:=
cadvisormetrics
.
MetricSet
{
cadvisormetrics
.
NetworkTcpUsageMetrics
:
struct
{}{},
cadvisormetrics
.
NetworkUdpUsageMetrics
:
struct
{}{}}
ignoreMetrics
:=
cadvisormetrics
.
MetricSet
{
cadvisormetrics
.
NetworkTcpUsageMetrics
:
struct
{}{},
cadvisormetrics
.
NetworkUdpUsageMetrics
:
struct
{}{},
cadvisormetrics
.
PerCpuUsageMetrics
:
struct
{}{},
}
if
!
usingLegacyStats
{
ignoreMetrics
[
cadvisormetrics
.
DiskUsageMetrics
]
=
struct
{}{}
}
...
...
vendor/github.com/google/cadvisor/container/factory.go
View file @
65394fe1
...
...
@@ -42,6 +42,7 @@ type MetricKind string
const
(
CpuUsageMetrics
MetricKind
=
"cpu"
PerCpuUsageMetrics
MetricKind
=
"percpu"
MemoryUsageMetrics
MetricKind
=
"memory"
CpuLoadMetrics
MetricKind
=
"cpuLoad"
DiskIOMetrics
MetricKind
=
"diskIO"
...
...
vendor/github.com/google/cadvisor/container/libcontainer/helpers.go
View file @
65394fe1
...
...
@@ -113,7 +113,8 @@ func GetStats(cgroupManager cgroups.Manager, rootFs string, pid int, ignoreMetri
libcontainerStats
:=
&
libcontainer
.
Stats
{
CgroupStats
:
cgroupStats
,
}
stats
:=
newContainerStats
(
libcontainerStats
)
withPerCPU
:=
!
ignoreMetrics
.
Has
(
container
.
PerCpuUsageMetrics
)
stats
:=
newContainerStats
(
libcontainerStats
,
withPerCPU
)
// If we know the pid then get network stats from /proc/<pid>/net/dev
if
pid
==
0
{
...
...
@@ -467,14 +468,17 @@ func minUint32(x, y uint32) uint32 {
var
numCpusFunc
=
getNumberOnlineCPUs
// Convert libcontainer stats to info.ContainerStats.
func
setCpuStats
(
s
*
cgroups
.
Stats
,
ret
*
info
.
ContainerStats
)
{
func
setCpuStats
(
s
*
cgroups
.
Stats
,
ret
*
info
.
ContainerStats
,
withPerCPU
bool
)
{
ret
.
Cpu
.
Usage
.
User
=
s
.
CpuStats
.
CpuUsage
.
UsageInUsermode
ret
.
Cpu
.
Usage
.
System
=
s
.
CpuStats
.
CpuUsage
.
UsageInKernelmode
ret
.
Cpu
.
Usage
.
Total
=
0
ret
.
Cpu
.
Usage
.
Total
=
s
.
CpuStats
.
CpuUsage
.
TotalUsage
ret
.
Cpu
.
CFS
.
Periods
=
s
.
CpuStats
.
ThrottlingData
.
Periods
ret
.
Cpu
.
CFS
.
ThrottledPeriods
=
s
.
CpuStats
.
ThrottlingData
.
ThrottledPeriods
ret
.
Cpu
.
CFS
.
ThrottledTime
=
s
.
CpuStats
.
ThrottlingData
.
ThrottledTime
if
!
withPerCPU
{
return
}
if
len
(
s
.
CpuStats
.
CpuUsage
.
PercpuUsage
)
==
0
{
// libcontainer's 'GetStats' can leave 'PercpuUsage' nil if it skipped the
// cpuacct subsystem.
...
...
@@ -501,7 +505,6 @@ func setCpuStats(s *cgroups.Stats, ret *info.ContainerStats) {
for
i
:=
uint32
(
0
);
i
<
numActual
;
i
++
{
ret
.
Cpu
.
Usage
.
PerCpu
[
i
]
=
s
.
CpuStats
.
CpuUsage
.
PercpuUsage
[
i
]
ret
.
Cpu
.
Usage
.
Total
+=
s
.
CpuStats
.
CpuUsage
.
PercpuUsage
[
i
]
}
}
...
...
@@ -587,13 +590,13 @@ func setNetworkStats(libcontainerStats *libcontainer.Stats, ret *info.ContainerS
}
}
func
newContainerStats
(
libcontainerStats
*
libcontainer
.
Stats
)
*
info
.
ContainerStats
{
func
newContainerStats
(
libcontainerStats
*
libcontainer
.
Stats
,
withPerCPU
bool
)
*
info
.
ContainerStats
{
ret
:=
&
info
.
ContainerStats
{
Timestamp
:
time
.
Now
(),
}
if
s
:=
libcontainerStats
.
CgroupStats
;
s
!=
nil
{
setCpuStats
(
s
,
ret
)
setCpuStats
(
s
,
ret
,
withPerCPU
)
setDiskIoStats
(
s
,
ret
)
setMemoryStats
(
s
,
ret
)
}
...
...
vendor/github.com/google/cadvisor/metrics/prometheus.go
View file @
65394fe1
...
...
@@ -150,10 +150,18 @@ func NewPrometheusCollector(i infoProvider, f ContainerLabelsFunc) *PrometheusCo
},
},
{
name
:
"container_cpu_usage_seconds_total"
,
help
:
"Cumulative cpu time consumed
per cpu
in seconds."
,
help
:
"Cumulative cpu time consumed in seconds."
,
valueType
:
prometheus
.
CounterValue
,
extraLabels
:
[]
string
{
"cpu"
},
getValues
:
func
(
s
*
info
.
ContainerStats
)
metricValues
{
if
len
(
s
.
Cpu
.
Usage
.
PerCpu
)
==
0
{
if
s
.
Cpu
.
Usage
.
Total
>
0
{
return
metricValues
{{
value
:
float64
(
s
.
Cpu
.
Usage
.
Total
)
/
float64
(
time
.
Second
),
labels
:
[]
string
{
"total"
},
}}
}
}
values
:=
make
(
metricValues
,
0
,
len
(
s
.
Cpu
.
Usage
.
PerCpu
))
for
i
,
value
:=
range
s
.
Cpu
.
Usage
.
PerCpu
{
if
value
>
0
{
...
...
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