Skip to content

Commit 5fed4f0

Browse files
committed
Handle no data from powersupplyclass
Handle the case when /sys/class/power_supply doesn't exist. Fixes logging error spam. Requires prometheus/procfs#308 Signed-off-by: Ben Kochie <superq@gmail.com>
1 parent 594f417 commit 5fed4f0

2 files changed

Lines changed: 5 additions & 1 deletion

File tree

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* [CHANGE]
44
* [FEATURE]
55
* [ENHANCEMENT]
6-
* [BUGFIX]
6+
* [BUGFIX] Handle no data from powersupplyclass
77

88
## 1.0.0 / 2020-05-25
99

collector/powersupplyclass.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ package collector
1818

1919
import (
2020
"fmt"
21+
"os"
2122
"regexp"
2223

2324
"github.com/go-kit/kit/log"
@@ -54,6 +55,9 @@ func NewPowerSupplyClassCollector(logger log.Logger) (Collector, error) {
5455
func (c *powerSupplyClassCollector) Update(ch chan<- prometheus.Metric) error {
5556
powerSupplyClass, err := getPowerSupplyClassInfo(c.ignoredPattern)
5657
if err != nil {
58+
if os.IsNotExist(err) {
59+
return ErrNoData
60+
}
5761
return fmt.Errorf("could not get power_supply class info: %s", err)
5862
}
5963
for _, powerSupply := range powerSupplyClass {

0 commit comments

Comments
 (0)