Merge pull request #1992 from prometheus/superq/release-1.1.2

Release version 1.1.2
This commit is contained in:
Ben Kochie 2021-03-05 10:27:11 +01:00 committed by GitHub
commit b597c1244d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 24 additions and 6 deletions

View File

@ -5,6 +5,12 @@
* [ENHANCEMENT] * [ENHANCEMENT]
* [BUGFIX] * [BUGFIX]
## 1.1.2 / 2021-03-05
* [BUGFIX] Handle errors from disabled PSI subsystem #1983
* [BUGFIX] Sanitize strings from /sys/class/power_supply #1984
* [BUGFIX] Silence missing netclass errors #1986
## 1.1.1 / 2021-02-12 ## 1.1.1 / 2021-02-12
* [BUGFIX] Fix ineffassign issue #1957 * [BUGFIX] Fix ineffassign issue #1957

View File

@ -1 +1 @@
1.1.1 1.1.2

View File

@ -2613,7 +2613,7 @@ node_power_supply_energy_watthour{power_supply="BAT0"} 36.58
# HELP node_power_supply_info info of /sys/class/power_supply/<power_supply>. # HELP node_power_supply_info info of /sys/class/power_supply/<power_supply>.
# TYPE node_power_supply_info gauge # TYPE node_power_supply_info gauge
node_power_supply_info{power_supply="AC",type="Mains"} 1 node_power_supply_info{power_supply="AC",type="Mains"} 1
node_power_supply_info{capacity_level="Normal",manufacturer="LGC",model_name="LNV-45N1",power_supply="BAT0",serial_number="38109",status="Discharging",technology="Li-ion",type="Battery"} 1 node_power_supply_info{capacity_level="Normal",manufacturer="LGC",model_name="LNV-45N1<EFBFBD>",power_supply="BAT0",serial_number="38109",status="Discharging",technology="Li-ion",type="Battery"} 1
# HELP node_power_supply_online online value of /sys/class/power_supply/<power_supply>. # HELP node_power_supply_online online value of /sys/class/power_supply/<power_supply>.
# TYPE node_power_supply_online gauge # TYPE node_power_supply_online gauge
node_power_supply_online{power_supply="AC"} 0 node_power_supply_online{power_supply="AC"} 0

View File

@ -1298,7 +1298,7 @@ Mode: 444
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Path: sys/class/power_supply/BAT0/model_name Path: sys/class/power_supply/BAT0/model_name
Lines: 1 Lines: 1
LNV-45N1 LNV-45N1タタ
Mode: 444 Mode: 444
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Directory: sys/class/power_supply/BAT0/power Directory: sys/class/power_supply/BAT0/power

View File

@ -17,10 +17,13 @@
package collector package collector
import ( import (
"errors"
"fmt" "fmt"
"os"
"regexp" "regexp"
"github.com/go-kit/kit/log" "github.com/go-kit/kit/log"
"github.com/go-kit/kit/log/level"
"github.com/prometheus/client_golang/prometheus" "github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/procfs/sysfs" "github.com/prometheus/procfs/sysfs"
"gopkg.in/alecthomas/kingpin.v2" "gopkg.in/alecthomas/kingpin.v2"
@ -61,6 +64,10 @@ func NewNetClassCollector(logger log.Logger) (Collector, error) {
func (c *netClassCollector) Update(ch chan<- prometheus.Metric) error { func (c *netClassCollector) Update(ch chan<- prometheus.Metric) error {
netClass, err := c.getNetClassInfo() netClass, err := c.getNetClassInfo()
if err != nil { if err != nil {
if errors.Is(err, os.ErrNotExist) || errors.Is(err, os.ErrPermission) {
level.Debug(c.logger).Log("msg", "Could not read netclass file", "err", err)
return ErrNoData
}
return fmt.Errorf("could not get net class info: %w", err) return fmt.Errorf("could not get net class info: %w", err)
} }
for _, ifaceInfo := range netClass { for _, ifaceInfo := range netClass {
@ -173,9 +180,8 @@ func pushMetric(ch chan<- prometheus.Metric, subsystem string, name string, valu
func (c *netClassCollector) getNetClassInfo() (sysfs.NetClass, error) { func (c *netClassCollector) getNetClassInfo() (sysfs.NetClass, error) {
netClass, err := c.fs.NetClass() netClass, err := c.fs.NetClass()
if err != nil { if err != nil {
return netClass, fmt.Errorf("error obtaining net class info: %w", err) return netClass, err
} }
for device := range netClass { for device := range netClass {

View File

@ -21,6 +21,7 @@ import (
"fmt" "fmt"
"os" "os"
"regexp" "regexp"
"strings"
"github.com/go-kit/kit/log" "github.com/go-kit/kit/log"
"github.com/prometheus/client_golang/prometheus" "github.com/prometheus/client_golang/prometheus"
@ -153,7 +154,7 @@ func (c *powerSupplyClassCollector) Update(ch chan<- prometheus.Metric) error {
} { } {
if value != "" { if value != "" {
keys = append(keys, name) keys = append(keys, name)
values = append(values, value) values = append(values, strings.ToValidUTF8(value, "<22>"))
} }
} }

View File

@ -19,6 +19,7 @@ import (
"errors" "errors"
"fmt" "fmt"
"os" "os"
"syscall"
"github.com/go-kit/kit/log" "github.com/go-kit/kit/log"
"github.com/go-kit/kit/log/level" "github.com/go-kit/kit/log/level"
@ -94,6 +95,10 @@ func (c *pressureStatsCollector) Update(ch chan<- prometheus.Metric) error {
level.Debug(c.logger).Log("msg", "pressure information is unavailable, you need a Linux kernel >= 4.20 and/or CONFIG_PSI enabled for your kernel") level.Debug(c.logger).Log("msg", "pressure information is unavailable, you need a Linux kernel >= 4.20 and/or CONFIG_PSI enabled for your kernel")
return ErrNoData return ErrNoData
} }
if errors.Is(err, syscall.ENOTSUP) {
level.Debug(c.logger).Log("msg", "pressure information is disabled, add psi=1 kernel command line to enable it")
return ErrNoData
}
return fmt.Errorf("failed to retrieve pressure stats: %w", err) return fmt.Errorf("failed to retrieve pressure stats: %w", err)
} }
switch res { switch res {