From fe78e7e51ae7d01db2849813927a5ad282dfcef3 Mon Sep 17 00:00:00 2001 From: TaoGe <6657718+yowenter@users.noreply.github.com> Date: Sat, 3 Feb 2024 17:13:12 +0800 Subject: [PATCH] fix hwmon nil ptr (#2873) * 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..476eed7b30 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)