Skip to content

Commit

Permalink
Handle EPERM for syscall in timex collector
Browse files Browse the repository at this point in the history
Handle case where Adjtimex syscall gets a permission denined error.

Fixes: #1934

Signed-off-by: Ben Kochie <[email protected]>
  • Loading branch information
SuperQ committed Jan 23, 2021
1 parent cfdd9dd commit 1d03daf
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 1d03daf

Please sign in to comment.