mirror of
https://github.com/kubernetes/node-problem-detector.git
synced 2026-03-03 02:00:36 +00:00
Update dependencies
This commit is contained in:
4
vendor/github.com/prometheus/common/expfmt/text_parse.go
generated
vendored
4
vendor/github.com/prometheus/common/expfmt/text_parse.go
generated
vendored
@@ -345,8 +345,8 @@ func (p *TextParser) startLabelName() stateFn {
|
||||
}
|
||||
// Special summary/histogram treatment. Don't add 'quantile' and 'le'
|
||||
// labels to 'real' labels.
|
||||
if !(p.currentMF.GetType() == dto.MetricType_SUMMARY && p.currentLabelPair.GetName() == model.QuantileLabel) &&
|
||||
!(p.currentMF.GetType() == dto.MetricType_HISTOGRAM && p.currentLabelPair.GetName() == model.BucketLabel) {
|
||||
if (p.currentMF.GetType() != dto.MetricType_SUMMARY || p.currentLabelPair.GetName() != model.QuantileLabel) &&
|
||||
(p.currentMF.GetType() != dto.MetricType_HISTOGRAM || p.currentLabelPair.GetName() != model.BucketLabel) {
|
||||
p.currentLabelPairs = append(p.currentLabelPairs, p.currentLabelPair)
|
||||
}
|
||||
// Check for duplicate label names.
|
||||
|
||||
3
vendor/github.com/prometheus/common/model/labels.go
generated
vendored
3
vendor/github.com/prometheus/common/model/labels.go
generated
vendored
@@ -122,7 +122,8 @@ func (ln LabelName) IsValidLegacy() bool {
|
||||
return false
|
||||
}
|
||||
for i, b := range ln {
|
||||
if !((b >= 'a' && b <= 'z') || (b >= 'A' && b <= 'Z') || b == '_' || (b >= '0' && b <= '9' && i > 0)) {
|
||||
// TODO: Apply De Morgan's law. Make sure there are tests for this.
|
||||
if !((b >= 'a' && b <= 'z') || (b >= 'A' && b <= 'Z') || b == '_' || (b >= '0' && b <= '9' && i > 0)) { //nolint:staticcheck
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
25
vendor/github.com/prometheus/common/model/time.go
generated
vendored
25
vendor/github.com/prometheus/common/model/time.go
generated
vendored
@@ -201,6 +201,7 @@ var unitMap = map[string]struct {
|
||||
|
||||
// ParseDuration parses a string into a time.Duration, assuming that a year
|
||||
// always has 365d, a week always has 7d, and a day always has 24h.
|
||||
// Negative durations are not supported.
|
||||
func ParseDuration(s string) (Duration, error) {
|
||||
switch s {
|
||||
case "0":
|
||||
@@ -253,18 +254,36 @@ func ParseDuration(s string) (Duration, error) {
|
||||
return 0, errors.New("duration out of range")
|
||||
}
|
||||
}
|
||||
|
||||
return Duration(dur), nil
|
||||
}
|
||||
|
||||
// ParseDurationAllowNegative is like ParseDuration but also accepts negative durations.
|
||||
func ParseDurationAllowNegative(s string) (Duration, error) {
|
||||
if s == "" || s[0] != '-' {
|
||||
return ParseDuration(s)
|
||||
}
|
||||
|
||||
d, err := ParseDuration(s[1:])
|
||||
|
||||
return -d, err
|
||||
}
|
||||
|
||||
func (d Duration) String() string {
|
||||
var (
|
||||
ms = int64(time.Duration(d) / time.Millisecond)
|
||||
r = ""
|
||||
ms = int64(time.Duration(d) / time.Millisecond)
|
||||
r = ""
|
||||
sign = ""
|
||||
)
|
||||
|
||||
if ms == 0 {
|
||||
return "0s"
|
||||
}
|
||||
|
||||
if ms < 0 {
|
||||
sign, ms = "-", -ms
|
||||
}
|
||||
|
||||
f := func(unit string, mult int64, exact bool) {
|
||||
if exact && ms%mult != 0 {
|
||||
return
|
||||
@@ -286,7 +305,7 @@ func (d Duration) String() string {
|
||||
f("s", 1000, false)
|
||||
f("ms", 1, false)
|
||||
|
||||
return r
|
||||
return sign + r
|
||||
}
|
||||
|
||||
// MarshalJSON implements the json.Marshaler interface.
|
||||
|
||||
15
vendor/github.com/prometheus/procfs/Makefile.common
generated
vendored
15
vendor/github.com/prometheus/procfs/Makefile.common
generated
vendored
@@ -33,7 +33,7 @@ GOHOSTOS ?= $(shell $(GO) env GOHOSTOS)
|
||||
GOHOSTARCH ?= $(shell $(GO) env GOHOSTARCH)
|
||||
|
||||
GO_VERSION ?= $(shell $(GO) version)
|
||||
GO_VERSION_NUMBER ?= $(word 3, $(GO_VERSION))Error Parsing File
|
||||
GO_VERSION_NUMBER ?= $(word 3, $(GO_VERSION))
|
||||
PRE_GO_111 ?= $(shell echo $(GO_VERSION_NUMBER) | grep -E 'go1\.(10|[0-9])\.')
|
||||
|
||||
PROMU := $(FIRST_GOPATH)/bin/promu
|
||||
@@ -61,7 +61,8 @@ PROMU_URL := https://github.com/prometheus/promu/releases/download/v$(PROMU_
|
||||
SKIP_GOLANGCI_LINT :=
|
||||
GOLANGCI_LINT :=
|
||||
GOLANGCI_LINT_OPTS ?=
|
||||
GOLANGCI_LINT_VERSION ?= v2.0.2
|
||||
GOLANGCI_LINT_VERSION ?= v2.1.5
|
||||
GOLANGCI_FMT_OPTS ?=
|
||||
# golangci-lint only supports linux, darwin and windows platforms on i386/amd64/arm64.
|
||||
# windows isn't included here because of the path separator being different.
|
||||
ifeq ($(GOHOSTOS),$(filter $(GOHOSTOS),linux darwin))
|
||||
@@ -156,9 +157,13 @@ $(GOTEST_DIR):
|
||||
@mkdir -p $@
|
||||
|
||||
.PHONY: common-format
|
||||
common-format:
|
||||
common-format: $(GOLANGCI_LINT)
|
||||
@echo ">> formatting code"
|
||||
$(GO) fmt $(pkgs)
|
||||
ifdef GOLANGCI_LINT
|
||||
@echo ">> formatting code with golangci-lint"
|
||||
$(GOLANGCI_LINT) fmt $(GOLANGCI_FMT_OPTS)
|
||||
endif
|
||||
|
||||
.PHONY: common-vet
|
||||
common-vet:
|
||||
@@ -248,8 +253,8 @@ $(PROMU):
|
||||
cp $(PROMU_TMP)/promu-$(PROMU_VERSION).$(GO_BUILD_PLATFORM)/promu $(FIRST_GOPATH)/bin/promu
|
||||
rm -r $(PROMU_TMP)
|
||||
|
||||
.PHONY: proto
|
||||
proto:
|
||||
.PHONY: common-proto
|
||||
common-proto:
|
||||
@echo ">> generating code from proto files"
|
||||
@./scripts/genproto.sh
|
||||
|
||||
|
||||
5
vendor/github.com/prometheus/procfs/mdstat.go
generated
vendored
5
vendor/github.com/prometheus/procfs/mdstat.go
generated
vendored
@@ -123,13 +123,16 @@ func parseMDStat(mdStatData []byte) ([]MDStat, error) {
|
||||
finish := float64(0)
|
||||
pct := float64(0)
|
||||
recovering := strings.Contains(lines[syncLineIdx], "recovery")
|
||||
reshaping := strings.Contains(lines[syncLineIdx], "reshape")
|
||||
resyncing := strings.Contains(lines[syncLineIdx], "resync")
|
||||
checking := strings.Contains(lines[syncLineIdx], "check")
|
||||
|
||||
// Append recovery and resyncing state info.
|
||||
if recovering || resyncing || checking {
|
||||
if recovering || resyncing || checking || reshaping {
|
||||
if recovering {
|
||||
state = "recovering"
|
||||
} else if reshaping {
|
||||
state = "reshaping"
|
||||
} else if checking {
|
||||
state = "checking"
|
||||
} else {
|
||||
|
||||
33
vendor/github.com/prometheus/procfs/meminfo.go
generated
vendored
33
vendor/github.com/prometheus/procfs/meminfo.go
generated
vendored
@@ -66,6 +66,10 @@ type Meminfo struct {
|
||||
// Memory which has been evicted from RAM, and is temporarily
|
||||
// on the disk
|
||||
SwapFree *uint64
|
||||
// Memory consumed by the zswap backend (compressed size)
|
||||
Zswap *uint64
|
||||
// Amount of anonymous memory stored in zswap (original size)
|
||||
Zswapped *uint64
|
||||
// Memory which is waiting to get written back to the disk
|
||||
Dirty *uint64
|
||||
// Memory which is actively being written back to the disk
|
||||
@@ -85,6 +89,8 @@ type Meminfo struct {
|
||||
// amount of memory dedicated to the lowest level of page
|
||||
// tables.
|
||||
PageTables *uint64
|
||||
// secondary page tables.
|
||||
SecPageTables *uint64
|
||||
// NFS pages sent to the server, but not yet committed to
|
||||
// stable storage
|
||||
NFSUnstable *uint64
|
||||
@@ -129,15 +135,18 @@ type Meminfo struct {
|
||||
Percpu *uint64
|
||||
HardwareCorrupted *uint64
|
||||
AnonHugePages *uint64
|
||||
FileHugePages *uint64
|
||||
ShmemHugePages *uint64
|
||||
ShmemPmdMapped *uint64
|
||||
CmaTotal *uint64
|
||||
CmaFree *uint64
|
||||
Unaccepted *uint64
|
||||
HugePagesTotal *uint64
|
||||
HugePagesFree *uint64
|
||||
HugePagesRsvd *uint64
|
||||
HugePagesSurp *uint64
|
||||
Hugepagesize *uint64
|
||||
Hugetlb *uint64
|
||||
DirectMap4k *uint64
|
||||
DirectMap2M *uint64
|
||||
DirectMap1G *uint64
|
||||
@@ -161,6 +170,8 @@ type Meminfo struct {
|
||||
MlockedBytes *uint64
|
||||
SwapTotalBytes *uint64
|
||||
SwapFreeBytes *uint64
|
||||
ZswapBytes *uint64
|
||||
ZswappedBytes *uint64
|
||||
DirtyBytes *uint64
|
||||
WritebackBytes *uint64
|
||||
AnonPagesBytes *uint64
|
||||
@@ -171,6 +182,7 @@ type Meminfo struct {
|
||||
SUnreclaimBytes *uint64
|
||||
KernelStackBytes *uint64
|
||||
PageTablesBytes *uint64
|
||||
SecPageTablesBytes *uint64
|
||||
NFSUnstableBytes *uint64
|
||||
BounceBytes *uint64
|
||||
WritebackTmpBytes *uint64
|
||||
@@ -182,11 +194,14 @@ type Meminfo struct {
|
||||
PercpuBytes *uint64
|
||||
HardwareCorruptedBytes *uint64
|
||||
AnonHugePagesBytes *uint64
|
||||
FileHugePagesBytes *uint64
|
||||
ShmemHugePagesBytes *uint64
|
||||
ShmemPmdMappedBytes *uint64
|
||||
CmaTotalBytes *uint64
|
||||
CmaFreeBytes *uint64
|
||||
UnacceptedBytes *uint64
|
||||
HugepagesizeBytes *uint64
|
||||
HugetlbBytes *uint64
|
||||
DirectMap4kBytes *uint64
|
||||
DirectMap2MBytes *uint64
|
||||
DirectMap1GBytes *uint64
|
||||
@@ -287,6 +302,12 @@ func parseMemInfo(r io.Reader) (*Meminfo, error) {
|
||||
case "SwapFree:":
|
||||
m.SwapFree = &val
|
||||
m.SwapFreeBytes = &valBytes
|
||||
case "Zswap:":
|
||||
m.Zswap = &val
|
||||
m.ZswapBytes = &valBytes
|
||||
case "Zswapped:":
|
||||
m.Zswapped = &val
|
||||
m.ZswapBytes = &valBytes
|
||||
case "Dirty:":
|
||||
m.Dirty = &val
|
||||
m.DirtyBytes = &valBytes
|
||||
@@ -317,6 +338,9 @@ func parseMemInfo(r io.Reader) (*Meminfo, error) {
|
||||
case "PageTables:":
|
||||
m.PageTables = &val
|
||||
m.PageTablesBytes = &valBytes
|
||||
case "SecPageTables:":
|
||||
m.SecPageTables = &val
|
||||
m.SecPageTablesBytes = &valBytes
|
||||
case "NFS_Unstable:":
|
||||
m.NFSUnstable = &val
|
||||
m.NFSUnstableBytes = &valBytes
|
||||
@@ -350,6 +374,9 @@ func parseMemInfo(r io.Reader) (*Meminfo, error) {
|
||||
case "AnonHugePages:":
|
||||
m.AnonHugePages = &val
|
||||
m.AnonHugePagesBytes = &valBytes
|
||||
case "FileHugePages:":
|
||||
m.FileHugePages = &val
|
||||
m.FileHugePagesBytes = &valBytes
|
||||
case "ShmemHugePages:":
|
||||
m.ShmemHugePages = &val
|
||||
m.ShmemHugePagesBytes = &valBytes
|
||||
@@ -362,6 +389,9 @@ func parseMemInfo(r io.Reader) (*Meminfo, error) {
|
||||
case "CmaFree:":
|
||||
m.CmaFree = &val
|
||||
m.CmaFreeBytes = &valBytes
|
||||
case "Unaccepted:":
|
||||
m.Unaccepted = &val
|
||||
m.UnacceptedBytes = &valBytes
|
||||
case "HugePages_Total:":
|
||||
m.HugePagesTotal = &val
|
||||
case "HugePages_Free:":
|
||||
@@ -373,6 +403,9 @@ func parseMemInfo(r io.Reader) (*Meminfo, error) {
|
||||
case "Hugepagesize:":
|
||||
m.Hugepagesize = &val
|
||||
m.HugepagesizeBytes = &valBytes
|
||||
case "Hugetlb:":
|
||||
m.Hugetlb = &val
|
||||
m.HugetlbBytes = &valBytes
|
||||
case "DirectMap4k:":
|
||||
m.DirectMap4k = &val
|
||||
m.DirectMap4kBytes = &valBytes
|
||||
|
||||
12
vendor/github.com/prometheus/procfs/proc_stat.go
generated
vendored
12
vendor/github.com/prometheus/procfs/proc_stat.go
generated
vendored
@@ -101,6 +101,12 @@ type ProcStat struct {
|
||||
RSS int
|
||||
// Soft limit in bytes on the rss of the process.
|
||||
RSSLimit uint64
|
||||
// The address above which program text can run.
|
||||
StartCode uint64
|
||||
// The address below which program text can run.
|
||||
EndCode uint64
|
||||
// The address of the start (i.e., bottom) of the stack.
|
||||
StartStack uint64
|
||||
// CPU number last executed on.
|
||||
Processor uint
|
||||
// Real-time scheduling priority, a number in the range 1 to 99 for processes
|
||||
@@ -177,9 +183,9 @@ func (p Proc) Stat() (ProcStat, error) {
|
||||
&s.VSize,
|
||||
&s.RSS,
|
||||
&s.RSSLimit,
|
||||
&ignoreUint64,
|
||||
&ignoreUint64,
|
||||
&ignoreUint64,
|
||||
&s.StartCode,
|
||||
&s.EndCode,
|
||||
&s.StartStack,
|
||||
&ignoreUint64,
|
||||
&ignoreUint64,
|
||||
&ignoreUint64,
|
||||
|
||||
116
vendor/github.com/prometheus/procfs/proc_statm.go
generated
vendored
Normal file
116
vendor/github.com/prometheus/procfs/proc_statm.go
generated
vendored
Normal file
@@ -0,0 +1,116 @@
|
||||
// Copyright 2025 The Prometheus Authors
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package procfs
|
||||
|
||||
import (
|
||||
"os"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
"github.com/prometheus/procfs/internal/util"
|
||||
)
|
||||
|
||||
// - https://man7.org/linux/man-pages/man5/proc_pid_statm.5.html
|
||||
|
||||
// ProcStatm Provides memory usage information for a process, measured in memory pages.
|
||||
// Read from /proc/[pid]/statm.
|
||||
type ProcStatm struct {
|
||||
// The process ID.
|
||||
PID int
|
||||
// total program size (same as VmSize in status)
|
||||
Size uint64
|
||||
// resident set size (same as VmRSS in status)
|
||||
Resident uint64
|
||||
// number of resident shared pages (i.e., backed by a file)
|
||||
Shared uint64
|
||||
// text (code)
|
||||
Text uint64
|
||||
// library (unused since Linux 2.6; always 0)
|
||||
Lib uint64
|
||||
// data + stack
|
||||
Data uint64
|
||||
// dirty pages (unused since Linux 2.6; always 0)
|
||||
Dt uint64
|
||||
}
|
||||
|
||||
// NewStatm returns the current status information of the process.
|
||||
// Deprecated: Use p.Statm() instead.
|
||||
func (p Proc) NewStatm() (ProcStatm, error) {
|
||||
return p.Statm()
|
||||
}
|
||||
|
||||
// Statm returns the current memory usage information of the process.
|
||||
func (p Proc) Statm() (ProcStatm, error) {
|
||||
data, err := util.ReadFileNoStat(p.path("statm"))
|
||||
if err != nil {
|
||||
return ProcStatm{}, err
|
||||
}
|
||||
|
||||
statmSlice, err := parseStatm(data)
|
||||
if err != nil {
|
||||
return ProcStatm{}, err
|
||||
}
|
||||
|
||||
procStatm := ProcStatm{
|
||||
PID: p.PID,
|
||||
Size: statmSlice[0],
|
||||
Resident: statmSlice[1],
|
||||
Shared: statmSlice[2],
|
||||
Text: statmSlice[3],
|
||||
Lib: statmSlice[4],
|
||||
Data: statmSlice[5],
|
||||
Dt: statmSlice[6],
|
||||
}
|
||||
|
||||
return procStatm, nil
|
||||
}
|
||||
|
||||
// parseStatm return /proc/[pid]/statm data to uint64 slice.
|
||||
func parseStatm(data []byte) ([]uint64, error) {
|
||||
var statmSlice []uint64
|
||||
statmItems := strings.Fields(string(data))
|
||||
for i := 0; i < len(statmItems); i++ {
|
||||
statmItem, err := strconv.ParseUint(statmItems[i], 10, 64)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
statmSlice = append(statmSlice, statmItem)
|
||||
}
|
||||
return statmSlice, nil
|
||||
}
|
||||
|
||||
// SizeBytes returns the process of total program size in bytes.
|
||||
func (s ProcStatm) SizeBytes() uint64 {
|
||||
return s.Size * uint64(os.Getpagesize())
|
||||
}
|
||||
|
||||
// ResidentBytes returns the process of resident set size in bytes.
|
||||
func (s ProcStatm) ResidentBytes() uint64 {
|
||||
return s.Resident * uint64(os.Getpagesize())
|
||||
}
|
||||
|
||||
// SHRBytes returns the process of share memory size in bytes.
|
||||
func (s ProcStatm) SHRBytes() uint64 {
|
||||
return s.Shared * uint64(os.Getpagesize())
|
||||
}
|
||||
|
||||
// TextBytes returns the process of text (code) size in bytes.
|
||||
func (s ProcStatm) TextBytes() uint64 {
|
||||
return s.Text * uint64(os.Getpagesize())
|
||||
}
|
||||
|
||||
// DataBytes returns the process of data + stack size in bytes.
|
||||
func (s ProcStatm) DataBytes() uint64 {
|
||||
return s.Data * uint64(os.Getpagesize())
|
||||
}
|
||||
Reference in New Issue
Block a user