prometheus / node_exporter

Exporter for machine metrics
https://prometheus.io/
Apache License 2.0
10.98k stars 2.33k forks source link

Work (bug?) powersupplyclass on kernel 3.18.140 #2510

Open Mistikan opened 1 year ago

Mistikan commented 1 year ago

Host operating system: output of uname -a

Linux xiaomi-santoni 3.18.140-postmarketos #5-postmarketOS SMP PREEMPT Sun Aug 21 13:33:19 UTC 2022 aarch64 Linux

node_exporter version: output of node_exporter --version

node_exporter, version 1.3.1 (branch: , revision: )
  build user:
  build date:
  go version:       go1.19.2
  platform:         linux/arm64

and

node_exporter, version 1.4.0 (branch: HEAD, revision: 7da1321761b3b8dfc9e496e1a60e6a476fec6018)
  build user:       root@83d90983e89c
  build date:       20220926-12:33:37
  go version:       go1.19.1
  platform:         linux/arm64

node_exporter command line flags

/usr/bin/node_exporter  --web.listen-address=':6666'

node_exporter log output

ts=2022-10-18T19:58:28.013Z caller=node_exporter.go:182 level=info msg="Starting node_exporter" version="(version=1.4.0, branch=HEAD, revision=7da1321761b3b8dfc9e496e1a60e6a476fec6018)"
ts=2022-10-18T19:58:28.013Z caller=node_exporter.go:183 level=info msg="Build context" build_context="(go=go1.19.1, user=root@83d90983e89c, date=20220926-12:33:37)"
ts=2022-10-18T19:58:28.014Z caller=filesystem_common.go:111 level=info collector=filesystem msg="Parsed flag --collector.filesystem.mount-points-exclude" flag=^/(dev|proc|run/credentials/.+|sys|var/lib/docker/.+|var/lib/containers/storage/.+)($|/)
ts=2022-10-18T19:58:28.014Z caller=filesystem_common.go:113 level=info collector=filesystem msg="Parsed flag --collector.filesystem.fs-types-exclude" flag=^(autofs|binfmt_misc|bpf|cgroup2?|configfs|debugfs|devpts|devtmpfs|fusectl|hugetlbfs|iso9660|mqueue|nsfs|overlay|proc|procfs|pstore|rpc_pipefs|securityfs|selinuxfs|squashfs|sysfs|tracefs)$
ts=2022-10-18T19:58:28.018Z caller=diskstats_common.go:100 level=info collector=diskstats msg="Parsed flag --collector.diskstats.device-exclude" flag=^(ram|loop|fd|(h|s|v|xv)d[a-z]|nvme\d+n\d+p)\d+$
ts=2022-10-18T19:58:28.019Z caller=node_exporter.go:108 level=info msg="Enabled collectors"
ts=2022-10-18T19:58:28.019Z caller=node_exporter.go:115 level=info collector=arp
ts=2022-10-18T19:58:28.019Z caller=node_exporter.go:115 level=info collector=bcache
ts=2022-10-18T19:58:28.019Z caller=node_exporter.go:115 level=info collector=bonding
ts=2022-10-18T19:58:28.019Z caller=node_exporter.go:115 level=info collector=btrfs
ts=2022-10-18T19:58:28.019Z caller=node_exporter.go:115 level=info collector=conntrack
ts=2022-10-18T19:58:28.019Z caller=node_exporter.go:115 level=info collector=cpu
ts=2022-10-18T19:58:28.019Z caller=node_exporter.go:115 level=info collector=cpufreq
ts=2022-10-18T19:58:28.020Z caller=node_exporter.go:115 level=info collector=diskstats
ts=2022-10-18T19:58:28.020Z caller=node_exporter.go:115 level=info collector=dmi
ts=2022-10-18T19:58:28.020Z caller=node_exporter.go:115 level=info collector=edac
ts=2022-10-18T19:58:28.020Z caller=node_exporter.go:115 level=info collector=entropy
ts=2022-10-18T19:58:28.020Z caller=node_exporter.go:115 level=info collector=fibrechannel
ts=2022-10-18T19:58:28.020Z caller=node_exporter.go:115 level=info collector=filefd
ts=2022-10-18T19:58:28.020Z caller=node_exporter.go:115 level=info collector=filesystem
ts=2022-10-18T19:58:28.020Z caller=node_exporter.go:115 level=info collector=hwmon
ts=2022-10-18T19:58:28.021Z caller=node_exporter.go:115 level=info collector=infiniband
ts=2022-10-18T19:58:28.021Z caller=node_exporter.go:115 level=info collector=ipvs
ts=2022-10-18T19:58:28.021Z caller=node_exporter.go:115 level=info collector=loadavg
ts=2022-10-18T19:58:28.021Z caller=node_exporter.go:115 level=info collector=mdadm
ts=2022-10-18T19:58:28.021Z caller=node_exporter.go:115 level=info collector=meminfo
ts=2022-10-18T19:58:28.021Z caller=node_exporter.go:115 level=info collector=netclass
ts=2022-10-18T19:58:28.021Z caller=node_exporter.go:115 level=info collector=netdev
ts=2022-10-18T19:58:28.021Z caller=node_exporter.go:115 level=info collector=netstat
ts=2022-10-18T19:58:28.022Z caller=node_exporter.go:115 level=info collector=nfs
ts=2022-10-18T19:58:28.022Z caller=node_exporter.go:115 level=info collector=nfsd
ts=2022-10-18T19:58:28.022Z caller=node_exporter.go:115 level=info collector=nvme
ts=2022-10-18T19:58:28.022Z caller=node_exporter.go:115 level=info collector=os
ts=2022-10-18T19:58:28.022Z caller=node_exporter.go:115 level=info collector=powersupplyclass
ts=2022-10-18T19:58:28.022Z caller=node_exporter.go:115 level=info collector=pressure
ts=2022-10-18T19:58:28.022Z caller=node_exporter.go:115 level=info collector=rapl
ts=2022-10-18T19:58:28.022Z caller=node_exporter.go:115 level=info collector=schedstat
ts=2022-10-18T19:58:28.023Z caller=node_exporter.go:115 level=info collector=selinux
ts=2022-10-18T19:58:28.023Z caller=node_exporter.go:115 level=info collector=sockstat
ts=2022-10-18T19:58:28.023Z caller=node_exporter.go:115 level=info collector=softnet
ts=2022-10-18T19:58:28.023Z caller=node_exporter.go:115 level=info collector=stat
ts=2022-10-18T19:58:28.023Z caller=node_exporter.go:115 level=info collector=tapestats
ts=2022-10-18T19:58:28.023Z caller=node_exporter.go:115 level=info collector=textfile
ts=2022-10-18T19:58:28.023Z caller=node_exporter.go:115 level=info collector=thermal_zone
ts=2022-10-18T19:58:28.023Z caller=node_exporter.go:115 level=info collector=time
ts=2022-10-18T19:58:28.024Z caller=node_exporter.go:115 level=info collector=timex
ts=2022-10-18T19:58:28.024Z caller=node_exporter.go:115 level=info collector=udp_queues
ts=2022-10-18T19:58:28.024Z caller=node_exporter.go:115 level=info collector=uname
ts=2022-10-18T19:58:28.024Z caller=node_exporter.go:115 level=info collector=vmstat
ts=2022-10-18T19:58:28.024Z caller=node_exporter.go:115 level=info collector=xfs
ts=2022-10-18T19:58:28.024Z caller=node_exporter.go:115 level=info collector=zfs
ts=2022-10-18T19:58:28.025Z caller=node_exporter.go:199 level=info msg="Listening on" address=:6666
ts=2022-10-18T19:58:28.026Z caller=tls_config.go:195 level=info msg="TLS is disabled." http2=false

