Skip to content

Commit

Permalink
Add NTP stratum to NTP collector
Browse files Browse the repository at this point in the history
  • Loading branch information
knyar committed Jun 3, 2016
1 parent d479999 commit fc3a7b7
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions collector/ntp.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ var (
)

type ntpCollector struct {
drift prometheus.Gauge
drift prometheus.Gauge
stratum prometheus.Gauge
}

func init() {
Expand All @@ -53,6 +54,11 @@ func NewNtpCollector() (Collector, error) {
Name: "ntp_drift_seconds",
Help: "Time between system time and ntp time.",
}),
stratum: prometheus.NewGauge(prometheus.GaugeOpts{
Namespace: Namespace,
Name: "ntp_stratum",
Help: "NTP server stratum.",
}),
}, nil
}

Expand All @@ -65,5 +71,10 @@ func (c *ntpCollector) Update(ch chan<- prometheus.Metric) (err error) {
log.Debugf("Set ntp_drift_seconds: %f", driftSeconds)
c.drift.Set(driftSeconds)
c.drift.Collect(ch)
return err

stratum := float64(resp.Stratum)
log.Debugf("Set ntp_stratum: %f", stratum)
c.stratum.Set(stratum)
c.stratum.Collect(ch)
return nil
}

0 comments on commit fc3a7b7

Please sign in to comment.