Skip to content

Commit

Permalink
Merge pull request #1992 from prometheus/superq/release-1.1.2
Browse files Browse the repository at this point in the history
Release version 1.1.2
  • Loading branch information
SuperQ authored Mar 5, 2021
2 parents 4e837d4 + 03d8426 commit b597c12
Show file tree
Hide file tree
Showing 7 changed files with 24 additions and 6 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@
* [ENHANCEMENT]
* [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

* [BUGFIX] Fix ineffassign issue #1957
Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.1.1
1.1.2
2 changes: 1 addition & 1 deletion collector/fixtures/e2e-output.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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>.
# TYPE node_power_supply_info gauge
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",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>.
# TYPE node_power_supply_online gauge
node_power_supply_online{power_supply="AC"} 0
Expand Down
2 changes: 1 addition & 1 deletion collector/fixtures/sys.ttar
Original file line number Diff line number Diff line change
Expand Up @@ -1298,7 +1298,7 @@ Mode: 444
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Path: sys/class/power_supply/BAT0/model_name
Lines: 1
LNV-45N1
LNV-45N1��
Mode: 444
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Directory: sys/class/power_supply/BAT0/power
Expand Down
10 changes: 8 additions & 2 deletions collector/netclass_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,13 @@
package collector

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

"github.com/go-kit/kit/log"
"github.com/go-kit/kit/log/level"
"github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/procfs/sysfs"
"gopkg.in/alecthomas/kingpin.v2"
Expand Down Expand Up @@ -61,6 +64,10 @@ func NewNetClassCollector(logger log.Logger) (Collector, error) {
func (c *netClassCollector) Update(ch chan<- prometheus.Metric) error {
netClass, err := c.getNetClassInfo()
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)
}
for _, ifaceInfo := range netClass {
Expand Down Expand Up @@ -173,9 +180,8 @@ func pushMetric(ch chan<- prometheus.Metric, subsystem string, name string, valu

func (c *netClassCollector) getNetClassInfo() (sysfs.NetClass, error) {
netClass, err := c.fs.NetClass()

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

for device := range netClass {
Expand Down
3 changes: 2 additions & 1 deletion collector/powersupplyclass.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import (
"fmt"
"os"
"regexp"
"strings"

"github.com/go-kit/kit/log"
"github.com/prometheus/client_golang/prometheus"
Expand Down Expand Up @@ -153,7 +154,7 @@ func (c *powerSupplyClassCollector) Update(ch chan<- prometheus.Metric) error {
} {
if value != "" {
keys = append(keys, name)
values = append(values, value)
values = append(values, strings.ToValidUTF8(value, "�"))
}
}

Expand Down
5 changes: 5 additions & 0 deletions collector/pressure_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import (
"errors"
"fmt"
"os"
"syscall"

"github.com/go-kit/kit/log"
"github.com/go-kit/kit/log/level"
Expand Down Expand Up @@ -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")
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)
}
switch res {
Expand Down

0 comments on commit b597c12

Please sign in to comment.