Merge pull request #247 from knyar/ntp

Add NTP stratum to NTP collector.
pull/217/merge
Ben Kochie 2016-06-05 09:28:48 +02:00
commit 6969918c95
1 changed files with 13 additions and 2 deletions

View File

@ -30,7 +30,8 @@ var (
) )
type ntpCollector struct { type ntpCollector struct {
drift prometheus.Gauge drift prometheus.Gauge
stratum prometheus.Gauge
} }
func init() { func init() {
@ -53,6 +54,11 @@ func NewNtpCollector() (Collector, error) {
Name: "ntp_drift_seconds", Name: "ntp_drift_seconds",
Help: "Time between system time and ntp time.", Help: "Time between system time and ntp time.",
}), }),
stratum: prometheus.NewGauge(prometheus.GaugeOpts{
Namespace: Namespace,
Name: "ntp_stratum",
Help: "NTP server stratum.",
}),
}, nil }, nil
} }
@ -65,5 +71,10 @@ func (c *ntpCollector) Update(ch chan<- prometheus.Metric) (err error) {
log.Debugf("Set ntp_drift_seconds: %f", driftSeconds) log.Debugf("Set ntp_drift_seconds: %f", driftSeconds)
c.drift.Set(driftSeconds) c.drift.Set(driftSeconds)
c.drift.Collect(ch) 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
} }