mirror of
https://github.com/siderolabs/talos.git
synced 2025-12-16 06:51:27 +01:00
The new command `talosctl cgroups` fetches cgroups snapshot from the machine, parses it fully, enhances with additional information (e.g. resolves pod names), and presents a customizable view of cgroups configuration (e.g. limits) and current consumption. Signed-off-by: Andrey Smirnov <andrey.smirnov@siderolabs.com>
31 lines
635 B
Go
31 lines
635 B
Go
// This Source Code Form is subject to the terms of the Mozilla Public
|
|
// License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
|
|
package cgroups
|
|
|
|
import (
|
|
"bufio"
|
|
"io"
|
|
)
|
|
|
|
// RawValue is a raw cgroup value (without any parsing).
|
|
type RawValue string
|
|
|
|
// ParseRawValue parses the raw cgroup value.
|
|
func ParseRawValue(r io.Reader) (RawValue, error) {
|
|
scanner := bufio.NewScanner(r)
|
|
|
|
if !scanner.Scan() {
|
|
return RawValue(""), nil
|
|
}
|
|
|
|
line := scanner.Text()
|
|
|
|
if err := scanner.Err(); err != nil {
|
|
return RawValue(""), err
|
|
}
|
|
|
|
return RawValue(line), nil
|
|
}
|