Skip to content

Commit

Permalink
Handle no data from powersupplyclass
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
SuperQ authored and oblitorum committed Apr 9, 2024
1 parent a4da624 commit c638250
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* [CHANGE]
* [FEATURE]
* [ENHANCEMENT]
* [BUGFIX]
* [BUGFIX] Handle no data from powersupplyclass

## 1.0.0 / 2020-05-25

Expand Down
4 changes: 4 additions & 0 deletions collector/powersupplyclass.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ package collector

import (
"fmt"
"os"
"regexp"

"github.com/go-kit/kit/log"
Expand Down Expand Up @@ -54,6 +55,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 os.IsNotExist(err) {
return ErrNoData
}
return fmt.Errorf("could not get power_supply class info: %s", err)
}
for _, powerSupply := range powerSupplyClass {
Expand Down

0 comments on commit c638250

Please sign in to comment.