Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions completions/bash/crio
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ h
--selinux
--separate-pull-cgroup
--signature-policy
--stats-collection-period
--storage-driver
--storage-opt
--stream-address
Expand Down
1 change: 1 addition & 0 deletions completions/fish/crio.fish
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@ complete -c crio -n '__fish_crio_no_subcommand' -f -l seccomp-use-default-when-e
complete -c crio -n '__fish_crio_no_subcommand' -f -l selinux -d 'Enable selinux support (default: false)'
complete -c crio -n '__fish_crio_no_subcommand' -f -l separate-pull-cgroup -r -d '[EXPERIMENTAL] Pull in new cgroup (default: "")'
complete -c crio -n '__fish_crio_no_subcommand' -l signature-policy -r -d 'Path to signature policy JSON file. (default: "", to use the system-wide default)'
complete -c crio -n '__fish_crio_no_subcommand' -f -l stats-collection-period -r -d 'The number of seconds between collecting pod and container stats. If set to 0, the stats are collected on-demand instead.'
complete -c crio -n '__fish_crio_no_subcommand' -f -l storage-driver -s s -r -d 'OCI storage driver (default: "")'
complete -c crio -n '__fish_crio_no_subcommand' -f -l storage-opt -r -d 'OCI storage driver option'
complete -c crio -n '__fish_crio_no_subcommand' -f -l stream-address -r -d 'Bind address for streaming socket'
Expand Down
2 changes: 1 addition & 1 deletion completions/zsh/_crio
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ it later with **--config**. Global options will modify the output.' 'version:dis
_describe 'commands' cmds

local -a opts
opts=('--absent-mount-sources-to-reject' '--additional-devices' '--address' '--apparmor-profile' '--big-files-temporary-dir' '--bind-mount-prefix' '--blockio-config-file' '--cgroup-manager' '--clean-shutdown-file' '--cni-config-dir' '--cni-default-network' '--cni-plugin-dir' '--config' '--config-dir' '--conmon' '--conmon-cgroup' '--conmon-env' '--container-attach-socket-dir' '--container-exits-dir' '--ctr-stop-timeout' '--decryption-keys-path' '--default-capabilities' '--default-env' '--default-mounts-file' '--default-runtime' '--default-sysctls' '--default-transport' '--default-ulimits' '--device-ownership-from-security-context' '--drop-infra-ctr' '--enable-metrics' '--enable-profile-unix-socket' '--enable-tracing' '--gid-mappings' '--global-auth-file' '--grpc-max-recv-msg-size' '--grpc-max-send-msg-size' '--hooks-dir' '--image-volumes' '--infra-ctr-cpuset' '--insecure-registry' '--internal-wipe' '--irqbalance-config-file' '--listen' '--log' '--log-dir' '--log-filter' '--log-format' '--log-journald' '--log-level' '--log-size-max' '--metrics-cert' '--metrics-collectors' '--metrics-key' '--metrics-port' '--metrics-socket' '--namespaces-dir' '--no-pivot' '--pause-command' '--pause-image' '--pause-image-auth-file' '--pids-limit' '--pinns-path' '--profile' '--profile-cpu' '--profile-mem' '--profile-port' '--rdt-config-file' '--read-only' '--registries-conf' '--registries-conf-dir' '--registry' '--root' '--runroot' '--runtimes' '--seccomp-profile' '--seccomp-use-default-when-empty' '--selinux' '--separate-pull-cgroup' '--signature-policy' '--storage-driver' '--storage-opt' '--stream-address' '--stream-enable-tls' '--stream-idle-timeout' '--stream-port' '--stream-tls-ca' '--stream-tls-cert' '--stream-tls-key' '--tracing-endpoint' '--tracing-sampling-rate-per-million' '--uid-mappings' '--version-file' '--version-file-persist' '--help' '--version')
opts=('--absent-mount-sources-to-reject' '--additional-devices' '--address' '--apparmor-profile' '--big-files-temporary-dir' '--bind-mount-prefix' '--blockio-config-file' '--cgroup-manager' '--clean-shutdown-file' '--cni-config-dir' '--cni-default-network' '--cni-plugin-dir' '--config' '--config-dir' '--conmon' '--conmon-cgroup' '--conmon-env' '--container-attach-socket-dir' '--container-exits-dir' '--ctr-stop-timeout' '--decryption-keys-path' '--default-capabilities' '--default-env' '--default-mounts-file' '--default-runtime' '--default-sysctls' '--default-transport' '--default-ulimits' '--device-ownership-from-security-context' '--drop-infra-ctr' '--enable-metrics' '--enable-profile-unix-socket' '--enable-tracing' '--gid-mappings' '--global-auth-file' '--grpc-max-recv-msg-size' '--grpc-max-send-msg-size' '--hooks-dir' '--image-volumes' '--infra-ctr-cpuset' '--insecure-registry' '--internal-wipe' '--irqbalance-config-file' '--listen' '--log' '--log-dir' '--log-filter' '--log-format' '--log-journald' '--log-level' '--log-size-max' '--metrics-cert' '--metrics-collectors' '--metrics-key' '--metrics-port' '--metrics-socket' '--namespaces-dir' '--no-pivot' '--pause-command' '--pause-image' '--pause-image-auth-file' '--pids-limit' '--pinns-path' '--profile' '--profile-cpu' '--profile-mem' '--profile-port' '--rdt-config-file' '--read-only' '--registries-conf' '--registries-conf-dir' '--registry' '--root' '--runroot' '--runtimes' '--seccomp-profile' '--seccomp-use-default-when-empty' '--selinux' '--separate-pull-cgroup' '--signature-policy' '--stats-collection-period' '--storage-driver' '--storage-opt' '--stream-address' '--stream-enable-tls' '--stream-idle-timeout' '--stream-port' '--stream-tls-ca' '--stream-tls-cert' '--stream-tls-key' '--tracing-endpoint' '--tracing-sampling-rate-per-million' '--uid-mappings' '--version-file' '--version-file-persist' '--help' '--version')
_describe 'global options' opts

