Skip to content

Commit

Permalink
Merge pull request #1938 from prometheus/superq/timex_error
Browse files Browse the repository at this point in the history
Handle EPERM for syscall in timex collector
  • Loading branch information
SuperQ authored Jan 23, 2021
2 parents cfdd9dd + 1d03daf commit 87993cd
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
* [ENHANCEMENT] Include TCP OutRsts in netstat metrics
* [ENHANCEMENT] Added XFS inode operations to XFS metrics
* [ENHANCEMENT] Remove CGO dependencies for OpenBSD amd64
* [BUGFIX] Handle EPERM for syscall in timex collector
* [BUGFIX]

## 1.0.1 / 2020-06-15
Expand Down
7 changes: 7 additions & 0 deletions collector/timex.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,12 @@
package collector

import (
"errors"
"fmt"
"os"

"github.com/go-kit/kit/log"
"github.com/go-kit/kit/log/level"
"github.com/prometheus/client_golang/prometheus"
"golang.org/x/sys/unix"
)
Expand Down Expand Up @@ -163,6 +166,10 @@ func (c *timexCollector) Update(ch chan<- prometheus.Metric) error {

status, err := unix.Adjtimex(timex)
if err != nil {
if errors.Is(err, os.ErrPermission) {
level.Debug(c.logger).Log("msg", "Not collecting timex metrics", "err", err)
return ErrNoData
}
return fmt.Errorf("failed to retrieve adjtimex stats: %w", err)
}

Expand Down

0 comments on commit 87993cd

Please sign in to comment.