Skip to content

Commit 94ef5cc

Browse files
authored
Enable watchdog module by default; Add no data error (#2953)
Signed-off-by: Gavin Lam <gavin.oss@tutamail.com>
1 parent 95efb86 commit 94ef5cc

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,7 @@ timex | Exposes selected adjtimex(2) system call stats. | Linux
158158
udp_queues | Exposes UDP total lengths of the rx_queue and tx_queue from `/proc/net/udp` and `/proc/net/udp6`. | Linux
159159
uname | Exposes system information as provided by the uname system call. | Darwin, FreeBSD, Linux, OpenBSD
160160
vmstat | Exposes statistics from `/proc/vmstat`. | Linux
161+
watchdog | Exposes statistics from `/sys/class/watchdog` | Linux
161162
xfs | Exposes XFS runtime statistics. | Linux (kernel 4.4+)
162163
zfs | Exposes [ZFS](http://open-zfs.org/) performance statistics. | FreeBSD, [Linux](http://zfsonlinux.org/), Solaris
163164

@@ -204,7 +205,6 @@ softirqs | Exposes detailed softirq statistics from `/proc/softirqs`. | Linux
204205
sysctl | Expose sysctl values from `/proc/sys`. Use `--collector.sysctl.include(-info)` to configure. | Linux
205206
systemd | Exposes service and system status from [systemd](http://www.freedesktop.org/wiki/Software/systemd/). | Linux
206207
tcpstat | Exposes TCP connection status information from `/proc/net/tcp` and `/proc/net/tcp6`. (Warning: the current version has potential performance issues in high load situations.) | Linux
207-
watchdog | Exposes statistics from `/sys/class/watchdog` | Linux
208208
wifi | Exposes WiFi device and station statistics. | Linux
209209
xfrm | Exposes statistics from `/proc/net/xfrm_stat` | Linux
210210
zoneinfo | Exposes NUMA memory zone metrics. | Linux

collector/watchdog.go

+8-1
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,12 @@
1717
package collector
1818

1919
import (
20+
"errors"
2021
"fmt"
22+
"os"
2123

2224
"github.com/go-kit/log"
25+
"github.com/go-kit/log/level"
2326
"github.com/prometheus/client_golang/prometheus"
2427
"github.com/prometheus/procfs/sysfs"
2528
)
@@ -30,7 +33,7 @@ type watchdogCollector struct {
3033
}
3134

3235
func init() {
33-
registerCollector("watchdog", defaultDisabled, NewWatchdogCollector)
36+
registerCollector("watchdog", defaultEnabled, NewWatchdogCollector)
3437
}
3538

3639
// NewWatchdogCollector returns a new Collector exposing watchdog stats.
@@ -99,6 +102,10 @@ func toLabelValue(ptr *string) string {
99102
func (c *watchdogCollector) Update(ch chan<- prometheus.Metric) error {
100103
watchdogClass, err := c.fs.WatchdogClass()
101104
if err != nil {
105+
if errors.Is(err, os.ErrNotExist) || errors.Is(err, os.ErrPermission) || errors.Is(err, os.ErrInvalid) {
106+
level.Debug(c.logger).Log("msg", "Could not read watchdog stats", "err", err)
107+
return ErrNoData
108+
}
102109
return err
103110
}
104111

0 commit comments

Comments
 (0)