return
Expand Down
3 changes: 3 additions & 0 deletions docs/crio.8.md
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ crio
[--selinux]
[--separate-pull-cgroup]=[value]
[--signature-policy]=[value]
[--stats-collection-period]=[value]
[--storage-driver|-s]=[value]
[--storage-opt]=[value]
[--stream-address]=[value]
Expand Down Expand Up @@ -327,6 +328,8 @@ crio [GLOBAL OPTIONS] command [COMMAND OPTIONS] [ARGUMENTS...]

**--signature-policy**="": Path to signature policy JSON file. (default: "", to use the system-wide default)

**--stats-collection-period**="": The number of seconds between collecting pod and container stats. If set to 0, the stats are collected on-demand instead. (default: 0)

**--storage-driver, -s**="": OCI storage driver (default: "")

**--storage-opt**="": OCI storage driver option (default: [])
Expand Down
6 changes: 6 additions & 0 deletions docs/crio.conf.5.md
Original file line number Diff line number Diff line change
Expand Up @@ -402,6 +402,12 @@ If set to true, enable users to set a custom shm size instead of using the defau
**tracing_sampling_rate_per_million**=""
Number of samples to collect per million OpenTelemetry spans.

## CRIO.STATS TABLE
The `crio.stats` table specifies all necessary configuration for reporting container and pod stats.

**stats_collection_period**=0
The number of seconds between collecting pod and container stats. If set to 0, the stats are collected on-demand instead.

# SEE ALSO
crio.conf.d(5), containers-storage.conf(5), containers-policy.json(5), containers-registries.conf(5), crio(8)

