Skip to content

Commit 8cd5eb3

Browse files
authored
Fix kernel_hung for no data (#3613)
Return an ErrNoData for the kernel_hung collector if the file does not exist. Fixes: #3612 Signed-off-by: Ben Kochie <superq@gmail.com>
1 parent 03ec2f1 commit 8cd5eb3

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

collector/kernel_hung_linux.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,10 @@
1616
package collector
1717

1818
import (
19+
"errors"
1920
"fmt"
2021
"log/slog"
22+
"os"
2123

2224
"github.com/prometheus/client_golang/prometheus"
2325
"github.com/prometheus/procfs"
@@ -54,6 +56,10 @@ var (
5456
func (c *kernelHungCollector) Update(ch chan<- prometheus.Metric) error {
5557
kernelHung, err := c.fs.KernelHung()
5658
if err != nil {
59+
if errors.Is(err, os.ErrNotExist) {
60+
c.logger.Debug("hung_task_detect_count does not exist")
61+
return ErrNoData
62+
}
5763
return err
5864
}
5965

0 commit comments

Comments
 (0)