Skip to content

Commit

Permalink
Merge branch 'master' into fix_num_cpu
Browse files Browse the repository at this point in the history
  • Loading branch information
hodgesds authored Feb 19, 2020
2 parents 1f58ab4 + 14eafab commit d444b15
Show file tree
Hide file tree
Showing 747 changed files with 116,642 additions and 42,756 deletions.
6 changes: 3 additions & 3 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,19 +28,19 @@ jobs:
steps:
- checkout
- run: sudo pip install codespell
- run: codespell --skip=".git,./vendor,ttar,go.mod,go.sum" -L uint,packages\',uptodate
- run: codespell --skip=".git,./vendor,ttar,go.mod,go.sum,*pem" -L uint,packages\',uptodate

build:
machine:
image: ubuntu-1604:201903-01

environment:
DOCKER_TEST_IMAGE_NAME: quay.io/prometheus/golang-builder:1.11-base
DOCKER_TEST_IMAGE_NAME: quay.io/prometheus/golang-builder:1.13-base
REPO_PATH: github.com/prometheus/node_exporter

steps:
- checkout
- run: docker run --privileged linuxkit/binfmt:v0.6
- run: docker run --privileged linuxkit/binfmt:v0.7
- run: make promu
- run: promu crossbuild
- run: promu --config .promu-cgo.yml crossbuild
Expand Down
1 change: 1 addition & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@
!.build/linux-armv7
!.build/linux-arm64
!.build/linux-ppc64le
!.build/linux-s390x
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,22 @@
* [FEATURE] Add new metric node_cpu_info #1489
* [FEATURE] Add new thermal_zone collector #1425
* [FEATURE] Add new cooling_device metrics to thermal zone collector #1445
* [FEATURE] Add new softnet collector #1576
* [FEATURE] Add RAPL collector #1523
* [ENHANCEMENT] Collect InfiniBand port state and physical state #1357
* [ENHANCEMENT] Include additional XFS runtime statistics. #1423
* [ENHANCEMENT] Report non-fatal collection errors in the exporter metric. #1439
* [ENHANCEMENT] Expose IPVS firewall mark as a label #1455
* [ENHANCEMENT] Add check for systemd version before attempting to query certain metrics. #1413
* [ENHANCEMENT] Add new counters for flush requests in Linux 5.5 #1548
* [ENHANCEMENT] The sockstat collector now exposes IPv6 statistics in addition to the existing IPv4 support. #1552
* [ENHANCEMENT] Add unix socket support for supervisord collector #262
* [BUGFIX] Renamed label `state` to `name` on `node_systemd_service_restart_total`. #1393
* [BUGFIX] Fix netdev nil reference on Darwin #1414
* [BUGFIX] Strip path.rootfs from mountpoint labels #1421
* [BUGFIX] Fix empty string in path.rootfs #1464
* [BUGFIX] Fix typo in cpufreq metric names #1510
* [BUGFIX] Fix network speed math #1580

## 0.18.1 / 2019-06-04

Expand Down
14 changes: 9 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
all::

# Needs to be defined before including Makefile.common to auto-generate targets
DOCKER_ARCHS ?= amd64 armv7 arm64 ppc64le
DOCKER_ARCHS ?= amd64 armv7 arm64 ppc64le s390x

include Makefile.common

Expand Down Expand Up @@ -91,12 +91,16 @@ test-32bit: collector/fixtures/sys/.unpacked
skip-test-32bit:
@echo ">> SKIP running tests in 32-bit mode: not supported on $(GOHOSTOS)/$(GOHOSTARCH)"

collector/fixtures/sys/.unpacked: collector/fixtures/sys.ttar
@echo ">> extracting sysfs fixtures"
if [ -d collector/fixtures/sys ] ; then rm -r collector/fixtures/sys ; fi
./ttar -C collector/fixtures -x -f collector/fixtures/sys.ttar
%/.unpacked: %.ttar
@echo ">> extracting fixtures"
if [ -d $(dir $@) ] ; then rm -r $(dir $@) ; fi
./ttar -C $(dir $*) -x -f $*.ttar
touch $@

update_fixtures:
rm -vf collector/fixtures/sys/.unpacked
./ttar -C collector/fixtures -c -f collector/fixtures/sys.ttar sys

