diff --git a/collector/ntp.go b/collector/ntp.go index 12426f91..60c9b76e 100644 --- a/collector/ntp.go +++ b/collector/ntp.go @@ -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 }