Expand Down
6 changes: 3 additions & 3 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -60,14 +60,14 @@ require (
go.opentelemetry.io/otel v1.2.0
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.2.0
go.opentelemetry.io/otel/sdk v1.2.0
golang.org/x/net v0.0.0-20210525063256-abc453219eb5
golang.org/x/net v0.0.0-20210813160813-60bc85c4be6d
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c
golang.org/x/sys v0.0.0-20210910150752-751e447fb3d0
google.golang.org/grpc v1.42.0
k8s.io/api v0.22.2
k8s.io/apimachinery v0.22.2
k8s.io/client-go v0.22.2
k8s.io/cri-api v0.22.2
k8s.io/cri-api v0.23.0-alpha.3
k8s.io/klog/v2 v2.30.0
k8s.io/kubernetes v1.22.2
k8s.io/release v0.8.0
Expand All @@ -92,7 +92,7 @@ replace (
k8s.io/component-base => k8s.io/kubernetes/staging/src/k8s.io/component-base v0.0.0-20210915213132-8b5a19147530
k8s.io/component-helpers => k8s.io/kubernetes/staging/src/k8s.io/component-helpers v0.0.0-20210915213132-8b5a19147530
k8s.io/controller-manager => k8s.io/kubernetes/staging/src/k8s.io/controller-manager v0.0.0-20210915213132-8b5a19147530
k8s.io/cri-api => k8s.io/kubernetes/staging/src/k8s.io/cri-api v0.0.0-20210915213132-8b5a19147530
k8s.io/cri-api => k8s.io/kubernetes/staging/src/k8s.io/cri-api v0.0.0-20210928072042-90051602459c
k8s.io/csi-translation-lib => k8s.io/kubernetes/staging/src/k8s.io/csi-translation-lib v0.0.0-20210915213132-8b5a19147530
k8s.io/kube-aggregator => k8s.io/kubernetes/staging/src/k8s.io/kube-aggregator v0.0.0-20210915213132-8b5a19147530
k8s.io/kube-controller-manager => k8s.io/kubernetes/staging/src/k8s.io/kube-controller-manager v0.0.0-20210915213132-8b5a19147530
Expand Down
7 changes: 4 additions & 3 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -1538,8 +1538,9 @@ golang.org/x/net v0.0.0-20210331212208-0fccb6fa2b5c/go.mod h1:p54w0d4576C0XHj96b
golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM=
golang.org/x/net v0.0.0-20210428140749-89ef3d95e781/go.mod h1:OJAsFXCWl8Ukc7SiCT/9KSuxbyM7479/AVlXFRxuMCk=
golang.org/x/net v0.0.0-20210520170846-37e1c6afe023/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
golang.org/x/net v0.0.0-20210525063256-abc453219eb5 h1:wjuX4b5yYQnEQHzd+CBcrcC6OVR2J1CN6mUy0oSxIPo=
golang.org/x/net v0.0.0-20210525063256-abc453219eb5/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
golang.org/x/net v0.0.0-20210813160813-60bc85c4be6d h1:LO7XpTYMwTqxjLcGWPijK3vRXg1aWdlNOVOHRq45d7c=
golang.org/x/net v0.0.0-20210813160813-60bc85c4be6d/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
golang.org/x/oauth2 v0.0.0-20181106182150-f42d05182288/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
Expand Down Expand Up @@ -1974,8 +1975,8 @@ k8s.io/kubernetes/staging/src/k8s.io/component-base v0.0.0-20210915213132-8b5a19
k8s.io/kubernetes/staging/src/k8s.io/component-helpers v0.0.0-20210915213132-8b5a19147530 h1:0+mecJdoPert4AyZZANMnYEs8k36Scq4i0Ud4gzhCFg=
k8s.io/kubernetes/staging/src/k8s.io/component-helpers v0.0.0-20210915213132-8b5a19147530/go.mod h1:9Bx6HezI9sKzn5Boasw7vMT8FRgcXsExOoT87Wzdls4=
k8s.io/kubernetes/staging/src/k8s.io/controller-manager v0.0.0-20210915213132-8b5a19147530/go.mod h1:aPin+82yKPEirDGBtNS/4fcc3a1QVOqdt6zzxOlrfc8=
k8s.io/kubernetes/staging/src/k8s.io/cri-api v0.0.0-20210915213132-8b5a19147530 h1:TJWxdbcm0amNDD9SxUI59DsS+ZcjoQ+G8QBv0wX1EAI=
k8s.io/kubernetes/staging/src/k8s.io/cri-api v0.0.0-20210915213132-8b5a19147530/go.mod h1:2XpB3zC24SSO5mhWTzWwBHrO5rO19ncH1bdqS+VuQsI=
k8s.io/kubernetes/staging/src/k8s.io/cri-api v0.0.0-20210928072042-90051602459c h1:fDaVFEHeDenucbpGfzN4zUJYLQb5sZlnsQpGN1wh4zg=
k8s.io/kubernetes/staging/src/k8s.io/cri-api v0.0.0-20210928072042-90051602459c/go.mod h1:9/iOLM7O5FjuFC/92n/5gSH+pLy8kfU1ugnNLe7I90Q=
k8s.io/kubernetes/staging/src/k8s.io/csi-translation-lib v0.0.0-20210915213132-8b5a19147530/go.mod h1:B1gPUSbK2PVSnkxCgw/fmDckzQU6UCuyl670XFbEw6Q=
k8s.io/kubernetes/staging/src/k8s.io/kube-aggregator v0.0.0-20210915213132-8b5a19147530/go.mod h1:LyGGFXi1A101JZQjBNy4RgVgAwtQ5UhRy2KfX/STctk=
k8s.io/kubernetes/staging/src/k8s.io/kube-controller-manager v0.0.0-20210915213132-8b5a19147530/go.mod h1:46iKO45TZat/zvPyqe8TjLLrTS/U/nGB92Ft63PEPF0=
Expand Down
7 changes: 7 additions & 0 deletions internal/config/cgmgr/cgmgr.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import (

"github.com/containers/podman/v3/pkg/cgroups"
"github.com/cri-o/cri-o/internal/config/node"
"github.com/cri-o/cri-o/server/cri/types"
rspec "github.com/opencontainers/runtime-spec/specs-go"
"github.com/pkg/errors"
"github.com/sirupsen/logrus"
Expand Down Expand Up @@ -55,10 +56,16 @@ type CgroupManager interface {
// returns the cgroup path on disk for that containerID. If parentCgroup is empty, it
// uses the default parent for that particular manager
ContainerCgroupAbsolutePath(string, string) (string, error)
// PopulateContainerCgroupStats fills the stats object with information from the cgroup found
// given a cgroup parent and container ID.
PopulateContainerCgroupStats(sbParent, containerID string, stats *types.ContainerStats) error
// SandboxCgroupPath takes the sandbox parent, and sandbox ID. It
// returns the cgroup parent, cgroup path, and error. For systemd cgroups,
// it also checks there is enough memory in the given cgroup
SandboxCgroupPath(string, string) (string, string, error)
// PopulateContainerCgroupStats takes arguments sandbox parent cgroup, and sandbox stats object.
// It fills the object with information from the cgroup found given that parent.
PopulateSandboxCgroupStats(sbParent string, stats *types.PodSandboxStats) error
// MoveConmonToCgroup takes the container ID, cgroup parent, conmon's cgroup (from the config), conmon's PID, and some customized resources
// It attempts to move conmon to the correct cgroup, and set the resources for that cgroup.
// It returns the cgroupfs parent that conmon was put into
Expand Down
2 changes: 1 addition & 1 deletion internal/config/cgmgr/cgmgr_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ const (
)

// The actual test suite
var _ = t.Describe("Config", func() {
var _ = t.Describe("Cgmgr", func() {
var sut cgmgr.CgroupManager

BeforeEach(func() {
Expand Down
22 changes: 22 additions & 0 deletions internal/config/cgmgr/cgroupfs.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (
"github.com/containers/podman/v3/pkg/cgroups"
"github.com/containers/podman/v3/pkg/rootless"
"github.com/cri-o/cri-o/internal/config/node"
"github.com/cri-o/cri-o/server/cri/types"
libctr "github.com/opencontainers/runc/libcontainer/cgroups"
"github.com/opencontainers/runc/libcontainer/cgroups/fs"
"github.com/opencontainers/runc/libcontainer/cgroups/fs2"
Expand Down Expand Up @@ -52,6 +53,17 @@ func (*CgroupfsManager) ContainerCgroupPath(sbParent, containerID string) string
return filepath.Join("/", parent, crioPrefix+"-"+containerID)
}

// PopulateContainerCgroupStats takes arguments sandbox parent cgroup, container ID, and
// containers stats object. It fills the object with information from the cgroup found
// given that parent and ID
func (m *CgroupfsManager) PopulateContainerCgroupStats(sbParent, containerID string, stats *types.ContainerStats) error {
cgPath, err := m.ContainerCgroupAbsolutePath(sbParent, containerID)
if err != nil {
return err
}
return populateContainerCgroupStatsFromPath(cgPath, stats)
}

// ContainerCgroupAbsolutePath just calls ContainerCgroupPath,
// because they both return the absolute path
func (m *CgroupfsManager) ContainerCgroupAbsolutePath(sbParent, containerID string) (string, error) {
Expand All @@ -72,6 +84,16 @@ func (m *CgroupfsManager) SandboxCgroupPath(sbParent, sbID string) (cgParent, cg
return sbParent, filepath.Join(sbParent, crioPrefix+"-"+sbID), nil
}

// PopulateSandboxCgroupStats takes arguments sandbox parent cgroup and sandbox stats object
// It fills the object with information from the cgroup found given that cgroup
func (m *CgroupfsManager) PopulateSandboxCgroupStats(sbParent string, stats *types.PodSandboxStats) error {
_, cgPath, err := sandboxCgroupAbsolutePath(sbParent)
if err != nil {
return err
}
return populateSandboxCgroupStatsFromPath(cgPath, stats)
}

// MoveConmonToCgroup takes the container ID, cgroup parent, conmon's cgroup (from the config) and conmon's PID
// It attempts to move conmon to the correct cgroup.
// It returns the cgroupfs parent that conmon was put into
Expand Down
168 changes: 168 additions & 0 deletions internal/config/cgmgr/stats.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,168 @@
package cgmgr

import (
"bufio"
"os"
"path/filepath"
"strconv"
"strings"
"syscall"
"time"

"github.com/containers/podman/v3/pkg/cgroups"
"github.com/cri-o/cri-o/internal/config/node"
"github.com/cri-o/cri-o/server/cri/types"
"github.com/pkg/errors"
"github.com/sirupsen/logrus"
)

func populateSandboxCgroupStatsFromPath(cgroupPath string, stats *types.PodSandboxStats) error {
cgroupStats, err := cgroupStatsFromPath(cgroupPath)
if err != nil {
return err
}
systemNano := time.Now().UnixNano()
stats.CPU = createCPUStats(systemNano, cgroupStats)
stats.Process = createProcessUsage(systemNano, cgroupStats)
stats.Memory, err = createMemoryStats(systemNano, cgroupStats, cgroupPath)
return err
}

func populateContainerCgroupStatsFromPath(cgroupPath string, stats *types.ContainerStats) error {
// checks cgroup just for the container, not the entire pod
cgroupStats, err := cgroupStatsFromPath(cgroupPath)
if err != nil {
return err
}
systemNano := time.Now().UnixNano()
stats.CPU = createCPUStats(systemNano, cgroupStats)
stats.Memory, err = createMemoryStats(systemNano, cgroupStats, cgroupPath)
return err
}

func cgroupStatsFromPath(cgroupPath string) (*cgroups.Metrics, error) {
cg, err := cgroups.Load(cgroupPath)
if err != nil {
return nil, errors.Wrapf(err, "unable to load cgroup at %s", cgroupPath)
}

return cg.Stat()
}

func createCPUStats(systemNano int64, cgroupStats *cgroups.Metrics) *types.CPUUsage {
return &types.CPUUsage{
Timestamp: systemNano,
UsageCoreNanoSeconds: &types.UInt64Value{Value: cgroupStats.CPU.Usage.Total},
}
}

func createMemoryStats(systemNano int64, cgroupStats *cgroups.Metrics, cgroupPath string) (*types.MemoryUsage, error) {
memUsage := cgroupStats.Memory.Usage.Usage
memLimit := MemLimitGivenSystem(cgroupStats.Memory.Usage.Limit)

memory := &types.MemoryUsage{
Timestamp: systemNano,
WorkingSetBytes: &types.UInt64Value{},
RssBytes: &types.UInt64Value{},
PageFaults: &types.UInt64Value{},
MajorPageFaults: &types.UInt64Value{},
UsageBytes: &types.UInt64Value{Value: memUsage},
AvailableBytes: &types.UInt64Value{Value: memUsage - memLimit},
}

if err := updateWithMemoryStats(cgroupPath, memory, memUsage); err != nil {
return memory, errors.Wrap(err, "unable to update with memory.stat info")
}
return memory, nil
}

// MemLimitGivenSystem limit returns the memory limit for a given cgroup
// If the configured memory limit is larger than the total memory on the sys, the
// physical system memory size is returned
func MemLimitGivenSystem(cgroupLimit uint64) uint64 {
si := &syscall.Sysinfo_t{}
err := syscall.Sysinfo(si)
if err != nil {
return cgroupLimit
}

// conversion to uint64 needed to build on 32-bit
// but lint complains about unnecessary conversion
// see: pr#2409
physicalLimit := uint64(si.Totalram) //nolint:unconvert
if cgroupLimit > physicalLimit {
return physicalLimit
}
return cgroupLimit
}

// updateWithMemoryStats updates the ContainerStats object with info
// from cgroup's memory.stat. Returns an error if the file does not exists,
// or not parsable.
func updateWithMemoryStats(path string, memory *types.MemoryUsage, usage uint64) error {
const memoryStatFile = "memory.stat"
var memoryStatPath, inactiveFileSearchString string
if !node.CgroupIsV2() {
memoryStatPath = filepath.Join(cgroupMemoryPathV1, path, memoryStatFile)
inactiveFileSearchString = "total_inactive_file "
} else {
memoryStatPath = filepath.Join(cgroupMemoryPathV2, path, memoryStatFile)
inactiveFileSearchString = "inactive_file "
}
return UpdateWithMemoryStatsFromFile(memoryStatPath, inactiveFileSearchString, memory, usage)
}

func UpdateWithMemoryStatsFromFile(memoryStatPath, inactiveFileSearchString string, memory *types.MemoryUsage, usage uint64) error {
var totalInactive uint64
f, err := os.Open(memoryStatPath)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

G304: Potential file inclusion via variable
(at-me in a reply with help or ignore)

if err != nil {
return err
}
defer f.Close()

toUpdate := []struct {
prefix string
field *uint64
}{
{inactiveFileSearchString, &totalInactive},
{"rss ", &memory.RssBytes.Value},
{"pgfault ", &memory.PageFaults.Value},
{"pgmajfault ", &memory.MajorPageFaults.Value},
}

scanner := bufio.NewScanner(f)
for scanner.Scan() {
for _, field := range toUpdate {
if !strings.HasPrefix(scanner.Text(), field.prefix) {
continue
}
val, err := strconv.ParseUint(
strings.TrimPrefix(scanner.Text(), field.prefix), 10, 64,
)
if err != nil {
return errors.Wrapf(err, "unable to parse %s", field.prefix)
}
*field.field = val
}
}
if err := scanner.Err(); err != nil {
return err
}
if usage > totalInactive {
memory.WorkingSetBytes.Value = usage - totalInactive
} else {
logrus.Warnf(
"Unable to account working set stats: total_inactive_file (%d) > memory usage (%d)",
totalInactive, usage,
)
}

return nil
}

func createProcessUsage(systemNano int64, cgroupStats *cgroups.Metrics) *types.ProcessUsage {
return &types.ProcessUsage{
Timestamp: systemNano,
ProcessCount: &types.UInt64Value{Value: cgroupStats.Pids.Current},
}
}
Loading