Are you running node_exporter in Docker?

No.

What did you do that produced an error?

curl http://localhost:6666/metrics

What did you expect to see?

Node exporter read files StartCharging_Test, StopCharging_Test in a directory /sys/class/power_supply/battery/. This caused the charging to start and stop on my device Xiaomi Santoni (postMarketOS)

Dmesg log

[49100.583203] show_StartCharging_Test : 1 success
[49100.583238] SMBCHG: power_ok_handler: triggered: 0x01
[49100.583252] SMBCHG: smbchg_usb_update_online_work: chip->usb_online:0,online:1,user_enabled:1,chip->usb_present:1,chip->very_weak_charger:0
[49100.583258] SMBCHG: smbchg_usb_update_online_work: setting usb psy online = 1
[49100.583308] SMBCHG: smbchg_external_power_changed: usb type = SDP current_limit = 500
[49100.583679] SMBCHG: smbchg_calc_max_flash_current: avail_iflash=872412, ocv=3362407, ibat=76212, rbatt=176904
[49100.583996] SMBCHG: power_ok_handler: triggered: 0x00
[49100.584033] SMBCHG: smbchg_usb_update_online_work: chip->usb_online:1,online:0,user_enabled:0,chip->usb_present:1,chip->very_weak_charger:0
[49100.584060] SMBCHG: smbchg_usb_update_online_work: setting usb psy online = 0
[49100.584094] show_StopCharging_Test : 0 success
[49100.584751] SMBCHG: smbchg_external_power_changed: usb type = SDP current_limit = 500
[49100.587446] SMBCHG: smbchg_calc_max_flash_current: avail_iflash=872412, ocv=3362407, ibat=76212, rbatt=176904
[49100.588893] SMBCHG: smbchg_calc_max_flash_current: avail_iflash=872412, ocv=3362407, ibat=76212, rbatt=176904
[49100.592617] SMBCHG: smbchg_calc_max_flash_current: avail_iflash=872412, ocv=3362407, ibat=76212, rbatt=176904

