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

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,16 @@ jobs:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-20.04, macos-11]
os: [ubuntu-22.04, macos-13, macos-14] # linux-x86_64, darwin-x86_64, darwin-arm64
steps:
- uses: actions/checkout@v3
- uses: actions/setup-go@v3
- uses: actions/checkout@v4
- uses: actions/setup-go@v4
with:
go-version: '1.17.9'
go-version: '1.23.6'
- run: make test
- run: make package
- run: shasum -a 256 node_exporter node_exporter*.tar.gz
- uses: actions/upload-artifact@v3
- uses: actions/upload-artifact@v4
with:
name: package
name: package-${{ matrix.os }}
path: "*.tar.gz"
7 changes: 3 additions & 4 deletions collector/bcache_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ import (
// https://godoc.org/github.com/prometheus/client_golang/prometheus
"github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/procfs/bcache"
"github.com/prometheus/procfs/sysfs"
)

func init() {
Expand All @@ -31,13 +30,13 @@ func init() {

// A bcacheCollector is a Collector which gathers metrics from Linux bcache.
type bcacheCollector struct {
fs sysfs.FS
fs bcache.FS
}

// NewBcacheCollector returns a newly allocated bcacheCollector.
// It exposes a number of Linux bcache statistics.
func NewBcacheCollector() (Collector, error) {
fs, err := sysfs.NewFS(*sysPath)
fs, err := bcache.NewFS(*sysPath)
if err != nil {
return nil, fmt.Errorf("failed to open sysfs: %v", err)
}
Expand All @@ -50,7 +49,7 @@ func NewBcacheCollector() (Collector, error) {
// Update reads and exposes bcache stats.
// It implements the Collector interface.
func (c *bcacheCollector) Update(ch chan<- prometheus.Metric) error {
stats, err := c.fs.BcacheStats()
stats, err := c.fs.Stats()
if err != nil {
return fmt.Errorf("failed to retrieve bcache stats: %v", err)
}
Expand Down
2 changes: 1 addition & 1 deletion collector/buddyinfo.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ func (c *buddyinfoCollector) Update(ch chan<- prometheus.Metric) error {
return fmt.Errorf("failed to open procfs: %v", err)
}

buddyInfo, err := fs.NewBuddyInfo()
buddyInfo, err := fs.BuddyInfo()
if err != nil {
return fmt.Errorf("couldn't get buddyinfo: %s", err)
}
Expand Down
4 changes: 2 additions & 2 deletions collector/ipvs_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ func newIPVSCollector() (*ipvsCollector, error) {
}

func (c *ipvsCollector) Update(ch chan<- prometheus.Metric) error {
ipvsStats, err := c.fs.NewIPVSStats()
ipvsStats, err := c.fs.IPVSStats()
if err != nil {
// Cannot access ipvs metrics, report no error.
if os.IsNotExist(err) {
Expand All @@ -122,7 +122,7 @@ func (c *ipvsCollector) Update(ch chan<- prometheus.Metric) error {
ch <- c.incomingBytes.mustNewConstMetric(float64(ipvsStats.IncomingBytes))
ch <- c.outgoingBytes.mustNewConstMetric(float64(ipvsStats.OutgoingBytes))

backendStats, err := c.fs.NewIPVSBackendStatus()
backendStats, err := c.fs.IPVSBackendStatus()
if err != nil {
return fmt.Errorf("could not get backend status: %s", err)
}
Expand Down
13 changes: 9 additions & 4 deletions collector/mountstats_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,11 @@ import (
"github.com/prometheus/procfs"
)

var (
// 64-bit float mantissa: https://en.wikipedia.org/wiki/Double-precision_floating-point_format
float64Mantissa uint64 = 9007199254740992
)

type mountStatsCollector struct {
// General statistics
NFSAgeSecondsTotal *prometheus.Desc
Expand Down Expand Up @@ -618,7 +623,7 @@ func (c *mountStatsCollector) updateNFSStats(ch chan<- prometheus.Metric, export
ch <- prometheus.MustNewConstMetric(
c.NFSTransportIdleTimeSeconds,
prometheus.GaugeValue,
s.Transport.IdleTime.Seconds(),
float64(s.Transport.IdleTimeSeconds%float64Mantissa),

Choose a reason for hiding this comment

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

What the heck is this doing?

Copy link
Author

@cce cce Feb 24, 2025

Choose a reason for hiding this comment

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

This was copied from prometheus#1364 which updated the upstream dependency, while fixing a rollover bug in the handling of some values collected. The function .Seconds() was removed from the upstream library, I think to force downstream consumers to do their own unit conversions (?). Because counters in Prometheus are meant to "roll over" to 0, usually when they hit some kind of max like MaxInt64, or otherwise, he is manually implementing a custom max here (Grafana and other systems handle metrics rollovers pretty well when deriving values like rates, etc). Since this is a float64 counter (I think for legacy reasons, this was a float before, so he is preserving its type?), I believe he wanted to pick a max value that would safely roll over. On his commit he left the comment Rollover counter automatically to avoid float64 accuracy issues. so I think he is trying to avoid some precision cliff?

Choose a reason for hiding this comment

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

I think I get it. That value is probably the largest that can be represented precisely in a float64.

export,
protocol,
)
Expand Down Expand Up @@ -728,7 +733,7 @@ func (c *mountStatsCollector) updateNFSStats(ch chan<- prometheus.Metric, export
ch <- prometheus.MustNewConstMetric(
c.NFSOperationsQueueTimeSecondsTotal,
prometheus.CounterValue,
op.CumulativeQueueTime.Seconds(),
float64(op.CumulativeQueueMilliseconds%float64Mantissa)/1000.0,
export,
protocol,
op.Operation,
Expand All @@ -737,7 +742,7 @@ func (c *mountStatsCollector) updateNFSStats(ch chan<- prometheus.Metric, export
ch <- prometheus.MustNewConstMetric(
c.NFSOperationsResponseTimeSecondsTotal,
prometheus.CounterValue,
op.CumulativeTotalResponseTime.Seconds(),
float64(op.CumulativeTotalResponseMilliseconds%float64Mantissa)/1000.0,
export,
protocol,
op.Operation,
Expand All @@ -746,7 +751,7 @@ func (c *mountStatsCollector) updateNFSStats(ch chan<- prometheus.Metric, export
ch <- prometheus.MustNewConstMetric(
c.NFSOperationsRequestTimeSecondsTotal,
prometheus.CounterValue,
op.CumulativeTotalRequestTime.Seconds(),
float64(op.CumulativeTotalRequestMilliseconds%float64Mantissa)/1000.0,
export,
protocol,
op.Operation,
Expand Down
2 changes: 1 addition & 1 deletion collector/netclass_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ func getNetClassInfo(ignore *regexp.Regexp) (sysfs.NetClass, error) {
if err != nil {
return nil, err
}
netClass, err := fs.NewNetClass()
netClass, err := fs.NetClass()

if err != nil {
return netClass, fmt.Errorf("error obtaining net class info: %s", err)
Expand Down
7 changes: 3 additions & 4 deletions collector/nfs_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ import (

"github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/common/log"
"github.com/prometheus/procfs"
"github.com/prometheus/procfs/nfs"
)

Expand All @@ -29,7 +28,7 @@ const (
)

type nfsCollector struct {
fs procfs.FS
fs nfs.FS
nfsNetReadsDesc *prometheus.Desc
nfsNetConnectionsDesc *prometheus.Desc
nfsRPCOperationsDesc *prometheus.Desc
Expand All @@ -44,7 +43,7 @@ func init() {

// NewNfsCollector returns a new Collector exposing NFS statistics.
func NewNfsCollector() (Collector, error) {
fs, err := procfs.NewFS(*procPath)
fs, err := nfs.NewFS(*procPath)
if err != nil {
return nil, fmt.Errorf("failed to open procfs: %v", err)
}
Expand Down Expand Up @@ -91,7 +90,7 @@ func NewNfsCollector() (Collector, error) {
}

func (c *nfsCollector) Update(ch chan<- prometheus.Metric) error {
stats, err := c.fs.NFSClientRPCStats()
stats, err := c.fs.ClientRPCStats()
if err != nil {
if os.IsNotExist(err) {
log.Debugf("Not collecting NFS metrics: %s", err)
Expand Down
7 changes: 3 additions & 4 deletions collector/nfsd_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,13 @@ import (

"github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/common/log"
"github.com/prometheus/procfs"
"github.com/prometheus/procfs/nfs"
)

// A nfsdCollector is a Collector which gathers metrics from /proc/net/rpc/nfsd.
// See: https://www.svennd.be/nfsd-stats-explained-procnetrpcnfsd/
type nfsdCollector struct {
fs procfs.FS
fs nfs.FS
requestsDesc *prometheus.Desc
}

Expand All @@ -40,7 +39,7 @@ const (

// NewNFSdCollector returns a new Collector exposing /proc/net/rpc/nfsd statistics.
func NewNFSdCollector() (Collector, error) {
fs, err := procfs.NewFS(*procPath)
fs, err := nfs.NewFS(*procPath)
if err != nil {
return nil, fmt.Errorf("failed to open procfs: %v", err)
}
Expand All @@ -57,7 +56,7 @@ func NewNFSdCollector() (Collector, error) {

// Update implements Collector.
func (c *nfsdCollector) Update(ch chan<- prometheus.Metric) error {
stats, err := c.fs.NFSdServerRPCStats()
stats, err := c.fs.ServerRPCStats()
if err != nil {
if os.IsNotExist(err) {
log.Debugf("Not collecting NFSd metrics: %s", err)
Expand Down
7 changes: 3 additions & 4 deletions collector/xfs_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,12 @@ import (
"fmt"

"github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/procfs/sysfs"
"github.com/prometheus/procfs/xfs"
)

// An xfsCollector is a Collector which gathers metrics from XFS filesystems.
type xfsCollector struct {
fs sysfs.FS
fs xfs.FS
}

func init() {
Expand All @@ -32,7 +31,7 @@ func init() {

// NewXFSCollector returns a new Collector exposing XFS statistics.
func NewXFSCollector() (Collector, error) {
fs, err := sysfs.NewFS(*sysPath)
fs, err := xfs.NewFS(*procPath, *sysPath)
if err != nil {
return nil, fmt.Errorf("failed to open sysfs: %v", err)
}
Expand All @@ -44,7 +43,7 @@ func NewXFSCollector() (Collector, error) {

// Update implements Collector.
func (c *xfsCollector) Update(ch chan<- prometheus.Metric) error {
stats, err := c.fs.XFSStats()
stats, err := c.fs.SysStats()
if err != nil {
return fmt.Errorf("failed to retrieve XFS stats: %v", err)
}
Expand Down
30 changes: 15 additions & 15 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/algorand/node_exporter

go 1.17
go 1.23

require (
github.com/beevik/ntp v0.2.0
Expand All @@ -10,28 +10,28 @@ require (
github.com/lufia/iostat v1.0.0
github.com/mattn/go-xmlrpc v0.0.0-20180913190254-6e944673e4c0
github.com/mdlayher/wifi v0.0.0-20180727163819-efdf3f4195d9
github.com/prometheus/client_golang v0.9.0-pre1.0.20181001174001-0a8115f42e03
github.com/prometheus/client_model v0.0.0-20171117100541-99fa1f4be8e5
github.com/prometheus/common v0.0.0-20180326160409-38c53a9f4bfc
github.com/prometheus/procfs v0.0.0-20181005140218-185b4288413d
github.com/prometheus/client_golang v1.11.1
github.com/prometheus/client_model v0.2.0
github.com/prometheus/common v0.26.0
github.com/prometheus/procfs v0.6.0
github.com/soundcloud/go-runit v0.0.0-20150630195641-06ad41a06c4a
golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f
golang.org/x/sys v0.30.0
gopkg.in/alecthomas/kingpin.v2 v2.2.6
)

require (
github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc // indirect
github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf // indirect
github.com/beorn7/perks v0.0.0-20160804104726-4c0e84591b9a // indirect
github.com/gogo/protobuf v1.3.2 // indirect
github.com/golang/protobuf v1.2.0 // indirect
github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751 // indirect
github.com/alecthomas/units v0.0.0-20190924025748-f65c72e2690d // indirect
github.com/beorn7/perks v1.0.1 // indirect
github.com/cespare/xxhash/v2 v2.1.1 // indirect
github.com/golang/protobuf v1.4.3 // indirect
github.com/google/go-cmp v0.5.8 // indirect
github.com/konsorten/go-windows-terminal-sequences v1.0.1 // indirect
github.com/konsorten/go-windows-terminal-sequences v1.0.3 // indirect
github.com/matttproud/golang_protobuf_extensions v1.0.1 // indirect
github.com/mdlayher/genetlink v0.0.0-20180917171408-7615bc153978 // indirect
github.com/mdlayher/netlink v0.0.0-20180920202405-794849f2d5bf // indirect
github.com/sirupsen/logrus v1.1.1 // indirect
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9 // indirect
golang.org/x/net v0.0.0-20201021035429-f5854403a974 // indirect
github.com/sirupsen/logrus v1.6.0 // indirect
golang.org/x/net v0.35.0 // indirect
golang.org/x/sync v0.0.0-20220513210516-0976fa681c29 // indirect
google.golang.org/protobuf v1.26.0-rc.1 // indirect
)
Loading