.PHONY: test-e2e
test-e2e: build collector/fixtures/sys/.unpacked
@echo ">> running end-to-end tests"
Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,10 @@ netstat | Exposes network statistics from `/proc/net/netstat`. This is the same
nfs | Exposes NFS client statistics from `/proc/net/rpc/nfs`. This is the same information as `nfsstat -c`. | Linux
nfsd | Exposes NFS kernel server statistics from `/proc/net/rpc/nfsd`. This is the same information as `nfsstat -s`. | Linux
pressure | Exposes pressure stall statistics from `/proc/pressure/`. | Linux (kernel 4.20+ and/or [CONFIG\_PSI](https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/accounting/psi.txt))
rapl | Exposes various statistics from `/sys/class/powercap`. | Linux
schedstat | Exposes task scheduler statistics from `/proc/schedstat`. | Linux
sockstat | Exposes various statistics from `/proc/net/sockstat`. | Linux
softnet | Exposes statistics from `/proc/net/softnet_stat`. | Linux
stat | Exposes various statistics from `/proc/stat`. This includes boot time, forks and interrupts. | Linux
textfile | Exposes statistics read from local disk. The `--collector.textfile.directory` flag must be set. | _any_
thermal\_zone | Exposes thermal zone & cooling device statistics from `/sys/class/thermal`. | Linux
Expand Down
5 changes: 4 additions & 1 deletion collector/arp_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,25 +22,28 @@ import (
"os"
"strings"

"github.com/go-kit/kit/log"
"github.com/prometheus/client_golang/prometheus"
)

type arpCollector struct {
entries *prometheus.Desc
logger log.Logger
}

func init() {
registerCollector("arp", defaultEnabled, NewARPCollector)
}

