コード例 #1
0
// Retrieve metrics from the kubelet server of the given node.
func getKubeletMetricsThroughProxy(c *client.Client, node string) (string, error) {
	client, err := nodeProxyRequest(c, node, "metrics")
	if err != nil {
		return "", err
	}
	metric, errRaw := client.Raw()
	if errRaw != nil {
		return "", err
	}
	return string(metric), nil
}
コード例 #2
0
func GetKubeletHeapStats(c *client.Client, nodeName string) (string, error) {
	client, err := NodeProxyRequest(c, nodeName, "debug/pprof/heap")
	if err != nil {
		return "", err
	}
	raw, errRaw := client.Raw()
	if errRaw != nil {
		return "", err
	}
	stats := string(raw)
	// Only dumping the runtime.MemStats numbers to avoid polluting the log.
	numLines := 23
	lines := strings.Split(stats, "\n")
	return strings.Join(lines[len(lines)-numLines:], "\n"), nil
}