From 92ee355ee242d34ff4287992ddf1023620bbd36b Mon Sep 17 00:00:00 2001 From: TaoGe <6657718+yowenter@users.noreply.github.com> Date: Tue, 12 Dec 2023 17:46:38 +0800 Subject: [PATCH 1/2] fix hwmon nil ptr syslink maybe lost in some cases. Signed-off-by: TaoGe <6657718+yowenter@users.noreply.github.com> --- collector/hwmon_linux.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/collector/hwmon_linux.go b/collector/hwmon_linux.go index 3ad469a61a..3f2c7115a9 100644 --- a/collector/hwmon_linux.go +++ b/collector/hwmon_linux.go @@ -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) From 1db328d2ec6a570d216bcf7d5510d92479a00a63 Mon Sep 17 00:00:00 2001 From: TaoGe <6657718+yowenter@users.noreply.github.com> Date: Tue, 12 Dec 2023 17:52:52 +0800 Subject: [PATCH 2/2] Update hwmon_linux.go Signed-off-by: TaoGe <6657718+yowenter@users.noreply.github.com> --- collector/hwmon_linux.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/collector/hwmon_linux.go b/collector/hwmon_linux.go index 3f2c7115a9..476eed7b30 100644 --- a/collector/hwmon_linux.go +++ b/collector/hwmon_linux.go @@ -447,7 +447,7 @@ func (c *hwMonCollector) Update(ch chan<- prometheus.Metric) error { for _, hwDir := range hwmonFiles { hwmonXPathName := filepath.Join(hwmonPathName, hwDir.Name()) fileInfo, err := os.Lstat(hwmonXPathName) - if err!=nil { + if err != nil { continue }