Skip to content

Commit

Permalink
Fixup hwmon chip include
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
SuperQ committed Jul 7, 2023
1 parent 8b4dc82 commit fb21d0a
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 1 deletion.
42 changes: 42 additions & 0 deletions collector/fixtures/sys.ttar
Original file line number Diff line number Diff line change
Expand Up @@ -356,6 +356,9 @@ Lines: 1
100000
Mode: 644
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Path: sys/class/hwmon/hwmon5
SymlinkTo: ../../devices/platform/bogus.0/hwmon/hwmon5/
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Directory: sys/class/infiniband
Mode: 755
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Expand Down Expand Up @@ -2672,6 +2675,45 @@ Lines: 1
applesmc
Mode: 644
# 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
Mode: 755
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Expand Down
3 changes: 2 additions & 1 deletion collector/hwmon_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ func NewHwMonCollector(logger log.Logger) (Collector, error) {

return &hwMonCollector{
logger: logger,
deviceFilter: newDeviceFilter(*collectorHWmonChipExclude, *collectorHWmonChipExclude),
deviceFilter: newDeviceFilter(*collectorHWmonChipExclude, *collectorHWmonChipInclude),
}, nil
}

Expand Down Expand Up @@ -164,6 +164,7 @@ func (c *hwMonCollector) updateHwmon(ch chan<- prometheus.Metric, dir string) er
}

if c.deviceFilter.ignored(hwmonName) {
level.Debug(c.logger).Log("msg", "ignoring hwmon chip", "chip", hwmonName)
return nil
}

Expand Down
1 change: 1 addition & 0 deletions end-to-end-test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ fi
--collector.qdisc.fixtures="collector/fixtures/qdisc/" \
--collector.qdisk.device-include="(wlan0|eth0)" \
--collector.arp.device-exclude="nope" \
--collector.hwmon.chip-include="(applesmc|coretemp|hwmon4|nct6779)" \
--collector.netclass.ignored-devices="(dmz|int)" \
--collector.netclass.ignore-invalid-speed \
--collector.netdev.device-include="lo" \
Expand Down

0 comments on commit fb21d0a

Please sign in to comment.