Skip to content

Commit

Permalink
fix hwmon nil ptr (prometheus#2873)
Browse files Browse the repository at this point in the history
* fix hwmon nil ptr

syslink maybe lost in some cases.

---------

Signed-off-by: TaoGe <[email protected]>
Signed-off-by: Vitaly Zhuravlev <[email protected]>
  • Loading branch information
yowenter authored and v-zhuravlev committed Nov 1, 2024
1 parent c422c5d commit b2e4cb1
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion collector/hwmon_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -446,7 +446,10 @@ func (c *hwMonCollector) Update(ch chan<- prometheus.Metric) error {

for _, hwDir := range hwmonFiles {
hwmonXPathName := filepath.Join(hwmonPathName, hwDir.Name())
fileInfo, _ := os.Lstat(hwmonXPathName)
fileInfo, err := os.Lstat(hwmonXPathName)
if err != nil {
continue
}

if fileInfo.Mode()&os.ModeSymlink > 0 {
fileInfo, err = os.Stat(hwmonXPathName)
Expand Down

0 comments on commit b2e4cb1

Please sign in to comment.