mirror of
https://github.com/prometheus/node_exporter.git
synced 2024-11-09 23:24:09 -08:00
Signed-off-by: Li Ling <liiling@google.com>
This commit is contained in:
parent
875f437fcc
commit
bf154d485b
|
@ -16,7 +16,9 @@
|
|||
package collector
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"github.com/go-kit/kit/log"
|
||||
"github.com/go-kit/kit/log/level"
|
||||
|
@ -88,8 +90,11 @@ func (c *pressureStatsCollector) Update(ch chan<- prometheus.Metric) error {
|
|||
level.Debug(c.logger).Log("msg", "collecting statistics for resource", "resource", res)
|
||||
vals, err := c.fs.PSIStatsForResource(res)
|
||||
if err != nil {
|
||||
level.Debug(c.logger).Log("msg", "pressure information is unavailable, you need a Linux kernel >= 4.20 and/or CONFIG_PSI enabled for your kernel")
|
||||
return ErrNoData
|
||||
if errors.Is(err, os.ErrNotExist) {
|
||||
level.Debug(c.logger).Log("msg", "pressure information is unavailable, you need a Linux kernel >= 4.20 and/or CONFIG_PSI enabled for your kernel")
|
||||
return ErrNoData
|
||||
}
|
||||
return fmt.Errorf("failed to retrieve pressure stats: %w", err)
|
||||
}
|
||||
switch res {
|
||||
case "cpu":
|
||||
|
|
|
@ -16,15 +16,20 @@
|
|||
package collector
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"os"
|
||||
"strconv"
|
||||
|
||||
"github.com/go-kit/kit/log"
|
||||
"github.com/go-kit/kit/log/level"
|
||||
"github.com/prometheus/client_golang/prometheus"
|
||||
"github.com/prometheus/procfs/sysfs"
|
||||
)
|
||||
|
||||
type raplCollector struct {
|
||||
fs sysfs.FS
|
||||
fs sysfs.FS
|
||||
logger log.Logger
|
||||
}
|
||||
|
||||
func init() {
|
||||
|
@ -40,7 +45,8 @@ func NewRaplCollector(logger log.Logger) (Collector, error) {
|
|||
}
|
||||
|
||||
collector := raplCollector{
|
||||
fs: fs,
|
||||
fs: fs,
|
||||
logger: logger,
|
||||
}
|
||||
return &collector, nil
|
||||
}
|
||||
|
@ -50,7 +56,11 @@ func (c *raplCollector) Update(ch chan<- prometheus.Metric) error {
|
|||
// nil zones are fine when platform doesn't have powercap files present.
|
||||
zones, err := sysfs.GetRaplZones(c.fs)
|
||||
if err != nil {
|
||||
return ErrNoData
|
||||
if errors.Is(err, os.ErrNotExist) {
|
||||
level.Debug(c.logger).Log("msg", "Platform doesn't have powercap files present", "err", err)
|
||||
return ErrNoData
|
||||
}
|
||||
return fmt.Errorf("failed to retrieve rapl stats: %w", err)
|
||||
}
|
||||
|
||||
for _, rz := range zones {
|
||||
|
|
Loading…
Reference in a new issue