// NewARPCollector returns a new Collector exposing ARP stats.
func NewARPCollector() (Collector, error) {
func NewARPCollector(logger log.Logger) (Collector, error) {
return &arpCollector{
entries: prometheus.NewDesc(
prometheus.BuildFQName(namespace, "arp", "entries"),
"ARP entries by device",
[]string{"device"}, nil,
),
logger: logger,
}, nil
}

Expand Down
13 changes: 8 additions & 5 deletions collector/bcache_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ package collector
import (
"fmt"

"github.com/go-kit/kit/log"
"github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/procfs/bcache"
)
Expand All @@ -28,19 +29,21 @@ func init() {

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

// NewBcacheCollector returns a newly allocated bcacheCollector.
// It exposes a number of Linux bcache statistics.
func NewBcacheCollector() (Collector, error) {
func NewBcacheCollector(logger log.Logger) (Collector, error) {
fs, err := bcache.NewFS(*sysPath)
if err != nil {
return nil, fmt.Errorf("failed to open sysfs: %v", err)
return nil, fmt.Errorf("failed to open sysfs: %w", err)
}

return &bcacheCollector{
fs: fs,
fs: fs,
logger: logger,
}, nil
}

Expand All @@ -49,7 +52,7 @@ func NewBcacheCollector() (Collector, error) {
func (c *bcacheCollector) Update(ch chan<- prometheus.Metric) error {
stats, err := c.fs.Stats()
if err != nil {
return fmt.Errorf("failed to retrieve bcache stats: %v", err)
return fmt.Errorf("failed to retrieve bcache stats: %w", err)
}

for _, s := range stats {
Expand Down
9 changes: 6 additions & 3 deletions collector/bonding_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,14 @@ import (
"path/filepath"
"strings"

"github.com/go-kit/kit/log"
"github.com/go-kit/kit/log/level"
"github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/common/log"
)

type bondingCollector struct {
slaves, active typedDesc
logger log.Logger
}

func init() {
Expand All @@ -36,7 +38,7 @@ func init() {

// NewBondingCollector returns a newly allocated bondingCollector.
// It exposes the number of configured and active slave of linux bonding interfaces.
func NewBondingCollector() (Collector, error) {
func NewBondingCollector(logger log.Logger) (Collector, error) {
return &bondingCollector{
slaves: typedDesc{prometheus.NewDesc(
prometheus.BuildFQName(namespace, "bonding", "slaves"),
Expand All @@ -48,6 +50,7 @@ func NewBondingCollector() (Collector, error) {
"Number of active slaves per bonding interface.",
[]string{"master"}, nil,
), prometheus.GaugeValue},
logger: logger,
}, nil
}

Expand All @@ -57,7 +60,7 @@ func (c *bondingCollector) Update(ch chan<- prometheus.Metric) error {
bondingStats, err := readBondingStats(statusfile)
if err != nil {
if os.IsNotExist(err) {
log.Debugf("Not collecting bonding, file does not exist: %s", statusfile)
level.Debug(c.logger).Log("msg", "Not collecting bonding, file does not exist", "file", statusfile)
return nil
}
return err
Expand Down
9 changes: 7 additions & 2 deletions collector/boot_time_bsd.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,24 +17,29 @@
package collector

import (
"github.com/go-kit/kit/log"
"github.com/prometheus/client_golang/prometheus"
)

type bootTimeCollector struct{ boottime bsdSysctl }
type bootTimeCollector struct {
boottime bsdSysctl
logger log.Logger
}

func init() {
registerCollector("boottime", defaultEnabled, newBootTimeCollector)
}

// newBootTimeCollector returns a new Collector exposing system boot time on BSD systems.
func newBootTimeCollector() (Collector, error) {
func newBootTimeCollector(logger log.Logger) (Collector, error) {
return &bootTimeCollector{
boottime: bsdSysctl{
name: "boot_time_seconds",
description: "Unix time of last boot, including microseconds.",
mib: "kern.boottime",
dataType: bsdSysctlTypeStructTimeval,
},
logger: logger,
}, nil
}

Expand Down
5 changes: 4 additions & 1 deletion collector/boot_time_solaris.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,26 +17,29 @@
package collector

import (
"github.com/go-kit/kit/log"
"github.com/prometheus/client_golang/prometheus"
"github.com/siebenmann/go-kstat"
)

type bootTimeCollector struct {
boottime typedDesc
logger log.Logger
}

func init() {
registerCollector("boottime", defaultEnabled, newBootTimeCollector)
}

func newBootTimeCollector() (Collector, error) {
func newBootTimeCollector(logger log.Logger) (Collector, error) {
return &bootTimeCollector{
boottime: typedDesc{
prometheus.NewDesc(
prometheus.BuildFQName(namespace, "", "boot_time_seconds"),
"Unix time of last boot, including microseconds.",
nil, nil,
), prometheus.GaugeValue},
logger: logger,
}, nil
}

Expand Down
16 changes: 9 additions & 7 deletions collector/buddyinfo.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,9 @@ import (
"fmt"
"strconv"

"github.com/go-kit/kit/log"
"github.com/go-kit/kit/log/level"
"github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/common/log"
"github.com/prometheus/procfs"
)

Expand All @@ -30,26 +31,27 @@ const (
)

type buddyinfoCollector struct {
fs procfs.FS
desc *prometheus.Desc
fs procfs.FS
desc *prometheus.Desc
logger log.Logger
}

func init() {
registerCollector("buddyinfo", defaultDisabled, NewBuddyinfoCollector)
}

// NewBuddyinfoCollector returns a new Collector exposing buddyinfo stats.
func NewBuddyinfoCollector() (Collector, error) {
func NewBuddyinfoCollector(logger log.Logger) (Collector, error) {
desc := prometheus.NewDesc(
prometheus.BuildFQName(namespace, buddyInfoSubsystem, "blocks"),
"Count of free blocks according to size.",
[]string{"node", "zone", "size"}, nil,
)
fs, err := procfs.NewFS(*procPath)
if err != nil {
return nil, fmt.Errorf("failed to open procfs: %v", err)
return nil, fmt.Errorf("failed to open procfs: %w", err)
}
return &buddyinfoCollector{fs, desc}, nil
return &buddyinfoCollector{fs, desc, logger}, nil
}

// Update calls (*buddyinfoCollector).getBuddyInfo to get the platform specific
Expand All @@ -60,7 +62,7 @@ func (c *buddyinfoCollector) Update(ch chan<- prometheus.Metric) error {
return fmt.Errorf("couldn't get buddyinfo: %s", err)
}

log.Debugf("Set node_buddy: %#v", buddyInfo)
level.Debug(c.logger).Log("msg", "Set node_buddy", "buddyInfo", buddyInfo)
for _, entry := range buddyInfo {
for size, value := range entry.Sizes {
ch <- prometheus.MustNewConstMetric(
Expand Down
Loading

0 comments on commit d444b15

Please sign in to comment.