mirror of
https://github.com/prometheus/node_exporter.git
synced 2024-12-30 07:59:53 -08:00
Merge pull request #2368 from mrueg/update-go-systemd
go.mod: Update coreos/go-systemd
This commit is contained in:
commit
3999866a36
|
@ -22,7 +22,7 @@ import (
|
||||||
"strconv"
|
"strconv"
|
||||||
|
|
||||||
"github.com/go-kit/log"
|
"github.com/go-kit/log"
|
||||||
"github.com/godbus/dbus"
|
"github.com/godbus/dbus/v5"
|
||||||
"github.com/prometheus/client_golang/prometheus"
|
"github.com/prometheus/client_golang/prometheus"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
@ -16,7 +16,7 @@ package collector
|
||||||
import (
|
import (
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/godbus/dbus"
|
"github.com/godbus/dbus/v5"
|
||||||
"github.com/prometheus/client_golang/prometheus"
|
"github.com/prometheus/client_golang/prometheus"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
@ -17,6 +17,7 @@
|
||||||
package collector
|
package collector
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"context"
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"math"
|
"math"
|
||||||
|
@ -26,7 +27,7 @@ import (
|
||||||
"sync"
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/coreos/go-systemd/dbus"
|
"github.com/coreos/go-systemd/v22/dbus"
|
||||||
"github.com/go-kit/log"
|
"github.com/go-kit/log"
|
||||||
"github.com/go-kit/log/level"
|
"github.com/go-kit/log/level"
|
||||||
"github.com/prometheus/client_golang/prometheus"
|
"github.com/prometheus/client_golang/prometheus"
|
||||||
|
@ -270,14 +271,14 @@ func (c *systemdCollector) collectUnitStatusMetrics(conn *dbus.Conn, ch chan<- p
|
||||||
for _, unit := range units {
|
for _, unit := range units {
|
||||||
serviceType := ""
|
serviceType := ""
|
||||||
if strings.HasSuffix(unit.Name, ".service") {
|
if strings.HasSuffix(unit.Name, ".service") {
|
||||||
serviceTypeProperty, err := conn.GetUnitTypeProperty(unit.Name, "Service", "Type")
|
serviceTypeProperty, err := conn.GetUnitTypePropertyContext(context.TODO(), unit.Name, "Service", "Type")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
level.Debug(c.logger).Log("msg", "couldn't get unit type", "unit", unit.Name, "err", err)
|
level.Debug(c.logger).Log("msg", "couldn't get unit type", "unit", unit.Name, "err", err)
|
||||||
} else {
|
} else {
|
||||||
serviceType = serviceTypeProperty.Value.Value().(string)
|
serviceType = serviceTypeProperty.Value.Value().(string)
|
||||||
}
|
}
|
||||||
} else if strings.HasSuffix(unit.Name, ".mount") {
|
} else if strings.HasSuffix(unit.Name, ".mount") {
|
||||||
serviceTypeProperty, err := conn.GetUnitTypeProperty(unit.Name, "Mount", "Type")
|
serviceTypeProperty, err := conn.GetUnitTypePropertyContext(context.TODO(), unit.Name, "Mount", "Type")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
level.Debug(c.logger).Log("msg", "couldn't get unit type", "unit", unit.Name, "err", err)
|
level.Debug(c.logger).Log("msg", "couldn't get unit type", "unit", unit.Name, "err", err)
|
||||||
} else {
|
} else {
|
||||||
|
@ -295,7 +296,7 @@ func (c *systemdCollector) collectUnitStatusMetrics(conn *dbus.Conn, ch chan<- p
|
||||||
}
|
}
|
||||||
if *enableRestartsMetrics && strings.HasSuffix(unit.Name, ".service") {
|
if *enableRestartsMetrics && strings.HasSuffix(unit.Name, ".service") {
|
||||||
// NRestarts wasn't added until systemd 235.
|
// NRestarts wasn't added until systemd 235.
|
||||||
restartsCount, err := conn.GetUnitTypeProperty(unit.Name, "Service", "NRestarts")
|
restartsCount, err := conn.GetUnitTypePropertyContext(context.TODO(), unit.Name, "Service", "NRestarts")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
level.Debug(c.logger).Log("msg", "couldn't get unit NRestarts", "unit", unit.Name, "err", err)
|
level.Debug(c.logger).Log("msg", "couldn't get unit NRestarts", "unit", unit.Name, "err", err)
|
||||||
} else {
|
} else {
|
||||||
|
@ -313,7 +314,7 @@ func (c *systemdCollector) collectSockets(conn *dbus.Conn, ch chan<- prometheus.
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
acceptedConnectionCount, err := conn.GetUnitTypeProperty(unit.Name, "Socket", "NAccepted")
|
acceptedConnectionCount, err := conn.GetUnitTypePropertyContext(context.TODO(), unit.Name, "Socket", "NAccepted")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
level.Debug(c.logger).Log("msg", "couldn't get unit NAccepted", "unit", unit.Name, "err", err)
|
level.Debug(c.logger).Log("msg", "couldn't get unit NAccepted", "unit", unit.Name, "err", err)
|
||||||
continue
|
continue
|
||||||
|
@ -322,7 +323,7 @@ func (c *systemdCollector) collectSockets(conn *dbus.Conn, ch chan<- prometheus.
|
||||||
c.socketAcceptedConnectionsDesc, prometheus.CounterValue,
|
c.socketAcceptedConnectionsDesc, prometheus.CounterValue,
|
||||||
float64(acceptedConnectionCount.Value.Value().(uint32)), unit.Name)
|
float64(acceptedConnectionCount.Value.Value().(uint32)), unit.Name)
|
||||||
|
|
||||||
currentConnectionCount, err := conn.GetUnitTypeProperty(unit.Name, "Socket", "NConnections")
|
currentConnectionCount, err := conn.GetUnitTypePropertyContext(context.TODO(), unit.Name, "Socket", "NConnections")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
level.Debug(c.logger).Log("msg", "couldn't get unit NConnections", "unit", unit.Name, "err", err)
|
level.Debug(c.logger).Log("msg", "couldn't get unit NConnections", "unit", unit.Name, "err", err)
|
||||||
continue
|
continue
|
||||||
|
@ -332,7 +333,7 @@ func (c *systemdCollector) collectSockets(conn *dbus.Conn, ch chan<- prometheus.
|
||||||
float64(currentConnectionCount.Value.Value().(uint32)), unit.Name)
|
float64(currentConnectionCount.Value.Value().(uint32)), unit.Name)
|
||||||
|
|
||||||
// NRefused wasn't added until systemd 239.
|
// NRefused wasn't added until systemd 239.
|
||||||
refusedConnectionCount, err := conn.GetUnitTypeProperty(unit.Name, "Socket", "NRefused")
|
refusedConnectionCount, err := conn.GetUnitTypePropertyContext(context.TODO(), unit.Name, "Socket", "NRefused")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
//log.Debugf("couldn't get unit '%s' NRefused: %s", unit.Name, err)
|
//log.Debugf("couldn't get unit '%s' NRefused: %s", unit.Name, err)
|
||||||
} else {
|
} else {
|
||||||
|
@ -350,7 +351,7 @@ func (c *systemdCollector) collectUnitStartTimeMetrics(conn *dbus.Conn, ch chan<
|
||||||
if unit.ActiveState != "active" {
|
if unit.ActiveState != "active" {
|
||||||
startTimeUsec = 0
|
startTimeUsec = 0
|
||||||
} else {
|
} else {
|
||||||
timestampValue, err := conn.GetUnitProperty(unit.Name, "ActiveEnterTimestamp")
|
timestampValue, err := conn.GetUnitPropertyContext(context.TODO(), unit.Name, "ActiveEnterTimestamp")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
level.Debug(c.logger).Log("msg", "couldn't get unit StartTimeUsec", "unit", unit.Name, "err", err)
|
level.Debug(c.logger).Log("msg", "couldn't get unit StartTimeUsec", "unit", unit.Name, "err", err)
|
||||||
continue
|
continue
|
||||||
|
@ -368,7 +369,7 @@ func (c *systemdCollector) collectUnitTasksMetrics(conn *dbus.Conn, ch chan<- pr
|
||||||
var val uint64
|
var val uint64
|
||||||
for _, unit := range units {
|
for _, unit := range units {
|
||||||
if strings.HasSuffix(unit.Name, ".service") {
|
if strings.HasSuffix(unit.Name, ".service") {
|
||||||
tasksCurrentCount, err := conn.GetUnitTypeProperty(unit.Name, "Service", "TasksCurrent")
|
tasksCurrentCount, err := conn.GetUnitTypePropertyContext(context.TODO(), unit.Name, "Service", "TasksCurrent")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
level.Debug(c.logger).Log("msg", "couldn't get unit TasksCurrent", "unit", unit.Name, "err", err)
|
level.Debug(c.logger).Log("msg", "couldn't get unit TasksCurrent", "unit", unit.Name, "err", err)
|
||||||
} else {
|
} else {
|
||||||
|
@ -380,7 +381,7 @@ func (c *systemdCollector) collectUnitTasksMetrics(conn *dbus.Conn, ch chan<- pr
|
||||||
float64(val), unit.Name)
|
float64(val), unit.Name)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
tasksMaxCount, err := conn.GetUnitTypeProperty(unit.Name, "Service", "TasksMax")
|
tasksMaxCount, err := conn.GetUnitTypePropertyContext(context.TODO(), unit.Name, "Service", "TasksMax")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
level.Debug(c.logger).Log("msg", "couldn't get unit TasksMax", "unit", unit.Name, "err", err)
|
level.Debug(c.logger).Log("msg", "couldn't get unit TasksMax", "unit", unit.Name, "err", err)
|
||||||
} else {
|
} else {
|
||||||
|
@ -402,7 +403,7 @@ func (c *systemdCollector) collectTimers(conn *dbus.Conn, ch chan<- prometheus.M
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
lastTriggerValue, err := conn.GetUnitTypeProperty(unit.Name, "Timer", "LastTriggerUSec")
|
lastTriggerValue, err := conn.GetUnitTypePropertyContext(context.TODO(), unit.Name, "Timer", "LastTriggerUSec")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
level.Debug(c.logger).Log("msg", "couldn't get unit LastTriggerUSec", "unit", unit.Name, "err", err)
|
level.Debug(c.logger).Log("msg", "couldn't get unit LastTriggerUSec", "unit", unit.Name, "err", err)
|
||||||
continue
|
continue
|
||||||
|
@ -436,9 +437,9 @@ func (c *systemdCollector) collectSystemState(conn *dbus.Conn, ch chan<- prometh
|
||||||
|
|
||||||
func newSystemdDbusConn() (*dbus.Conn, error) {
|
func newSystemdDbusConn() (*dbus.Conn, error) {
|
||||||
if *systemdPrivate {
|
if *systemdPrivate {
|
||||||
return dbus.NewSystemdConnection()
|
return dbus.NewSystemdConnectionContext(context.TODO())
|
||||||
}
|
}
|
||||||
return dbus.New()
|
return dbus.NewWithContext(context.TODO())
|
||||||
}
|
}
|
||||||
|
|
||||||
type unit struct {
|
type unit struct {
|
||||||
|
@ -446,7 +447,7 @@ type unit struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *systemdCollector) getAllUnits(conn *dbus.Conn) ([]unit, error) {
|
func (c *systemdCollector) getAllUnits(conn *dbus.Conn) ([]unit, error) {
|
||||||
allUnits, err := conn.ListUnits()
|
allUnits, err := conn.ListUnitsContext(context.TODO())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,7 +17,7 @@ import (
|
||||||
"regexp"
|
"regexp"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/coreos/go-systemd/dbus"
|
"github.com/coreos/go-systemd/v22/dbus"
|
||||||
"github.com/go-kit/log"
|
"github.com/go-kit/log"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
4
go.mod
4
go.mod
|
@ -2,10 +2,10 @@ module github.com/prometheus/node_exporter
|
||||||
|
|
||||||
require (
|
require (
|
||||||
github.com/beevik/ntp v0.3.0
|
github.com/beevik/ntp v0.3.0
|
||||||
github.com/coreos/go-systemd v0.0.0-20191104093116-d3cd4ed1dbcf
|
github.com/coreos/go-systemd/v22 v22.3.2
|
||||||
github.com/ema/qdisc v0.0.0-20200603082823-62d0308e3e00
|
github.com/ema/qdisc v0.0.0-20200603082823-62d0308e3e00
|
||||||
github.com/go-kit/log v0.2.0
|
github.com/go-kit/log v0.2.0
|
||||||
github.com/godbus/dbus v0.0.0-20190402143921-271e53dc4968
|
github.com/godbus/dbus/v5 v5.1.0
|
||||||
github.com/hashicorp/go-envparse v0.0.0-20200406174449-d9cfd743a15e
|
github.com/hashicorp/go-envparse v0.0.0-20200406174449-d9cfd743a15e
|
||||||
github.com/hodgesds/perf-utils v0.5.1
|
github.com/hodgesds/perf-utils v0.5.1
|
||||||
github.com/illumos/go-kstat v0.0.0-20210513183136-173c9b0a9973
|
github.com/illumos/go-kstat v0.0.0-20210513183136-173c9b0a9973
|
||||||
|
|
9
go.sum
9
go.sum
|
@ -57,8 +57,8 @@ github.com/cilium/ebpf v0.8.1 h1:bLSSEbBLqGPXxls55pGr5qWZaTqcmfDJHhou7t254ao=
|
||||||
github.com/cilium/ebpf v0.8.1/go.mod h1:f5zLIM0FSNuAkSyLAN7X+Hy6yznlF1mNiWUMfxMtrgk=
|
github.com/cilium/ebpf v0.8.1/go.mod h1:f5zLIM0FSNuAkSyLAN7X+Hy6yznlF1mNiWUMfxMtrgk=
|
||||||
github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw=
|
github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw=
|
||||||
github.com/cncf/udpa/go v0.0.0-20191209042840-269d4d468f6f/go.mod h1:M8M6+tZqaGXZJjfX53e64911xZQV5JYwmTeXPW+k8Sc=
|
github.com/cncf/udpa/go v0.0.0-20191209042840-269d4d468f6f/go.mod h1:M8M6+tZqaGXZJjfX53e64911xZQV5JYwmTeXPW+k8Sc=
|
||||||
github.com/coreos/go-systemd v0.0.0-20191104093116-d3cd4ed1dbcf h1:iW4rZ826su+pqaw19uhpSCzhj44qo35pNgKFGqzDKkU=
|
github.com/coreos/go-systemd/v22 v22.3.2 h1:D9/bQk5vlXQFZ6Kwuu6zaiXJ9oTPe68++AzAJc1DzSI=
|
||||||
github.com/coreos/go-systemd v0.0.0-20191104093116-d3cd4ed1dbcf/go.mod h1:F5haX7vjVVG0kc13fIWeqUViNPyEJxv/OmvnBo0Yme4=
|
github.com/coreos/go-systemd/v22 v22.3.2/go.mod h1:Y58oyj3AT4RCenI/lSvhwexgC+NSVTIJ3seZv2GcEnc=
|
||||||
github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E=
|
github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E=
|
||||||
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||||
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
|
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
|
||||||
|
@ -85,8 +85,9 @@ github.com/go-logfmt/logfmt v0.5.0/go.mod h1:wCYkCAKZfumFQihp8CzCvQ3paCTfi41vtzG
|
||||||
github.com/go-logfmt/logfmt v0.5.1 h1:otpy5pqBCBZ1ng9RQ0dPu4PN7ba75Y/aA+UpowDyNVA=
|
github.com/go-logfmt/logfmt v0.5.1 h1:otpy5pqBCBZ1ng9RQ0dPu4PN7ba75Y/aA+UpowDyNVA=
|
||||||
github.com/go-logfmt/logfmt v0.5.1/go.mod h1:WYhtIu8zTZfxdn5+rREduYbwxfcBr/Vr6KEVveWlfTs=
|
github.com/go-logfmt/logfmt v0.5.1/go.mod h1:WYhtIu8zTZfxdn5+rREduYbwxfcBr/Vr6KEVveWlfTs=
|
||||||
github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY=
|
github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY=
|
||||||
github.com/godbus/dbus v0.0.0-20190402143921-271e53dc4968 h1:s+PDl6lozQ+dEUtUtQnO7+A2iPG3sK1pI4liU+jxn90=
|
github.com/godbus/dbus/v5 v5.0.4/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA=
|
||||||
github.com/godbus/dbus v0.0.0-20190402143921-271e53dc4968/go.mod h1:/YcGZj5zSblfDWMMoOzV4fas9FZnQYTkDnsGvmh2Grw=
|
github.com/godbus/dbus/v5 v5.1.0 h1:4KLkAxT3aOY8Li4FRJe/KvhoNFFxo0m6fNuFUO8QJUk=
|
||||||
|
github.com/godbus/dbus/v5 v5.1.0/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA=
|
||||||
github.com/gogo/protobuf v1.1.1/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ=
|
github.com/gogo/protobuf v1.1.1/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ=
|
||||||
github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q=
|
github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q=
|
||||||
github.com/golang/groupcache v0.0.0-20190702054246-869f871628b6/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc=
|
github.com/golang/groupcache v0.0.0-20190702054246-869f871628b6/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc=
|
||||||
|
|
Loading…
Reference in a new issue