Fixup hwmon chip include (#2739)

Use the correct include value to the device filter function.
* Add new bogus hwmon fixture.
* Update end-to-end test to use hwmon chip include flag.

Signed-off-by: Ben Kochie <superq@gmail.com>
This commit is contained in:
Ben Kochie 2023-07-10 12:46:30 +02:00 committed by GitHub
parent c241ecf8bd
commit 7c564bcbef
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 46 additions and 1 deletions

View file

@ -101,6 +101,7 @@ ethtool | device | --collector.ethtool.device-include | --collector.ethtool.devi
ethtool | metrics | --collector.ethtool.metrics-include | N/A ethtool | metrics | --collector.ethtool.metrics-include | N/A
filesystem | fs-types | N/A | --collector.filesystem.fs-types-exclude filesystem | fs-types | N/A | --collector.filesystem.fs-types-exclude
filesystem | mount-points | N/A | --collector.filesystem.mount-points-exclude filesystem | mount-points | N/A | --collector.filesystem.mount-points-exclude
hwmon | chip | --collector.hwmon.chip-include | --collector.hwmon.chip-exclude
netdev | device | --collector.netdev.device-include | --collector.netdev.device-exclude netdev | device | --collector.netdev.device-include | --collector.netdev.device-exclude
qdisk | device | --collector.qdisk.device-include | --collector.qdisk.device-exclude qdisk | device | --collector.qdisk.device-include | --collector.qdisk.device-exclude
sysctl | all | --collector.sysctl.include | N/A sysctl | all | --collector.sysctl.include | N/A

View file

@ -356,6 +356,9 @@ Lines: 1
100000 100000
Mode: 644 Mode: 644
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Path: sys/class/hwmon/hwmon5
SymlinkTo: ../../devices/platform/bogus.0/hwmon/hwmon5/
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Directory: sys/class/infiniband Directory: sys/class/infiniband
Mode: 755 Mode: 755
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -2672,6 +2675,45 @@ Lines: 1
applesmc applesmc
Mode: 644 Mode: 644
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Directory: sys/devices/platform/bogus.0
Mode: 775
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Directory: sys/devices/platform/bogus.0/hwmon
Mode: 775
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Directory: sys/devices/platform/bogus.0/hwmon/hwmon5
Mode: 775
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Path: sys/devices/platform/bogus.0/hwmon/hwmon5/bogus1_crit
Lines: 1
100000
Mode: 644
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Path: sys/devices/platform/bogus.0/hwmon/hwmon5/bogus1_crit_alarm
Lines: 1
0
Mode: 644
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Path: sys/devices/platform/bogus.0/hwmon/hwmon5/bogus1_input
Lines: 1
55000
Mode: 644
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Path: sys/devices/platform/bogus.0/hwmon/hwmon5/bogus1_label
Lines: 1
Physical id 0
Mode: 644
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Path: sys/devices/platform/bogus.0/hwmon/hwmon5/bogus1_max
Lines: 1
84000
Mode: 644
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Path: sys/devices/platform/bogus.0/hwmon/hwmon5/name
Lines: 1
bogus
Mode: 664
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Directory: sys/devices/platform/coretemp.0 Directory: sys/devices/platform/coretemp.0
Mode: 755 Mode: 755
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

View file

@ -61,7 +61,7 @@ func NewHwMonCollector(logger log.Logger) (Collector, error) {
return &hwMonCollector{ return &hwMonCollector{
logger: logger, logger: logger,
deviceFilter: newDeviceFilter(*collectorHWmonChipExclude, *collectorHWmonChipExclude), deviceFilter: newDeviceFilter(*collectorHWmonChipExclude, *collectorHWmonChipInclude),
}, nil }, nil
} }
@ -164,6 +164,7 @@ func (c *hwMonCollector) updateHwmon(ch chan<- prometheus.Metric, dir string) er
} }
if c.deviceFilter.ignored(hwmonName) { if c.deviceFilter.ignored(hwmonName) {
level.Debug(c.logger).Log("msg", "ignoring hwmon chip", "chip", hwmonName)
return nil return nil
} }

View file

@ -132,6 +132,7 @@ fi
--collector.qdisc.fixtures="collector/fixtures/qdisc/" \ --collector.qdisc.fixtures="collector/fixtures/qdisc/" \
--collector.qdisk.device-include="(wlan0|eth0)" \ --collector.qdisk.device-include="(wlan0|eth0)" \
--collector.arp.device-exclude="nope" \ --collector.arp.device-exclude="nope" \
--collector.hwmon.chip-include="(applesmc|coretemp|hwmon4|nct6779)" \
--collector.netclass.ignored-devices="(dmz|int)" \ --collector.netclass.ignored-devices="(dmz|int)" \
--collector.netclass.ignore-invalid-speed \ --collector.netclass.ignore-invalid-speed \
--collector.netdev.device-include="lo" \ --collector.netdev.device-include="lo" \