Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sanitize strings from /sys/class/power_supply #1984

Merged
merged 1 commit into from
Mar 3, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
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
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