Battery directory

xiaomi-santoni:~$ ls -lah /sys/class/power_supply/battery/
total 0
drwxr-xr-x    3 root     root           0 Jan  2  1970 .
drwxr-xr-x    3 root     root           0 Jan  2  1970 ..
-rw-rw-r--    1 root     root        4.0K Oct 18 22:08 StartCharging_Test
-rw-rw-r--    1 root     root        4.0K Oct 18 22:08 StopCharging_Test
-rw-r--r--    1 root     root        4.0K Oct 18 22:08 allow_hvdcp3
-rw-r--r--    1 root     root        4.0K Oct 18 22:08 battery_charging_enabled
-rw-r--r--    1 root     root        4.0K Oct 18 22:08 capacity
-r--r--r--    1 root     root        4.0K Oct 18 22:08 charge_counter
-r--r--r--    1 root     root        4.0K Oct 18 22:08 charge_full
-r--r--r--    1 root     root        4.0K Oct 18 22:08 charge_full_design
-r--r--r--    1 root     root        4.0K Oct 18 22:08 charge_type
-rw-r--r--    1 root     root        4.0K Oct 18 22:08 charging_call_state
-rw-r--r--    1 root     root        4.0K Oct 18 22:08 charging_enabled
-rw-r--r--    1 root     root        4.0K Oct 18 22:08 constant_charge_current_max
-r--r--r--    1 root     root        4.0K Oct 18 22:08 current_max
-r--r--r--    1 root     root        4.0K Oct 18 22:08 current_now
lrwxrwxrwx    1 root     root           0 Oct 18 22:08 device -> ../../../qpnp-smbcharger-17
-rw-r--r--    1 root     root        4.0K Oct 18 22:08 dp_dm
-r--r--r--    1 root     root        4.0K Oct 18 22:08 flash_active
-r--r--r--    1 root     root        4.0K Oct 18 22:08 flash_current_max
-r--r--r--    1 root     root        4.0K Oct 18 22:08 flash_trigger
-r--r--r--    1 root     root        4.0K Oct 18 22:08 health
-r--r--r--    1 root     root        4.0K Oct 18 22:08 input_current_limited
-r--r--r--    1 root     root        4.0K Oct 18 22:08 input_current_max
-r--r--r--    1 root     root        4.0K Oct 18 22:08 input_current_now
-r--r--r--    1 root     root        4.0K Oct 18 22:08 input_current_settled
-r--r--r--    1 root     root        4.0K Oct 18 22:08 max_pulse_allowed
drwxr-xr-x    2 root     root           0 Oct 18 22:08 power
-r--r--r--    1 root     root        4.0K Oct 18 22:08 present
-rw-r--r--    1 root     root        4.0K Oct 18 22:08 rerun_aicl
-r--r--r--    1 root     root        4.0K Oct 18 22:08 resistance_id
-rw-r--r--    1 root     root        4.0K Oct 18 22:08 restricted_charging
-rw-r--r--    1 root     root        4.0K Oct 18 22:08 safety_timer_enabled
-r--r--r--    1 root     root        4.0K Oct 18 07:30 status
lrwxrwxrwx    1 root     root           0 Oct 18 22:08 subsystem -> ../../../../../class/power_supply
-rw-r--r--    1 root     root        4.0K Oct 18 22:08 system_temp_level
-r--r--r--    1 root     root        4.0K Oct 18 22:08 technology
-r--r--r--    1 root     root        4.0K Oct 18 22:08 temp
-r--r--r--    1 root     root        4.0K Oct 18 22:08 type
-rw-r--r--    1 root     root        4.0K Jan  2  1970 uevent
-rw-r--r--    1 root     root        4.0K Oct 18 08:03 voltage_max
-r--r--r--    1 root     root        4.0K Oct 18 08:03 voltage_max_design
-r--r--r--    1 root     root        4.0K Oct 18 07:30 voltage_now

What did you see instead?

Node exporter will not read these files, thus it will not switch the charging mode.

Temporary solution

Disable powersupplyclass with option --no-collector.powersupplyclass

Links

Kernel StopChargingTest

discordianfish commented 1 year ago

That reading a file causes charging to stop seems like a odd design choice...

That being said, right now we naively try to open all files and I don't get why.. https://github.com/prometheus/procfs/blob/master/sysfs/class_power_supply.go#L142 I've asked on the PR that implemented this functionality.

rexagod commented 3 months ago

@discordianfish Please correct me if I'm wrong but I believe even after fixing https://github.com/prometheus/procfs/pull/178#discussion_r1012799750, i.e., not opening a file that's not read, we'd still have to figure out a way to extract this information somehow.

Charge issues after a read-only operation is indeed a strange design by all means.