Fix initial lifetime update
This commit is contained in:
parent
4b7ab8cd0f
commit
040a73e891
2
main.go
2
main.go
@ -17,7 +17,7 @@ import (
|
||||
"github.com/prometheus/client_golang/prometheus/promhttp"
|
||||
)
|
||||
|
||||
const Version = "0.1.1"
|
||||
const Version = "0.1.2"
|
||||
|
||||
func LoadConfig() (*config.Config, error) {
|
||||
path := "labmon.toml"
|
||||
|
@ -68,6 +68,8 @@ func (sm *StepMonitor) Start() {
|
||||
stepCertError.WithLabelValues(sm.RootID).Set(1)
|
||||
} else {
|
||||
stepCertError.WithLabelValues(sm.RootID).Set(0)
|
||||
lifetime := sm.certificate.NotAfter.Sub(sm.certificate.NotBefore).Seconds()
|
||||
stepCertLifetime.WithLabelValues(sm.RootID).Set(lifetime)
|
||||
}
|
||||
secondsLeft := time.Until(sm.certificate.NotAfter).Seconds()
|
||||
stepCertTimeLeft.WithLabelValues(sm.RootID).Set(secondsLeft)
|
||||
|
@ -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:
|
||||
|
Loading…
x
Reference in New Issue
Block a user