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
6a39a618
Commit
6a39a618
authored
Dec 04, 2015
by
k8s-merge-robot
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #18150 from gmarek/grab-profiles
Auto commit by PR queue bot
parents
37d22999
9d111955
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
69 additions
and
14 deletions
+69
-14
grab-profiles.sh
hack/grab-profiles.sh
+69
-14
No files found.
hack/grab-profiles.sh
View file @
6a39a618
...
@@ -18,17 +18,48 @@ set -o errexit
...
@@ -18,17 +18,48 @@ set -o errexit
set
-o
nounset
set
-o
nounset
set
-o
pipefail
set
-o
pipefail
function
grab_profiles_from_component
{
local
requested_profiles
=
$1
local
mem_pprof_flags
=
$2
local
binary
=
$3
local
tunnel_port
=
$4
local
path
=
$5
local
output_prefix
=
$6
local
timestamp
=
$7
echo
"binary:
$binary
"
for
profile
in
${
requested_profiles
}
;
do
case
${
profile
}
in
cpu
)
go tool pprof
"-pdf"
"
${
binary
}
"
"http://localhost:
${
tunnel_port
}
/
${
path
}
/profile"
>
"
${
output_prefix
}
-
${
profile
}
-profile-
${
timestamp
}
.pdf"
;;
mem
)
# There are different kinds of memory profiles that are available that
# had to be grabbed separately: --inuse-space, --inuse-objects,
# --alloc-space, --alloc-objects. We need to iterate over all requested
# kinds.
for
flag
in
${
mem_pprof_flags
}
;
do
go tool pprof
"-
${
flag
}
"
"-pdf"
"
${
binary
}
"
"http://localhost:
${
tunnel_port
}
/
${
path
}
/heap"
>
"
${
output_prefix
}
-
${
profile
}
-
${
flag
}
-profile-
${
timestamp
}
.pdf"
done
;;
esac
done
}
KUBE_ROOT
=
$(
dirname
"
${
BASH_SOURCE
}
"
)
/..
KUBE_ROOT
=
$(
dirname
"
${
BASH_SOURCE
}
"
)
/..
source
"
${
KUBE_ROOT
}
/hack/lib/init.sh"
source
"
${
KUBE_ROOT
}
/hack/lib/init.sh"
server_addr
=
""
server_addr
=
""
kubelet_addreses
=
""
kubelet_binary
=
""
requested_profiles
=
""
requested_profiles
=
""
mem_pprof_flags
=
""
mem_pprof_flags
=
""
profile_components
=
""
profile_components
=
""
output_dir
=
"."
output_dir
=
"."
tunnel_port
=
"
${
tunnel_port
:-
1234
}
"
tunnel_port
=
"
${
tunnel_port
:-
1234
}
"
args
=
$(
getopt
-o
s:mho:
-l
server:,master,heapster,output:,help,inuse-space,inuse-objects,alloc-space,alloc-objects,cpu
--
"
$@
"
)
args
=
$(
getopt
-o
s:mho:
k:
-l
server:,master,heapster,output:,kubelet:,help,inuse-space,inuse-objects,alloc-space,alloc-objects,cpu,kubelet-binary:
--
"
$@
"
)
if
[[
$?
-ne
0
]]
;
then
if
[[
$?
-ne
0
]]
;
then
>
&2
echo
"Error in getopt"
>
&2
echo
"Error in getopt"
exit
1
exit
1
...
@@ -37,6 +68,7 @@ fi
...
@@ -37,6 +68,7 @@ fi
HEAPSTER_VERSION
=
"v0.18.2"
HEAPSTER_VERSION
=
"v0.18.2"
MASTER_PPROF_PATH
=
"debug/pprof"
MASTER_PPROF_PATH
=
"debug/pprof"
HEAPSTER_PPROF_PATH
=
"api/v1/proxy/namespaces/kube-system/services/monitoring-heapster/debug/pprof"
HEAPSTER_PPROF_PATH
=
"api/v1/proxy/namespaces/kube-system/services/monitoring-heapster/debug/pprof"
KUBELET_PPROF_PATH_PREFIX
=
"api/v1/proxy/nodes"
eval set
--
"
${
args
}
"
eval set
--
"
${
args
}
"
...
@@ -68,6 +100,25 @@ while true; do
...
@@ -68,6 +100,25 @@ while true; do
output_dir
=
$1
output_dir
=
$1
shift
shift
;;
;;
-k
|
--kubelet
)
shift
profile_components
=
"kubelet
${
profile_components
}
"
if
[
-z
"
$1
"
]
;
then
>
&2
echo
"empty argumet to --kubelet flag"
exit
1
fi
kubelet_addreses
=
"
$1
$kubelet_addreses
"
shift
;;
--kubelet-binary
)
shift
if
[
-z
"
$1
"
]
;
then
>
&2
echo
"empty argumet to --kubelet-binary flag"
exit
1
fi
kubelet_binary
=
$1
shift
;;
--inuse-space
)
--inuse-space
)
shift
shift
requested_profiles
=
"mem
${
requested_profiles
}
"
requested_profiles
=
"mem
${
requested_profiles
}
"
...
@@ -139,6 +190,8 @@ kube::util::trap_add 'kill $SSH_PID' EXIT
...
@@ -139,6 +190,8 @@ kube::util::trap_add 'kill $SSH_PID' EXIT
kube::util::trap_add
'kill $SSH_PID'
SIGTERM
kube::util::trap_add
'kill $SSH_PID'
SIGTERM
requested_profiles
=
$(
echo
${
requested_profiles
}
| xargs
-n1
|
sort
-u
| xargs
)
requested_profiles
=
$(
echo
${
requested_profiles
}
| xargs
-n1
|
sort
-u
| xargs
)
profile_components
=
$(
echo
${
profile_components
}
| xargs
-n1
|
sort
-u
| xargs
)
kubelet_addreses
=
$(
echo
${
kubelet_addreses
}
| xargs
-n1
|
sort
-u
| xargs
)
echo
"requested profiles:
${
requested_profiles
}
"
echo
"requested profiles:
${
requested_profiles
}
"
echo
"flags for heap profile:
${
mem_pprof_flags
}
"
echo
"flags for heap profile:
${
mem_pprof_flags
}
"
...
@@ -159,19 +212,21 @@ for component in ${profile_components}; do
...
@@ -159,19 +212,21 @@ for component in ${profile_components}; do
binary
=
heapster
binary
=
heapster
path
=
${
HEAPSTER_PPROF_PATH
}
path
=
${
HEAPSTER_PPROF_PATH
}
;;
;;
kubelet
)
path
=
"
${
KUBELET_PPROF_PATH_PREFIX
}
"
if
[[
-z
"
${
kubelet_binary
}
"
]]
;
then
binary
=
"
${
KUBE_ROOT
}
/_output/local/bin/linux/amd64/kubelet"
else
binary
=
${
kubelet_binary
}
fi
;;
esac
esac
for
profile
in
${
requested_profiles
}
;
do
if
[[
"
${
component
}
"
==
"kubelet"
]]
;
then
case
${
profile
}
in
for
node
in
$(
echo
${
kubelet_addreses
}
|
sed
's/[,;]/\n/g'
)
;
do
cpu
)
grab_profiles_from_component
"
${
requested_profiles
}
"
"
${
mem_pprof_flags
}
"
"
${
binary
}
"
"
${
tunnel_port
}
"
"
${
path
}
/
${
node
}
/debug/pprof"
"
${
output_dir
}
/
${
component
}
"
"
${
timestamp
}
"
go tool pprof
"-pdf"
"
${
binary
}
"
"http://localhost:
${
tunnel_port
}
/
${
path
}
/profile"
>
"
${
output_dir
}
/
${
component
}
-
${
profile
}
-profile-
${
timestamp
}
.pdf"
done
;;
else
mem
)
grab_profiles_from_component
"
${
requested_profiles
}
"
"
${
mem_pprof_flags
}
"
"
${
binary
}
"
"
${
tunnel_port
}
"
"
${
path
}
"
"
${
output_dir
}
/
${
component
}
"
"
${
timestamp
}
"
for
flag
in
${
mem_pprof_flags
}
;
do
fi
go tool pprof
"-
${
flag
}
"
"-pdf"
"
${
binary
}
"
"http://localhost:
${
tunnel_port
}
/
${
path
}
/heap"
>
"
${
output_dir
}
/
${
component
}
-
${
profile
}
-
${
flag
}
-profile-
${
timestamp
}
.pdf"
done
;;
esac
done
done
done
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