Enable watchdog module by default; Add no data error (#2953)

Signed-off-by: Gavin Lam <gavin.oss@tutamail.com>
This commit is contained in:
Gavin Lam 2024-03-14 02:50:55 -04:00 committed by GitHub
parent 95efb86f6b
commit 94ef5cc666
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 9 additions and 2 deletions

View File

@ -158,6 +158,7 @@ timex | Exposes selected adjtimex(2) system call stats. | Linux
udp_queues | Exposes UDP total lengths of the rx_queue and tx_queue from `/proc/net/udp` and `/proc/net/udp6`. | Linux udp_queues | Exposes UDP total lengths of the rx_queue and tx_queue from `/proc/net/udp` and `/proc/net/udp6`. | Linux
uname | Exposes system information as provided by the uname system call. | Darwin, FreeBSD, Linux, OpenBSD uname | Exposes system information as provided by the uname system call. | Darwin, FreeBSD, Linux, OpenBSD
vmstat | Exposes statistics from `/proc/vmstat`. | Linux vmstat | Exposes statistics from `/proc/vmstat`. | Linux
watchdog | Exposes statistics from `/sys/class/watchdog` | Linux
xfs | Exposes XFS runtime statistics. | Linux (kernel 4.4+) xfs | Exposes XFS runtime statistics. | Linux (kernel 4.4+)
zfs | Exposes [ZFS](http://open-zfs.org/) performance statistics. | FreeBSD, [Linux](http://zfsonlinux.org/), Solaris zfs | Exposes [ZFS](http://open-zfs.org/) performance statistics. | FreeBSD, [Linux](http://zfsonlinux.org/), Solaris
@ -204,7 +205,6 @@ softirqs | Exposes detailed softirq statistics from `/proc/softirqs`. | Linux
sysctl | Expose sysctl values from `/proc/sys`. Use `--collector.sysctl.include(-info)` to configure. | Linux sysctl | Expose sysctl values from `/proc/sys`. Use `--collector.sysctl.include(-info)` to configure. | Linux
systemd | Exposes service and system status from [systemd](http://www.freedesktop.org/wiki/Software/systemd/). | Linux systemd | Exposes service and system status from [systemd](http://www.freedesktop.org/wiki/Software/systemd/). | Linux
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 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
watchdog | Exposes statistics from `/sys/class/watchdog` | Linux
wifi | Exposes WiFi device and station statistics. | Linux wifi | Exposes WiFi device and station statistics. | Linux
xfrm | Exposes statistics from `/proc/net/xfrm_stat` | Linux xfrm | Exposes statistics from `/proc/net/xfrm_stat` | Linux
zoneinfo | Exposes NUMA memory zone metrics. | Linux zoneinfo | Exposes NUMA memory zone metrics. | Linux

View File

@ -17,9 +17,12 @@
package collector package collector
import ( import (
"errors"
"fmt" "fmt"
"os"
"github.com/go-kit/log" "github.com/go-kit/log"
"github.com/go-kit/log/level"
"github.com/prometheus/client_golang/prometheus" "github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/procfs/sysfs" "github.com/prometheus/procfs/sysfs"
) )
@ -30,7 +33,7 @@ type watchdogCollector struct {
} }
func init() { func init() {
registerCollector("watchdog", defaultDisabled, NewWatchdogCollector) registerCollector("watchdog", defaultEnabled, NewWatchdogCollector)
} }
// NewWatchdogCollector returns a new Collector exposing watchdog stats. // NewWatchdogCollector returns a new Collector exposing watchdog stats.
@ -99,6 +102,10 @@ func toLabelValue(ptr *string) string {
func (c *watchdogCollector) Update(ch chan<- prometheus.Metric) error { func (c *watchdogCollector) Update(ch chan<- prometheus.Metric) error {
watchdogClass, err := c.fs.WatchdogClass() watchdogClass, err := c.fs.WatchdogClass()
if err != nil { if err != nil {
if errors.Is(err, os.ErrNotExist) || errors.Is(err, os.ErrPermission) || errors.Is(err, os.ErrInvalid) {
level.Debug(c.logger).Log("msg", "Could not read watchdog stats", "err", err)
return ErrNoData
}
return err return err
} }