Add lifetime to certificates monitored
This commit is contained in:
@@ -29,6 +29,13 @@ var stepCertError = promauto.NewGaugeVec(prometheus.GaugeOpts{
|
||||
Help: "Error checking the certificate.",
|
||||
}, []string{"cert_id"})
|
||||
|
||||
var stepCertLifetime = promauto.NewGaugeVec(prometheus.GaugeOpts{
|
||||
Namespace: "labmon",
|
||||
Subsystem: "stepmon",
|
||||
Name: "certificate_lifetime_seconds",
|
||||
Help: "How long the certificate is valid in seconds.",
|
||||
}, []string{"cert_id"})
|
||||
|
||||
type StepMonitor struct {
|
||||
BaseURL string
|
||||
RootID string
|
||||
@@ -77,6 +84,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)
|
||||
}
|
||||
|
||||
timerCertFetch.Reset(5 * time.Minute)
|
||||
|
Reference in New Issue
Block a user