open-nomad/client/lib/resources/pid.go
hc-github-team-nomad-core e5fb6fe687
backport of commit 615e76ef3c23497f768ebd175f0c624d32aeece8 (#17993)
This pull request was automerged via backport-assistant
2023-07-19 13:31:14 -05:00

29 lines
619 B
Go

// Copyright (c) HashiCorp, Inc.
// SPDX-License-Identifier: MPL-2.0
package resources
import (
"github.com/hashicorp/nomad/helper/stats"
)
// PIDs holds all of a task's pids and their cpu percentage calculators
type PIDs map[int]*PID
// PID holds one task's pid and it's cpu percentage calculator
type PID struct {
PID int
StatsTotalCPU *stats.CpuStats
StatsUserCPU *stats.CpuStats
StatsSysCPU *stats.CpuStats
}
func NewPID(pid int) *PID {
return &PID{
PID: pid,
StatsTotalCPU: stats.NewCpuStats(),
StatsUserCPU: stats.NewCpuStats(),
StatsSysCPU: stats.NewCpuStats(),
}
}