From bd111272c49f64328de3a1a89e142f778d269236 Mon Sep 17 00:00:00 2001 From: prombot Date: Tue, 4 Jun 2024 17:48:02 +0000 Subject: [PATCH 01/15] Update common Prometheus files Signed-off-by: prombot --- .github/workflows/golangci-lint.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/golangci-lint.yml b/.github/workflows/golangci-lint.yml index 5ceb5909..8de7af63 100644 --- a/.github/workflows/golangci-lint.yml +++ b/.github/workflows/golangci-lint.yml @@ -26,7 +26,7 @@ jobs: - name: Checkout repository uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6 - name: Install Go - uses: actions/setup-go@0c52d547c9bc32b1aa3301fd7a9cb496313a4491 # v5.0.0 + uses: actions/setup-go@cdcb36043654635271a94b9a6d1392de5bb323a7 # v5.0.1 with: go-version: 1.22.x - name: Install snmp_exporter/generator dependencies From e416d6dbc784c46140d50cfe49b7cc4aa8867d06 Mon Sep 17 00:00:00 2001 From: Timur Alperovich Date: Mon, 17 Jun 2024 10:55:08 -0700 Subject: [PATCH 02/15] Fix parsing NSpids field in /proc/{PID}/status The NSpids field uses a tab (\t) to separate the list of PIDs. The procfs parser should split on \t, rather than space. This was not caught because the test fixtures themselves used the space character. The patch updates the parser, the fixtures, and adds an explicit test for NSpids. Signed-off-by: Timur Alperovich --- proc_status.go | 18 +++++++++++------- proc_status_test.go | 16 ++++++++++++++++ testdata/fixtures.ttar | 8 ++++---- 3 files changed, 31 insertions(+), 11 deletions(-) diff --git a/proc_status.go b/proc_status.go index a055197c..dd8aa568 100644 --- a/proc_status.go +++ b/proc_status.go @@ -146,7 +146,11 @@ func (s *ProcStatus) fillStatus(k string, vString string, vUint uint64, vUintByt } } case "NSpid": - s.NSpids = calcNSPidsList(vString) + nspids, err := calcNSPidsList(vString) + if err != nil { + return err + } + s.NSpids = nspids case "VmPeak": s.VmPeak = vUintBytes case "VmSize": @@ -222,17 +226,17 @@ func calcCpusAllowedList(cpuString string) []uint64 { return g } -func calcNSPidsList(nspidsString string) []uint64 { - s := strings.Split(nspidsString, " ") +func calcNSPidsList(nspidsString string) ([]uint64, error) { + s := strings.Split(nspidsString, "\t") var nspids []uint64 for _, nspid := range s { - nspid, _ := strconv.ParseUint(nspid, 10, 64) - if nspid == 0 { - continue + nspid, err := strconv.ParseUint(nspid, 10, 64) + if err != nil { + return nil, err } nspids = append(nspids, nspid) } - return nspids + return nspids, nil } diff --git a/proc_status_test.go b/proc_status_test.go index 9644bf01..e41d36ba 100644 --- a/proc_status_test.go +++ b/proc_status_test.go @@ -139,3 +139,19 @@ func TestCpusAllowedList(t *testing.T) { t.Errorf("want CpusAllowedList %v, have %v", want, have) } } + +func TestNsPids(t *testing.T) { + p, err := getProcFixtures(t).Proc(26235) + if err != nil { + t.Fatal(err) + } + + s, err := p.NewStatus() + if err != nil { + t.Fatal(err) + } + + if want, have := []uint64{26235, 1}, s.NSpids; !reflect.DeepEqual(want, have) { + t.Errorf("want NsPids %v, have %v", want, have) + } +} diff --git a/testdata/fixtures.ttar b/testdata/fixtures.ttar index 4bc508b8..f2bd5e56 100644 --- a/testdata/fixtures.ttar +++ b/testdata/fixtures.ttar @@ -818,10 +818,10 @@ Uid: 0 0 0 0 Gid: 0 0 0 0 FDSize: 64 Groups: -NStgid: 26235 1 -NSpid: 26235 1 -NSpgid: 26235 1 -NSsid: 26235 1 +NStgid: 26235 1 +NSpid: 26235 1 +NSpgid: 26235 1 +NSsid: 26235 1 VmPeak: 758200 kB VmSize: 758200 kB VmLck: 0 kB From 0e0b4b16e172f6c40f789a4d43c2f51495a45e22 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 1 Jul 2024 20:58:52 +0000 Subject: [PATCH 03/15] Bump golang.org/x/sys from 0.20.0 to 0.21.0 Bumps [golang.org/x/sys](https://github.com/golang/sys) from 0.20.0 to 0.21.0. - [Commits](https://github.com/golang/sys/compare/v0.20.0...v0.21.0) --- updated-dependencies: - dependency-name: golang.org/x/sys dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 6e9fd6f7..8b7c4f47 100644 --- a/go.mod +++ b/go.mod @@ -5,5 +5,5 @@ go 1.20 require ( github.com/google/go-cmp v0.6.0 golang.org/x/sync v0.7.0 - golang.org/x/sys v0.20.0 + golang.org/x/sys v0.21.0 ) diff --git a/go.sum b/go.sum index cc15e2fb..535a646e 100644 --- a/go.sum +++ b/go.sum @@ -2,5 +2,5 @@ github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI= github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= golang.org/x/sync v0.7.0 h1:YsImfSBoP9QPYL0xyKJPq0gcaJdG3rInoqxTWbfQu9M= golang.org/x/sync v0.7.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= -golang.org/x/sys v0.20.0 h1:Od9JTbYCk261bKm4M/mw7AklTlFYIa0bIp9BgSm1S8Y= -golang.org/x/sys v0.20.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/sys v0.21.0 h1:rF+pYz3DAGSQAxAu1CbC7catZg4ebC4UIeIhKxBZvws= +golang.org/x/sys v0.21.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= From 6acd75f31dccf7a7374391c098bc64bc76d0256a Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 2 Aug 2024 06:33:43 +0200 Subject: [PATCH 04/15] Bump golang.org/x/sys from 0.21.0 to 0.22.0 (#656) Bumps [golang.org/x/sys](https://github.com/golang/sys) from 0.21.0 to 0.22.0. - [Commits](https://github.com/golang/sys/compare/v0.21.0...v0.22.0) --- updated-dependencies: - dependency-name: golang.org/x/sys dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 8b7c4f47..00efa9b6 100644 --- a/go.mod +++ b/go.mod @@ -5,5 +5,5 @@ go 1.20 require ( github.com/google/go-cmp v0.6.0 golang.org/x/sync v0.7.0 - golang.org/x/sys v0.21.0 + golang.org/x/sys v0.22.0 ) diff --git a/go.sum b/go.sum index 535a646e..35019176 100644 --- a/go.sum +++ b/go.sum @@ -2,5 +2,5 @@ github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI= github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= golang.org/x/sync v0.7.0 h1:YsImfSBoP9QPYL0xyKJPq0gcaJdG3rInoqxTWbfQu9M= golang.org/x/sync v0.7.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= -golang.org/x/sys v0.21.0 h1:rF+pYz3DAGSQAxAu1CbC7catZg4ebC4UIeIhKxBZvws= -golang.org/x/sys v0.21.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/sys v0.22.0 h1:RI27ohtqKCnwULzJLqkv897zojh5/DwS/ENaMzUOaWI= +golang.org/x/sys v0.22.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= From 09209a4d52330dff700b57d52b8c3787000186c9 Mon Sep 17 00:00:00 2001 From: PrometheusBot Date: Fri, 2 Aug 2024 06:34:03 +0200 Subject: [PATCH 05/15] Update common Prometheus files (#652) Signed-off-by: prombot --- .github/workflows/golangci-lint.yml | 4 ++-- Makefile.common | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/golangci-lint.yml b/.github/workflows/golangci-lint.yml index 8de7af63..83ae3906 100644 --- a/.github/workflows/golangci-lint.yml +++ b/.github/workflows/golangci-lint.yml @@ -24,7 +24,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout repository - uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6 + uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 - name: Install Go uses: actions/setup-go@cdcb36043654635271a94b9a6d1392de5bb323a7 # v5.0.1 with: @@ -36,4 +36,4 @@ jobs: uses: golangci/golangci-lint-action@a4f60bb28d35aeee14e6880718e0c85ff1882e64 # v6.0.1 with: args: --verbose - version: v1.59.0 + version: v1.59.1 diff --git a/Makefile.common b/Makefile.common index 16172923..e3da72ab 100644 --- a/Makefile.common +++ b/Makefile.common @@ -61,7 +61,7 @@ PROMU_URL := https://github.com/prometheus/promu/releases/download/v$(PROMU_ SKIP_GOLANGCI_LINT := GOLANGCI_LINT := GOLANGCI_LINT_OPTS ?= -GOLANGCI_LINT_VERSION ?= v1.59.0 +GOLANGCI_LINT_VERSION ?= v1.59.1 # 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)) From b4e04cdd63a9187e85c99eb17825435f0d0084a9 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 2 Sep 2024 08:07:56 +0200 Subject: [PATCH 06/15] Bump golang.org/x/sys from 0.22.0 to 0.24.0 (#661) Bumps [golang.org/x/sys](https://github.com/golang/sys) from 0.22.0 to 0.24.0. - [Commits](https://github.com/golang/sys/compare/v0.22.0...v0.24.0) --- updated-dependencies: - dependency-name: golang.org/x/sys dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 00efa9b6..9d58eaf2 100644 --- a/go.mod +++ b/go.mod @@ -5,5 +5,5 @@ go 1.20 require ( github.com/google/go-cmp v0.6.0 golang.org/x/sync v0.7.0 - golang.org/x/sys v0.22.0 + golang.org/x/sys v0.24.0 ) diff --git a/go.sum b/go.sum index 35019176..6a09bb7b 100644 --- a/go.sum +++ b/go.sum @@ -2,5 +2,5 @@ github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI= github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= golang.org/x/sync v0.7.0 h1:YsImfSBoP9QPYL0xyKJPq0gcaJdG3rInoqxTWbfQu9M= golang.org/x/sync v0.7.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= -golang.org/x/sys v0.22.0 h1:RI27ohtqKCnwULzJLqkv897zojh5/DwS/ENaMzUOaWI= -golang.org/x/sys v0.22.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/sys v0.24.0 h1:Twjiwq9dn6R1fQcyiK+wQyHWfaz/BJB+YIpzU/Cv3Xg= +golang.org/x/sys v0.24.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= From 1808690d14ff4feb1e430cf5e6ed4f4ae6ccd617 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 2 Sep 2024 08:12:11 +0200 Subject: [PATCH 07/15] Bump golang.org/x/sync from 0.7.0 to 0.8.0 (#660) Bumps [golang.org/x/sync](https://github.com/golang/sync) from 0.7.0 to 0.8.0. - [Commits](https://github.com/golang/sync/compare/v0.7.0...v0.8.0) --- updated-dependencies: - dependency-name: golang.org/x/sync dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 9d58eaf2..6279cd78 100644 --- a/go.mod +++ b/go.mod @@ -4,6 +4,6 @@ go 1.20 require ( github.com/google/go-cmp v0.6.0 - golang.org/x/sync v0.7.0 + golang.org/x/sync v0.8.0 golang.org/x/sys v0.24.0 ) diff --git a/go.sum b/go.sum index 6a09bb7b..8df1b749 100644 --- a/go.sum +++ b/go.sum @@ -1,6 +1,6 @@ github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI= github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= -golang.org/x/sync v0.7.0 h1:YsImfSBoP9QPYL0xyKJPq0gcaJdG3rInoqxTWbfQu9M= -golang.org/x/sync v0.7.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= +golang.org/x/sync v0.8.0 h1:3NFvSEYkUoMifnESzZl15y791HH1qU2xm6eCJU5ZPXQ= +golang.org/x/sync v0.8.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= golang.org/x/sys v0.24.0 h1:Twjiwq9dn6R1fQcyiK+wQyHWfaz/BJB+YIpzU/Cv3Xg= golang.org/x/sys v0.24.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= From 65f78fc3bd6bbc9c98faebc6c918e8c4e8372641 Mon Sep 17 00:00:00 2001 From: Muhammad Shahzeb Date: Fri, 6 Sep 2024 21:35:40 +0500 Subject: [PATCH 08/15] Add Disk IO stats and ext4 FS stats (#651) Adds function to return disk stats from: * /sys/block//device/ioerr_cnt: number of SCSI commands that completed with an error * /sys/block//device/iodone_cnt: number of completed or rejected SCSI commands Add function to return stats for ext4 filesystem * /sys/fs/ext4//errors_count: number of ext4 errors * /sys/fs/ext4//warning_count: number of ext4 warning log messages * /sys/fs/ext4//msg_count: number of other ext4 log messages Signed-off-by: Muhammad Shahzeb --- blockdevice/stats.go | 28 +++++++++++ ext4/ext4.go | 103 +++++++++++++++++++++++++++++++++++++++++ internal/util/parse.go | 14 ++++++ 3 files changed, 145 insertions(+) create mode 100644 ext4/ext4.go diff --git a/blockdevice/stats.go b/blockdevice/stats.go index 22533002..75b68845 100644 --- a/blockdevice/stats.go +++ b/blockdevice/stats.go @@ -178,6 +178,11 @@ type BlockQueueStats struct { WriteZeroesMaxBytes uint64 } +type IODeviceStats struct { + IODoneCount uint64 + IOErrCount uint64 +} + // DeviceMapperInfo models the devicemapper files that are located in the sysfs tree for each block device // and described in the kernel documentation: // https://www.kernel.org/doc/Documentation/ABI/testing/sysfs-block-dm @@ -209,6 +214,7 @@ const ( sysBlockQueue = "queue" sysBlockDM = "dm" sysUnderlyingDev = "slaves" + sysDevicePath = "device" ) // FS represents the pseudo-filesystems proc and sys, which provides an @@ -474,3 +480,25 @@ func (fs FS) SysBlockDeviceUnderlyingDevices(device string) (UnderlyingDeviceInf return UnderlyingDeviceInfo{DeviceNames: underlying}, nil } + +// SysBlockDeviceIO returns stats for the block device io counters +// IO done count: /sys/block//device/iodone_cnt +// IO error count: /sys/block//device/ioerr_cnt. +func (fs FS) SysBlockDeviceIOStat(device string) (IODeviceStats, error) { + var ( + ioDeviceStats IODeviceStats + err error + ) + for file, p := range map[string]*uint64{ + "iodone_cnt": &ioDeviceStats.IODoneCount, + "ioerr_cnt": &ioDeviceStats.IOErrCount, + } { + var val uint64 + val, err = util.ReadHexFromFile(fs.sys.Path(sysBlockPath, device, sysDevicePath, file)) + if err != nil { + return IODeviceStats{}, err + } + *p = val + } + return ioDeviceStats, nil +} diff --git a/ext4/ext4.go b/ext4/ext4.go new file mode 100644 index 00000000..b7f83a58 --- /dev/null +++ b/ext4/ext4.go @@ -0,0 +1,103 @@ +// Copyright 2019 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 btrfs provides access to statistics exposed by ext4 filesystems. +package ext4 + +import ( + "path/filepath" + "strings" + + "github.com/prometheus/procfs/internal/fs" + "github.com/prometheus/procfs/internal/util" +) + +const ( + sysFSPath = "fs" + sysFSExt4Path = "ext4" +) + +// Stats contains statistics for a single Btrfs filesystem. +// See Linux fs/btrfs/sysfs.c for more information. +type Stats struct { + Name string + + Errors uint64 + Warnings uint64 + Messages uint64 +} + +// FS represents the pseudo-filesystems proc and sys, which provides an +// interface to kernel data structures. +type FS struct { + proc *fs.FS + sys *fs.FS +} + +// NewDefaultFS returns a new blockdevice fs using the default mountPoints for proc and sys. +// It will error if either of these mount points can't be read. +func NewDefaultFS() (FS, error) { + return NewFS(fs.DefaultProcMountPoint, fs.DefaultSysMountPoint) +} + +// NewFS returns a new XFS handle using the given proc and sys mountPoints. It will error +// if either of the mounts point can't be read. +func NewFS(procMountPoint string, sysMountPoint string) (FS, error) { + if strings.TrimSpace(procMountPoint) == "" { + procMountPoint = fs.DefaultProcMountPoint + } + procfs, err := fs.NewFS(procMountPoint) + if err != nil { + return FS{}, err + } + if strings.TrimSpace(sysMountPoint) == "" { + sysMountPoint = fs.DefaultSysMountPoint + } + sysfs, err := fs.NewFS(sysMountPoint) + if err != nil { + return FS{}, err + } + return FS{&procfs, &sysfs}, nil +} + +// ProcStat returns stats for the filesystem. +func (fs FS) ProcStat() ([]*Stats, error) { + matches, err := filepath.Glob(fs.sys.Path("fs/ext4/*")) + if err != nil { + return nil, err + } + + stats := make([]*Stats, 0, len(matches)) + for _, m := range matches { + s := &Stats{} + + // "*" used in glob above indicates the name of the filesystem. + name := filepath.Base(m) + s.Name = name + for file, p := range map[string]*uint64{ + "errors_count": &s.Errors, + "warning_count": &s.Warnings, + "msg_count": &s.Messages, + } { + var val uint64 + val, err = util.ReadUintFromFile(fs.sys.Path(sysFSPath, sysFSExt4Path, name, file)) + if err == nil { + *p = val + } + } + + stats = append(stats, s) + } + + return stats, nil +} diff --git a/internal/util/parse.go b/internal/util/parse.go index 14272dc7..5a7d2df0 100644 --- a/internal/util/parse.go +++ b/internal/util/parse.go @@ -14,6 +14,7 @@ package util import ( + "errors" "os" "strconv" "strings" @@ -110,3 +111,16 @@ func ParseBool(b string) *bool { } return &truth } + +// ReadHexFromFile reads a file and attempts to parse a uint64 from a hexadecimal format 0xXX. +func ReadHexFromFile(path string) (uint64, error) { + data, err := os.ReadFile(path) + if err != nil { + return 0, err + } + hexString := strings.TrimSpace(string(data)) + if !strings.HasPrefix(hexString, "0x") { + return 0, errors.New("invalid format: hex string does not start with '0x'") + } + return strconv.ParseUint(hexString[2:], 16, 64) +} From 31d6315af879bf47bdcd25f95e126925bca965bc Mon Sep 17 00:00:00 2001 From: PrometheusBot Date: Fri, 6 Sep 2024 18:36:15 +0200 Subject: [PATCH 09/15] Update common Prometheus files (#657) Signed-off-by: prombot --- .github/workflows/golangci-lint.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/golangci-lint.yml b/.github/workflows/golangci-lint.yml index 83ae3906..937f2e21 100644 --- a/.github/workflows/golangci-lint.yml +++ b/.github/workflows/golangci-lint.yml @@ -33,7 +33,7 @@ jobs: run: sudo apt-get update && sudo apt-get -y install libsnmp-dev if: github.repository == 'prometheus/snmp_exporter' - name: Lint - uses: golangci/golangci-lint-action@a4f60bb28d35aeee14e6880718e0c85ff1882e64 # v6.0.1 + uses: golangci/golangci-lint-action@aaa42aa0628b4ae2578232a66b541047968fac86 # v6.1.0 with: args: --verbose version: v1.59.1 From a49c6d20a05fcee86662df0e79e5e8c59aa6197a Mon Sep 17 00:00:00 2001 From: PrometheusBot Date: Sat, 7 Sep 2024 06:42:20 +0200 Subject: [PATCH 10/15] Update common Prometheus files (#662) Signed-off-by: prombot --- .github/workflows/golangci-lint.yml | 6 +++--- Makefile.common | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/golangci-lint.yml b/.github/workflows/golangci-lint.yml index 937f2e21..a15cfc97 100644 --- a/.github/workflows/golangci-lint.yml +++ b/.github/workflows/golangci-lint.yml @@ -26,9 +26,9 @@ jobs: - name: Checkout repository uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 - name: Install Go - uses: actions/setup-go@cdcb36043654635271a94b9a6d1392de5bb323a7 # v5.0.1 + uses: actions/setup-go@0a12ed9d6a96ab950c8f026ed9f722fe0da7ef32 # v5.0.2 with: - go-version: 1.22.x + go-version: 1.23.x - name: Install snmp_exporter/generator dependencies run: sudo apt-get update && sudo apt-get -y install libsnmp-dev if: github.repository == 'prometheus/snmp_exporter' @@ -36,4 +36,4 @@ jobs: uses: golangci/golangci-lint-action@aaa42aa0628b4ae2578232a66b541047968fac86 # v6.1.0 with: args: --verbose - version: v1.59.1 + version: v1.60.2 diff --git a/Makefile.common b/Makefile.common index e3da72ab..34d65bb5 100644 --- a/Makefile.common +++ b/Makefile.common @@ -61,7 +61,7 @@ PROMU_URL := https://github.com/prometheus/promu/releases/download/v$(PROMU_ SKIP_GOLANGCI_LINT := GOLANGCI_LINT := GOLANGCI_LINT_OPTS ?= -GOLANGCI_LINT_VERSION ?= v1.59.1 +GOLANGCI_LINT_VERSION ?= v1.60.2 # 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)) From 3b2db06802124921acac90898393b2a15056b143 Mon Sep 17 00:00:00 2001 From: PrometheusBot Date: Mon, 23 Sep 2024 01:47:08 +0200 Subject: [PATCH 11/15] Update common Prometheus files (#666) Signed-off-by: prombot --- Makefile.common | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Makefile.common b/Makefile.common index 34d65bb5..cbb5d863 100644 --- a/Makefile.common +++ b/Makefile.common @@ -275,3 +275,9 @@ $(1)_precheck: exit 1; \ fi endef + +govulncheck: install-govulncheck + govulncheck ./... + +install-govulncheck: + command -v govulncheck > /dev/null || go install golang.org/x/vuln/cmd/govulncheck@latest From fc5df4e22f269d6a28e16820f9b029d155798d21 Mon Sep 17 00:00:00 2001 From: Ben Kochie Date: Mon, 23 Sep 2024 11:13:15 -0700 Subject: [PATCH 12/15] Forbid print statements (#668) Enable `forbidigo` to make sure print statements are not used in this library. This avoids injecting random log output into upstream user's log formatting. Signed-off-by: SuperQ --- .golangci.yml | 5 +++++ proc_smaps.go | 2 -- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/.golangci.yml b/.golangci.yml index d7476d56..e07e8211 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -2,6 +2,7 @@ linters: enable: - errcheck + - forbidigo - godot - gofmt - goimports @@ -15,6 +16,10 @@ linters: - unused linter-settings: + forbidigo: + forbid: + - p: ^fmt\.Print.*$ + msg: Do not commit print statements. godot: capital: true exclude: diff --git a/proc_smaps.go b/proc_smaps.go index 09060e82..07e7e650 100644 --- a/proc_smaps.go +++ b/proc_smaps.go @@ -19,7 +19,6 @@ package procfs import ( "bufio" "errors" - "fmt" "os" "regexp" "strconv" @@ -117,7 +116,6 @@ func (p Proc) procSMapsRollupManual() (ProcSMapsRollup, error) { func (s *ProcSMapsRollup) parseLine(line string) error { kv := strings.SplitN(line, ":", 2) if len(kv) != 2 { - fmt.Println(line) return errors.New("invalid net/dev line, missing colon") } From 54b2b569290aad467dfbb973dbb1ac619c8ae2aa Mon Sep 17 00:00:00 2001 From: SuperQ Date: Mon, 23 Sep 2024 02:14:09 +0200 Subject: [PATCH 13/15] Update supported Go versions * Update to Go 1.21 - 1.23. * Bump modules. Signed-off-by: SuperQ --- .circleci/config.yml | 6 +++--- go.mod | 4 ++-- go.sum | 4 ++-- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 684eb154..8a00ef62 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -4,7 +4,7 @@ version: 2.1 jobs: lint: docker: - - image: cimg/go:1.22 + - image: cimg/go:1.23 steps: - checkout - run: make check_license @@ -46,9 +46,9 @@ workflows: matrix: parameters: go_version: - - "1.20" - "1.21" - "1.22" + - "1.23" - test: name: test-windows os: windows @@ -56,6 +56,6 @@ workflows: matrix: parameters: go_version: - - "1.20" - "1.21" - "1.22" + - "1.23" diff --git a/go.mod b/go.mod index 6279cd78..83f0c358 100644 --- a/go.mod +++ b/go.mod @@ -1,9 +1,9 @@ module github.com/prometheus/procfs -go 1.20 +go 1.21 require ( github.com/google/go-cmp v0.6.0 golang.org/x/sync v0.8.0 - golang.org/x/sys v0.24.0 + golang.org/x/sys v0.25.0 ) diff --git a/go.sum b/go.sum index 8df1b749..f04865b6 100644 --- a/go.sum +++ b/go.sum @@ -2,5 +2,5 @@ github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI= github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= golang.org/x/sync v0.8.0 h1:3NFvSEYkUoMifnESzZl15y791HH1qU2xm6eCJU5ZPXQ= golang.org/x/sync v0.8.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= -golang.org/x/sys v0.24.0 h1:Twjiwq9dn6R1fQcyiK+wQyHWfaz/BJB+YIpzU/Cv3Xg= -golang.org/x/sys v0.24.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/sys v0.25.0 h1:r+8e+loiHxRqhXVl6ML1nO3l1+oFoWbnlu2Ehimmi34= +golang.org/x/sys v0.25.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= From 93a635a52a6fee400a98ae7438ccb8fd5169338e Mon Sep 17 00:00:00 2001 From: Miciah Masters Date: Tue, 29 Oct 2024 16:13:44 -0400 Subject: [PATCH 14/15] =?UTF-8?q?NetIPSocketSummary:=20Fix=20typo=20in=20g?= =?UTF-8?q?odoc:=20UPD=E2=86=92UDP?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change "UPD" to "UDP" in the godoc for the Drops field. Follow-up to commit 9fdfbe8443465c0da56ca44ff5b1d16250e6a396. Signed-off-by: Miciah Masters --- net_ip_socket.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/net_ip_socket.go b/net_ip_socket.go index b70f1fc7..0dc3c30f 100644 --- a/net_ip_socket.go +++ b/net_ip_socket.go @@ -50,7 +50,7 @@ type ( // UsedSockets shows the total number of parsed lines representing the // number of used sockets. UsedSockets uint64 - // Drops shows the total number of dropped packets of all UPD sockets. + // Drops shows the total number of dropped packets of all UDP sockets. Drops *uint64 } From 9c0d20a1ae50a490b82c0bb9694d79cb6752dac8 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 1 Nov 2024 20:32:01 +0000 Subject: [PATCH 15/15] Bump golang.org/x/sys from 0.25.0 to 0.26.0 Bumps [golang.org/x/sys](https://github.com/golang/sys) from 0.25.0 to 0.26.0. - [Commits](https://github.com/golang/sys/compare/v0.25.0...v0.26.0) --- updated-dependencies: - dependency-name: golang.org/x/sys dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 83f0c358..f1337ebe 100644 --- a/go.mod +++ b/go.mod @@ -5,5 +5,5 @@ go 1.21 require ( github.com/google/go-cmp v0.6.0 golang.org/x/sync v0.8.0 - golang.org/x/sys v0.25.0 + golang.org/x/sys v0.26.0 ) diff --git a/go.sum b/go.sum index f04865b6..2149e39b 100644 --- a/go.sum +++ b/go.sum @@ -2,5 +2,5 @@ github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI= github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= golang.org/x/sync v0.8.0 h1:3NFvSEYkUoMifnESzZl15y791HH1qU2xm6eCJU5ZPXQ= golang.org/x/sync v0.8.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= -golang.org/x/sys v0.25.0 h1:r+8e+loiHxRqhXVl6ML1nO3l1+oFoWbnlu2Ehimmi34= -golang.org/x/sys v0.25.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/sys v0.26.0 h1:KHjCJyddX0LoSTb3J+vWpupP9p0oznkqVk/IfjymZbo= +golang.org/x/sys v0.26.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=