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
c73266b5
Commit
c73266b5
authored
Apr 13, 2017
by
gmarek
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Make resource gatherer get data about etcd resource usage in kubemark setup
parent
5ba21e83
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
34 additions
and
2 deletions
+34
-2
get-kubemark-resource-usage.go
test/e2e/framework/get-kubemark-resource-usage.go
+34
-2
No files found.
test/e2e/framework/get-kubemark-resource-usage.go
View file @
c73266b5
...
@@ -28,15 +28,24 @@ type KubemarkResourceUsage struct {
...
@@ -28,15 +28,24 @@ type KubemarkResourceUsage struct {
CPUUsageInCores
float64
CPUUsageInCores
float64
}
}
func
getMasterUsageByPrefix
(
prefix
string
)
(
string
,
error
)
{
sshResult
,
err
:=
SSH
(
fmt
.
Sprintf
(
"ps ax -o %%cpu,rss,command | tail -n +2 | grep %v | sed 's/
\\
s+/ /g'"
,
prefix
),
GetMasterHost
()
+
":22"
,
TestContext
.
Provider
)
if
err
!=
nil
{
return
""
,
err
}
return
sshResult
.
Stdout
,
nil
}
// TODO: figure out how to move this to kubemark directory (need to factor test SSH out of e2e framework)
// TODO: figure out how to move this to kubemark directory (need to factor test SSH out of e2e framework)
func
GetKubemarkMasterComponentsResourceUsage
()
map
[
string
]
*
KubemarkResourceUsage
{
func
GetKubemarkMasterComponentsResourceUsage
()
map
[
string
]
*
KubemarkResourceUsage
{
result
:=
make
(
map
[
string
]
*
KubemarkResourceUsage
)
result
:=
make
(
map
[
string
]
*
KubemarkResourceUsage
)
sshResult
,
err
:=
SSH
(
"ps ax -o %cpu,rss,command | tail -n +2 | grep kube | sed 's/
\\
s+/ /g'"
,
GetMasterHost
()
+
":22"
,
TestContext
.
Provider
)
// Get kuberenetes component resource usage
sshResult
,
err
:=
getMasterUsageByPrefix
(
"kube"
)
if
err
!=
nil
{
if
err
!=
nil
{
Logf
(
"Error when trying to SSH to master machine. Skipping probe"
)
Logf
(
"Error when trying to SSH to master machine. Skipping probe"
)
return
nil
return
nil
}
}
scanner
:=
bufio
.
NewScanner
(
strings
.
NewReader
(
sshResult
.
Stdout
))
scanner
:=
bufio
.
NewScanner
(
strings
.
NewReader
(
sshResult
))
for
scanner
.
Scan
()
{
for
scanner
.
Scan
()
{
var
cpu
float64
var
cpu
float64
var
mem
uint64
var
mem
uint64
...
@@ -48,5 +57,28 @@ func GetKubemarkMasterComponentsResourceUsage() map[string]*KubemarkResourceUsag
...
@@ -48,5 +57,28 @@ func GetKubemarkMasterComponentsResourceUsage() map[string]*KubemarkResourceUsag
result
[
fullName
]
=
&
KubemarkResourceUsage
{
Name
:
fullName
,
MemoryWorkingSetInBytes
:
mem
*
1024
,
CPUUsageInCores
:
cpu
/
100
}
result
[
fullName
]
=
&
KubemarkResourceUsage
{
Name
:
fullName
,
MemoryWorkingSetInBytes
:
mem
*
1024
,
CPUUsageInCores
:
cpu
/
100
}
}
}
}
}
// Get etcd resource usage
sshResult
,
err
=
getMasterUsageByPrefix
(
"bin/etcd"
)
if
err
!=
nil
{
Logf
(
"Error when trying to SSH to master machine. Skipping probe"
)
return
nil
}
scanner
=
bufio
.
NewScanner
(
strings
.
NewReader
(
sshResult
))
for
scanner
.
Scan
()
{
var
cpu
float64
var
mem
uint64
var
etcdKind
string
fmt
.
Sscanf
(
strings
.
TrimSpace
(
scanner
.
Text
()),
"%f %d /bin/sh -c /usr/local/bin/etcd"
,
&
cpu
,
&
mem
)
dataDirStart
:=
strings
.
Index
(
scanner
.
Text
(),
"--data-dir"
)
if
dataDirStart
<
0
{
continue
}
fmt
.
Sscanf
(
scanner
.
Text
()[
dataDirStart
:
],
"--data-dir=/var/%s"
,
&
etcdKind
)
if
etcdKind
!=
""
{
// Gatherer expects pod_name/container_name format
fullName
:=
"etcd/"
+
etcdKind
result
[
fullName
]
=
&
KubemarkResourceUsage
{
Name
:
fullName
,
MemoryWorkingSetInBytes
:
mem
*
1024
,
CPUUsageInCores
:
cpu
/
100
}
}
}
return
result
return
result
}
}
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