Fix initial lifetime update
This commit is contained in:
@@ -111,12 +111,12 @@ func (tm *TLSConnectionMonitor) Start(ctx context.Context) {
|
||||
if err := tm.fetchCert(ctx); err != nil {
|
||||
gaugeCertError.WithLabelValues(tm.Address).Set(1)
|
||||
gaugeCertTimeLeft.WithLabelValues(tm.Address).Set(0)
|
||||
lifetime := tm.cert.NotAfter.Sub(tm.cert.NotBefore).Seconds()
|
||||
gaugeCertLifetime.WithLabelValues(tm.Address).Set(lifetime)
|
||||
} else {
|
||||
gaugeCertError.WithLabelValues(tm.Address).Set(0)
|
||||
timeLeft := time.Until(tm.cert.NotAfter).Seconds()
|
||||
gaugeCertTimeLeft.WithLabelValues(tm.Address).Set(timeLeft)
|
||||
lifetime := tm.cert.NotAfter.Sub(tm.cert.NotBefore).Seconds()
|
||||
gaugeCertLifetime.WithLabelValues(tm.Address).Set(lifetime)
|
||||
}
|
||||
|
||||
timerCertFetch := time.NewTimer(tm.CheckDuration)
|
||||
@@ -131,6 +131,8 @@ func (tm *TLSConnectionMonitor) Start(ctx context.Context) {
|
||||
gaugeCertError.WithLabelValues(tm.Address).Set(1)
|
||||
} else {
|
||||
gaugeCertError.WithLabelValues(tm.Address).Set(0)
|
||||
lifetime := tm.cert.NotAfter.Sub(tm.cert.NotBefore).Seconds()
|
||||
gaugeCertLifetime.WithLabelValues(tm.Address).Set(lifetime)
|
||||
}
|
||||
timerCertFetch.Reset(tm.CheckDuration)
|
||||
case <-timerUpdateMonitor.C:
|
||||
|
Reference in New Issue
Block a user