Skip to content

Commit

Permalink
Merge pull request #250 from sky-uk/ntp-rtt
Browse files Browse the repository at this point in the history
Use the offset calculation that includes round trip time in the ntp collector
  • Loading branch information
juliusv committed Jun 2, 2016
2 parents df8dcd2 + 387c644 commit d479999
Show file tree
Hide file tree
Showing 6 changed files with 145 additions and 40 deletions.
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,8 @@ dependencies-stamp
/.deps
/.release
/.tarballs

# Intellij

/.idea
*.iml
9 changes: 4 additions & 5 deletions collector/ntp.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ package collector
import (
"flag"
"fmt"
"time"

"github.com/beevik/ntp"
"github.com/prometheus/client_golang/prometheus"
Expand Down Expand Up @@ -58,13 +57,13 @@ func NewNtpCollector() (Collector, error) {
}

func (c *ntpCollector) Update(ch chan<- prometheus.Metric) (err error) {
t, err := ntp.TimeV(*ntpServer, byte(*ntpProtocolVersion))
resp, err := ntp.Query(*ntpServer, *ntpProtocolVersion)
if err != nil {
return fmt.Errorf("couldn't get NTP drift: %s", err)
}
drift := t.Sub(time.Now())
log.Debugf("Set ntp_drift_seconds: %f", drift.Seconds())
c.drift.Set(drift.Seconds())
driftSeconds := resp.ClockOffset.Seconds()
log.Debugf("Set ntp_drift_seconds: %f", driftSeconds)
c.drift.Set(driftSeconds)
c.drift.Collect(ch)
return err
}
4 changes: 4 additions & 0 deletions vendor/github.com/beevik/ntp/CONTRIBUTORS

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions vendor/github.com/beevik/ntp/README.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

159 changes: 126 additions & 33 deletions vendor/github.com/beevik/ntp/ntp.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 3 additions & 2 deletions vendor/vendor.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,10 @@
"revisionTime": "2016-01-18T19:00:32-05:00"
},
{
"checksumSHA1": "JhaYHdVIj52Fpdcb7DuDjr/gk0Q=",
"path": "github.com/beevik/ntp",
"revision": "283ed9d548825a1dae0994311560e8dbf8efac68",
"revisionTime": "2015-11-09T15:30:19-08:00"
"revision": "f0545e6f2c3cb0d0a2ed115b88c539d8e5247ef3",
"revisionTime": "2016-05-31T23:09:58Z"
},
{
"path": "github.com/beorn7/perks/quantile",
Expand Down

0 comments on commit d479999

Please sign in to comment.