Add NTP stratum to NTP collector

This commit is contained in:
Anton Tolchanov 2016-06-03 13:25:30 +03:00
parent d4799999fc
commit fc3a7b7a97

View file

@ -30,7 +30,8 @@ var (
)
type ntpCollector struct {
drift prometheus.Gauge
drift prometheus.Gauge
stratum prometheus.Gauge
}
func init() {
@ -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
}
@ -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
}