Merge pull request #1984 from prometheus/superq/power_supply_panic

Sanitize strings from /sys/class/power_supply
This commit is contained in:
Ben Kochie 2021-03-03 20:38:58 +01:00 committed by GitHub
commit 40e9d294be
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 5 additions and 3 deletions

View file

@ -6,6 +6,7 @@
* [BUGFIX]
* [BUGFIX] Handle errors from disabled PSI subsystem #1983
* [BUGFIX] Sanitize strings from /sys/class/power_supply #1984
## 1.1.1 / 2021-02-12

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>.
# 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<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>.
# TYPE node_power_supply_online gauge
node_power_supply_online{power_supply="AC"} 0

View file

@ -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

View file

@ -21,6 +21,7 @@ import (
"fmt"
"os"
"regexp"
"strings"
"github.com/go-kit/kit/log"
"github.com/prometheus/client_golang/prometheus"
@ -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, "<22>"))
}
}