From 5d1b96c9361d67bf1e41c44205bfd71353076520 Mon Sep 17 00:00:00 2001 From: L <3177243+LukeLR@users.noreply.github.com> Date: Thu, 27 Jul 2023 03:23:59 +0200 Subject: [PATCH 01/22] Include drm collector in README The DRM collector was missing in the README, this change includes it together with a short description. Signed-off-by: L <3177243+LukeLR@users.noreply.github.com> --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 0a0fbdfd..73751920 100644 --- a/README.md +++ b/README.md @@ -186,6 +186,7 @@ buddyinfo | Exposes statistics of memory fragments as reported by /proc/buddyinf cgroups | A summary of the number of active and enabled cgroups | Linux cpu\_vulnerabilities | Exposes CPU vulnerability information from sysfs. | Linux devstat | Exposes device statistics | Dragonfly, FreeBSD +drm | Expose GPU metrics using sysfs / DRM, `amdgpu` is the only driver which exposes this information through DRM | Linux drbd | Exposes Distributed Replicated Block Device statistics (to version 8.4) | Linux ethtool | Exposes network interface information and network driver statistics equivalent to `ethtool`, `ethtool -S`, and `ethtool -i`. | Linux interrupts | Exposes detailed interrupts statistics. | Linux, OpenBSD From 3b9613cfae0a662a666da03c8d038ec21dba512e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Beno=C3=AEt=20Knecht?= Date: Tue, 1 Aug 2023 15:58:53 +0200 Subject: [PATCH 02/22] collector/netdev_linux.go: Fallback to 32-bit stats (#2757) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit On some platforms, `msg.Attributes.Stats64` is `nil` because the kernel doesn't expose 64-bit stats. In that case, return `msg.Attributes.Stats` instead, which are the 32-bit equivalent. Note that `RXOtherhostDropped` isn't available in that case, so we hardcode it to zero. Fixes #2756. Signed-off-by: BenoƮt Knecht --- collector/netdev_linux.go | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/collector/netdev_linux.go b/collector/netdev_linux.go index 3156d64a..f3348cda 100644 --- a/collector/netdev_linux.go +++ b/collector/netdev_linux.go @@ -56,14 +56,53 @@ func parseNetlinkStats(links []rtnetlink.LinkMessage, filter *deviceFilter, logg metrics := netDevStats{} for _, msg := range links { + if msg.Attributes == nil { + level.Debug(logger).Log("msg", "No netlink attributes, skipping") + continue + } name := msg.Attributes.Name stats := msg.Attributes.Stats64 + if stats32 := msg.Attributes.Stats; stats == nil && stats32 != nil { + stats = &rtnetlink.LinkStats64{ + RXPackets: uint64(stats32.RXPackets), + TXPackets: uint64(stats32.TXPackets), + RXBytes: uint64(stats32.RXBytes), + TXBytes: uint64(stats32.TXBytes), + RXErrors: uint64(stats32.RXErrors), + TXErrors: uint64(stats32.TXErrors), + RXDropped: uint64(stats32.RXDropped), + TXDropped: uint64(stats32.TXDropped), + Multicast: uint64(stats32.Multicast), + Collisions: uint64(stats32.Collisions), + RXLengthErrors: uint64(stats32.RXLengthErrors), + RXOverErrors: uint64(stats32.RXOverErrors), + RXCRCErrors: uint64(stats32.RXCRCErrors), + RXFrameErrors: uint64(stats32.RXFrameErrors), + RXFIFOErrors: uint64(stats32.RXFIFOErrors), + RXMissedErrors: uint64(stats32.RXMissedErrors), + TXAbortedErrors: uint64(stats32.TXAbortedErrors), + TXCarrierErrors: uint64(stats32.TXCarrierErrors), + TXFIFOErrors: uint64(stats32.TXFIFOErrors), + TXHeartbeatErrors: uint64(stats32.TXHeartbeatErrors), + TXWindowErrors: uint64(stats32.TXWindowErrors), + RXCompressed: uint64(stats32.RXCompressed), + TXCompressed: uint64(stats32.TXCompressed), + RXNoHandler: uint64(stats32.RXNoHandler), + RXOtherhostDropped: 0, + } + } if filter.ignored(name) { level.Debug(logger).Log("msg", "Ignoring device", "device", name) continue } + // Make sure we don't panic when accessing `stats` attributes below. + if stats == nil { + level.Debug(logger).Log("msg", "No netlink stats, skipping") + continue + } + // https://github.com/torvalds/linux/blob/master/include/uapi/linux/if_link.h#L42-L246 metrics[name] = map[string]uint64{ "receive_packets": stats.RXPackets, From 35278b94f8c2058ffe39fa5fc08ac922dc52360a Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 2 Aug 2023 17:49:21 +0200 Subject: [PATCH 03/22] build(deps): bump github.com/beevik/ntp from 1.1.1 to 1.3.0 (#2762) Signed-off-by: Ben Kochie --- go.mod | 6 +++--- go.sum | 11 +++++++---- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/go.mod b/go.mod index 9aa81a70..09db70c9 100644 --- a/go.mod +++ b/go.mod @@ -4,7 +4,7 @@ go 1.19 require ( github.com/alecthomas/kingpin/v2 v2.3.2 - github.com/beevik/ntp v1.1.1 + github.com/beevik/ntp v1.3.0 github.com/coreos/go-systemd/v22 v22.5.0 github.com/dennwc/btrfs v0.0.0-20230312211831-a1f570bd01a1 github.com/ema/qdisc v0.0.0-20230120214811-5b708f463de3 @@ -29,7 +29,7 @@ require ( github.com/prometheus/procfs v0.11.0 github.com/safchain/ethtool v0.3.0 golang.org/x/exp v0.0.0-20230522175609-2e198f4a06a1 - golang.org/x/sys v0.9.0 + golang.org/x/sys v0.10.0 howett.net/plist v1.0.0 ) @@ -53,7 +53,7 @@ require ( go.uber.org/atomic v1.7.0 // indirect go.uber.org/multierr v1.6.0 // indirect golang.org/x/crypto v0.10.0 // indirect - golang.org/x/net v0.10.0 // indirect + golang.org/x/net v0.11.0 // indirect golang.org/x/oauth2 v0.8.0 // indirect golang.org/x/sync v0.2.0 // indirect golang.org/x/text v0.10.0 // indirect diff --git a/go.sum b/go.sum index 279497cb..e2f75467 100644 --- a/go.sum +++ b/go.sum @@ -2,8 +2,8 @@ github.com/alecthomas/kingpin/v2 v2.3.2 h1:H0aULhgmSzN8xQ3nX1uxtdlTHYoPLu5AhHxWr github.com/alecthomas/kingpin/v2 v2.3.2/go.mod h1:0gyi0zQnjuFk8xrkNKamJoyUo382HRL7ATRpFZCw6tE= github.com/alecthomas/units v0.0.0-20211218093645-b94a6e3cc137 h1:s6gZFSlWYmbqAuRjVTiNNhvNRfY2Wxp9nhfyel4rklc= github.com/alecthomas/units v0.0.0-20211218093645-b94a6e3cc137/go.mod h1:OMCwj8VM1Kc9e19TLln2VL61YJF0x1XFtfdL4JdbSyE= -github.com/beevik/ntp v1.1.1 h1:ah1SrQMwiyL8eRpb7+Erm7l4PvXnZ/Dnh/gjGZXPvp0= -github.com/beevik/ntp v1.1.1/go.mod h1:br1ZC24XiJQWuIUdrmQT3Bf5jQXIOLaPT+MoAK9Vlk0= +github.com/beevik/ntp v1.3.0 h1:/w5VhpW5BGKS37vFm1p9oVk/t4HnnkKZAZIubHM6F7Q= +github.com/beevik/ntp v1.3.0/go.mod h1:vD6h1um4kzXpqmLTuu0cCLcC+NfvC0IC+ltmEDA8E78= github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM= github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw= github.com/cespare/xxhash/v2 v2.2.0 h1:DC2CZ1Ep5Y4k3ZQ899DldepgrayRUGE6BBZ/cd9Cj44= @@ -120,8 +120,9 @@ golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLL golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c= golang.org/x/net v0.6.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs= -golang.org/x/net v0.10.0 h1:X2//UzNDwYmtCLn7To6G58Wr6f5ahEAQgKNzv9Y951M= golang.org/x/net v0.10.0/go.mod h1:0qNGK6F8kojg2nk9dLZ2mShWaEBan6FAoqfSigmmuDg= +golang.org/x/net v0.11.0 h1:Gi2tvZIJyBtO9SDr1q9h5hEQCp/4L2RQ+ar0qjx2oNU= +golang.org/x/net v0.11.0/go.mod h1:2L/ixqYpgIVXmeoSA/4Lu7BzTG4KIyPIryS4IsOd1oQ= golang.org/x/oauth2 v0.8.0 h1:6dkIjl3j3LtZ/O3sTgZTMsLKSftL/B8Zgq4huOIIUu8= golang.org/x/oauth2 v0.8.0/go.mod h1:yr7u4HXZRm1R1kBWqr/xKNqewf0plRYoB7sla+BCIXE= golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= @@ -139,12 +140,14 @@ golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBc golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.8.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.9.0 h1:KS/R3tvhPqvJvwcKfnBHJwwthS11LRhmM5D59eEXa0s= golang.org/x/sys v0.9.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.10.0 h1:SqMFp9UcQJZa+pmYuAKjd9xq1f0j5rLcDIk0mj4qAsA= +golang.org/x/sys v0.10.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= golang.org/x/term v0.5.0/go.mod h1:jMB1sMXY+tzblOD4FWmEbocvup2/aLOaQEp7JmGp78k= golang.org/x/term v0.8.0/go.mod h1:xPskH00ivmX89bAKVGSKKtLOWNx2+17Eiy94tnKShWo= +golang.org/x/term v0.9.0/go.mod h1:M6DEAAIenWoTxdKrOltXcmDY3rSplQUkrvaDU5FcQyo= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= From 60f08e0aacd99959a1ac3a66df33a97b246c0696 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 2 Aug 2023 18:13:17 +0200 Subject: [PATCH 04/22] build(deps): bump github.com/prometheus/procfs from 0.11.0 to 0.11.1 (#2763) Bumps [github.com/prometheus/procfs](https://github.com/prometheus/procfs) from 0.11.0 to 0.11.1. - [Release notes](https://github.com/prometheus/procfs/releases) - [Commits](https://github.com/prometheus/procfs/compare/v0.11.0...v0.11.1) --- updated-dependencies: - dependency-name: github.com/prometheus/procfs dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- go.mod | 4 ++-- go.sum | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/go.mod b/go.mod index 09db70c9..ef401379 100644 --- a/go.mod +++ b/go.mod @@ -26,7 +26,7 @@ require ( github.com/prometheus/client_model v0.4.0 github.com/prometheus/common v0.44.0 github.com/prometheus/exporter-toolkit v0.10.0 - github.com/prometheus/procfs v0.11.0 + github.com/prometheus/procfs v0.11.1 github.com/safchain/ethtool v0.3.0 golang.org/x/exp v0.0.0-20230522175609-2e198f4a06a1 golang.org/x/sys v0.10.0 @@ -55,7 +55,7 @@ require ( golang.org/x/crypto v0.10.0 // indirect golang.org/x/net v0.11.0 // indirect golang.org/x/oauth2 v0.8.0 // indirect - golang.org/x/sync v0.2.0 // indirect + golang.org/x/sync v0.3.0 // indirect golang.org/x/text v0.10.0 // indirect google.golang.org/appengine v1.6.7 // indirect google.golang.org/protobuf v1.30.0 // indirect diff --git a/go.sum b/go.sum index e2f75467..8db1da2f 100644 --- a/go.sum +++ b/go.sum @@ -84,8 +84,8 @@ github.com/prometheus/common v0.44.0 h1:+5BrQJwiBB9xsMygAB3TNvpQKOwlkc25LbISbrdO github.com/prometheus/common v0.44.0/go.mod h1:ofAIvZbQ1e/nugmZGz4/qCb9Ap1VoSTIO7x0VV9VvuY= github.com/prometheus/exporter-toolkit v0.10.0 h1:yOAzZTi4M22ZzVxD+fhy1URTuNRj/36uQJJ5S8IPza8= github.com/prometheus/exporter-toolkit v0.10.0/go.mod h1:+sVFzuvV5JDyw+Ih6p3zFxZNVnKQa3x5qPmDSiPu4ZY= -github.com/prometheus/procfs v0.11.0 h1:5EAgkfkMl659uZPbe9AS2N68a7Cc1TJbPEuGzFuRbyk= -github.com/prometheus/procfs v0.11.0/go.mod h1:nwNm2aOCAYw8uTR/9bWRREkZFxAUcWzPHWJq+XBB/FM= +github.com/prometheus/procfs v0.11.1 h1:xRC8Iq1yyca5ypa9n1EZnWZkt7dwcoRPQwX/5gwaUuI= +github.com/prometheus/procfs v0.11.1/go.mod h1:eesXgaPo1q7lBpVMoMy0ZOFTth9hBn4W/y0/p/ScXhY= github.com/rogpeppe/go-internal v1.10.0 h1:TMyTOH3F/DB16zRVcYyreMH6GnZZrwQVAoYjRBZyWFQ= github.com/safchain/ethtool v0.3.0 h1:gimQJpsI6sc1yIqP/y8GYgiXn/NjgvpM0RNoWLVVmP0= github.com/safchain/ethtool v0.3.0/go.mod h1:SA9BwrgyAqNo7M+uaL6IYbxpm5wk3L7Mm6ocLW+CJUs= @@ -129,8 +129,8 @@ golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJ golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.1.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.2.0 h1:PUR+T4wwASmuSTYdKjYHI5TD22Wy5ogLU5qZCOLxBrI= -golang.org/x/sync v0.2.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.3.0 h1:ftCYgMx6zT/asHUrPw8BLLscYtGznsLAnjq5RH9P66E= +golang.org/x/sync v0.3.0/go.mod h1:FU7BRWz2tNW+3quACPkgCx/L+uEAv1htQ0V83Z9Rj+Y= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= From c6c28d915ccb96e20fa4d2b76df8d0c28e90a50a Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 2 Aug 2023 18:13:53 +0200 Subject: [PATCH 05/22] build(deps): bump github.com/jsimonetti/rtnetlink from 1.3.3 to 1.3.4 (#2765) Bumps [github.com/jsimonetti/rtnetlink](https://github.com/jsimonetti/rtnetlink) from 1.3.3 to 1.3.4. - [Release notes](https://github.com/jsimonetti/rtnetlink/releases) - [Commits](https://github.com/jsimonetti/rtnetlink/compare/v1.3.3...v1.3.4) --- updated-dependencies: - dependency-name: github.com/jsimonetti/rtnetlink dependency-type: direct:production update-type: version-update:semver-patch ... 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 ef401379..2e9321eb 100644 --- a/go.mod +++ b/go.mod @@ -14,7 +14,7 @@ require ( github.com/hodgesds/perf-utils v0.7.0 github.com/illumos/go-kstat v0.0.0-20210513183136-173c9b0a9973 github.com/josharian/native v1.1.0 - github.com/jsimonetti/rtnetlink v1.3.3 + github.com/jsimonetti/rtnetlink v1.3.4 github.com/lufia/iostat v1.2.1 github.com/mattn/go-xmlrpc v0.0.3 github.com/mdlayher/ethtool v0.1.0 diff --git a/go.sum b/go.sum index 8db1da2f..9910ef0d 100644 --- a/go.sum +++ b/go.sum @@ -47,8 +47,8 @@ github.com/josharian/native v1.1.0 h1:uuaP0hAbW7Y4l0ZRQ6C9zfb7Mg1mbFKry/xzDAfmtL github.com/josharian/native v1.1.0/go.mod h1:7X/raswPFr05uY3HiLlYeyQntB6OO7E/d2Cu7qoaN2w= github.com/jpillora/backoff v1.0.0 h1:uvFg412JmmHBHw7iwprIxkPMI+sGQ4kzOWsMeHnm2EA= github.com/jpillora/backoff v1.0.0/go.mod h1:J/6gKK9jxlEcS3zixgDgUAsiuZ7yrSoa/FX5e0EB2j4= -github.com/jsimonetti/rtnetlink v1.3.3 h1:ycpm3z8XlAzmaacVRjdUT3x6MM1o3YBXsXc7DXSRNCE= -github.com/jsimonetti/rtnetlink v1.3.3/go.mod h1:mW4xSP3wkiqWxHMlfG/gOufp3XnhAxu7EhfABmrWSh8= +github.com/jsimonetti/rtnetlink v1.3.4 h1:uUcd9SE8sQe/enLBEVaWDkgGYWNsX3EU4eIxbEZYmF0= +github.com/jsimonetti/rtnetlink v1.3.4/go.mod h1:jGCNm5lJdGplEXKCVwqhQ5tRIGV0dNREhLyNWVzBxHc= github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE= github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= From 3fb5f70b0ce8481568f18227552638333ea6982d Mon Sep 17 00:00:00 2001 From: Daniel Swarbrick Date: Thu, 3 Aug 2023 15:29:03 +0200 Subject: [PATCH 06/22] Drop redundant GOOS build tags if already in filename Drop redundant GOOS build tags at start of file if the constraint is already specified by the filename, e.g. foo_GOOS.go or foo_GOOS_GOARCH.go, avoiding potential confusion in future. cf. https://pkg.go.dev/cmd/go#hdr-Build_constraints Signed-off-by: Daniel Swarbrick --- collector/boot_time_solaris.go | 4 ++-- collector/cpu_solaris.go | 4 ++-- collector/cpufreq_solaris.go | 4 ++-- collector/diskstats_openbsd.go | 4 ++-- collector/fibrechannel_linux.go | 4 ++-- collector/filesystem_openbsd.go | 4 ++-- collector/infiniband_linux.go | 4 ++-- collector/interrupts_openbsd.go | 4 ++-- collector/meminfo_netbsd.go | 4 ++-- collector/meminfo_openbsd.go | 4 ++-- collector/netdev_openbsd.go | 4 ++-- collector/netisr_freebsd.go | 4 ++-- collector/nvme_linux.go | 4 ++-- collector/selinux_linux.go | 4 ++-- collector/slabinfo_linux.go | 4 ++-- collector/time_linux.go | 4 ++-- collector/zfs_solaris.go | 4 ++-- 17 files changed, 34 insertions(+), 34 deletions(-) diff --git a/collector/boot_time_solaris.go b/collector/boot_time_solaris.go index 3d55e783..15955121 100644 --- a/collector/boot_time_solaris.go +++ b/collector/boot_time_solaris.go @@ -11,8 +11,8 @@ // See the License for the specific language governing permissions and // limitations under the License. -//go:build solaris && !noboottime -// +build solaris,!noboottime +//go:build !noboottime +// +build !noboottime package collector diff --git a/collector/cpu_solaris.go b/collector/cpu_solaris.go index c28b4d6d..32466a1e 100644 --- a/collector/cpu_solaris.go +++ b/collector/cpu_solaris.go @@ -11,8 +11,8 @@ // See the License for the specific language governing permissions and // limitations under the License. -//go:build solaris && !nocpu -// +build solaris,!nocpu +//go:build !nocpu +// +build !nocpu package collector diff --git a/collector/cpufreq_solaris.go b/collector/cpufreq_solaris.go index 6c76ad01..c3fb9ee6 100644 --- a/collector/cpufreq_solaris.go +++ b/collector/cpufreq_solaris.go @@ -11,8 +11,8 @@ // See the License for the specific language governing permissions and // limitations under the License. -//go:build solaris && !nocpu -// +build solaris,!nocpu +//go:build !nocpu +// +build !nocpu package collector diff --git a/collector/diskstats_openbsd.go b/collector/diskstats_openbsd.go index 46d9bc1a..2a69042a 100644 --- a/collector/diskstats_openbsd.go +++ b/collector/diskstats_openbsd.go @@ -11,8 +11,8 @@ // See the License for the specific language governing permissions and // limitations under the License. -//go:build openbsd && !amd64 && !nodiskstats -// +build openbsd,!amd64,!nodiskstats +//go:build !nodiskstats && !amd64 +// +build !nodiskstats,!amd64 package collector diff --git a/collector/fibrechannel_linux.go b/collector/fibrechannel_linux.go index 3993b277..32e4d1e7 100644 --- a/collector/fibrechannel_linux.go +++ b/collector/fibrechannel_linux.go @@ -11,8 +11,8 @@ // See the License for the specific language governing permissions and // limitations under the License. -//go:build linux && !nofibrechannel -// +build linux,!nofibrechannel +//go:build !nofibrechannel +// +build !nofibrechannel package collector diff --git a/collector/filesystem_openbsd.go b/collector/filesystem_openbsd.go index 16cd610d..1c1e479e 100644 --- a/collector/filesystem_openbsd.go +++ b/collector/filesystem_openbsd.go @@ -11,8 +11,8 @@ // See the License for the specific language governing permissions and // limitations under the License. -//go:build openbsd && !nofilesystem -// +build openbsd,!nofilesystem +//go:build !nofilesystem +// +build !nofilesystem package collector diff --git a/collector/infiniband_linux.go b/collector/infiniband_linux.go index 3afb7c45..b0928da3 100644 --- a/collector/infiniband_linux.go +++ b/collector/infiniband_linux.go @@ -11,8 +11,8 @@ // See the License for the specific language governing permissions and // limitations under the License. -//go:build linux && !noinfiniband -// +build linux,!noinfiniband +//go:build !noinfiniband +// +build !noinfiniband package collector diff --git a/collector/interrupts_openbsd.go b/collector/interrupts_openbsd.go index ba734069..9fa5b68d 100644 --- a/collector/interrupts_openbsd.go +++ b/collector/interrupts_openbsd.go @@ -11,8 +11,8 @@ // See the License for the specific language governing permissions and // limitations under the License. -//go:build openbsd && !amd64 && !nointerrupts -// +build openbsd,!amd64,!nointerrupts +//go:build !nointerrupts && !amd64 +// +build !nointerrupts,!amd64 package collector diff --git a/collector/meminfo_netbsd.go b/collector/meminfo_netbsd.go index 7f418479..a1bd1185 100644 --- a/collector/meminfo_netbsd.go +++ b/collector/meminfo_netbsd.go @@ -11,8 +11,8 @@ // See the License for the specific language governing permissions and // limitations under the License. -//go:build netbsd && !nomeminfo -// +build netbsd,!nomeminfo +//go:build !nomeminfo +// +build !nomeminfo package collector diff --git a/collector/meminfo_openbsd.go b/collector/meminfo_openbsd.go index 2c81c50c..c5d2947e 100644 --- a/collector/meminfo_openbsd.go +++ b/collector/meminfo_openbsd.go @@ -11,8 +11,8 @@ // See the License for the specific language governing permissions and // limitations under the License. -//go:build openbsd && !amd64 && !nomeminfo -// +build openbsd,!amd64,!nomeminfo +//go:build !nomeminfo && !amd64 +// +build !nomeminfo,!amd64 package collector diff --git a/collector/netdev_openbsd.go b/collector/netdev_openbsd.go index 5d53678d..b90e3ba7 100644 --- a/collector/netdev_openbsd.go +++ b/collector/netdev_openbsd.go @@ -11,8 +11,8 @@ // See the License for the specific language governing permissions and // limitations under the License. -//go:build openbsd && !amd64 && !nonetdev -// +build openbsd,!amd64,!nonetdev +//go:build !nonetdev && !amd64 +// +build !nonetdev,!amd64 package collector diff --git a/collector/netisr_freebsd.go b/collector/netisr_freebsd.go index 4ac10dae..442bcdc6 100644 --- a/collector/netisr_freebsd.go +++ b/collector/netisr_freebsd.go @@ -11,8 +11,8 @@ // See the License for the specific language governing permissions and // limitations under the License. -//go:build freebsd && !nonetisr -// +build freebsd,!nonetisr +//go:build !nonetisr +// +build !nonetisr package collector diff --git a/collector/nvme_linux.go b/collector/nvme_linux.go index 15af5d75..81d4ab29 100644 --- a/collector/nvme_linux.go +++ b/collector/nvme_linux.go @@ -11,8 +11,8 @@ // See the License for the specific language governing permissions and // limitations under the License. -//go:build linux && !nonvme -// +build linux,!nonvme +//go:build !nonvme +// +build !nonvme package collector diff --git a/collector/selinux_linux.go b/collector/selinux_linux.go index 71a3c021..79316362 100644 --- a/collector/selinux_linux.go +++ b/collector/selinux_linux.go @@ -11,8 +11,8 @@ // See the License for the specific language governing permissions and // limitations under the License. -//go:build linux && !noselinux -// +build linux,!noselinux +//go:build !noselinux +// +build !noselinux package collector diff --git a/collector/slabinfo_linux.go b/collector/slabinfo_linux.go index 8c032cbb..a3c3ebce 100644 --- a/collector/slabinfo_linux.go +++ b/collector/slabinfo_linux.go @@ -11,8 +11,8 @@ // See the License for the specific language governing permissions and // limitations under the License. -//go:build linux && !noslabinfo -// +build linux,!noslabinfo +//go:build !noslabinfo +// +build !noslabinfo package collector diff --git a/collector/time_linux.go b/collector/time_linux.go index a67f5a8f..dd4afe75 100644 --- a/collector/time_linux.go +++ b/collector/time_linux.go @@ -11,8 +11,8 @@ // See the License for the specific language governing permissions and // limitations under the License. -//go:build linux && !notime -// +build linux,!notime +//go:build !notime +// +build !notime package collector diff --git a/collector/zfs_solaris.go b/collector/zfs_solaris.go index 040f31db..52f2500f 100644 --- a/collector/zfs_solaris.go +++ b/collector/zfs_solaris.go @@ -11,8 +11,8 @@ // See the License for the specific language governing permissions and // limitations under the License. -//go:build solaris && !nozfs -// +build solaris,!nozfs +//go:build !nozfs +// +build !nozfs package collector From 37ce0bab8c7afe5133b33bb44cff06fe965cf109 Mon Sep 17 00:00:00 2001 From: Daniel Swarbrick Date: Tue, 15 Aug 2023 11:38:13 +0200 Subject: [PATCH 07/22] Sync build tags in *_test.go (#2767) Ensure that unwanted tests are correctly excluded when various build tags are specified, i.e. when the code that they test would be excluded from compilation. Signed-off-by: Daniel Swarbrick --- collector/bonding_linux_test.go | 3 +++ collector/diskstats_linux_test.go | 3 +++ collector/ethtool_linux_test.go | 3 +++ collector/filefd_linux_test.go | 3 +++ collector/filesystem_linux_test.go | 5 ++++- collector/interrupts_linux_test.go | 3 +++ collector/ipvs_linux_test.go | 3 +++ collector/loadavg_linux_test.go | 3 +++ collector/logind_linux_test.go | 3 +++ collector/meminfo_linux_test.go | 3 +++ collector/meminfo_numa_linux_test.go | 3 +++ collector/netdev_linux_test.go | 3 +++ collector/netstat_linux_test.go | 3 +++ collector/perf_linux_test.go | 5 ++--- collector/systemd_linux_test.go | 3 +++ collector/tcpstat_linux_test.go | 3 +++ collector/textfile_test.go | 3 +++ 17 files changed, 51 insertions(+), 4 deletions(-) diff --git a/collector/bonding_linux_test.go b/collector/bonding_linux_test.go index 564cf01e..98af73fa 100644 --- a/collector/bonding_linux_test.go +++ b/collector/bonding_linux_test.go @@ -11,6 +11,9 @@ // See the License for the specific language governing permissions and // limitations under the License. +//go:build !nobonding +// +build !nobonding + package collector import ( diff --git a/collector/diskstats_linux_test.go b/collector/diskstats_linux_test.go index 526b25d6..f0d7499b 100644 --- a/collector/diskstats_linux_test.go +++ b/collector/diskstats_linux_test.go @@ -11,6 +11,9 @@ // See the License for the specific language governing permissions and // limitations under the License. +//go:build !nodiskstats +// +build !nodiskstats + package collector import ( diff --git a/collector/ethtool_linux_test.go b/collector/ethtool_linux_test.go index 761351c6..cf55c6b1 100644 --- a/collector/ethtool_linux_test.go +++ b/collector/ethtool_linux_test.go @@ -11,6 +11,9 @@ // See the License for the specific language governing permissions and // limitations under the License. +//go:build !noethtool +// +build !noethtool + package collector import ( diff --git a/collector/filefd_linux_test.go b/collector/filefd_linux_test.go index 37e16a4e..f31a5c2c 100644 --- a/collector/filefd_linux_test.go +++ b/collector/filefd_linux_test.go @@ -11,6 +11,9 @@ // See the License for the specific language governing permissions and // limitations under the License. +//go:build !nofilefd +// +build !nofilefd + package collector import "testing" diff --git a/collector/filesystem_linux_test.go b/collector/filesystem_linux_test.go index 4705630d..325ffc87 100644 --- a/collector/filesystem_linux_test.go +++ b/collector/filesystem_linux_test.go @@ -11,14 +11,17 @@ // See the License for the specific language governing permissions and // limitations under the License. +//go:build !nofilesystem +// +build !nofilesystem + package collector import ( - "github.com/go-kit/log" "strings" "testing" "github.com/alecthomas/kingpin/v2" + "github.com/go-kit/log" ) func Test_parseFilesystemLabelsError(t *testing.T) { diff --git a/collector/interrupts_linux_test.go b/collector/interrupts_linux_test.go index 01898368..82e536e4 100644 --- a/collector/interrupts_linux_test.go +++ b/collector/interrupts_linux_test.go @@ -11,6 +11,9 @@ // See the License for the specific language governing permissions and // limitations under the License. +//go:build !nointerrupts +// +build !nointerrupts + package collector import ( diff --git a/collector/ipvs_linux_test.go b/collector/ipvs_linux_test.go index 8c43ad8b..6ee41b29 100644 --- a/collector/ipvs_linux_test.go +++ b/collector/ipvs_linux_test.go @@ -11,6 +11,9 @@ // See the License for the specific language governing permissions and // limitations under the License. +//go:build !noipvs +// +build !noipvs + package collector import ( diff --git a/collector/loadavg_linux_test.go b/collector/loadavg_linux_test.go index e8e5a0ce..2d56317d 100644 --- a/collector/loadavg_linux_test.go +++ b/collector/loadavg_linux_test.go @@ -11,6 +11,9 @@ // See the License for the specific language governing permissions and // limitations under the License. +//go:build !noloadavg +// +build !noloadavg + package collector import "testing" diff --git a/collector/logind_linux_test.go b/collector/logind_linux_test.go index e8d9cb02..5cfedff4 100644 --- a/collector/logind_linux_test.go +++ b/collector/logind_linux_test.go @@ -11,6 +11,9 @@ // See the License for the specific language governing permissions and // limitations under the License. +//go:build !nologind +// +build !nologind + package collector import ( diff --git a/collector/meminfo_linux_test.go b/collector/meminfo_linux_test.go index dc0aff58..a000bea5 100644 --- a/collector/meminfo_linux_test.go +++ b/collector/meminfo_linux_test.go @@ -11,6 +11,9 @@ // See the License for the specific language governing permissions and // limitations under the License. +//go:build !nomeminfo +// +build !nomeminfo + package collector import ( diff --git a/collector/meminfo_numa_linux_test.go b/collector/meminfo_numa_linux_test.go index a17714e8..33bc362e 100644 --- a/collector/meminfo_numa_linux_test.go +++ b/collector/meminfo_numa_linux_test.go @@ -11,6 +11,9 @@ // See the License for the specific language governing permissions and // limitations under the License. +//go:build !nomeminfo_numa +// +build !nomeminfo_numa + package collector import ( diff --git a/collector/netdev_linux_test.go b/collector/netdev_linux_test.go index ff5e1c22..7909d018 100644 --- a/collector/netdev_linux_test.go +++ b/collector/netdev_linux_test.go @@ -11,6 +11,9 @@ // See the License for the specific language governing permissions and // limitations under the License. +//go:build !nonetdev +// +build !nonetdev + package collector import ( diff --git a/collector/netstat_linux_test.go b/collector/netstat_linux_test.go index a27382b4..ec430bc3 100644 --- a/collector/netstat_linux_test.go +++ b/collector/netstat_linux_test.go @@ -11,6 +11,9 @@ // See the License for the specific language governing permissions and // limitations under the License. +//go:build !nonetstat +// +build !nonetstat + package collector import ( diff --git a/collector/perf_linux_test.go b/collector/perf_linux_test.go index c4990d77..fc557ffd 100644 --- a/collector/perf_linux_test.go +++ b/collector/perf_linux_test.go @@ -11,8 +11,8 @@ // See the License for the specific language governing permissions and // limitations under the License. -//go:build !noprocesses -// +build !noprocesses +//go:build !noperf +// +build !noperf package collector @@ -24,7 +24,6 @@ import ( "testing" "github.com/go-kit/log" - "github.com/prometheus/client_golang/prometheus" ) diff --git a/collector/systemd_linux_test.go b/collector/systemd_linux_test.go index 86573d2a..d4e300d1 100644 --- a/collector/systemd_linux_test.go +++ b/collector/systemd_linux_test.go @@ -11,6 +11,9 @@ // See the License for the specific language governing permissions and // limitations under the License. +//go:build !nosystemd +// +build !nosystemd + package collector import ( diff --git a/collector/tcpstat_linux_test.go b/collector/tcpstat_linux_test.go index 693f04fe..e1bd090a 100644 --- a/collector/tcpstat_linux_test.go +++ b/collector/tcpstat_linux_test.go @@ -11,6 +11,9 @@ // See the License for the specific language governing permissions and // limitations under the License. +//go:build !notcpstat +// +build !notcpstat + package collector import ( diff --git a/collector/textfile_test.go b/collector/textfile_test.go index d759dfaf..95e5966f 100644 --- a/collector/textfile_test.go +++ b/collector/textfile_test.go @@ -11,6 +11,9 @@ // See the License for the specific language governing permissions and // limitations under the License. +//go:build !notextfile +// +build !notextfile + package collector import ( From 62254356778647855b8d8bebc585bd0faa0a2623 Mon Sep 17 00:00:00 2001 From: takt Date: Fri, 18 Aug 2023 15:20:22 +0200 Subject: [PATCH 08/22] Upgrade github.com/ema/qdisc to v1.0.0 to improve qdisc collector (#2779) performance Signed-off-by: Oliver Geiselhardt-Herms Co-authored-by: Oliver Geiselhardt-Herms --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 2e9321eb..54d823db 100644 --- a/go.mod +++ b/go.mod @@ -7,7 +7,7 @@ require ( github.com/beevik/ntp v1.3.0 github.com/coreos/go-systemd/v22 v22.5.0 github.com/dennwc/btrfs v0.0.0-20230312211831-a1f570bd01a1 - github.com/ema/qdisc v0.0.0-20230120214811-5b708f463de3 + github.com/ema/qdisc v1.0.0 github.com/go-kit/log v0.2.1 github.com/godbus/dbus/v5 v5.1.0 github.com/hashicorp/go-envparse v0.1.0 diff --git a/go.sum b/go.sum index 9910ef0d..bd2c5c21 100644 --- a/go.sum +++ b/go.sum @@ -19,8 +19,8 @@ github.com/dennwc/btrfs v0.0.0-20230312211831-a1f570bd01a1 h1:ue4Es4Xzz255hWQ7NA github.com/dennwc/btrfs v0.0.0-20230312211831-a1f570bd01a1/go.mod h1:MYsOV9Dgsec3FFSOjywi0QK5r6TeBbdWxdrMGtiYXHA= github.com/dennwc/ioctl v1.0.0 h1:DsWAAjIxRqNcLn9x6mwfuf2pet3iB7aK90K4tF16rLg= github.com/dennwc/ioctl v1.0.0/go.mod h1:ellh2YB5ldny99SBU/VX7Nq0xiZbHphf1DrtHxxjMk0= -github.com/ema/qdisc v0.0.0-20230120214811-5b708f463de3 h1:Jrl8sD8wO34+EE1dV2vhOXrqFAZa/FILDnZRaV28+cw= -github.com/ema/qdisc v0.0.0-20230120214811-5b708f463de3/go.mod h1:FhIc0fLYi7f+lK5maMsesDqwYojIOh3VfRs8EVd5YJQ= +github.com/ema/qdisc v1.0.0 h1:EHLG08FVRbWLg8uRICa3xzC9Zm0m7HyMHfXobWFnXYg= +github.com/ema/qdisc v1.0.0/go.mod h1:FhIc0fLYi7f+lK5maMsesDqwYojIOh3VfRs8EVd5YJQ= github.com/go-kit/log v0.2.1 h1:MRVx0/zhvdseW+Gza6N9rVzU/IVzaeE1SFI4raAhmBU= github.com/go-kit/log v0.2.1/go.mod h1:NwTd00d/i8cPZ3xOwwiv2PO5MOcx78fFErGNcVmBjv0= github.com/go-logfmt/logfmt v0.5.1 h1:otpy5pqBCBZ1ng9RQ0dPu4PN7ba75Y/aA+UpowDyNVA= From 223ebbd50c00178e5bc1652d4664178c79744e76 Mon Sep 17 00:00:00 2001 From: John Kordich Date: Thu, 17 Aug 2023 18:49:41 -0700 Subject: [PATCH 09/22] Add CPU MHz as the value for "node_cpu_info" metric For CPUs which don't have an available (or insertable) cpufreq driver, the /proc/cpuinfo file can sometimes have accurate CPU core frequency measurements. This change replaces the constant value of "1" for the "node_cpu_info" metric with the parsed CPU MHz value from /proc/cpuinfo for each core. Signed-off-by: John Kordich --- collector/cpu_linux.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/collector/cpu_linux.go b/collector/cpu_linux.go index 69e0a175..95efdcb1 100644 --- a/collector/cpu_linux.go +++ b/collector/cpu_linux.go @@ -184,7 +184,7 @@ func (c *cpuCollector) updateInfo(ch chan<- prometheus.Metric) error { for _, cpu := range info { ch <- prometheus.MustNewConstMetric(c.cpuInfo, prometheus.GaugeValue, - 1, + cpu.CPUMHz, cpu.PhysicalID, cpu.CoreID, strconv.Itoa(int(cpu.Processor)), From e84c27810781944987ec309fc991ef779433d4f9 Mon Sep 17 00:00:00 2001 From: John Kordich Date: Thu, 17 Aug 2023 19:24:57 -0700 Subject: [PATCH 10/22] Update e2e-output.txt with new expected metric values Changes the e2e-output.txt file to have the expected CPU MHz values for the node_cpu_info metric. Signed-off-by: John Kordich --- collector/fixtures/e2e-output.txt | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/collector/fixtures/e2e-output.txt b/collector/fixtures/e2e-output.txt index 63a1bab7..8aadc690 100644 --- a/collector/fixtures/e2e-output.txt +++ b/collector/fixtures/e2e-output.txt @@ -311,14 +311,14 @@ node_cpu_guest_seconds_total{cpu="7",mode="nice"} 0.08 node_cpu_guest_seconds_total{cpu="7",mode="user"} 0.09 # HELP node_cpu_info CPU information from /proc/cpuinfo. # TYPE node_cpu_info gauge -node_cpu_info{cachesize="8192 KB",core="0",cpu="0",family="6",microcode="0xb4",model="142",model_name="Intel(R) Core(TM) i7-8650U CPU @ 1.90GHz",package="0",stepping="10",vendor="GenuineIntel"} 1 -node_cpu_info{cachesize="8192 KB",core="0",cpu="4",family="6",microcode="0xb4",model="142",model_name="Intel(R) Core(TM) i7-8650U CPU @ 1.90GHz",package="0",stepping="10",vendor="GenuineIntel"} 1 -node_cpu_info{cachesize="8192 KB",core="1",cpu="1",family="6",microcode="0xb4",model="142",model_name="Intel(R) Core(TM) i7-8650U CPU @ 1.90GHz",package="0",stepping="10",vendor="GenuineIntel"} 1 -node_cpu_info{cachesize="8192 KB",core="1",cpu="5",family="6",microcode="0xb4",model="142",model_name="Intel(R) Core(TM) i7-8650U CPU @ 1.90GHz",package="0",stepping="10",vendor="GenuineIntel"} 1 -node_cpu_info{cachesize="8192 KB",core="2",cpu="2",family="6",microcode="0xb4",model="142",model_name="Intel(R) Core(TM) i7-8650U CPU @ 1.90GHz",package="0",stepping="10",vendor="GenuineIntel"} 1 -node_cpu_info{cachesize="8192 KB",core="2",cpu="6",family="6",microcode="0xb4",model="142",model_name="Intel(R) Core(TM) i7-8650U CPU @ 1.90GHz",package="0",stepping="10",vendor="GenuineIntel"} 1 -node_cpu_info{cachesize="8192 KB",core="3",cpu="3",family="6",microcode="0xb4",model="142",model_name="Intel(R) Core(TM) i7-8650U CPU @ 1.90GHz",package="0",stepping="10",vendor="GenuineIntel"} 1 -node_cpu_info{cachesize="8192 KB",core="3",cpu="7",family="6",microcode="0xb4",model="142",model_name="Intel(R) Core(TM) i7-8650U CPU @ 1.90GHz",package="0",stepping="10",vendor="GenuineIntel"} 1 +node_cpu_info{cachesize="8192 KB",core="0",cpu="0",family="6",microcode="0xb4",model="142",model_name="Intel(R) Core(TM) i7-8650U CPU @ 1.90GHz",package="0",stepping="10",vendor="GenuineIntel"} 799.998 +node_cpu_info{cachesize="8192 KB",core="0",cpu="4",family="6",microcode="0xb4",model="142",model_name="Intel(R) Core(TM) i7-8650U CPU @ 1.90GHz",package="0",stepping="10",vendor="GenuineIntel"} 799.989 +node_cpu_info{cachesize="8192 KB",core="1",cpu="1",family="6",microcode="0xb4",model="142",model_name="Intel(R) Core(TM) i7-8650U CPU @ 1.90GHz",package="0",stepping="10",vendor="GenuineIntel"} 800.037 +node_cpu_info{cachesize="8192 KB",core="1",cpu="5",family="6",microcode="0xb4",model="142",model_name="Intel(R) Core(TM) i7-8650U CPU @ 1.90GHz",package="0",stepping="10",vendor="GenuineIntel"} 800.083 +node_cpu_info{cachesize="8192 KB",core="2",cpu="2",family="6",microcode="0xb4",model="142",model_name="Intel(R) Core(TM) i7-8650U CPU @ 1.90GHz",package="0",stepping="10",vendor="GenuineIntel"} 800.01 +node_cpu_info{cachesize="8192 KB",core="2",cpu="6",family="6",microcode="0xb4",model="142",model_name="Intel(R) Core(TM) i7-8650U CPU @ 1.90GHz",package="0",stepping="10",vendor="GenuineIntel"} 800.017 +node_cpu_info{cachesize="8192 KB",core="3",cpu="3",family="6",microcode="0xb4",model="142",model_name="Intel(R) Core(TM) i7-8650U CPU @ 1.90GHz",package="0",stepping="10",vendor="GenuineIntel"} 800.028 +node_cpu_info{cachesize="8192 KB",core="3",cpu="7",family="6",microcode="0xb4",model="142",model_name="Intel(R) Core(TM) i7-8650U CPU @ 1.90GHz",package="0",stepping="10",vendor="GenuineIntel"} 800.03 # HELP node_cpu_isolated Whether each core is isolated, information from /sys/devices/system/cpu/isolated. # TYPE node_cpu_isolated gauge node_cpu_isolated{cpu="1"} 1 From 933b1c1797fc0c4f738cc0bcb8304483cdc17591 Mon Sep 17 00:00:00 2001 From: John Kordich Date: Fri, 18 Aug 2023 18:23:40 -0700 Subject: [PATCH 11/22] Add new node_cpu_frequency_hertz metric Revert changes to node_cpu_info and add new node_cpu_frequency_hertz metric for measuring CPU frequency from /proc/cpuinfo Signed-off-by: John Kordich --- collector/cpu_linux.go | 22 +++++++++++++++++++++- collector/fixtures/e2e-output.txt | 16 ++++++++-------- 2 files changed, 29 insertions(+), 9 deletions(-) diff --git a/collector/cpu_linux.go b/collector/cpu_linux.go index 95efdcb1..8c5c998e 100644 --- a/collector/cpu_linux.go +++ b/collector/cpu_linux.go @@ -38,6 +38,7 @@ type cpuCollector struct { fs procfs.FS cpu *prometheus.Desc cpuInfo *prometheus.Desc + cpuFrequencyHz *prometheus.Desc cpuFlagsInfo *prometheus.Desc cpuBugsInfo *prometheus.Desc cpuGuest *prometheus.Desc @@ -96,6 +97,11 @@ func NewCPUCollector(logger log.Logger) (Collector, error) { "CPU information from /proc/cpuinfo.", []string{"package", "core", "cpu", "vendor", "family", "model", "model_name", "microcode", "stepping", "cachesize"}, nil, ), + cpuFrequencyHz: prometheus.NewDesc( + prometheus.BuildFQName(namespace, cpuCollectorSubsystem, "frequency_hertz"), + "CPU frequency in hertz from /proc/cpuinfo.", + []string{"package", "core", "cpu"}, nil, + ), cpuFlagsInfo: prometheus.NewDesc( prometheus.BuildFQName(namespace, cpuCollectorSubsystem, "flag_info"), "The `flags` field of CPU information from /proc/cpuinfo taken from the first core.", @@ -184,7 +190,7 @@ func (c *cpuCollector) updateInfo(ch chan<- prometheus.Metric) error { for _, cpu := range info { ch <- prometheus.MustNewConstMetric(c.cpuInfo, prometheus.GaugeValue, - cpu.CPUMHz, + 1, cpu.PhysicalID, cpu.CoreID, strconv.Itoa(int(cpu.Processor)), @@ -197,6 +203,20 @@ func (c *cpuCollector) updateInfo(ch chan<- prometheus.Metric) error { cpu.CacheSize) } + cpuFreqEnabled, ok := collectorState["cpufreq"] + if !ok || cpuFreqEnabled == nil { + level.Warn(c.logger).Log("cpufreq key missing or nil value in collectorState map", err) + } else if !*cpuFreqEnabled { + for _, cpu := range info { + ch <- prometheus.MustNewConstMetric(c.cpuFrequencyHz, + prometheus.GaugeValue, + cpu.CPUMHz*1e6, + cpu.PhysicalID, + cpu.CoreID, + strconv.Itoa(int(cpu.Processor))) + } + } + if len(info) != 0 { cpu := info[0] if err := updateFieldInfo(cpu.Flags, c.cpuFlagsIncludeRegexp, c.cpuFlagsInfo, ch); err != nil { diff --git a/collector/fixtures/e2e-output.txt b/collector/fixtures/e2e-output.txt index 8aadc690..63a1bab7 100644 --- a/collector/fixtures/e2e-output.txt +++ b/collector/fixtures/e2e-output.txt @@ -311,14 +311,14 @@ node_cpu_guest_seconds_total{cpu="7",mode="nice"} 0.08 node_cpu_guest_seconds_total{cpu="7",mode="user"} 0.09 # HELP node_cpu_info CPU information from /proc/cpuinfo. # TYPE node_cpu_info gauge -node_cpu_info{cachesize="8192 KB",core="0",cpu="0",family="6",microcode="0xb4",model="142",model_name="Intel(R) Core(TM) i7-8650U CPU @ 1.90GHz",package="0",stepping="10",vendor="GenuineIntel"} 799.998 -node_cpu_info{cachesize="8192 KB",core="0",cpu="4",family="6",microcode="0xb4",model="142",model_name="Intel(R) Core(TM) i7-8650U CPU @ 1.90GHz",package="0",stepping="10",vendor="GenuineIntel"} 799.989 -node_cpu_info{cachesize="8192 KB",core="1",cpu="1",family="6",microcode="0xb4",model="142",model_name="Intel(R) Core(TM) i7-8650U CPU @ 1.90GHz",package="0",stepping="10",vendor="GenuineIntel"} 800.037 -node_cpu_info{cachesize="8192 KB",core="1",cpu="5",family="6",microcode="0xb4",model="142",model_name="Intel(R) Core(TM) i7-8650U CPU @ 1.90GHz",package="0",stepping="10",vendor="GenuineIntel"} 800.083 -node_cpu_info{cachesize="8192 KB",core="2",cpu="2",family="6",microcode="0xb4",model="142",model_name="Intel(R) Core(TM) i7-8650U CPU @ 1.90GHz",package="0",stepping="10",vendor="GenuineIntel"} 800.01 -node_cpu_info{cachesize="8192 KB",core="2",cpu="6",family="6",microcode="0xb4",model="142",model_name="Intel(R) Core(TM) i7-8650U CPU @ 1.90GHz",package="0",stepping="10",vendor="GenuineIntel"} 800.017 -node_cpu_info{cachesize="8192 KB",core="3",cpu="3",family="6",microcode="0xb4",model="142",model_name="Intel(R) Core(TM) i7-8650U CPU @ 1.90GHz",package="0",stepping="10",vendor="GenuineIntel"} 800.028 -node_cpu_info{cachesize="8192 KB",core="3",cpu="7",family="6",microcode="0xb4",model="142",model_name="Intel(R) Core(TM) i7-8650U CPU @ 1.90GHz",package="0",stepping="10",vendor="GenuineIntel"} 800.03 +node_cpu_info{cachesize="8192 KB",core="0",cpu="0",family="6",microcode="0xb4",model="142",model_name="Intel(R) Core(TM) i7-8650U CPU @ 1.90GHz",package="0",stepping="10",vendor="GenuineIntel"} 1 +node_cpu_info{cachesize="8192 KB",core="0",cpu="4",family="6",microcode="0xb4",model="142",model_name="Intel(R) Core(TM) i7-8650U CPU @ 1.90GHz",package="0",stepping="10",vendor="GenuineIntel"} 1 +node_cpu_info{cachesize="8192 KB",core="1",cpu="1",family="6",microcode="0xb4",model="142",model_name="Intel(R) Core(TM) i7-8650U CPU @ 1.90GHz",package="0",stepping="10",vendor="GenuineIntel"} 1 +node_cpu_info{cachesize="8192 KB",core="1",cpu="5",family="6",microcode="0xb4",model="142",model_name="Intel(R) Core(TM) i7-8650U CPU @ 1.90GHz",package="0",stepping="10",vendor="GenuineIntel"} 1 +node_cpu_info{cachesize="8192 KB",core="2",cpu="2",family="6",microcode="0xb4",model="142",model_name="Intel(R) Core(TM) i7-8650U CPU @ 1.90GHz",package="0",stepping="10",vendor="GenuineIntel"} 1 +node_cpu_info{cachesize="8192 KB",core="2",cpu="6",family="6",microcode="0xb4",model="142",model_name="Intel(R) Core(TM) i7-8650U CPU @ 1.90GHz",package="0",stepping="10",vendor="GenuineIntel"} 1 +node_cpu_info{cachesize="8192 KB",core="3",cpu="3",family="6",microcode="0xb4",model="142",model_name="Intel(R) Core(TM) i7-8650U CPU @ 1.90GHz",package="0",stepping="10",vendor="GenuineIntel"} 1 +node_cpu_info{cachesize="8192 KB",core="3",cpu="7",family="6",microcode="0xb4",model="142",model_name="Intel(R) Core(TM) i7-8650U CPU @ 1.90GHz",package="0",stepping="10",vendor="GenuineIntel"} 1 # HELP node_cpu_isolated Whether each core is isolated, information from /sys/devices/system/cpu/isolated. # TYPE node_cpu_isolated gauge node_cpu_isolated{cpu="1"} 1 From e120d958f51016cb3efdd533e6948955ca272e07 Mon Sep 17 00:00:00 2001 From: John Kordich Date: Fri, 18 Aug 2023 20:47:46 -0700 Subject: [PATCH 12/22] Change log message from Warn to Debug Signed-off-by: John Kordich Co-authored-by: Ben Kochie Signed-off-by: John Kordich --- collector/cpu_linux.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/collector/cpu_linux.go b/collector/cpu_linux.go index 8c5c998e..d158567f 100644 --- a/collector/cpu_linux.go +++ b/collector/cpu_linux.go @@ -205,7 +205,7 @@ func (c *cpuCollector) updateInfo(ch chan<- prometheus.Metric) error { cpuFreqEnabled, ok := collectorState["cpufreq"] if !ok || cpuFreqEnabled == nil { - level.Warn(c.logger).Log("cpufreq key missing or nil value in collectorState map", err) + level.Debug(c.logger).Log("cpufreq key missing or nil value in collectorState map", err) } else if !*cpuFreqEnabled { for _, cpu := range info { ch <- prometheus.MustNewConstMetric(c.cpuFrequencyHz, From f2b274350a07bfd8afcad1a62ef561f8a303fcc2 Mon Sep 17 00:00:00 2001 From: Josh Bradley <49180168+jbradleynh@users.noreply.github.com> Date: Mon, 21 Aug 2023 01:48:09 -0400 Subject: [PATCH 13/22] fix(qdisc) flag naming corrected for consistency (#2782) * fix collector qdisc flag naming for consistency --------- Signed-off-by: jbradleynh --- collector/qdisc_linux.go | 33 +++++++++++++++++++++++++++------ end-to-end-test.sh | 2 +- 2 files changed, 28 insertions(+), 7 deletions(-) diff --git a/collector/qdisc_linux.go b/collector/qdisc_linux.go index 639608df..06ab6a88 100644 --- a/collector/qdisc_linux.go +++ b/collector/qdisc_linux.go @@ -25,6 +25,7 @@ import ( "github.com/alecthomas/kingpin/v2" "github.com/ema/qdisc" "github.com/go-kit/log" + "github.com/go-kit/log/level" "github.com/prometheus/client_golang/prometheus" ) @@ -41,9 +42,11 @@ type qdiscStatCollector struct { } var ( - collectorQdisc = kingpin.Flag("collector.qdisc.fixtures", "test fixtures to use for qdisc collector end-to-end testing").Default("").String() - collectorQdiskDeviceInclude = kingpin.Flag("collector.qdisk.device-include", "Regexp of qdisk devices to include (mutually exclusive to device-exclude).").String() - collectorQdiskDeviceExclude = kingpin.Flag("collector.qdisk.device-exclude", "Regexp of qdisk devices to exclude (mutually exclusive to device-include).").String() + collectorQdisc = kingpin.Flag("collector.qdisc.fixtures", "test fixtures to use for qdisc collector end-to-end testing").Default("").String() + collectorQdiscDeviceInclude = kingpin.Flag("collector.qdisc.device-include", "Regexp of qdisc devices to include (mutually exclusive to device-exclude).").String() + oldCollectorQdiskDeviceInclude = kingpin.Flag("collector.qdisk.device-include", "DEPRECATED: Use collector.qdisc.device-include").Hidden().String() + collectorQdiscDeviceExclude = kingpin.Flag("collector.qdisc.device-exclude", "Regexp of qdisc devices to exclude (mutually exclusive to device-include).").String() + oldCollectorQdiskDeviceExclude = kingpin.Flag("collector.qdisk.device-exclude", "DEPRECATED: Use collector.qdisc.device-exclude").Hidden().String() ) func init() { @@ -52,8 +55,26 @@ func init() { // NewQdiscStatCollector returns a new Collector exposing queuing discipline statistics. func NewQdiscStatCollector(logger log.Logger) (Collector, error) { - if *collectorQdiskDeviceExclude != "" && *collectorQdiskDeviceInclude != "" { - return nil, fmt.Errorf("collector.qdisk.device-include and collector.qdisk.device-exclude are mutaly exclusive") + if *oldCollectorQdiskDeviceInclude != "" { + if *collectorQdiscDeviceInclude == "" { + level.Warn(logger).Log("msg", "--collector.qdisk.device-include is DEPRECATED and will be removed in 2.0.0, use --collector.qdisc.device-include") + *collectorQdiscDeviceInclude = *oldCollectorQdiskDeviceInclude + } else { + return nil, fmt.Errorf("--collector.qdisk.device-include and --collector.qdisc.device-include are mutually exclusive") + } + } + + if *oldCollectorQdiskDeviceExclude != "" { + if *collectorQdiscDeviceExclude == "" { + level.Warn(logger).Log("msg", "--collector.qdisk.device-exclude is DEPRECATED and will be removed in 2.0.0, use --collector.qdisc.device-exclude") + *collectorQdiscDeviceExclude = *oldCollectorQdiskDeviceExclude + } else { + return nil, fmt.Errorf("--collector.qdisk.device-exclude and --collector.qdisc.device-exclude are mutually exclusive") + } + } + + if *collectorQdiscDeviceExclude != "" && *collectorQdiscDeviceInclude != "" { + return nil, fmt.Errorf("collector.qdisc.device-include and collector.qdisc.device-exclude are mutaly exclusive") } return &qdiscStatCollector{ @@ -93,7 +114,7 @@ func NewQdiscStatCollector(logger log.Logger) (Collector, error) { []string{"device", "kind"}, nil, ), prometheus.GaugeValue}, logger: logger, - deviceFilter: newDeviceFilter(*collectorQdiskDeviceExclude, *collectorQdiskDeviceExclude), + deviceFilter: newDeviceFilter(*collectorQdiscDeviceExclude, *collectorQdiscDeviceInclude), }, nil } diff --git a/end-to-end-test.sh b/end-to-end-test.sh index 9aa2b7bf..be40e50d 100755 --- a/end-to-end-test.sh +++ b/end-to-end-test.sh @@ -130,7 +130,7 @@ fi --collector.textfile.directory="collector/fixtures/textfile/two_metric_files/" \ --collector.wifi.fixtures="collector/fixtures/wifi" \ --collector.qdisc.fixtures="collector/fixtures/qdisc/" \ - --collector.qdisk.device-include="(wlan0|eth0)" \ + --collector.qdisc.device-include="(wlan0|eth0)" \ --collector.arp.device-exclude="nope" \ --collector.hwmon.chip-include="(applesmc|coretemp|hwmon4|nct6779)" \ --collector.netclass.ignored-devices="(dmz|int)" \ From 381f32b1c5943afb35940b88c45c3fa4bf5fc1de Mon Sep 17 00:00:00 2001 From: Daniel Swarbrick Date: Fri, 18 Aug 2023 12:49:16 +0200 Subject: [PATCH 14/22] btrfs: close btrfs.FS handle after use Despite being quite hard to provoke (< 10% in my testing), the btrfs collector would occasionally leave stale FDs relating to btrfs mountpoints, making the filesystems unable to be unmounted. Fixes: #2772. Signed-off-by: Daniel Swarbrick --- collector/btrfs_linux.go | 1 + 1 file changed, 1 insertion(+) diff --git a/collector/btrfs_linux.go b/collector/btrfs_linux.go index b5642b33..f1490541 100644 --- a/collector/btrfs_linux.go +++ b/collector/btrfs_linux.go @@ -135,6 +135,7 @@ func (c *btrfsCollector) getIoctlStats() (map[string]*btrfsIoctlFsStats, error) "err", err) continue } + defer fs.Close() fsInfo, err := fs.Info() if err != nil { From cda1d820bb7e913759c22b8e4795eff70f0e442a Mon Sep 17 00:00:00 2001 From: Ben Kochie Date: Sat, 9 Sep 2023 15:44:48 +0200 Subject: [PATCH 15/22] Update to Go 1.21 (#2796) * Update Go build to 1.21. * Update machine images to Ubuntu 22.04 current. Signed-off-by: Ben Kochie --- .circleci/config.yml | 8 ++++---- .promu-cgo.yml | 2 +- .promu.yml | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index d6e6b870..ab00b232 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -7,10 +7,10 @@ executors: # should also be updated. golang: docker: - - image: cimg/go:1.20 + - image: cimg/go:1.21 arm: machine: - image: ubuntu-2004:current + image: ubuntu-2204:current resource_class: arm.medium jobs: @@ -42,7 +42,7 @@ jobs: - run: git diff --exit-code build: machine: - image: ubuntu-2004:202101-01 + image: ubuntu-2204:current parallelism: 3 steps: - prometheus/setup_environment @@ -58,7 +58,7 @@ jobs: destination: /build test_docker: machine: - image: ubuntu-2204:2022.04.2 + image: ubuntu-2204:current environment: DOCKER_TEST_IMAGE_NAME: quay.io/prometheus/golang-builder:1.18-base REPO_PATH: github.com/prometheus/node_exporter diff --git a/.promu-cgo.yml b/.promu-cgo.yml index 975c6e32..d6f82529 100644 --- a/.promu-cgo.yml +++ b/.promu-cgo.yml @@ -1,7 +1,7 @@ go: # Whenever the Go version is updated here, .circle/config.yml and # .promu.yml should also be updated. - version: 1.20 + version: 1.21 cgo: true repository: path: github.com/prometheus/node_exporter diff --git a/.promu.yml b/.promu.yml index f37f8502..d0a66635 100644 --- a/.promu.yml +++ b/.promu.yml @@ -1,7 +1,7 @@ go: # Whenever the Go version is updated here, .circle/config.yml and # .promu-cgo.yml should also be updated. - version: 1.20 + version: 1.21 repository: path: github.com/prometheus/node_exporter build: From 685b98ec7f4855e056ef7d958decfb2cd1fb69b2 Mon Sep 17 00:00:00 2001 From: Daniel Swarbrick Date: Sat, 9 Sep 2023 16:41:09 +0200 Subject: [PATCH 16/22] Optionally fetch ARP stats via rtnetlink instead of procfs (#2777) * Optionally fetch ARP stats via rtnetlink instead of procfs Implement collection of ARP stats via rtnetlink to work around shortcomings in the output of /proc/net/arp, which truncates InfiniBand link-layer addresses. Fixes: #2776 --------- Signed-off-by: Daniel Swarbrick Co-authored-by: Ben Kochie --- collector/arp_linux.go | 66 +++++++++++++++++++++++++++++++++++++++--- end-to-end-test.sh | 1 + go.mod | 4 +-- go.sum | 9 +++--- 4 files changed, 70 insertions(+), 10 deletions(-) diff --git a/collector/arp_linux.go b/collector/arp_linux.go index 46b8893e..c7861156 100644 --- a/collector/arp_linux.go +++ b/collector/arp_linux.go @@ -17,16 +17,22 @@ package collector import ( + "errors" "fmt" + "net" + "github.com/alecthomas/kingpin/v2" "github.com/go-kit/log" + "github.com/jsimonetti/rtnetlink" "github.com/prometheus/client_golang/prometheus" "github.com/prometheus/procfs" + "golang.org/x/sys/unix" ) var ( arpDeviceInclude = kingpin.Flag("collector.arp.device-include", "Regexp of arp devices to include (mutually exclusive to device-exclude).").String() arpDeviceExclude = kingpin.Flag("collector.arp.device-exclude", "Regexp of arp devices to exclude (mutually exclusive to device-include).").String() + arpNetlink = kingpin.Flag("collector.arp.netlink", "Use netlink to gather stats instead of /proc/net/arp.").Default("true").Bool() ) type arpCollector struct { @@ -69,13 +75,65 @@ func getTotalArpEntries(deviceEntries []procfs.ARPEntry) map[string]uint32 { return entries } -func (c *arpCollector) Update(ch chan<- prometheus.Metric) error { - entries, err := c.fs.GatherARPEntries() +func getTotalArpEntriesRTNL() (map[string]uint32, error) { + conn, err := rtnetlink.Dial(nil) if err != nil { - return fmt.Errorf("could not get ARP entries: %w", err) + return nil, err + } + defer conn.Close() + + neighbors, err := conn.Neigh.List() + if err != nil { + return nil, err } - enumeratedEntry := getTotalArpEntries(entries) + ifIndexEntries := make(map[uint32]uint32) + + for _, n := range neighbors { + // Neighbors will also contain IPv6 neighbors, but since this is purely an ARP collector, + // restrict to AF_INET. Also skip entries which have state NUD_NOARP to conform to output + // of /proc/net/arp. + if n.Family == unix.AF_INET && n.State&unix.NUD_NOARP == 0 { + ifIndexEntries[n.Index]++ + } + } + + enumEntries := make(map[string]uint32) + + // Convert interface indexes to names. + for ifIndex, entryCount := range ifIndexEntries { + iface, err := net.InterfaceByIndex(int(ifIndex)) + if err != nil { + if errors.Unwrap(err).Error() == "no such network interface" { + continue + } + return nil, err + } + + enumEntries[iface.Name] = entryCount + } + + return enumEntries, nil +} + +func (c *arpCollector) Update(ch chan<- prometheus.Metric) error { + var enumeratedEntry map[string]uint32 + + if *arpNetlink { + var err error + + enumeratedEntry, err = getTotalArpEntriesRTNL() + if err != nil { + return fmt.Errorf("could not get ARP entries: %w", err) + } + } else { + entries, err := c.fs.GatherARPEntries() + if err != nil { + return fmt.Errorf("could not get ARP entries: %w", err) + } + + enumeratedEntry = getTotalArpEntries(entries) + } for device, entryCount := range enumeratedEntry { if c.deviceFilter.ignored(device) { diff --git a/end-to-end-test.sh b/end-to-end-test.sh index be40e50d..c0b9d67a 100755 --- a/end-to-end-test.sh +++ b/end-to-end-test.sh @@ -132,6 +132,7 @@ fi --collector.qdisc.fixtures="collector/fixtures/qdisc/" \ --collector.qdisc.device-include="(wlan0|eth0)" \ --collector.arp.device-exclude="nope" \ + --no-collector.arp.netlink \ --collector.hwmon.chip-include="(applesmc|coretemp|hwmon4|nct6779)" \ --collector.netclass.ignored-devices="(dmz|int)" \ --collector.netclass.ignore-invalid-speed \ diff --git a/go.mod b/go.mod index 54d823db..8a9b6f07 100644 --- a/go.mod +++ b/go.mod @@ -14,7 +14,7 @@ require ( github.com/hodgesds/perf-utils v0.7.0 github.com/illumos/go-kstat v0.0.0-20210513183136-173c9b0a9973 github.com/josharian/native v1.1.0 - github.com/jsimonetti/rtnetlink v1.3.4 + github.com/jsimonetti/rtnetlink v1.3.5 github.com/lufia/iostat v1.2.1 github.com/mattn/go-xmlrpc v0.0.3 github.com/mdlayher/ethtool v0.1.0 @@ -29,7 +29,7 @@ require ( github.com/prometheus/procfs v0.11.1 github.com/safchain/ethtool v0.3.0 golang.org/x/exp v0.0.0-20230522175609-2e198f4a06a1 - golang.org/x/sys v0.10.0 + golang.org/x/sys v0.11.0 howett.net/plist v1.0.0 ) diff --git a/go.sum b/go.sum index bd2c5c21..136bee36 100644 --- a/go.sum +++ b/go.sum @@ -8,7 +8,7 @@ github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM= github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw= github.com/cespare/xxhash/v2 v2.2.0 h1:DC2CZ1Ep5Y4k3ZQ899DldepgrayRUGE6BBZ/cd9Cj44= github.com/cespare/xxhash/v2 v2.2.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= -github.com/cilium/ebpf v0.10.0 h1:nk5HPMeoBXtOzbkZBWym+ZWq1GIiHUsBFXxwewXAHLQ= +github.com/cilium/ebpf v0.11.0 h1:V8gS/bTCCjX9uUnkUFUpPsksM8n1lXBAvHcpiFk1X2Y= github.com/coreos/go-systemd/v22 v22.5.0 h1:RrqgGjYQKalulkV8NGVIfkXQf6YYmOyiJKk8iXXhfZs= github.com/coreos/go-systemd/v22 v22.5.0/go.mod h1:Y58oyj3AT4RCenI/lSvhwexgC+NSVTIJ3seZv2GcEnc= github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= @@ -47,8 +47,8 @@ github.com/josharian/native v1.1.0 h1:uuaP0hAbW7Y4l0ZRQ6C9zfb7Mg1mbFKry/xzDAfmtL github.com/josharian/native v1.1.0/go.mod h1:7X/raswPFr05uY3HiLlYeyQntB6OO7E/d2Cu7qoaN2w= github.com/jpillora/backoff v1.0.0 h1:uvFg412JmmHBHw7iwprIxkPMI+sGQ4kzOWsMeHnm2EA= github.com/jpillora/backoff v1.0.0/go.mod h1:J/6gKK9jxlEcS3zixgDgUAsiuZ7yrSoa/FX5e0EB2j4= -github.com/jsimonetti/rtnetlink v1.3.4 h1:uUcd9SE8sQe/enLBEVaWDkgGYWNsX3EU4eIxbEZYmF0= -github.com/jsimonetti/rtnetlink v1.3.4/go.mod h1:jGCNm5lJdGplEXKCVwqhQ5tRIGV0dNREhLyNWVzBxHc= +github.com/jsimonetti/rtnetlink v1.3.5 h1:hVlNQNRlLDGZz31gBPicsG7Q53rnlsz1l1Ix/9XlpVA= +github.com/jsimonetti/rtnetlink v1.3.5/go.mod h1:0LFedyiTkebnd43tE4YAkWGIq9jQphow4CcwxaT2Y00= github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE= github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= @@ -141,8 +141,9 @@ golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.8.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.9.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.10.0 h1:SqMFp9UcQJZa+pmYuAKjd9xq1f0j5rLcDIk0mj4qAsA= golang.org/x/sys v0.10.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.11.0 h1:eG7RXZHdqOJ1i+0lgLgCpSXAp6M3LYlAo6osgSi0xOM= +golang.org/x/sys v0.11.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= golang.org/x/term v0.5.0/go.mod h1:jMB1sMXY+tzblOD4FWmEbocvup2/aLOaQEp7JmGp78k= From e590476dc7362ffa9d3bc52f087a911722f687f3 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Sat, 9 Sep 2023 17:09:30 +0200 Subject: [PATCH 17/22] build(deps): bump golang.org/x/sys from 0.10.0 to 0.12.0 (#2797) Bumps [golang.org/x/sys](https://github.com/golang/sys) from 0.10.0 to 0.12.0. - [Commits](https://github.com/golang/sys/compare/v0.10.0...v0.12.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 8a9b6f07..107f11c9 100644 --- a/go.mod +++ b/go.mod @@ -29,7 +29,7 @@ require ( github.com/prometheus/procfs v0.11.1 github.com/safchain/ethtool v0.3.0 golang.org/x/exp v0.0.0-20230522175609-2e198f4a06a1 - golang.org/x/sys v0.11.0 + golang.org/x/sys v0.12.0 howett.net/plist v1.0.0 ) diff --git a/go.sum b/go.sum index 136bee36..f1ea4e19 100644 --- a/go.sum +++ b/go.sum @@ -142,8 +142,8 @@ golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.8.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.9.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.10.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.11.0 h1:eG7RXZHdqOJ1i+0lgLgCpSXAp6M3LYlAo6osgSi0xOM= -golang.org/x/sys v0.11.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.12.0 h1:CM0HF96J0hcLAwsHPJZjfdNzs0gftsLfgKt57wWHJ0o= +golang.org/x/sys v0.12.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= golang.org/x/term v0.5.0/go.mod h1:jMB1sMXY+tzblOD4FWmEbocvup2/aLOaQEp7JmGp78k= From 5ae22fa2c075ab4527bc28d402df5fc6b11116a7 Mon Sep 17 00:00:00 2001 From: PrometheusBot Date: Sat, 9 Sep 2023 20:42:39 +0200 Subject: [PATCH 18/22] Update common Prometheus files (#2798) Signed-off-by: prombot --- .github/workflows/golangci-lint.yml | 2 +- Makefile.common | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/golangci-lint.yml b/.github/workflows/golangci-lint.yml index 433f71b8..a619a732 100644 --- a/.github/workflows/golangci-lint.yml +++ b/.github/workflows/golangci-lint.yml @@ -29,4 +29,4 @@ jobs: - name: Lint uses: golangci/golangci-lint-action@v3.4.0 with: - version: v1.53.3 + version: v1.54.2 diff --git a/Makefile.common b/Makefile.common index 0ce7ea46..062a2818 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.53.3 +GOLANGCI_LINT_VERSION ?= v1.54.2 # golangci-lint only supports linux, darwin and windows platforms on i386/amd64. # windows isn't included here because of the path separator being different. ifeq ($(GOHOSTOS),$(filter $(GOHOSTOS),linux darwin)) From f34aaa61092fe7e3c6618fdb0b0d16a68a291ff7 Mon Sep 17 00:00:00 2001 From: Conall O'Brien Date: Mon, 11 Sep 2023 05:33:21 +0100 Subject: [PATCH 19/22] Add ZFS freebsd per dataset stats (#2753) * Rename parsePoolObjsetFile to parseLinuxPoolObjsetFile to better reflect it's scope * Create a new parseFreeBSDPoolObjsetStats function, to generate a list of per pool metrics to be queried via sysctl --------- Signed-off-by: Conall O'Brien --- collector/exec_bsd.go | 6 ++++ collector/memory_bsd.go | 12 +++++++ collector/netisr_freebsd.go | 6 ++++ collector/sysctl_bsd.go | 3 ++ collector/zfs_freebsd.go | 70 +++++++++++++++++++++++++++++++++++++ collector/zfs_linux.go | 4 +-- collector/zfs_linux_test.go | 2 +- 7 files changed, 100 insertions(+), 3 deletions(-) diff --git a/collector/exec_bsd.go b/collector/exec_bsd.go index 87cb3cee..7ae5e2ee 100644 --- a/collector/exec_bsd.go +++ b/collector/exec_bsd.go @@ -49,31 +49,37 @@ func NewExecCollector(logger log.Logger) (Collector, error) { name: "exec_context_switches_total", description: "Context switches since system boot. Resets at architecture unsigned integer.", mib: "vm.stats.sys.v_swtch", + labels: nil, }, { name: "exec_traps_total", description: "Traps since system boot. Resets at architecture unsigned integer.", mib: "vm.stats.sys.v_trap", + labels: nil, }, { name: "exec_system_calls_total", description: "System calls since system boot. Resets at architecture unsigned integer.", mib: "vm.stats.sys.v_syscall", }, + labels: nil, { name: "exec_device_interrupts_total", description: "Device interrupts since system boot. Resets at architecture unsigned integer.", mib: "vm.stats.sys.v_intr", + labels: nil, }, { name: "exec_software_interrupts_total", description: "Software interrupts since system boot. Resets at architecture unsigned integer.", mib: "vm.stats.sys.v_soft", + labels: nil, }, { name: "exec_forks_total", description: "Number of fork() calls since system boot. Resets at architecture unsigned integer.", mib: "vm.stats.vm.v_forks", + labels: nil, }, }, logger: logger, diff --git a/collector/memory_bsd.go b/collector/memory_bsd.go index 6af9d8aa..6f16ac89 100644 --- a/collector/memory_bsd.go +++ b/collector/memory_bsd.go @@ -69,18 +69,21 @@ func NewMemoryCollector(logger log.Logger) (Collector, error) { description: "Recently used by userland", mib: "vm.stats.vm.v_active_count", conversion: fromPage, + labels: nil, }, { name: "inactive_bytes", description: "Not recently used by userland", mib: "vm.stats.vm.v_inactive_count", conversion: fromPage, + labels: nil, }, { name: "wired_bytes", description: "Locked in memory by kernel, mlock, etc", mib: "vm.stats.vm.v_wire_count", conversion: fromPage, + labels: nil, }, { name: "user_wired_bytes", @@ -88,42 +91,49 @@ func NewMemoryCollector(logger log.Logger) (Collector, error) { mib: "vm.stats.vm.v_user_wire_count", conversion: fromPage, dataType: bsdSysctlTypeCLong, + labels: nil, }, { name: "cache_bytes", description: "Almost free, backed by swap or files, available for re-allocation", mib: "vm.stats.vm.v_cache_count", conversion: fromPage, + labels: nil, }, { name: "buffer_bytes", description: "Disk IO Cache entries for non ZFS filesystems, only usable by kernel", mib: "vfs.bufspace", dataType: bsdSysctlTypeCLong, + labels: nil, }, { name: "free_bytes", description: "Unallocated, available for allocation", mib: "vm.stats.vm.v_free_count", conversion: fromPage, + labels: nil, }, { name: "laundry_bytes", description: "Dirty not recently used by userland", mib: "vm.stats.vm.v_laundry_count", conversion: fromPage, + labels: nil, }, { name: "size_bytes", description: "Total physical memory size", mib: "vm.stats.vm.v_page_count", conversion: fromPage, + labels: nil, }, { name: "swap_size_bytes", description: "Total swap memory size", mib: mibSwapTotal, dataType: bsdSysctlTypeUint64, + labels: nil, }, // Descriptions via: top(1) { @@ -132,6 +142,7 @@ func NewMemoryCollector(logger log.Logger) (Collector, error) { mib: "vm.stats.vm.v_swappgsin", valueType: prometheus.CounterValue, conversion: fromPage, + labels: nil, }, { name: "swap_out_bytes_total", @@ -139,6 +150,7 @@ func NewMemoryCollector(logger log.Logger) (Collector, error) { mib: "vm.stats.vm.v_swappgsout", valueType: prometheus.CounterValue, conversion: fromPage, + labels: nil, }, }, }, nil diff --git a/collector/netisr_freebsd.go b/collector/netisr_freebsd.go index 442bcdc6..43991f3a 100644 --- a/collector/netisr_freebsd.go +++ b/collector/netisr_freebsd.go @@ -45,6 +45,7 @@ func NewNetisrCollector(logger log.Logger) (Collector, error) { mib: "net.isr.numthreads", dataType: bsdSysctlTypeUint32, valueType: prometheus.GaugeValue, + labels: nil, }, { name: "maxprot", @@ -52,6 +53,7 @@ func NewNetisrCollector(logger log.Logger) (Collector, error) { mib: "net.isr.maxprot", dataType: bsdSysctlTypeUint32, valueType: prometheus.GaugeValue, + labels: nil, }, { name: "defaultqlimit", @@ -59,6 +61,7 @@ func NewNetisrCollector(logger log.Logger) (Collector, error) { mib: "net.isr.defaultqlimit", dataType: bsdSysctlTypeUint32, valueType: prometheus.GaugeValue, + labels: nil, }, { name: "maxqlimit", @@ -66,6 +69,7 @@ func NewNetisrCollector(logger log.Logger) (Collector, error) { mib: "net.isr.maxqlimit", dataType: bsdSysctlTypeUint32, valueType: prometheus.GaugeValue, + labels: nil, }, { name: "bindthreads", @@ -73,6 +77,7 @@ func NewNetisrCollector(logger log.Logger) (Collector, error) { mib: "net.isr.bindthreads", dataType: bsdSysctlTypeUint32, valueType: prometheus.GaugeValue, + labels: nil, }, { name: "maxthreads", @@ -80,6 +85,7 @@ func NewNetisrCollector(logger log.Logger) (Collector, error) { mib: "net.isr.maxthreads", dataType: bsdSysctlTypeUint32, valueType: prometheus.GaugeValue, + labels: nil, }, }, logger: logger, diff --git a/collector/sysctl_bsd.go b/collector/sysctl_bsd.go index 2ab248ed..df5c9f93 100644 --- a/collector/sysctl_bsd.go +++ b/collector/sysctl_bsd.go @@ -59,6 +59,9 @@ type bsdSysctl struct { // Post-retrieval conversion hooks conversion func(float64) float64 + + // Prometheus labels + labels prometheus.Labels } func (b bsdSysctl) Value() (float64, error) { diff --git a/collector/zfs_freebsd.go b/collector/zfs_freebsd.go index 2418b229..2b3948a5 100644 --- a/collector/zfs_freebsd.go +++ b/collector/zfs_freebsd.go @@ -21,6 +21,8 @@ import ( "github.com/go-kit/log" "github.com/prometheus/client_golang/prometheus" + + "golang.org/x/sys/unix" ) type zfsCollector struct { @@ -45,6 +47,7 @@ func NewZfsCollector(logger log.Logger) (Collector, error) { mib: "kstat.zfs.misc.abdstats.linear_cnt", dataType: bsdSysctlTypeUint64, valueType: prometheus.CounterValue, + labels: nil, }, { name: "abdstats_linear_data_bytes", @@ -52,6 +55,7 @@ func NewZfsCollector(logger log.Logger) (Collector, error) { mib: "kstat.zfs.misc.abdstats.linear_data_size", dataType: bsdSysctlTypeUint64, valueType: prometheus.GaugeValue, + labels: nil, }, { name: "abdstats_scatter_chunk_waste_bytes", @@ -59,6 +63,7 @@ func NewZfsCollector(logger log.Logger) (Collector, error) { mib: "kstat.zfs.misc.abdstats.scatter_chunk_waste", dataType: bsdSysctlTypeUint64, valueType: prometheus.GaugeValue, + labels: nil, }, { name: "abdstats_scatter_count_total", @@ -66,6 +71,7 @@ func NewZfsCollector(logger log.Logger) (Collector, error) { mib: "kstat.zfs.misc.abdstats.scatter_cnt", dataType: bsdSysctlTypeUint64, valueType: prometheus.CounterValue, + labels: nil, }, { name: "abdstats_scatter_data_bytes", @@ -73,6 +79,7 @@ func NewZfsCollector(logger log.Logger) (Collector, error) { mib: "kstat.zfs.misc.abdstats.scatter_data_size", dataType: bsdSysctlTypeUint64, valueType: prometheus.GaugeValue, + labels: nil, }, { name: "abdstats_struct_bytes", @@ -80,6 +87,7 @@ func NewZfsCollector(logger log.Logger) (Collector, error) { mib: "kstat.zfs.misc.abdstats.struct_size", dataType: bsdSysctlTypeUint64, valueType: prometheus.GaugeValue, + labels: nil, }, { name: "arcstats_anon_bytes", @@ -87,6 +95,7 @@ func NewZfsCollector(logger log.Logger) (Collector, error) { mib: "kstat.zfs.misc.arcstats.anon_size", dataType: bsdSysctlTypeUint64, valueType: prometheus.GaugeValue, + labels: nil, }, { name: "arcstats_c_bytes", @@ -94,6 +103,7 @@ func NewZfsCollector(logger log.Logger) (Collector, error) { mib: "kstat.zfs.misc.arcstats.c", dataType: bsdSysctlTypeUint64, valueType: prometheus.GaugeValue, + labels: nil, }, { name: "arcstats_c_max_bytes", @@ -101,6 +111,7 @@ func NewZfsCollector(logger log.Logger) (Collector, error) { mib: "kstat.zfs.misc.arcstats.c_max", dataType: bsdSysctlTypeUint64, valueType: prometheus.GaugeValue, + labels: nil, }, { name: "arcstats_c_min_bytes", @@ -108,6 +119,7 @@ func NewZfsCollector(logger log.Logger) (Collector, error) { mib: "kstat.zfs.misc.arcstats.c_min", dataType: bsdSysctlTypeUint64, valueType: prometheus.GaugeValue, + labels: nil, }, { name: "arcstats_data_bytes", @@ -115,6 +127,7 @@ func NewZfsCollector(logger log.Logger) (Collector, error) { mib: "kstat.zfs.misc.arcstats.data_size", dataType: bsdSysctlTypeUint64, valueType: prometheus.GaugeValue, + labels: nil, }, { name: "arcstats_demand_data_hits_total", @@ -122,6 +135,7 @@ func NewZfsCollector(logger log.Logger) (Collector, error) { mib: "kstat.zfs.misc.arcstats.demand_data_hits", dataType: bsdSysctlTypeUint64, valueType: prometheus.CounterValue, + labels: nil, }, { name: "arcstats_demand_data_misses_total", @@ -129,6 +143,7 @@ func NewZfsCollector(logger log.Logger) (Collector, error) { mib: "kstat.zfs.misc.arcstats.demand_data_misses", dataType: bsdSysctlTypeUint64, valueType: prometheus.CounterValue, + labels: nil, }, { name: "arcstats_demand_metadata_hits_total", @@ -136,6 +151,7 @@ func NewZfsCollector(logger log.Logger) (Collector, error) { mib: "kstat.zfs.misc.arcstats.demand_metadata_hits", dataType: bsdSysctlTypeUint64, valueType: prometheus.CounterValue, + labels: nil, }, { name: "arcstats_demand_metadata_misses_total", @@ -143,6 +159,7 @@ func NewZfsCollector(logger log.Logger) (Collector, error) { mib: "kstat.zfs.misc.arcstats.demand_metadata_misses", dataType: bsdSysctlTypeUint64, valueType: prometheus.CounterValue, + labels: nil, }, { name: "arcstats_hdr_bytes", @@ -150,6 +167,7 @@ func NewZfsCollector(logger log.Logger) (Collector, error) { mib: "kstat.zfs.misc.arcstats.hdr_size", dataType: bsdSysctlTypeUint64, valueType: prometheus.GaugeValue, + labels: nil, }, { name: "arcstats_hits_total", @@ -157,6 +175,7 @@ func NewZfsCollector(logger log.Logger) (Collector, error) { mib: "kstat.zfs.misc.arcstats.hits", dataType: bsdSysctlTypeUint64, valueType: prometheus.CounterValue, + labels: nil, }, { name: "arcstats_misses_total", @@ -164,6 +183,7 @@ func NewZfsCollector(logger log.Logger) (Collector, error) { mib: "kstat.zfs.misc.arcstats.misses", dataType: bsdSysctlTypeUint64, valueType: prometheus.CounterValue, + labels: nil, }, { name: "arcstats_mfu_ghost_hits_total", @@ -171,6 +191,7 @@ func NewZfsCollector(logger log.Logger) (Collector, error) { mib: "kstat.zfs.misc.arcstats.mfu_ghost_hits", dataType: bsdSysctlTypeUint64, valueType: prometheus.CounterValue, + labels: nil, }, { name: "arcstats_mfu_ghost_size", @@ -178,6 +199,7 @@ func NewZfsCollector(logger log.Logger) (Collector, error) { mib: "kstat.zfs.misc.arcstats.mfu_ghost_size", dataType: bsdSysctlTypeUint64, valueType: prometheus.GaugeValue, + labels: nil, }, { name: "arcstats_mfu_bytes", @@ -185,6 +207,7 @@ func NewZfsCollector(logger log.Logger) (Collector, error) { mib: "kstat.zfs.misc.arcstats.mfu_size", dataType: bsdSysctlTypeUint64, valueType: prometheus.GaugeValue, + labels: nil, }, { name: "arcstats_mru_ghost_hits_total", @@ -192,6 +215,7 @@ func NewZfsCollector(logger log.Logger) (Collector, error) { mib: "kstat.zfs.misc.arcstats.mru_ghost_hits", dataType: bsdSysctlTypeUint64, valueType: prometheus.CounterValue, + labels: nil, }, { name: "arcstats_mru_ghost_bytes", @@ -199,6 +223,7 @@ func NewZfsCollector(logger log.Logger) (Collector, error) { mib: "kstat.zfs.misc.arcstats.mru_ghost_size", dataType: bsdSysctlTypeUint64, valueType: prometheus.GaugeValue, + labels: nil, }, { name: "arcstats_mru_bytes", @@ -206,6 +231,7 @@ func NewZfsCollector(logger log.Logger) (Collector, error) { mib: "kstat.zfs.misc.arcstats.mru_size", dataType: bsdSysctlTypeUint64, valueType: prometheus.GaugeValue, + labels: nil, }, { name: "arcstats_other_bytes", @@ -213,6 +239,7 @@ func NewZfsCollector(logger log.Logger) (Collector, error) { mib: "kstat.zfs.misc.arcstats.other_size", dataType: bsdSysctlTypeUint64, valueType: prometheus.GaugeValue, + labels: nil, }, { name: "arcstats_p_bytes", @@ -220,6 +247,7 @@ func NewZfsCollector(logger log.Logger) (Collector, error) { mib: "kstat.zfs.misc.arcstats.p", dataType: bsdSysctlTypeUint64, valueType: prometheus.GaugeValue, + labels: nil, }, { name: "arcstats_size_bytes", @@ -227,6 +255,7 @@ func NewZfsCollector(logger log.Logger) (Collector, error) { mib: "kstat.zfs.misc.arcstats.size", dataType: bsdSysctlTypeUint64, valueType: prometheus.GaugeValue, + labels: nil, }, { name: "zfetchstats_hits_total", @@ -234,6 +263,7 @@ func NewZfsCollector(logger log.Logger) (Collector, error) { mib: "kstat.zfs.misc.zfetchstats.hits", dataType: bsdSysctlTypeUint64, valueType: prometheus.CounterValue, + labels: nil, }, { name: "zfetchstats_misses_total", @@ -241,6 +271,7 @@ func NewZfsCollector(logger log.Logger) (Collector, error) { mib: "kstat.zfs.misc.zfetchstats.misses", dataType: bsdSysctlTypeUint64, valueType: prometheus.CounterValue, + labels: nil, }, }, logger: logger, @@ -264,3 +295,42 @@ func (c *zfsCollector) Update(ch chan<- prometheus.Metric) error { return nil } + +func (c *zfsCollector) parseFreeBSDPoolObjsetStats() error { + + sysCtlMetrics := []string{ + "nunlinked", "nunlinks", "nread", "reads", "nwritten", "writes", + } + zfsPoolMibPrefix := "kstat.zfs.pool.dataset" + zfsDatasetsNames := []string{} + + zfsDatasets, err := unix.Sysctl(zfsPoolMibPrefix) + if err != nil { + return fmt.Errorf("couldn't get sysctl: %w", err) + } + + for dataset, _ := range zfsDatasets { + if strings.HasSuffix(dataset, ".dataset_name") { + zfsDatasetNames = append(zfsDatasetNames, strings.SplitAfter(dataset, ".")[3]) + } + } + + for zpoolDataset := range zfsDatasetsNames { + zfsDatasetLabels := map[string]string{ + "dataset": zpoolDataset, + "zpool": strings.SplitAfter(zpoolDataset, "/")[0], + } + for metric := range sysCtlMetrics { + c.sysctls = append(c.sysctls, bsdSysctl{ + name: fmt.SprintF("node_zfs_zpool_dataset_%s", metric), + description: fmt.SprintF("node_zfs_zpool_dataset_%s", metric), + mib: fmt.Sprintf("%s.%s.%s", zfsPoolMibPrefix, poolObj, metric), + dataType: bsdSysctlTypeUint64, + valueType: prometheus.CounterValue, + labels: zfsDatasetLabels, + }) + } + } + + return nil +} diff --git a/collector/zfs_linux.go b/collector/zfs_linux.go index ec195b3d..e7be4a98 100644 --- a/collector/zfs_linux.go +++ b/collector/zfs_linux.go @@ -104,7 +104,7 @@ func (c *zfsCollector) updatePoolStats(ch chan<- prometheus.Metric) error { return errZFSNotAvailable } - err = c.parsePoolObjsetFile(file, zpoolPath, func(poolName string, datasetName string, s zfsSysctl, v uint64) { + err = c.parseLinuxPoolObjsetFile(file, zpoolPath, func(poolName string, datasetName string, s zfsSysctl, v uint64) { ch <- c.constPoolObjsetMetric(poolName, datasetName, s, v) }) file.Close() @@ -220,7 +220,7 @@ func (c *zfsCollector) parsePoolProcfsFile(reader io.Reader, zpoolPath string, h return scanner.Err() } -func (c *zfsCollector) parsePoolObjsetFile(reader io.Reader, zpoolPath string, handler func(string, string, zfsSysctl, uint64)) error { +func (c *zfsCollector) parseLinuxPoolObjsetFile(reader io.Reader, zpoolPath string, handler func(string, string, zfsSysctl, uint64)) error { scanner := bufio.NewScanner(reader) parseLine := false diff --git a/collector/zfs_linux_test.go b/collector/zfs_linux_test.go index 69e4ed8f..f6ce8d94 100644 --- a/collector/zfs_linux_test.go +++ b/collector/zfs_linux_test.go @@ -332,7 +332,7 @@ func TestZpoolObjsetParsing(t *testing.T) { t.Fatal(err) } - err = c.parsePoolObjsetFile(file, zpoolPath, func(poolName string, datasetName string, s zfsSysctl, v uint64) { + err = c.parseLinuxPoolObjsetFile(file, zpoolPath, func(poolName string, datasetName string, s zfsSysctl, v uint64) { if s != zfsSysctl("kstat.zfs.misc.objset.writes") { return } From e387997e4cf0a04de49f580ecf7e492504782a67 Mon Sep 17 00:00:00 2001 From: Metbog Date: Tue, 19 Sep 2023 15:55:58 +0300 Subject: [PATCH 20/22] Move RO status before error return Signed-off-by: Metbog --- collector/filesystem_common.go | 9 +++++---- collector/filesystem_linux.go | 16 +++++++++------- 2 files changed, 14 insertions(+), 11 deletions(-) diff --git a/collector/filesystem_common.go b/collector/filesystem_common.go index b5473c37..f5dde59a 100644 --- a/collector/filesystem_common.go +++ b/collector/filesystem_common.go @@ -186,6 +186,11 @@ func (c *filesystemCollector) Update(ch chan<- prometheus.Metric) error { c.deviceErrorDesc, prometheus.GaugeValue, s.deviceError, s.labels.device, s.labels.mountPoint, s.labels.fsType, ) + ch <- prometheus.MustNewConstMetric( + c.roDesc, prometheus.GaugeValue, + s.ro, s.labels.device, s.labels.mountPoint, s.labels.fsType, + ) + if s.deviceError > 0 { continue } @@ -210,10 +215,6 @@ func (c *filesystemCollector) Update(ch chan<- prometheus.Metric) error { c.filesFreeDesc, prometheus.GaugeValue, s.filesFree, s.labels.device, s.labels.mountPoint, s.labels.fsType, ) - ch <- prometheus.MustNewConstMetric( - c.roDesc, prometheus.GaugeValue, - s.ro, s.labels.device, s.labels.mountPoint, s.labels.fsType, - ) } return nil } diff --git a/collector/filesystem_linux.go b/collector/filesystem_linux.go index a054e213..6e7623e2 100644 --- a/collector/filesystem_linux.go +++ b/collector/filesystem_linux.go @@ -109,6 +109,14 @@ func (c *filesystemCollector) GetStats() ([]filesystemStats, error) { } func (c *filesystemCollector) processStat(labels filesystemLabels) filesystemStats { + var ro float64 + for _, option := range strings.Split(labels.options, ",") { + if option == "ro" { + ro = 1 + break + } + } + success := make(chan struct{}) go stuckMountWatcher(labels.mountPoint, success, c.logger) @@ -129,16 +137,10 @@ func (c *filesystemCollector) processStat(labels filesystemLabels) filesystemSta return filesystemStats{ labels: labels, deviceError: 1, + ro: ro, } } - var ro float64 - for _, option := range strings.Split(labels.options, ",") { - if option == "ro" { - ro = 1 - break - } - } return filesystemStats{ labels: labels, size: float64(buf.Blocks) * float64(buf.Bsize), From 446b3e64ffd8078b69ae6aef531af8acb4fea6e3 Mon Sep 17 00:00:00 2001 From: prombot Date: Thu, 14 Sep 2023 17:48:49 +0000 Subject: [PATCH 21/22] Update common Prometheus files Signed-off-by: prombot --- .github/workflows/golangci-lint.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/golangci-lint.yml b/.github/workflows/golangci-lint.yml index a619a732..8ace97bd 100644 --- a/.github/workflows/golangci-lint.yml +++ b/.github/workflows/golangci-lint.yml @@ -18,15 +18,15 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout repository - uses: actions/checkout@v3 + uses: actions/checkout@3df4ab11eba7bda6032a0b82a6bb43b11571feac # v4.0.0 - name: install Go - uses: actions/setup-go@v3 + uses: actions/setup-go@6edd4406fa81c3da01a34fa6f6343087c207a568 # v3.5.0 with: go-version: 1.20.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' - name: Lint - uses: golangci/golangci-lint-action@v3.4.0 + uses: golangci/golangci-lint-action@3a919529898de77ec3da873e3063ca4b10e7f5cc # v3.7.0 with: version: v1.54.2 From e8c5110ada6152ec0efb8b2dc8be7e493624d232 Mon Sep 17 00:00:00 2001 From: dongjiang Date: Wed, 20 Sep 2023 17:49:56 +0800 Subject: [PATCH 22/22] fix(zfs) zfs `arcstats.p` on FreeBSD 14.0+ (#2754) * dongjiang, fix zfs arcstats.p Signed-off-by: dongjiang1989 * dongjiang, fix gofmt -s Signed-off-by: dongjiang1989 * change warn log to debug log by code review Signed-off-by: dongjiang1989 --------- Signed-off-by: dongjiang1989 --- collector/zfs_freebsd.go | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/collector/zfs_freebsd.go b/collector/zfs_freebsd.go index 2b3948a5..38379039 100644 --- a/collector/zfs_freebsd.go +++ b/collector/zfs_freebsd.go @@ -20,6 +20,7 @@ import ( "fmt" "github.com/go-kit/log" + "github.com/go-kit/log/level" "github.com/prometheus/client_golang/prometheus" "golang.org/x/sys/unix" @@ -241,6 +242,7 @@ func NewZfsCollector(logger log.Logger) (Collector, error) { valueType: prometheus.GaugeValue, labels: nil, }, + // when FreeBSD 14.0+, `meta/pm/pd` install of `p`. { name: "arcstats_p_bytes", description: "ZFS ARC MRU target size", @@ -249,6 +251,27 @@ func NewZfsCollector(logger log.Logger) (Collector, error) { valueType: prometheus.GaugeValue, labels: nil, }, + { + name: "arcstats_meta_bytes", + description: "ZFS ARC metadata target frac ", + mib: "kstat.zfs.misc.arcstats.meta", + dataType: bsdSysctlTypeUint64, + valueType: prometheus.GaugeValue, + }, + { + name: "arcstats_pd_bytes", + description: "ZFS ARC data MRU target frac", + mib: "kstat.zfs.misc.arcstats.pd", + dataType: bsdSysctlTypeUint64, + valueType: prometheus.GaugeValue, + }, + { + name: "arcstats_pm_bytes", + description: "ZFS ARC meta MRU target frac", + mib: "kstat.zfs.misc.arcstats.pm", + dataType: bsdSysctlTypeUint64, + valueType: prometheus.GaugeValue, + }, { name: "arcstats_size_bytes", description: "ZFS ARC size", @@ -282,7 +305,9 @@ func (c *zfsCollector) Update(ch chan<- prometheus.Metric) error { for _, m := range c.sysctls { v, err := m.Value() if err != nil { - return fmt.Errorf("couldn't get sysctl: %w", err) + // debug logging + level.Debug(c.logger).Log("name", m.name, "couldn't get sysctl:", err) + continue } ch <- prometheus.MustNewConstMetric(