Compare commits
	
		
			2 Commits
		
	
	
		
			0b3c06cab9
			...
			4b7ab8cd0f
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
| 4b7ab8cd0f | |||
| 8220d21ec4 | 
							
								
								
									
										6
									
								
								flake.lock
									
									
									
										generated
									
									
									
								
							
							
						
						
									
										6
									
								
								flake.lock
									
									
									
										generated
									
									
									
								
							| @@ -2,11 +2,11 @@ | |||||||
|   "nodes": { |   "nodes": { | ||||||
|     "nixpkgs": { |     "nixpkgs": { | ||||||
|       "locked": { |       "locked": { | ||||||
|         "lastModified": 1747744144, |         "lastModified": 1748693115, | ||||||
|         "narHash": "sha256-W7lqHp0qZiENCDwUZ5EX/lNhxjMdNapFnbErcbnP11Q=", |         "narHash": "sha256-StSrWhklmDuXT93yc3GrTlb0cKSS0agTAxMGjLKAsY8=", | ||||||
|         "owner": "NixOS", |         "owner": "NixOS", | ||||||
|         "repo": "nixpkgs", |         "repo": "nixpkgs", | ||||||
|         "rev": "2795c506fe8fb7b03c36ccb51f75b6df0ab2553f", |         "rev": "910796cabe436259a29a72e8d3f5e180fc6dfacc", | ||||||
|         "type": "github" |         "type": "github" | ||||||
|       }, |       }, | ||||||
|       "original": { |       "original": { | ||||||
|   | |||||||
							
								
								
									
										2
									
								
								main.go
									
									
									
									
									
								
							
							
						
						
									
										2
									
								
								main.go
									
									
									
									
									
								
							| @@ -17,7 +17,7 @@ import ( | |||||||
| 	"github.com/prometheus/client_golang/prometheus/promhttp" | 	"github.com/prometheus/client_golang/prometheus/promhttp" | ||||||
| ) | ) | ||||||
|  |  | ||||||
| const Version = "0.1.0" | const Version = "0.1.1" | ||||||
|  |  | ||||||
| func LoadConfig() (*config.Config, error) { | func LoadConfig() (*config.Config, error) { | ||||||
| 	path := "labmon.toml" | 	path := "labmon.toml" | ||||||
|   | |||||||
| @@ -29,6 +29,13 @@ var stepCertError = promauto.NewGaugeVec(prometheus.GaugeOpts{ | |||||||
| 	Help:      "Error checking the certificate.", | 	Help:      "Error checking the certificate.", | ||||||
| }, []string{"cert_id"}) | }, []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 { | type StepMonitor struct { | ||||||
| 	BaseURL string | 	BaseURL string | ||||||
| 	RootID  string | 	RootID  string | ||||||
| @@ -77,6 +84,8 @@ func (sm *StepMonitor) Start() { | |||||||
| 				stepCertError.WithLabelValues(sm.RootID).Set(1) | 				stepCertError.WithLabelValues(sm.RootID).Set(1) | ||||||
| 			} else { | 			} else { | ||||||
| 				stepCertError.WithLabelValues(sm.RootID).Set(0) | 				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) | 			timerCertFetch.Reset(5 * time.Minute) | ||||||
|   | |||||||
| @@ -37,6 +37,13 @@ var ( | |||||||
| 		Help:      "Error checking the certificate.", | 		Help:      "Error checking the certificate.", | ||||||
| 	}, []string{"address"}) | 	}, []string{"address"}) | ||||||
|  |  | ||||||
|  | 	gaugeCertLifetime = promauto.NewGaugeVec(prometheus.GaugeOpts{ | ||||||
|  | 		Namespace: "labmon", | ||||||
|  | 		Subsystem: "tlsconmon", | ||||||
|  | 		Name:      "certificate_lifetime_seconds", | ||||||
|  | 		Help:      "How long the certificate is valid in seconds.", | ||||||
|  | 	}, []string{"address"}) | ||||||
|  |  | ||||||
| 	// OTEL tracing | 	// OTEL tracing | ||||||
| 	tracer = otel.Tracer(name) | 	tracer = otel.Tracer(name) | ||||||
| ) | ) | ||||||
| @@ -104,6 +111,8 @@ func (tm *TLSConnectionMonitor) Start(ctx context.Context) { | |||||||
| 	if err := tm.fetchCert(ctx); err != nil { | 	if err := tm.fetchCert(ctx); err != nil { | ||||||
| 		gaugeCertError.WithLabelValues(tm.Address).Set(1) | 		gaugeCertError.WithLabelValues(tm.Address).Set(1) | ||||||
| 		gaugeCertTimeLeft.WithLabelValues(tm.Address).Set(0) | 		gaugeCertTimeLeft.WithLabelValues(tm.Address).Set(0) | ||||||
|  | 		lifetime := tm.cert.NotAfter.Sub(tm.cert.NotBefore).Seconds() | ||||||
|  | 		gaugeCertLifetime.WithLabelValues(tm.Address).Set(lifetime) | ||||||
| 	} else { | 	} else { | ||||||
| 		gaugeCertError.WithLabelValues(tm.Address).Set(0) | 		gaugeCertError.WithLabelValues(tm.Address).Set(0) | ||||||
| 		timeLeft := time.Until(tm.cert.NotAfter).Seconds() | 		timeLeft := time.Until(tm.cert.NotAfter).Seconds() | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user