Skip to content

Commit 07f3f70

Browse files
SuperQoblitorum
authored andcommitted
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 f7be555 commit 07f3f70

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

CHANGELOG.md

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

99
## 1.0.0 / 2020-05-25
1010

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)