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
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,13 @@
* [ENHANCEMENT]
* [BUGFIX]

## 1.0.1 / 2020-06-15

* [BUGFIX] filesystem_freebsd: Fix label values #1728
* [BUGFIX] Update prometheus/procfs to fix log noise #1735
* [BUGFIX] Fix build tags for collectors #1745
* [BUGFIX] Handle no data from powersupplyclass #1747, #1749

## 1.0.0 / 2020-05-25

### **Breaking changes**
Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.0.0
1.0.1
2 changes: 2 additions & 0 deletions collector/drbd_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
// See the License for the specific language governing permissions and
// limitations under the License.

// +build !nodrbd

package collector

import (
Expand Down
6 changes: 3 additions & 3 deletions collector/filesystem_freebsd.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,14 @@ func (c *filesystemCollector) GetStats() ([]filesystemStats, error) {
}
stats := []filesystemStats{}
for _, fs := range buf {
mountpoint := string(fs.Mntonname[:])
mountpoint := bytesToString(fs.Mntonname[:])
if c.ignoredMountPointsPattern.MatchString(mountpoint) {
level.Debug(c.logger).Log("msg", "Ignoring mount point", "mountpoint", mountpoint)
continue
}

device := string(fs.Mntfromname[:])
fstype := string(fs.Fstypename[:])
device := bytesToString(fs.Mntfromname[:])
fstype := bytesToString(fs.Fstypename[:])
if c.ignoredFSTypesPattern.MatchString(fstype) {
level.Debug(c.logger).Log("msg", "Ignoring fs type", "type", fstype)
continue
Expand Down
2 changes: 0 additions & 2 deletions collector/filesystem_linux_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@
// See the License for the specific language governing permissions and
// limitations under the License.

// +build !nofilesystem

package collector

import (
Expand Down
11 changes: 11 additions & 0 deletions collector/fixtures/sys.ttar
Original file line number Diff line number Diff line change
Expand Up @@ -1756,6 +1756,17 @@ Lines: 1
0
Mode: 644
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Path: sys/devices/pci0000:00/0000:00:0d.0/ata4/host3/target3:0:0/3:0:0:0/block/sdb/bcache/writeback_rate_debug
Lines: 7
rate: 1.1M/sec
dirty: 20.4G
target: 20.4G
proportional: 427.5k
integral: 790.0k
change: 321.5k/sec
next io: 17ms
Mode: 644
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Directory: sys/devices/pci0000:00/0000:00:0d.0/ata5
Mode: 755
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Expand Down
14 changes: 14 additions & 0 deletions collector/helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
package collector

import (
"bytes"
"io/ioutil"
"strconv"
"strings"
Expand All @@ -30,3 +31,16 @@ func readUintFromFile(path string) (uint64, error) {
}
return value, nil
}

// Take a []byte{} and return a string based on null termination.
// This is useful for situations where the OS has returned a null terminated
// string to use.
// If this function happens to receive a byteArray that contains no nulls, we
// simply convert the array to a string with no bounding.
func bytesToString(byteArray []byte) string {
n := bytes.IndexByte(byteArray, 0)
if n < 0 {
return string(byteArray)
}
return string(byteArray[:n])
}
63 changes: 63 additions & 0 deletions collector/helper_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
// Copyright 2020 The Prometheus Authors
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package collector

import (
"testing"
)

func TestBytesToString(t *testing.T) {
tests := []struct {
name string
b []byte
expected string
}{
{
"Single null byte",
[]byte{0},
"",
},
{
"Empty byte array",
[]byte{},
"",
},
{
"Not null terminated",
[]byte{65, 66, 67},
"ABC",
},
{
"Null randomly in array",
[]byte{65, 66, 67, 0, 65, 0, 65},
"ABC",
},
{
"Array starts with null and contains other valid bytes",
[]byte{0, 65, 66, 67, 0},
"",
},
}

for _, tt := range tests {
name := tt.name
b := tt.b
result := bytesToString(b)
expected := tt.expected

if result != expected {
t.Errorf("bytesToString(%#v): Name: %s, expected %#v, got %#v)", b, name, expected, result)
}
}
}
2 changes: 1 addition & 1 deletion collector/kvm_bsd.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.

// +build !nomeminfo
// +build !nokvm
// +build freebsd dragonfly

package collector
Expand Down
2 changes: 2 additions & 0 deletions collector/mountstats_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
// See the License for the specific language governing permissions and
// limitations under the License.

// +build !nomountstats

package collector

import (
Expand Down
2 changes: 2 additions & 0 deletions collector/nfs_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
// See the License for the specific language governing permissions and
// limitations under the License.

// +build !nonfs

package collector

import (
Expand Down
2 changes: 2 additions & 0 deletions collector/nfsd_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
// See the License for the specific language governing permissions and
// limitations under the License.

// +build !nonfsd

package collector

import (
Expand Down
2 changes: 2 additions & 0 deletions collector/perf_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
// See the License for the specific language governing permissions and
// limitations under the License.

// +build !noperf

package collector

import (
Expand Down
7 changes: 6 additions & 1 deletion collector/powersupplyclass.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@
package collector

import (
"errors"
"fmt"
"os"
"regexp"

"github.com/go-kit/kit/log"
Expand Down Expand Up @@ -54,6 +56,9 @@ func NewPowerSupplyClassCollector(logger log.Logger) (Collector, error) {
func (c *powerSupplyClassCollector) Update(ch chan<- prometheus.Metric) error {
powerSupplyClass, err := getPowerSupplyClassInfo(c.ignoredPattern)
if err != nil {
if errors.Is(err, os.ErrNotExist) {
return ErrNoData
}
return fmt.Errorf("could not get power_supply class info: %s", err)
}
for _, powerSupply := range powerSupplyClass {
Expand Down Expand Up @@ -184,7 +189,7 @@ func getPowerSupplyClassInfo(ignore *regexp.Regexp) (sysfs.PowerSupplyClass, err
powerSupplyClass, err := fs.PowerSupplyClass()

if err != nil {
return powerSupplyClass, fmt.Errorf("error obtaining power_supply class info: %s", err)
return powerSupplyClass, fmt.Errorf("error obtaining power_supply class info: %w", err)
}

for device := range powerSupplyClass {
Expand Down
2 changes: 2 additions & 0 deletions collector/schedstat_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
// See the License for the specific language governing permissions and
// limitations under the License.

// +build !noshedstat

package collector

import (
Expand Down
2 changes: 1 addition & 1 deletion collector/sysctl_bsd.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
// limitations under the License.

// +build freebsd dragonfly openbsd netbsd darwin
// +build !nomeminfo
// +build cgo

package collector

Expand Down
2 changes: 2 additions & 0 deletions collector/wifi_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
// See the License for the specific language governing permissions and
// limitations under the License.

// +build !nowifi

package collector

import (
Expand Down
2 changes: 2 additions & 0 deletions collector/xfs_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
// See the License for the specific language governing permissions and
// limitations under the License.

// +build !noxfs

package collector

import (
Expand Down
2 changes: 2 additions & 0 deletions collector/zfs_freebsd.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
// See the License for the specific language governing permissions and
// limitations under the License.

// +build !nozfs

package collector

import (
Expand Down
2 changes: 2 additions & 0 deletions collector/zfs_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
// See the License for the specific language governing permissions and
// limitations under the License.

// +build !nozfs

package collector

import (
Expand Down
1 change: 1 addition & 0 deletions collector/zfs_solaris.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
// limitations under the License.

// +build solaris
// +build !nozfs

package collector

Expand Down
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,15 @@ require (
github.com/prometheus/client_golang v1.6.0
github.com/prometheus/client_model v0.2.0
github.com/prometheus/common v0.10.0
github.com/prometheus/procfs v0.0.11
github.com/prometheus/procfs v0.1.3
github.com/siebenmann/go-kstat v0.0.0-20200303194639-4e8294f9e9d5
github.com/soundcloud/go-runit v0.0.0-20150630195641-06ad41a06c4a
go.uber.org/multierr v1.5.0 // indirect
golang.org/x/crypto v0.0.0-20200510223506-06a226fb4e37
golang.org/x/lint v0.0.0-20200302205851-738671d3881b // indirect
golang.org/x/net v0.0.0-20200513185701-a91f0712d120 // indirect
golang.org/x/sync v0.0.0-20200317015054-43a5402ce75a // indirect
golang.org/x/sys v0.0.0-20200523222454-059865788121
golang.org/x/sys v0.0.0-20200602225109-6fdc65e7d980
golang.org/x/tools v0.0.0-20200513201620-d5fe73897c97 // indirect
gopkg.in/alecthomas/kingpin.v2 v2.2.6
gopkg.in/yaml.v2 v2.3.0
Expand Down
6 changes: 4 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -289,6 +289,8 @@ github.com/prometheus/procfs v0.0.2/go.mod h1:TjEm7ze935MbeOT/UhFTIMYKhuLP4wbCsT
github.com/prometheus/procfs v0.0.8/go.mod h1:7Qr8sr6344vo1JqZ6HhLceV9o3AJ1Ff+GxbHq6oeK9A=
github.com/prometheus/procfs v0.0.11 h1:DhHlBtkHWPYi8O2y31JkK0TF+DGM+51OopZjH/Ia5qI=
github.com/prometheus/procfs v0.0.11/go.mod h1:lV6e/gmhEcM9IjHGsFOCxxuZ+z1YqCvr4OA4YeYWdaU=
github.com/prometheus/procfs v0.1.3 h1:F0+tqvhOksq22sc6iCHF5WGlWjdwj92p0udFh1VFBS8=
github.com/prometheus/procfs v0.1.3/go.mod h1:lV6e/gmhEcM9IjHGsFOCxxuZ+z1YqCvr4OA4YeYWdaU=
github.com/rcrowley/go-metrics v0.0.0-20181016184325-3113b8401b8a/go.mod h1:bCqnVzQkZxMG4s8nGwiZ5l3QUCyqpo9Y+/ZMZ9VjZe4=
github.com/rogpeppe/fastuuid v0.0.0-20150106093220-6724a57986af/go.mod h1:XWv6SoW27p1b0cqNHllgS5HIMJraePCO15w5zCzIWYg=
github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4=
Expand Down Expand Up @@ -432,8 +434,8 @@ golang.org/x/sys v0.0.0-20200106162015-b016eb3dc98e/go.mod h1:h1NjWce9XRLGQEsW7w
golang.org/x/sys v0.0.0-20200202164722-d101bd2416d5/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200420163511-1957bb5e6d1f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200523222454-059865788121 h1:rITEj+UZHYC927n8GT97eC3zrpzXdb/voyeOuVKS46o=
golang.org/x/sys v0.0.0-20200523222454-059865788121/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200602225109-6fdc65e7d980 h1:OjiUf46hAmXblsZdnoSXsEUSKU8r1UEzcL5RVZ4gO9Y=
golang.org/x/sys v0.0.0-20200602225109-6fdc65e7d980/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.2 h1:tW2bmiBqwgJj/UpqtC8EpXEZVYOwU0yG4iWbprSVAcs=
golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk=
Expand Down
11 changes: 11 additions & 0 deletions vendor/github.com/prometheus/procfs/Makefile.common

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 16 additions & 4 deletions vendor/github.com/prometheus/procfs/bcache/bcache.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading