Skip to content

Commit

Permalink
Fix issue on statuscake_ssl_valid_util_sec metrics (#11)
Browse files Browse the repository at this point in the history
Original issue: #9
  • Loading branch information
sadmin91 authored and mtulio committed Sep 21, 2019
1 parent 1adaf29 commit 1b3409e
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions collector/ssl.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package collector
import (
"strconv"
"time"
"math"

"github.com/mtulio/statuscake-exporter/stk"
"github.com/prometheus/client_golang/prometheus"
Expand Down Expand Up @@ -148,14 +149,13 @@ func (c *stkSSLCollector) updateStkSSL(ch chan<- prometheus.Metric) error {
test.Domain,
)

t, err := time.Parse("2021-03-18 23:59:00", test.ValidUntilUtc)
if err != nil {
tnow := time.Now()
secUntilExpiry := tnow.Sub(t)
t, err := time.Parse("2006-01-02 15:04:05", test.ValidUntilUtc)
if err == nil {
secUntilExpiry := math.Round(t.Sub(time.Now().UTC()).Seconds())
ch <- prometheus.MustNewConstMetric(
c.stkSslValidUntil,
prometheus.GaugeValue,
float64(secUntilExpiry),
secUntilExpiry,
test.Domain,
)
}
Expand Down

0 comments on commit 1b3409e

Please sign in to comment.